From 383edb4afaa059405d8a93efd48873ea3f1c047e Mon Sep 17 00:00:00 2001 From: Sunny Shao Date: Wed, 27 Sep 2023 10:52:41 +0800 Subject: [PATCH] Fixed the robo test failed in AutoRotatePreferenceControllerTest and SmartAutoRotatePreferenceControllerTest - Use the correct Settings.System.putIntForUser API. Fixes: 300200193 Fixes: 300201185 Test: atest AutoRotatePreferenceControllerTest Test: atest SmartAutoRotatePreferenceControllerTest Change-Id: Iadd890f21431ccb5d538e40426b0c7d43d46ba52 --- .../display/AutoRotatePreferenceControllerTest.java | 10 ++++++---- .../SmartAutoRotatePreferenceControllerTest.java | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java index 2bcf060eb0d..fd91867121f 100644 --- a/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java @@ -190,15 +190,17 @@ public class AutoRotatePreferenceControllerTest { private void enableAutoRotationPreference() { when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true); when(mContext.getResources().getBoolean(anyInt())).thenReturn(true); - Settings.System.putInt(mContentResolver, - Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 0); + Settings.System.putIntForUser(mContentResolver, + Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 0, + UserHandle.USER_CURRENT); } private void disableAutoRotationPreference() { when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true); when(mContext.getResources().getBoolean(anyInt())).thenReturn(true); - Settings.System.putInt(mContentResolver, - Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 1); + Settings.System.putIntForUser(mContentResolver, + Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 1, + UserHandle.USER_CURRENT); } private void enableAutoRotation() { diff --git a/tests/robotests/src/com/android/settings/display/SmartAutoRotatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/SmartAutoRotatePreferenceControllerTest.java index d9187eb9b4c..9f1b5d4357f 100644 --- a/tests/robotests/src/com/android/settings/display/SmartAutoRotatePreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/display/SmartAutoRotatePreferenceControllerTest.java @@ -236,15 +236,17 @@ public class SmartAutoRotatePreferenceControllerTest { private void enableAutoRotationPreference() { when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true); when(mResources.getBoolean(anyInt())).thenReturn(true); - Settings.System.putInt(mContentResolver, - Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 0); + Settings.System.putIntForUser(mContentResolver, + Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 0, + UserHandle.USER_CURRENT); } private void disableAutoRotationPreference() { when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true); when(mResources.getBoolean(anyInt())).thenReturn(true); - Settings.System.putInt(mContentResolver, - Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 1); + Settings.System.putIntForUser(mContentResolver, + Settings.System.HIDE_ROTATION_LOCK_TOGGLE_FOR_ACCESSIBILITY, 1, + UserHandle.USER_CURRENT); } private void enableAutoRotation() {