Check ACCELEROMETER_ROTATION_ANGLES for current user
Fixes a bug where secondary users get the rotation angle settings from user0 instead of their own settings.
Change-Id: I5e76d000a28756b70efc1ab3723edaec4d3714dc
diff --git a/src/com/android/settings/display/DisplayRotation.java b/src/com/android/settings/display/DisplayRotation.java
index 569dd51..f020a21 100644
--- a/src/com/android/settings/display/DisplayRotation.java
+++ b/src/com/android/settings/display/DisplayRotation.java
@@ -20,6 +20,7 @@
import android.database.ContentObserver;
import android.os.Bundle;
import android.os.Handler;
+import android.os.UserHandle;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.SwitchPreference;
@@ -78,9 +79,9 @@
mRotation180Pref = findPreference(ROTATION_180_PREF);
mRotation270Pref = findPreference(ROTATION_270_PREF);
- int mode = Settings.System.getInt(getContentResolver(),
+ int mode = Settings.System.getIntForUser(getContentResolver(),
Settings.System.ACCELEROMETER_ROTATION_ANGLES,
- ROTATION_0_MODE|ROTATION_90_MODE|ROTATION_270_MODE);
+ ROTATION_0_MODE|ROTATION_90_MODE|ROTATION_270_MODE, UserHandle.USER_CURRENT);
mRotation0Pref.setChecked((mode & ROTATION_0_MODE) != 0);
mRotation90Pref.setChecked((mode & ROTATION_90_MODE) != 0);
@@ -138,8 +139,8 @@
mode |= ROTATION_0_MODE;
mRotation0Pref.setChecked(true);
}
- Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(),
- Settings.System.ACCELEROMETER_ROTATION_ANGLES, mode);
+ Settings.System.putIntForUser(getActivity().getApplicationContext().getContentResolver(),
+ Settings.System.ACCELEROMETER_ROTATION_ANGLES, mode, UserHandle.USER_CURRENT);
return true;
}
return super.onPreferenceTreeClick(preference);