Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 198ef3bc authored by Nikhil Kumar's avatar Nikhil Kumar
Browse files

Refactor power menu bug reporting flow to work for multiple admins

Existing implementation of power menu bugreporting flow works only
for the primary user. In HSUM(Headless system user mode) there is
going to be more than one admin users who are allowed to trigger bug
report from the power menu, below refactorings has been done do handle
this case.

Configurations for handlerUser and handlerApp are moved from Global to
Secure settings so that each user can save them, and current user's
context is used to save and retrieve these secure settings.

In case of bugreports triggered from power menu the caller is always
going to be systemui running on user 0, ActivityManagerService has
been refactored to always initiate the shell process for bug reporting
on the current user.

Test: manually tested the bugreport is working for multiple admin with
different combination of handlerApps

Bug: 261184202
Change-Id: I5ea8e3b8b7cf9d032bfa3f3065aee5eb4f3da068
parent 8d22a5fa
Loading
Loading
Loading
Loading
+25 −5
Original line number Diff line number Diff line
@@ -6142,7 +6142,6 @@ public final class Settings {
            MOVED_TO_GLOBAL.add(Settings.Global.ADB_ENABLED);
            MOVED_TO_GLOBAL.add(Settings.Global.ASSISTED_GPS_ENABLED);
            MOVED_TO_GLOBAL.add(Settings.Global.BLUETOOTH_ON);
            MOVED_TO_GLOBAL.add(Settings.Global.BUGREPORT_IN_POWER_MENU);
            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_CELL_BROADCAST_SMS);
            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_ROAMING_MODE);
            MOVED_TO_GLOBAL.add(Settings.Global.CDMA_SUBSCRIPTION_MODE);
