Loading core/java/android/provider/Settings.java +11 −0 Original line number Diff line number Diff line Loading @@ -5163,6 +5163,16 @@ public final class Settings { public static final String ACCESSIBILITY_SOFT_KEYBOARD_MODE = "accessibility_soft_keyboard_mode"; /** * Should we disable all animations when accessibility is turned on. On low-power devices * like Android Wear, the performance makes the device unusable. Turning off animations * is a partial fix. * * @hide */ public static final String ACCESSIBILITY_DISABLE_ANIMATIONS = "accessibility_disable_animations"; /** * Default soft keyboard behavior. * Loading Loading @@ -6441,6 +6451,7 @@ public final class Settings { ACCESSIBILITY_CAPTIONING_TYPEFACE, ACCESSIBILITY_CAPTIONING_FONT_SCALE, ACCESSIBILITY_CAPTIONING_WINDOW_COLOR, ACCESSIBILITY_DISABLE_ANIMATIONS, TTS_USE_DEFAULTS, TTS_DEFAULT_RATE, TTS_DEFAULT_PITCH, Loading packages/SettingsProvider/res/values/defaults.xml +3 −0 Original line number Diff line number Diff line Loading @@ -220,4 +220,7 @@ <!-- Default setting for ability to add users from the lock screen --> <bool name="def_add_users_from_lockscreen">false</bool> <!-- Default setting for disable animations when accessibility is turned on. --> <bool name="def_accessibility_disable_animations">false</bool> </resources> packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +3 −0 Original line number Diff line number Diff line Loading @@ -2484,6 +2484,9 @@ class DatabaseHelper extends SQLiteOpenHelper { loadStringSetting(stmt, Settings.Secure.ACCESSIBILITY_SCREEN_READER_URL, R.string.def_accessibility_screen_reader_url); loadBooleanSetting(stmt, Settings.Secure.ACCESSIBILITY_DISABLE_ANIMATIONS, R.bool.def_accessibility_disable_animations); if (SystemProperties.getBoolean("ro.lockscreen.disable.default", false) == true) { loadSetting(stmt, Settings.System.LOCKSCREEN_DISABLED, "1"); } else { Loading services/core/java/com/android/server/wm/WindowManagerService.java +29 −4 Original line number Diff line number Diff line Loading @@ -350,11 +350,13 @@ public class WindowManagerService extends IWindowManager.Stub // Enums for animation scale update types. @Retention(RetentionPolicy.SOURCE) @IntDef({WINDOW_ANIMATION_SCALE, TRANSITION_ANIMATION_SCALE, ANIMATION_DURATION_SCALE}) @IntDef({WINDOW_ANIMATION_SCALE, TRANSITION_ANIMATION_SCALE, ANIMATION_DURATION_SCALE, ACCESSIBILITY_CHANGED}) private @interface UpdateAnimationScaleMode {}; private static final int WINDOW_ANIMATION_SCALE = 0; private static final int TRANSITION_ANIMATION_SCALE = 1; private static final int ANIMATION_DURATION_SCALE = 2; private static final int ACCESSIBILITY_CHANGED = 3; final private KeyguardDisableHandler mKeyguardDisableHandler; Loading Loading @@ -669,6 +671,8 @@ public class WindowManagerService extends IWindowManager.Stub Settings.Global.getUriFor(Settings.Global.TRANSITION_ANIMATION_SCALE); private final Uri mAnimationDurationScaleUri = Settings.Global.getUriFor(Settings.Global.ANIMATOR_DURATION_SCALE); private final Uri mAccessibilityEnabledUri = Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_ENABLED); public SettingsObserver() { super(new Handler()); Loading @@ -681,6 +685,8 @@ public class WindowManagerService extends IWindowManager.Stub UserHandle.USER_ALL); resolver.registerContentObserver(mAnimationDurationScaleUri, false, this, UserHandle.USER_ALL); resolver.registerContentObserver(mAccessibilityEnabledUri, false, this, UserHandle.USER_ALL); } @Override Loading @@ -700,6 +706,9 @@ public class WindowManagerService extends IWindowManager.Stub mode = TRANSITION_ANIMATION_SCALE; } else if (mAnimationDurationScaleUri.equals(uri)) { mode = ANIMATION_DURATION_SCALE; } else if (mAccessibilityEnabledUri.equals(uri)) { // Change all of them. mode = ACCESSIBILITY_CHANGED; } else { // Ignoring unrecognized content changes return; Loading Loading @@ -998,13 +1007,12 @@ public class WindowManagerService extends IWindowManager.Stub public void onLowPowerModeChanged(boolean enabled) { synchronized (mWindowMap) { if (mAnimationsDisabled != enabled && !mAllowAnimationsInLowPowerMode) { mAnimationsDisabled = enabled; dispatchNewAnimatorScaleLocked(null); setShouldAnimationsDisabled(enabled); } } } }); mAnimationsDisabled = mPowerManagerInternal.getLowPowerModeEnabled(); setShouldAnimationsDisabled(mPowerManagerInternal.getLowPowerModeEnabled()); mScreenFrozenLock = mPowerManager.newWakeLock( PowerManager.PARTIAL_WAKE_LOCK, "SCREEN_FROZEN"); mScreenFrozenLock.setReferenceCounted(false); Loading Loading @@ -1087,6 +1095,18 @@ public class WindowManagerService extends IWindowManager.Stub } } private void setShouldAnimationsDisabled(boolean isLowPowerEnabled) { boolean accessibilityEnabled = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1; boolean disableAnimationsWhenAccessibility = Settings.Secure.getInt( mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_DISABLE_ANIMATIONS, 0) == 1; mAnimationsDisabled = isLowPowerEnabled || (accessibilityEnabled && disableAnimationsWhenAccessibility); dispatchNewAnimatorScaleLocked(null); } private void placeWindowAfter(WindowState pos, WindowState window) { final WindowList windows = pos.getWindowList(); final int i = windows.indexOf(pos); Loading Loading @@ -8590,6 +8610,11 @@ public class WindowManagerService extends IWindowManager.Stub dispatchNewAnimatorScaleLocked(null); break; } case ACCESSIBILITY_CHANGED: { setShouldAnimationsDisabled( mPowerManagerInternal.getLowPowerModeEnabled()); } break; } break; } Loading Loading
core/java/android/provider/Settings.java +11 −0 Original line number Diff line number Diff line Loading @@ -5163,6 +5163,16 @@ public final class Settings { public static final String ACCESSIBILITY_SOFT_KEYBOARD_MODE = "accessibility_soft_keyboard_mode"; /** * Should we disable all animations when accessibility is turned on. On low-power devices * like Android Wear, the performance makes the device unusable. Turning off animations * is a partial fix. * * @hide */ public static final String ACCESSIBILITY_DISABLE_ANIMATIONS = "accessibility_disable_animations"; /** * Default soft keyboard behavior. * Loading Loading @@ -6441,6 +6451,7 @@ public final class Settings { ACCESSIBILITY_CAPTIONING_TYPEFACE, ACCESSIBILITY_CAPTIONING_FONT_SCALE, ACCESSIBILITY_CAPTIONING_WINDOW_COLOR, ACCESSIBILITY_DISABLE_ANIMATIONS, TTS_USE_DEFAULTS, TTS_DEFAULT_RATE, TTS_DEFAULT_PITCH, Loading
packages/SettingsProvider/res/values/defaults.xml +3 −0 Original line number Diff line number Diff line Loading @@ -220,4 +220,7 @@ <!-- Default setting for ability to add users from the lock screen --> <bool name="def_add_users_from_lockscreen">false</bool> <!-- Default setting for disable animations when accessibility is turned on. --> <bool name="def_accessibility_disable_animations">false</bool> </resources>
packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +3 −0 Original line number Diff line number Diff line Loading @@ -2484,6 +2484,9 @@ class DatabaseHelper extends SQLiteOpenHelper { loadStringSetting(stmt, Settings.Secure.ACCESSIBILITY_SCREEN_READER_URL, R.string.def_accessibility_screen_reader_url); loadBooleanSetting(stmt, Settings.Secure.ACCESSIBILITY_DISABLE_ANIMATIONS, R.bool.def_accessibility_disable_animations); if (SystemProperties.getBoolean("ro.lockscreen.disable.default", false) == true) { loadSetting(stmt, Settings.System.LOCKSCREEN_DISABLED, "1"); } else { Loading
services/core/java/com/android/server/wm/WindowManagerService.java +29 −4 Original line number Diff line number Diff line Loading @@ -350,11 +350,13 @@ public class WindowManagerService extends IWindowManager.Stub // Enums for animation scale update types. @Retention(RetentionPolicy.SOURCE) @IntDef({WINDOW_ANIMATION_SCALE, TRANSITION_ANIMATION_SCALE, ANIMATION_DURATION_SCALE}) @IntDef({WINDOW_ANIMATION_SCALE, TRANSITION_ANIMATION_SCALE, ANIMATION_DURATION_SCALE, ACCESSIBILITY_CHANGED}) private @interface UpdateAnimationScaleMode {}; private static final int WINDOW_ANIMATION_SCALE = 0; private static final int TRANSITION_ANIMATION_SCALE = 1; private static final int ANIMATION_DURATION_SCALE = 2; private static final int ACCESSIBILITY_CHANGED = 3; final private KeyguardDisableHandler mKeyguardDisableHandler; Loading Loading @@ -669,6 +671,8 @@ public class WindowManagerService extends IWindowManager.Stub Settings.Global.getUriFor(Settings.Global.TRANSITION_ANIMATION_SCALE); private final Uri mAnimationDurationScaleUri = Settings.Global.getUriFor(Settings.Global.ANIMATOR_DURATION_SCALE); private final Uri mAccessibilityEnabledUri = Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_ENABLED); public SettingsObserver() { super(new Handler()); Loading @@ -681,6 +685,8 @@ public class WindowManagerService extends IWindowManager.Stub UserHandle.USER_ALL); resolver.registerContentObserver(mAnimationDurationScaleUri, false, this, UserHandle.USER_ALL); resolver.registerContentObserver(mAccessibilityEnabledUri, false, this, UserHandle.USER_ALL); } @Override Loading @@ -700,6 +706,9 @@ public class WindowManagerService extends IWindowManager.Stub mode = TRANSITION_ANIMATION_SCALE; } else if (mAnimationDurationScaleUri.equals(uri)) { mode = ANIMATION_DURATION_SCALE; } else if (mAccessibilityEnabledUri.equals(uri)) { // Change all of them. mode = ACCESSIBILITY_CHANGED; } else { // Ignoring unrecognized content changes return; Loading Loading @@ -998,13 +1007,12 @@ public class WindowManagerService extends IWindowManager.Stub public void onLowPowerModeChanged(boolean enabled) { synchronized (mWindowMap) { if (mAnimationsDisabled != enabled && !mAllowAnimationsInLowPowerMode) { mAnimationsDisabled = enabled; dispatchNewAnimatorScaleLocked(null); setShouldAnimationsDisabled(enabled); } } } }); mAnimationsDisabled = mPowerManagerInternal.getLowPowerModeEnabled(); setShouldAnimationsDisabled(mPowerManagerInternal.getLowPowerModeEnabled()); mScreenFrozenLock = mPowerManager.newWakeLock( PowerManager.PARTIAL_WAKE_LOCK, "SCREEN_FROZEN"); mScreenFrozenLock.setReferenceCounted(false); Loading Loading @@ -1087,6 +1095,18 @@ public class WindowManagerService extends IWindowManager.Stub } } private void setShouldAnimationsDisabled(boolean isLowPowerEnabled) { boolean accessibilityEnabled = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1; boolean disableAnimationsWhenAccessibility = Settings.Secure.getInt( mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_DISABLE_ANIMATIONS, 0) == 1; mAnimationsDisabled = isLowPowerEnabled || (accessibilityEnabled && disableAnimationsWhenAccessibility); dispatchNewAnimatorScaleLocked(null); } private void placeWindowAfter(WindowState pos, WindowState window) { final WindowList windows = pos.getWindowList(); final int i = windows.indexOf(pos); Loading Loading @@ -8590,6 +8610,11 @@ public class WindowManagerService extends IWindowManager.Stub dispatchNewAnimatorScaleLocked(null); break; } case ACCESSIBILITY_CHANGED: { setShouldAnimationsDisabled( mPowerManagerInternal.getLowPowerModeEnabled()); } break; } break; } Loading