Loading src/com/android/settings/display/SmartAutoRotatePreferenceController.java +6 −13 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import static android.provider.Settings.Secure.CAMERA_AUTOROTATE; import android.content.Context; import android.os.UserHandle; import android.provider.Settings; import android.util.Log; import androidx.preference.Preference; Loading @@ -34,8 +33,6 @@ import com.android.settings.core.BasePreferenceController; */ public class SmartAutoRotatePreferenceController extends BasePreferenceController { private static final String TAG = "SmartAutoRotatePreferenceController"; public SmartAutoRotatePreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); } Loading @@ -54,16 +51,12 @@ public class SmartAutoRotatePreferenceController extends BasePreferenceControlle public CharSequence getSummary() { int activeStringId = R.string.auto_rotate_option_off; if (!RotationPolicy.isRotationLocked(mContext)) { try { final int cameraRotate = Settings.Secure.getIntForUser( mContext.getContentResolver(), CAMERA_AUTOROTATE, UserHandle.USER_CURRENT); 0, UserHandle.USER_CURRENT); activeStringId = cameraRotate == 1 ? R.string.auto_rotate_option_face_based : R.string.auto_rotate_option_on; } catch (Settings.SettingNotFoundException e) { Log.w(TAG, "CAMERA_AUTOROTATE setting not found", e); } } return mContext.getString(activeStringId); } Loading tests/robotests/src/com/android/settings/display/SmartAutoRotatePreferenceControllerTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,25 @@ public class SmartAutoRotatePreferenceControllerTest { assertThat(mController.getSummary()).isEqualTo("Off"); } @Test public void updatePreference_settingsIsOff_noSmartAuto_shouldTurnOffToggle() { disableAutoRotation(); Settings.Secure.putStringForUser(mContentResolver, CAMERA_AUTOROTATE, null, UserHandle.USER_CURRENT); assertThat(mController.getSummary()).isEqualTo("Off"); } @Test public void updatePreference_settingsIsOn_noSmartAuto_shouldTurnOnToggle() { enableAutoRotation(); Settings.Secure.putStringForUser(mContentResolver, CAMERA_AUTOROTATE, null, UserHandle.USER_CURRENT); assertThat(mController.getSummary()).isEqualTo("On"); } @Test public void testGetAvailabilityStatus() { assertThat(mController.getAvailabilityStatus()).isEqualTo(BasePreferenceController Loading Loading
src/com/android/settings/display/SmartAutoRotatePreferenceController.java +6 −13 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import static android.provider.Settings.Secure.CAMERA_AUTOROTATE; import android.content.Context; import android.os.UserHandle; import android.provider.Settings; import android.util.Log; import androidx.preference.Preference; Loading @@ -34,8 +33,6 @@ import com.android.settings.core.BasePreferenceController; */ public class SmartAutoRotatePreferenceController extends BasePreferenceController { private static final String TAG = "SmartAutoRotatePreferenceController"; public SmartAutoRotatePreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); } Loading @@ -54,16 +51,12 @@ public class SmartAutoRotatePreferenceController extends BasePreferenceControlle public CharSequence getSummary() { int activeStringId = R.string.auto_rotate_option_off; if (!RotationPolicy.isRotationLocked(mContext)) { try { final int cameraRotate = Settings.Secure.getIntForUser( mContext.getContentResolver(), CAMERA_AUTOROTATE, UserHandle.USER_CURRENT); 0, UserHandle.USER_CURRENT); activeStringId = cameraRotate == 1 ? R.string.auto_rotate_option_face_based : R.string.auto_rotate_option_on; } catch (Settings.SettingNotFoundException e) { Log.w(TAG, "CAMERA_AUTOROTATE setting not found", e); } } return mContext.getString(activeStringId); } Loading
tests/robotests/src/com/android/settings/display/SmartAutoRotatePreferenceControllerTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,25 @@ public class SmartAutoRotatePreferenceControllerTest { assertThat(mController.getSummary()).isEqualTo("Off"); } @Test public void updatePreference_settingsIsOff_noSmartAuto_shouldTurnOffToggle() { disableAutoRotation(); Settings.Secure.putStringForUser(mContentResolver, CAMERA_AUTOROTATE, null, UserHandle.USER_CURRENT); assertThat(mController.getSummary()).isEqualTo("Off"); } @Test public void updatePreference_settingsIsOn_noSmartAuto_shouldTurnOnToggle() { enableAutoRotation(); Settings.Secure.putStringForUser(mContentResolver, CAMERA_AUTOROTATE, null, UserHandle.USER_CURRENT); assertThat(mController.getSummary()).isEqualTo("On"); } @Test public void testGetAvailabilityStatus() { assertThat(mController.getAvailabilityStatus()).isEqualTo(BasePreferenceController Loading