@@ -6763,13 +6762,25 @@ public final class Settings {
        /**
         * When the user has enable the option to have a "bug report" command
         * in the power menu.
         * @deprecated Use {@link android.provider.Settings.Global#BUGREPORT_IN_POWER_MENU} instead
         * @hide
         */
        @Deprecated
        @Readable
        public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu";
        /**
         * The package name for the custom bugreport handler app. This app must be bugreport
         * allow-listed. This is currently used only by Power Menu short press.
         * @hide
         */
        public static final String CUSTOM_BUGREPORT_HANDLER_APP = "custom_bugreport_handler_app";
        /**
         * The user id for the custom bugreport handler app. This is currently used only by Power
         * Menu short press.
         * @hide
         */
        public static final String CUSTOM_BUGREPORT_HANDLER_USER = "custom_bugreport_handler_user";
        /**
         * @deprecated Use {@link android.provider.Settings.Global#ADB_ENABLED} instead
         */
@@ -11713,26 +11724,32 @@ public final class Settings {
        /**
         * When the user has enable the option to have a "bug report" command
         * in the power menu.
         * @deprecated Use {@link android.provider.Settings.Secure#BUGREPORT_IN_POWER_MENU} instead
         * @hide
         */
        @Deprecated
        @Readable
        public static final String BUGREPORT_IN_POWER_MENU = "bugreport_in_power_menu";
        /**
         * The package name for the custom bugreport handler app. This app must be whitelisted.
         * This is currently used only by Power Menu short press.
         *
         * @deprecated Use {@link android.provider.Settings.Secure#CUSTOM_BUGREPORT_HANDLER_APP}
         * instead
         * @hide
         */
        @Deprecated
        @Readable
        public static final String CUSTOM_BUGREPORT_HANDLER_APP = "custom_bugreport_handler_app";
        /**
         * The user id for the custom bugreport handler app. This is currently used only by Power
         * Menu short press.
         *
         * @deprecated Use {@link android.provider.Settings.Secure#CUSTOM_BUGREPORT_HANDLER_USER}
         * instead
         * @hide
         */
        @Deprecated
        @Readable
        public static final String CUSTOM_BUGREPORT_HANDLER_USER = "custom_bugreport_handler_user";
@@ -16351,6 +16368,9 @@ public final class Settings {
            MOVED_TO_SECURE.add(Global.CHARGING_SOUNDS_ENABLED);
            MOVED_TO_SECURE.add(Global.CHARGING_VIBRATION_ENABLED);
            MOVED_TO_SECURE.add(Global.NOTIFICATION_BUBBLES);
            MOVED_TO_SECURE.add(Global.BUGREPORT_IN_POWER_MENU);
            MOVED_TO_SECURE.add(Global.CUSTOM_BUGREPORT_HANDLER_APP);
            MOVED_TO_SECURE.add(Global.CUSTOM_BUGREPORT_HANDLER_USER);
        }
        // Certain settings have been moved from global to the per-user system namespace
+1 −1
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ message GlobalSettingsProto {
    optional Bluetooth bluetooth = 21;

    optional SettingProto boot_count = 22 [ (android.privacy).dest = DEST_AUTOMATIC ];
    optional SettingProto bugreport_in_power_menu = 23 [ (android.privacy).dest = DEST_AUTOMATIC ];
    reserved 23; // Moved to secure settings bugreport_in_power_menu
    optional SettingProto cached_apps_freezer_enabled = 152 [ (android.privacy).dest = DEST_AUTOMATIC ];
    optional SettingProto call_auto_retry = 24 [ (android.privacy).dest = DEST_AUTOMATIC ];

+2 −1
Original line number Diff line number Diff line
@@ -186,6 +186,7 @@ message SecureSettingsProto {
    optional Backup backup = 10;

    optional SettingProto bluetooth_on_while_driving = 11 [ (android.privacy).dest = DEST_AUTOMATIC ];
    optional SettingProto bugreport_in_power_menu = 95 [ (android.privacy).dest = DEST_AUTOMATIC ];

    message Camera {
        option (android.msg_privacy).dest = DEST_EXPLICIT;
@@ -696,5 +697,5 @@ message SecureSettingsProto {

    // Please insert fields in alphabetical order and group them into messages
    // if possible (to avoid reaching the method limit).
    // Next tag = 95;
    // Next tag = 96;
}
+3 −3
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ public class GlobalSettings {
     */
    public static final String[] SETTINGS_TO_BACKUP = {
        Settings.Global.APPLY_RAMPING_RINGER,
        Settings.Global.BUGREPORT_IN_POWER_MENU,
        Settings.Global.BUGREPORT_IN_POWER_MENU,                        // moved to secure
        Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
        Settings.Global.APP_AUTO_RESTRICTION_ENABLED,
        Settings.Global.AUTO_TIME,
@@ -70,8 +70,8 @@ public class GlobalSettings {
        Settings.Global.ZEN_DURATION,
        Settings.Global.CHARGING_VIBRATION_ENABLED,
        Settings.Global.AWARE_ALLOWED,
        Settings.Global.CUSTOM_BUGREPORT_HANDLER_APP,
        Settings.Global.CUSTOM_BUGREPORT_HANDLER_USER,
        Settings.Global.CUSTOM_BUGREPORT_HANDLER_APP,                   // moved to secure
        Settings.Global.CUSTOM_BUGREPORT_HANDLER_USER,                  // moved to secure
        Settings.Global.DEVELOPMENT_SETTINGS_ENABLED,
        Settings.Global.USER_DISABLED_HDR_FORMATS,
        Settings.Global.ARE_USER_DISABLED_HDR_FORMATS_ALLOWED,
+4 −2
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ public class SecureSettings {
     */
    @UnsupportedAppUsage
    public static final String[] SETTINGS_TO_BACKUP = {
        Settings.Secure.BUGREPORT_IN_POWER_MENU,                            // moved to global
        Settings.Secure.BUGREPORT_IN_POWER_MENU,
        Settings.Secure.ALLOW_MOCK_LOCATION,
        Settings.Secure.USB_MASS_STORAGE_ENABLED,                           // moved to global
        Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED,
@@ -225,6 +225,8 @@ public class SecureSettings {
        Settings.Secure.ASSIST_LONG_PRESS_HOME_ENABLED,
        Settings.Secure.BLUETOOTH_LE_BROADCAST_PROGRAM_INFO,
        Settings.Secure.BLUETOOTH_LE_BROADCAST_CODE,
        Settings.Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME
        Settings.Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME,
        Settings.Secure.CUSTOM_BUGREPORT_HANDLER_APP,
        Settings.Secure.CUSTOM_BUGREPORT_HANDLER_USER
    };
}
Loading