Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java +67 −1 Original line number Diff line number Diff line Loading @@ -16,9 +16,14 @@ package com.android.systemui.statusbar.phone; import android.content.ContentResolver; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; import android.hardware.display.AmbientDisplayConfiguration; import android.net.Uri; import android.os.Handler; import android.os.PowerManager; import android.os.SystemProperties; import android.os.UserHandle; Loading @@ -34,6 +39,7 @@ import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.systemui.Dumpable; import com.android.systemui.R; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.doze.AlwaysOnDisplayPolicy; import com.android.systemui.doze.DozeScreenState; Loading Loading @@ -86,6 +92,7 @@ public class DozeParameters implements private boolean mDozeAlwaysOn; private boolean mControlScreenOffAnimation; private boolean mIsQuickPickupEnabled; private boolean mKeyguardShowing; @VisibleForTesting Loading @@ -101,10 +108,17 @@ public class DozeParameters implements public void onShadeExpandedChanged(boolean expanded) { updateControlScreenOff(); } @Override public void onUserSwitchComplete(int newUserId) { updateQuickPickupEnabled(); } }; @Inject protected DozeParameters( Context context, @Background Handler handler, @Main Resources resources, AmbientDisplayConfiguration ambientDisplayConfiguration, AlwaysOnDisplayPolicy alwaysOnDisplayPolicy, Loading Loading @@ -146,6 +160,14 @@ public class DozeParameters implements if (mFoldAodAnimationController != null) { mFoldAodAnimationController.addCallback(this); } SettingsObserver quickPickupSettingsObserver = new SettingsObserver(context, handler); quickPickupSettingsObserver.observe(); } private void updateQuickPickupEnabled() { mIsQuickPickupEnabled = mAmbientDisplayConfiguration.quickPickupSensorEnabled(UserHandle.USER_CURRENT); } public boolean getDisplayStateSupported() { Loading Loading @@ -239,8 +261,11 @@ public class DozeParameters implements return mDozeAlwaysOn && !mBatteryController.isAodPowerSave(); } /** * Whether the quick pickup gesture is supported and enabled for the device. */ public boolean isQuickPickupEnabled() { return mAmbientDisplayConfiguration.quickPickupSensorEnabled(UserHandle.USER_CURRENT); return mIsQuickPickupEnabled; } /** Loading Loading @@ -436,6 +461,7 @@ public class DozeParameters implements pw.print("getPickupVibrationThreshold(): "); pw.println(getPickupVibrationThreshold()); pw.print("getSelectivelyRegisterSensorsUsingProx(): "); pw.println(getSelectivelyRegisterSensorsUsingProx()); pw.print("isQuickPickupEnabled(): "); pw.println(isQuickPickupEnabled()); } private boolean getPostureSpecificBool( Loading @@ -458,4 +484,44 @@ public class DozeParameters implements */ void onAlwaysOnChange(); } private final class SettingsObserver extends ContentObserver { private final Uri mQuickPickupGesture = Settings.Secure.getUriFor(Settings.Secure.DOZE_QUICK_PICKUP_GESTURE); private final Uri mPickupGesture = Settings.Secure.getUriFor(Settings.Secure.DOZE_PICK_UP_GESTURE); private final Uri mAlwaysOnEnabled = Settings.Secure.getUriFor(Settings.Secure.DOZE_ALWAYS_ON); private final Context mContext; SettingsObserver(Context context, Handler handler) { super(handler); mContext = context; } void observe() { ContentResolver resolver = mContext.getContentResolver(); resolver.registerContentObserver(mQuickPickupGesture, false, this, UserHandle.USER_ALL); resolver.registerContentObserver(mPickupGesture, false, this, UserHandle.USER_ALL); resolver.registerContentObserver(mAlwaysOnEnabled, false, this, UserHandle.USER_ALL); update(null); } @Override public void onChange(boolean selfChange, Uri uri) { update(uri); } public void update(Uri uri) { if (uri == null || mQuickPickupGesture.equals(uri) || mPickupGesture.equals(uri) || mAlwaysOnEnabled.equals(uri)) { // the quick pickup gesture is dependent on alwaysOn being disabled and // the pickup gesture being enabled updateQuickPickupEnabled(); } } } } packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeParametersTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import static org.mockito.Mockito.when; import android.content.res.Resources; import android.hardware.display.AmbientDisplayConfiguration; import android.os.Handler; import android.os.PowerManager; import android.provider.Settings; import android.test.suitebuilder.annotation.SmallTest; Loading Loading @@ -61,6 +62,7 @@ import java.util.Optional; public class DozeParametersTest extends SysuiTestCase { private DozeParameters mDozeParameters; @Mock Handler mHandler; @Mock Resources mResources; @Mock private AmbientDisplayConfiguration mAmbientDisplayConfiguration; @Mock private AlwaysOnDisplayPolicy mAlwaysOnDisplayPolicy; Loading Loading @@ -102,6 +104,8 @@ public class DozeParametersTest extends SysuiTestCase { .thenReturn(mFoldAodAnimationController); mDozeParameters = new DozeParameters( mContext, mHandler, mResources, mAmbientDisplayConfiguration, mAlwaysOnDisplayPolicy, Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java +67 −1 Original line number Diff line number Diff line Loading @@ -16,9 +16,14 @@ package com.android.systemui.statusbar.phone; import android.content.ContentResolver; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; import android.hardware.display.AmbientDisplayConfiguration; import android.net.Uri; import android.os.Handler; import android.os.PowerManager; import android.os.SystemProperties; import android.os.UserHandle; Loading @@ -34,6 +39,7 @@ import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.systemui.Dumpable; import com.android.systemui.R; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.doze.AlwaysOnDisplayPolicy; import com.android.systemui.doze.DozeScreenState; Loading Loading @@ -86,6 +92,7 @@ public class DozeParameters implements private boolean mDozeAlwaysOn; private boolean mControlScreenOffAnimation; private boolean mIsQuickPickupEnabled; private boolean mKeyguardShowing; @VisibleForTesting Loading @@ -101,10 +108,17 @@ public class DozeParameters implements public void onShadeExpandedChanged(boolean expanded) { updateControlScreenOff(); } @Override public void onUserSwitchComplete(int newUserId) { updateQuickPickupEnabled(); } }; @Inject protected DozeParameters( Context context, @Background Handler handler, @Main Resources resources, AmbientDisplayConfiguration ambientDisplayConfiguration, AlwaysOnDisplayPolicy alwaysOnDisplayPolicy, Loading Loading @@ -146,6 +160,14 @@ public class DozeParameters implements if (mFoldAodAnimationController != null) { mFoldAodAnimationController.addCallback(this); } SettingsObserver quickPickupSettingsObserver = new SettingsObserver(context, handler); quickPickupSettingsObserver.observe(); } private void updateQuickPickupEnabled() { mIsQuickPickupEnabled = mAmbientDisplayConfiguration.quickPickupSensorEnabled(UserHandle.USER_CURRENT); } public boolean getDisplayStateSupported() { Loading Loading @@ -239,8 +261,11 @@ public class DozeParameters implements return mDozeAlwaysOn && !mBatteryController.isAodPowerSave(); } /** * Whether the quick pickup gesture is supported and enabled for the device. */ public boolean isQuickPickupEnabled() { return mAmbientDisplayConfiguration.quickPickupSensorEnabled(UserHandle.USER_CURRENT); return mIsQuickPickupEnabled; } /** Loading Loading @@ -436,6 +461,7 @@ public class DozeParameters implements pw.print("getPickupVibrationThreshold(): "); pw.println(getPickupVibrationThreshold()); pw.print("getSelectivelyRegisterSensorsUsingProx(): "); pw.println(getSelectivelyRegisterSensorsUsingProx()); pw.print("isQuickPickupEnabled(): "); pw.println(isQuickPickupEnabled()); } private boolean getPostureSpecificBool( Loading @@ -458,4 +484,44 @@ public class DozeParameters implements */ void onAlwaysOnChange(); } private final class SettingsObserver extends ContentObserver { private final Uri mQuickPickupGesture = Settings.Secure.getUriFor(Settings.Secure.DOZE_QUICK_PICKUP_GESTURE); private final Uri mPickupGesture = Settings.Secure.getUriFor(Settings.Secure.DOZE_PICK_UP_GESTURE); private final Uri mAlwaysOnEnabled = Settings.Secure.getUriFor(Settings.Secure.DOZE_ALWAYS_ON); private final Context mContext; SettingsObserver(Context context, Handler handler) { super(handler); mContext = context; } void observe() { ContentResolver resolver = mContext.getContentResolver(); resolver.registerContentObserver(mQuickPickupGesture, false, this, UserHandle.USER_ALL); resolver.registerContentObserver(mPickupGesture, false, this, UserHandle.USER_ALL); resolver.registerContentObserver(mAlwaysOnEnabled, false, this, UserHandle.USER_ALL); update(null); } @Override public void onChange(boolean selfChange, Uri uri) { update(uri); } public void update(Uri uri) { if (uri == null || mQuickPickupGesture.equals(uri) || mPickupGesture.equals(uri) || mAlwaysOnEnabled.equals(uri)) { // the quick pickup gesture is dependent on alwaysOn being disabled and // the pickup gesture being enabled updateQuickPickupEnabled(); } } } }
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeParametersTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import static org.mockito.Mockito.when; import android.content.res.Resources; import android.hardware.display.AmbientDisplayConfiguration; import android.os.Handler; import android.os.PowerManager; import android.provider.Settings; import android.test.suitebuilder.annotation.SmallTest; Loading Loading @@ -61,6 +62,7 @@ import java.util.Optional; public class DozeParametersTest extends SysuiTestCase { private DozeParameters mDozeParameters; @Mock Handler mHandler; @Mock Resources mResources; @Mock private AmbientDisplayConfiguration mAmbientDisplayConfiguration; @Mock private AlwaysOnDisplayPolicy mAlwaysOnDisplayPolicy; Loading Loading @@ -102,6 +104,8 @@ public class DozeParametersTest extends SysuiTestCase { .thenReturn(mFoldAodAnimationController); mDozeParameters = new DozeParameters( mContext, mHandler, mResources, mAmbientDisplayConfiguration, mAlwaysOnDisplayPolicy, Loading