Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7313a08 authored by dshivangi's avatar dshivangi
Browse files

Adapt to APIs changes in DeviceStateAutoRotateSettingManagerImpl

Fixes: 405149392
Test: atest DeviceStateAutoRotateSettingControllerTest SmartAutoRotateControllerTest
Flag: com.android.window.flags.enable_device_state_auto_rotate_setting_refactor
Change-Id: I2eb71518ded94d9c9c21f790aea2125412cd9731
parent 7eacf7e6
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -113,7 +113,11 @@ public class DeviceStateAutoRotateSettingController extends TogglePreferenceCont

    @Override
    public boolean isChecked() {
        return !mAutoRotateSettingsManager.isRotationLocked(mDeviceState);
        // It is highly unlikely to receive null value here. In the improbable event of null, a
        // non-null update will follow shortly, and the users will potentially see incorrect
        // state for a short time.
        final Boolean isRotationLocked = mAutoRotateSettingsManager.isRotationLocked(mDeviceState);
        return isRotationLocked != null && !isRotationLocked;
    }

    @Override
+7 −3
Original line number Diff line number Diff line
@@ -85,8 +85,7 @@ public class SmartAutoRotateController extends TogglePreferenceController implem
        mPrivacyManager = SensorPrivacyManager.getInstance(context);
        mPowerManager = context.getSystemService(PowerManager.class);
        mDeviceStateAutoRotateSettingsManager =
                DeviceStateAutoRotateSettingManagerProvider.getSingletonInstance(
                        context);
                DeviceStateAutoRotateSettingManagerProvider.getSingletonInstance(context);
    }

    @Override
@@ -100,7 +99,12 @@ public class SmartAutoRotateController extends TogglePreferenceController implem

    protected boolean isRotationLocked() {
        if (DeviceStateAutoRotationHelper.isDeviceStateRotationEnabled(mContext)) {
            return mDeviceStateAutoRotateSettingsManager.isRotationLockedForAllStates();
            // It is highly unlikely to receive null value here. In the improbable event of null, a
            // non-null update will follow shortly, and the users will potentially see incorrect
            // state for a short time.
            final Boolean isRotationLockedForAllStates =
                    mDeviceStateAutoRotateSettingsManager.isRotationLockedForAllStates();
            return isRotationLockedForAllStates == null || isRotationLockedForAllStates;
        }
        return RotationPolicy.isRotationLocked(mContext);
    }