Loading packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java +4 −1 Original line number Diff line number Diff line Loading @@ -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( Loading Loading @@ -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 Loading Loading @@ -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; Loading packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RotationLockTileTest.java +31 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -207,6 +212,32 @@ public class RotationLockTileTest extends SysuiTestCase { assertEquals("", mLockTile.getState().secondaryLabel.toString()); } @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(); Loading Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java +4 −1 Original line number Diff line number Diff line Loading @@ -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( Loading Loading @@ -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 Loading Loading @@ -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; Loading
packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RotationLockTileTest.java +31 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -207,6 +212,32 @@ public class RotationLockTileTest extends SysuiTestCase { assertEquals("", mLockTile.getState().secondaryLabel.toString()); } @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(); Loading