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

Commit 1f596e0c authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Fix issue #77721907: Add global setting to hide all error dialogs" into pi-dev

parents 05f9b8a9 82b17ca3
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -11122,6 +11122,14 @@ public final class Settings {
         */
         */
        public static final String ALWAYS_FINISH_ACTIVITIES = "always_finish_activities";
        public static final String ALWAYS_FINISH_ACTIVITIES = "always_finish_activities";


        /**
         * If nonzero, all system error dialogs will be hidden.  For example, the
         * crash and ANR dialogs will not be shown, and the system will just proceed
         * as if they had been accepted by the user.
         * @hide
         */
        public static final String HIDE_ERROR_DIALOGS = "hide_error_dialogs";

        /**
        /**
         * Use Dock audio output for media:
         * Use Dock audio output for media:
         *      0 = disabled
         *      0 = disabled
+1 −0
Original line number Original line Diff line number Diff line
@@ -246,6 +246,7 @@ public class SettingsBackupTest {
                    Settings.Global.HDMI_CONTROL_ENABLED,
                    Settings.Global.HDMI_CONTROL_ENABLED,
                    Settings.Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED,
                    Settings.Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED,
                    Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED,
                    Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED,
                    Settings.Global.HIDE_ERROR_DIALOGS,
                    Settings.Global.HTTP_PROXY,
                    Settings.Global.HTTP_PROXY,
                    HYBRID_SYSUI_BATTERY_WARNING_FLAGS,
                    HYBRID_SYSUI_BATTERY_WARNING_FLAGS,
                    Settings.Global.INET_CONDITION_DEBOUNCE_DOWN_DELAY,
                    Settings.Global.INET_CONDITION_DEBOUNCE_DOWN_DELAY,
+13 −3
Original line number Original line Diff line number Diff line
@@ -118,6 +118,7 @@ import static android.provider.Settings.Global.DEBUG_APP;
import static android.provider.Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT;
import static android.provider.Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT;
import static android.provider.Settings.Global.DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES;
import static android.provider.Settings.Global.DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES;
import static android.provider.Settings.Global.DEVELOPMENT_FORCE_RTL;
import static android.provider.Settings.Global.DEVELOPMENT_FORCE_RTL;
import static android.provider.Settings.Global.HIDE_ERROR_DIALOGS;
import static android.provider.Settings.Global.NETWORK_ACCESS_TIMEOUT_MS;
import static android.provider.Settings.Global.NETWORK_ACCESS_TIMEOUT_MS;
import static android.provider.Settings.Global.WAIT_FOR_DEBUGGER;
import static android.provider.Settings.Global.WAIT_FOR_DEBUGGER;
import static android.provider.Settings.System.FONT_SCALE;
import static android.provider.Settings.System.FONT_SCALE;
@@ -1282,17 +1283,24 @@ public class ActivityManagerService extends IActivityManager.Stub
    private final class FontScaleSettingObserver extends ContentObserver {
    private final class FontScaleSettingObserver extends ContentObserver {
        private final Uri mFontScaleUri = Settings.System.getUriFor(FONT_SCALE);
        private final Uri mFontScaleUri = Settings.System.getUriFor(FONT_SCALE);
        private final Uri mHideErrorDialogsUri = Settings.Global.getUriFor(HIDE_ERROR_DIALOGS);
        public FontScaleSettingObserver() {
        public FontScaleSettingObserver() {
            super(mHandler);
            super(mHandler);
            ContentResolver resolver = mContext.getContentResolver();
            ContentResolver resolver = mContext.getContentResolver();
            resolver.registerContentObserver(mFontScaleUri, false, this, UserHandle.USER_ALL);
            resolver.registerContentObserver(mFontScaleUri, false, this, UserHandle.USER_ALL);
            resolver.registerContentObserver(mHideErrorDialogsUri, false, this,
                    UserHandle.USER_ALL);
        }
        }
        @Override
        @Override
        public void onChange(boolean selfChange, Uri uri, @UserIdInt int userId) {
        public void onChange(boolean selfChange, Uri uri, @UserIdInt int userId) {
            if (mFontScaleUri.equals(uri)) {
            if (mFontScaleUri.equals(uri)) {
                updateFontScaleIfNeeded(userId);
                updateFontScaleIfNeeded(userId);
            } else if (mHideErrorDialogsUri.equals(uri)) {
                synchronized (ActivityManagerService.this) {
                    updateShouldShowDialogsLocked(getGlobalConfiguration());
                }
            }
            }
        }
        }
    }
    }
@@ -22449,7 +22457,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                mUserController.getCurrentUserId());
                mUserController.getCurrentUserId());
        // TODO: If our config changes, should we auto dismiss any currently showing dialogs?
        // TODO: If our config changes, should we auto dismiss any currently showing dialogs?
        mShowDialogs = shouldShowDialogs(mTempConfig);
        updateShouldShowDialogsLocked(mTempConfig);
        AttributeCache ac = AttributeCache.instance();
        AttributeCache ac = AttributeCache.instance();
        if (ac != null) {
        if (ac != null) {
@@ -22704,7 +22712,7 @@ public class ActivityManagerService extends IActivityManager.Stub
     * A thought: SystemUI might also want to get told about this, the Power
     * A thought: SystemUI might also want to get told about this, the Power
     * dialog / global actions also might want different behaviors.
     * dialog / global actions also might want different behaviors.
     */
     */
    private static boolean shouldShowDialogs(Configuration config) {
    private void updateShouldShowDialogsLocked(Configuration config) {
        final boolean inputMethodExists = !(config.keyboard == Configuration.KEYBOARD_NOKEYS
        final boolean inputMethodExists = !(config.keyboard == Configuration.KEYBOARD_NOKEYS
                                   && config.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH
                                   && config.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH
                                   && config.navigation == Configuration.NAVIGATION_NONAV);
                                   && config.navigation == Configuration.NAVIGATION_NONAV);
@@ -22713,7 +22721,9 @@ public class ActivityManagerService extends IActivityManager.Stub
                && !(modeType == Configuration.UI_MODE_TYPE_WATCH && Build.IS_USER)
                && !(modeType == Configuration.UI_MODE_TYPE_WATCH && Build.IS_USER)
                && modeType != Configuration.UI_MODE_TYPE_TELEVISION
                && modeType != Configuration.UI_MODE_TYPE_TELEVISION
                && modeType != Configuration.UI_MODE_TYPE_VR_HEADSET);
                && modeType != Configuration.UI_MODE_TYPE_VR_HEADSET);
        return inputMethodExists && uiModeSupportsDialogs;
        final boolean hideDialogsSet = Settings.Global.getInt(mContext.getContentResolver(),
                HIDE_ERROR_DIALOGS, 0) != 0;
        mShowDialogs = inputMethodExists && uiModeSupportsDialogs && !hideDialogsSet;
    }
    }
    @Override
    @Override