Merge "Gate QS smart-auto-rotate status with config flag" into udc-dev

This commit is contained in:
Abel Tesfaye
2023-04-28 21:07:05 +00:00
committed by Android (Google) Code Review
2 changed files with 35 additions and 1 deletions

View File

@@ -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;

View File

@@ -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);
@@ -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();