diff options
author | 2023-04-26 00:11:15 +0000 | |
---|---|---|
committer | 2023-04-27 21:25:10 +0000 | |
commit | 9011f9236bf61f35ee67df7d9baf4c21e85d6262 (patch) | |
tree | 48e874a0c459415657a22c423eb091f1cfd6c7c6 | |
parent | 9b957e80da7becffd961351ddb7235782efff4f2 (diff) |
Gate QS smart-auto-rotate status with config flag
Test: locally, fliped flag on/off and verified qs change
Bug: 279124099
Change-Id: Ie3b7854c09564af2a93a5430d6e5f0db0a5450c4
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java | 5 | ||||
-rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RotationLockTileTest.java | 31 |
2 files changed, 35 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java index 7f7f8ad6a4c1..2d9f7dd038bc 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java @@ -68,6 +68,7 @@ public class RotationLockTile extends QSTileImpl<BooleanState> implements private final SensorPrivacyManager mPrivacyManager; private final BatteryController mBatteryController; private final SettingObserver mSetting; + private final boolean mAllowRotationResolver; @Inject public RotationLockTile( @@ -105,6 +106,8 @@ public class RotationLockTile extends QSTileImpl<BooleanState> implements } }; mBatteryController.observe(getLifecycle(), this); + mAllowRotationResolver = mContext.getResources().getBoolean( + com.android.internal.R.bool.config_allowRotationResolver); } @Override @@ -145,7 +148,7 @@ public class RotationLockTile extends QSTileImpl<BooleanState> implements final boolean powerSave = mBatteryController.isPowerSave(); final boolean cameraLocked = mPrivacyManager.isSensorPrivacyEnabled(CAMERA); - final boolean cameraRotation = + final boolean cameraRotation = mAllowRotationResolver && !powerSave && !cameraLocked && hasSufficientPermission(mContext) && mController.isCameraRotationEnabled(); state.value = !rotationLocked; diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RotationLockTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RotationLockTileTest.java index e106741499ab..41545fc2abfd 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RotationLockTileTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RotationLockTileTest.java @@ -30,6 +30,7 @@ import android.os.Handler; import android.test.suitebuilder.annotation.SmallTest; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; +import android.testing.TestableResources; import com.android.internal.logging.MetricsLogger; import com.android.systemui.R; @@ -94,14 +95,18 @@ public class RotationLockTileTest extends SysuiTestCase { private RotationLockController mController; private TestableLooper mTestableLooper; private RotationLockTile mLockTile; + private TestableResources mTestableResources; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mTestableLooper = TestableLooper.get(this); + mTestableResources = mContext.getOrCreateTestableResources(); when(mHost.getContext()).thenReturn(mContext); when(mHost.getUserContext()).thenReturn(mContext); + mTestableResources.addOverride(com.android.internal.R.bool.config_allowRotationResolver, + true); mController = new RotationLockControllerImpl(mRotationPolicyWrapper, mDeviceStateRotationLockSettingController, DEFAULT_SETTINGS); @@ -208,6 +213,32 @@ public class RotationLockTileTest extends SysuiTestCase { } @Test + public void testSecondaryString_rotationResolverDisabled_isEmpty() { + mTestableResources.addOverride(com.android.internal.R.bool.config_allowRotationResolver, + false); + mLockTile = new RotationLockTile( + mHost, + mUiEventLogger, + mTestableLooper.getLooper(), + new Handler(mTestableLooper.getLooper()), + new FalsingManagerFake(), + mMetricsLogger, + mStatusBarStateController, + mActivityStarter, + mQSLogger, + mController, + mPrivacyManager, + mBatteryController, + new FakeSettings() + ); + + mLockTile.refreshState(); + mTestableLooper.processAllMessages(); + + assertEquals("", mLockTile.getState().secondaryLabel.toString()); + } + + @Test public void testIcon_whenDisabled_isOffState() { QSTile.BooleanState state = new QSTile.BooleanState(); disableAutoRotation(); |