@@ -506,6 +506,7 @@ public void onInputEvent(InputEvent event) {
506506 private boolean mPowerKeyTriggered ;
507507 private long mPowerKeyTime ;
508508
509+ SettingsObserver mSettingsObserver ;
509510 ShortcutManager mShortcutManager ;
510511 PowerManager .WakeLock mBroadcastWakeLock ;
511512 boolean mHavePendingMediaKeyRepeatWithWakeLock ;
@@ -552,23 +553,32 @@ class SettingsObserver extends ContentObserver {
552553 }
553554
554555 void observe () {
556+ // Observe all users' changes
555557 ContentResolver resolver = mContext .getContentResolver ();
556558 resolver .registerContentObserver (Settings .System .getUriFor (
557- Settings .System .END_BUTTON_BEHAVIOR ), false , this );
559+ Settings .System .END_BUTTON_BEHAVIOR ), false , this ,
560+ UserHandle .USER_ALL );
558561 resolver .registerContentObserver (Settings .Secure .getUriFor (
559- Settings .Secure .INCALL_POWER_BUTTON_BEHAVIOR ), false , this );
562+ Settings .Secure .INCALL_POWER_BUTTON_BEHAVIOR ), false , this ,
563+ UserHandle .USER_ALL );
560564 resolver .registerContentObserver (Settings .System .getUriFor (
561- Settings .System .ACCELEROMETER_ROTATION ), false , this );
565+ Settings .System .ACCELEROMETER_ROTATION ), false , this ,
566+ UserHandle .USER_ALL );
562567 resolver .registerContentObserver (Settings .System .getUriFor (
563- Settings .System .USER_ROTATION ), false , this );
568+ Settings .System .USER_ROTATION ), false , this ,
569+ UserHandle .USER_ALL );
564570 resolver .registerContentObserver (Settings .System .getUriFor (
565- Settings .System .SCREEN_OFF_TIMEOUT ), false , this );
571+ Settings .System .SCREEN_OFF_TIMEOUT ), false , this ,
572+ UserHandle .USER_ALL );
566573 resolver .registerContentObserver (Settings .System .getUriFor (
567- Settings .System .POINTER_LOCATION ), false , this );
574+ Settings .System .POINTER_LOCATION ), false , this ,
575+ UserHandle .USER_ALL );
568576 resolver .registerContentObserver (Settings .Secure .getUriFor (
569- Settings .Secure .DEFAULT_INPUT_METHOD ), false , this );
577+ Settings .Secure .DEFAULT_INPUT_METHOD ), false , this ,
578+ UserHandle .USER_ALL );
570579 resolver .registerContentObserver (Settings .System .getUriFor (
571- "fancy_rotation_anim" ), false , this );
580+ "fancy_rotation_anim" ), false , this ,
581+ UserHandle .USER_ALL );
572582 updateSettings ();
573583 }
574584
@@ -875,8 +885,8 @@ public void init(Context context, IWindowManager windowManager,
875885 try {
876886 mOrientationListener .setCurrentRotation (windowManager .getRotation ());
877887 } catch (RemoteException ex ) { }
878- SettingsObserver settingsObserver = new SettingsObserver (mHandler );
879- settingsObserver .observe ();
888+ mSettingsObserver = new SettingsObserver (mHandler );
889+ mSettingsObserver .observe ();
880890 mShortcutManager = new ShortcutManager (context , mHandler );
881891 mShortcutManager .observe ();
882892 mUiMode = context .getResources ().getInteger (
@@ -928,6 +938,10 @@ public void init(Context context, IWindowManager windowManager,
928938 Intent .EXTRA_DOCK_STATE_UNDOCKED );
929939 }
930940
941+ // register for multiuser-relevant broadcasts
942+ filter = new IntentFilter (Intent .ACTION_USER_SWITCHED );
943+ context .registerReceiver (mMultiuserReceiver , filter );
944+
931945 mVibrator = (Vibrator )context .getSystemService (Context .VIBRATOR_SERVICE );
932946 mLongPressVibePattern = getLongIntArray (mContext .getResources (),
933947 com .android .internal .R .array .config_longPressVibePattern );
@@ -1066,22 +1080,25 @@ public void updateSettings() {
10661080 ContentResolver resolver = mContext .getContentResolver ();
10671081 boolean updateRotation = false ;
10681082 synchronized (mLock ) {
1069- mEndcallBehavior = Settings .System .getInt (resolver ,
1083+ mEndcallBehavior = Settings .System .getIntForUser (resolver ,
10701084 Settings .System .END_BUTTON_BEHAVIOR ,
1071- Settings .System .END_BUTTON_BEHAVIOR_DEFAULT );
1072- mIncallPowerBehavior = Settings .Secure .getInt (resolver ,
1085+ Settings .System .END_BUTTON_BEHAVIOR_DEFAULT ,
1086+ UserHandle .USER_CURRENT );
1087+ mIncallPowerBehavior = Settings .Secure .getIntForUser (resolver ,
10731088 Settings .Secure .INCALL_POWER_BUTTON_BEHAVIOR ,
1074- Settings .Secure .INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT );
1089+ Settings .Secure .INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT ,
1090+ UserHandle .USER_CURRENT );
10751091
10761092 // Configure rotation lock.
1077- int userRotation = Settings .System .getInt (resolver ,
1078- Settings .System .USER_ROTATION , Surface .ROTATION_0 );
1093+ int userRotation = Settings .System .getIntForUser (resolver ,
1094+ Settings .System .USER_ROTATION , Surface .ROTATION_0 ,
1095+ UserHandle .USER_CURRENT );
10791096 if (mUserRotation != userRotation ) {
10801097 mUserRotation = userRotation ;
10811098 updateRotation = true ;
10821099 }
1083- int userRotationMode = Settings .System .getInt (resolver ,
1084- Settings .System .ACCELEROMETER_ROTATION , 0 ) != 0 ?
1100+ int userRotationMode = Settings .System .getIntForUser (resolver ,
1101+ Settings .System .ACCELEROMETER_ROTATION , 0 , UserHandle . USER_CURRENT ) != 0 ?
10851102 WindowManagerPolicy .USER_ROTATION_FREE :
10861103 WindowManagerPolicy .USER_ROTATION_LOCKED ;
10871104 if (mUserRotationMode != userRotationMode ) {
@@ -1091,19 +1108,19 @@ public void updateSettings() {
10911108 }
10921109
10931110 if (mSystemReady ) {
1094- int pointerLocation = Settings .System .getInt (resolver ,
1095- Settings .System .POINTER_LOCATION , 0 );
1111+ int pointerLocation = Settings .System .getIntForUser (resolver ,
1112+ Settings .System .POINTER_LOCATION , 0 , UserHandle . USER_CURRENT );
10961113 if (mPointerLocationMode != pointerLocation ) {
10971114 mPointerLocationMode = pointerLocation ;
10981115 mHandler .sendEmptyMessage (pointerLocation != 0 ?
10991116 MSG_ENABLE_POINTER_LOCATION : MSG_DISABLE_POINTER_LOCATION );
11001117 }
11011118 }
11021119 // use screen off timeout setting as the timeout for the lockscreen
1103- mLockScreenTimeout = Settings .System .getInt (resolver ,
1104- Settings .System .SCREEN_OFF_TIMEOUT , 0 );
1105- String imId = Settings .Secure .getString (resolver ,
1106- Settings .Secure .DEFAULT_INPUT_METHOD );
1120+ mLockScreenTimeout = Settings .System .getIntForUser (resolver ,
1121+ Settings .System .SCREEN_OFF_TIMEOUT , 0 , UserHandle . USER_CURRENT );
1122+ String imId = Settings .Secure .getStringForUser (resolver ,
1123+ Settings .Secure .DEFAULT_INPUT_METHOD , UserHandle . USER_CURRENT );
11071124 boolean hasSoftInput = imId != null && imId .length () > 0 ;
11081125 if (mHasSoftInput != hasSoftInput ) {
11091126 mHasSoftInput = hasSoftInput ;
@@ -3557,6 +3574,19 @@ public void onReceive(Context context, Intent intent) {
35573574 }
35583575 };
35593576
3577+ BroadcastReceiver mMultiuserReceiver = new BroadcastReceiver () {
3578+ @ Override
3579+ public void onReceive (Context context , Intent intent ) {
3580+ if (Intent .ACTION_USER_SWITCHED .equals (intent .getAction ())) {
3581+ // tickle the settings observer: this first ensures that we're
3582+ // observing the relevant settings for the newly-active user,
3583+ // and then updates our own bookkeeping based on the now-
3584+ // current user.
3585+ mSettingsObserver .onChange (false );
3586+ }
3587+ }
3588+ };
3589+
35603590 /** {@inheritDoc} */
35613591 public void screenTurnedOff (int why ) {
35623592 EventLog .writeEvent (70000 , 0 );
@@ -3889,16 +3919,19 @@ public void setUserRotationMode(int mode, int rot) {
38893919
38903920 // mUserRotationMode and mUserRotation will be assigned by the content observer
38913921 if (mode == WindowManagerPolicy .USER_ROTATION_LOCKED ) {
3892- Settings .System .putInt (res ,
3922+ Settings .System .putIntForUser (res ,
38933923 Settings .System .USER_ROTATION ,
3894- rot );
3895- Settings .System .putInt (res ,
3924+ rot ,
3925+ UserHandle .USER_CURRENT );
3926+ Settings .System .putIntForUser (res ,
38963927 Settings .System .ACCELEROMETER_ROTATION ,
3897- 0 );
3928+ 0 ,
3929+ UserHandle .USER_CURRENT );
38983930 } else {
3899- Settings .System .putInt (res ,
3931+ Settings .System .putIntForUser (res ,
39003932 Settings .System .ACCELEROMETER_ROTATION ,
3901- 1 );
3933+ 1 ,
3934+ UserHandle .USER_CURRENT );
39023935 }
39033936 }
39043937
@@ -4218,8 +4251,8 @@ public void setCurrentOrientationLw(int newOrientation) {
42184251 }
42194252
42204253 public boolean performHapticFeedbackLw (WindowState win , int effectId , boolean always ) {
4221- final boolean hapticsDisabled = Settings .System .getInt (mContext .getContentResolver (),
4222- Settings .System .HAPTIC_FEEDBACK_ENABLED , 0 ) == 0 ;
4254+ final boolean hapticsDisabled = Settings .System .getIntForUser (mContext .getContentResolver (),
4255+ Settings .System .HAPTIC_FEEDBACK_ENABLED , 0 , UserHandle . USER_CURRENT ) == 0 ;
42234256 if (!always && (hapticsDisabled || mKeyguardMediator .isShowingAndNotHidden ())) {
42244257 return false ;
42254258 }
0 commit comments