summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2013-06-13 10:58:47 +0200
committerDanny Baumann <dannybaumann@web.de>2013-06-13 10:58:47 +0200
commit07bd77415e60cf74da6321fba7a61a2b426b295a (patch)
tree1333d9081c75f426bac7726890de14538cc9c812 /policy
parentc5c33031ad8a0b1fab388319f925155ce58528d4 (diff)
downloadframeworks_base-07bd77415e60cf74da6321fba7a61a2b426b295a.zip
frameworks_base-07bd77415e60cf74da6321fba7a61a2b426b295a.tar.gz
frameworks_base-07bd77415e60cf74da6321fba7a61a2b426b295a.tar.bz2
Fix a number of multi-user bugs.
In particular, expanded desktop mode couldn't be enabled for non-primary users as GlobalActions wrote the setting to the primary user's settings DB. Also fix some other cases where we didn't track the settings for multi-user correctly. Change-Id: I3bec45cb84903120639c2e85c1d71ec9a491933c
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/GlobalActions.java62
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindowManager.java88
2 files changed, 92 insertions, 58 deletions
diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java
index fd17530..36319d7 100644
--- a/policy/src/com/android/internal/policy/impl/GlobalActions.java
+++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java
@@ -30,6 +30,7 @@ import android.app.Profile;
import android.app.ProfileManager;
import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.ContentResolver;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
@@ -284,6 +285,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
};
onAirplaneModeChanged();
+ final ContentResolver cr = mContext.getContentResolver();
mItems = new ArrayList<Action>();
// first: power off
@@ -308,8 +310,9 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
// next: reboot
// only shown if enabled, enabled by default
- if (Settings.System.getInt(mContext.getContentResolver(),
- Settings.System.POWER_MENU_REBOOT_ENABLED, 1) == 1) {
+ boolean showReboot = Settings.System.getIntForUser(cr,
+ Settings.System.POWER_MENU_REBOOT_ENABLED, 1, UserHandle.USER_CURRENT) == 1;
+ if (showReboot) {
mItems.add(
new SinglePressAction(R.drawable.ic_lock_reboot, R.string.global_action_reboot) {
public void onPress() {
@@ -333,10 +336,12 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
// next: profile
// only shown if both system profiles and the menu item is enabled, enabled by default
- if ((Settings.System.getInt(mContext.getContentResolver(),
- Settings.System.SYSTEM_PROFILES_ENABLED, 1) == 1) &&
- (Settings.System.getInt(mContext.getContentResolver(),
- Settings.System.POWER_MENU_PROFILES_ENABLED, 1) == 1)) {
+ boolean showProfiles =
+ Settings.System.getIntForUser(cr,
+ Settings.System.SYSTEM_PROFILES_ENABLED, 1, UserHandle.USER_CURRENT) == 1
+ && Settings.System.getIntForUser(cr,
+ Settings.System.POWER_MENU_PROFILES_ENABLED, 1, UserHandle.USER_CURRENT) == 1;
+ if (showProfiles) {
mItems.add(
new ProfileChooseAction() {
public void onPress() {
@@ -359,8 +364,9 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
// next: screenshot
// only shown if enabled, disabled by default
- if (Settings.System.getInt(mContext.getContentResolver(),
- Settings.System.POWER_MENU_SCREENSHOT_ENABLED, 0) == 1) {
+ boolean showScreenshot = Settings.System.getIntForUser(cr,
+ Settings.System.POWER_MENU_SCREENSHOT_ENABLED, 0, UserHandle.USER_CURRENT) == 1;
+ if (showScreenshot) {
mItems.add(
new SinglePressAction(R.drawable.ic_lock_screenshot, R.string.global_action_screenshot) {
public void onPress() {
@@ -378,21 +384,28 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
}
// next: expanded desktop toggle
- // only shown if enabled, disabled by default
- if(Settings.System.getInt(mContext.getContentResolver(),
- Settings.System.POWER_MENU_EXPANDED_DESKTOP_ENABLED, 0) == 1){
+ // only shown if enabled and expanded desktop is enabled, disabled by default
+ boolean showExpandedDesktop =
+ Settings.System.getIntForUser(cr,
+ Settings.System.EXPANDED_DESKTOP_STYLE, 0, UserHandle.USER_CURRENT) != 0
+ && Settings.System.getIntForUser(cr,
+ Settings.System.POWER_MENU_EXPANDED_DESKTOP_ENABLED, 0, UserHandle.USER_CURRENT) == 1;
+
+ if (showExpandedDesktop) {
mItems.add(mExpandDesktopModeOn);
}
// next: airplane mode
- if (Settings.System.getInt(mContext.getContentResolver(),
- Settings.System.POWER_MENU_AIRPLANE_ENABLED, 1) == 1) {
+ boolean showAirplaneMode = Settings.System.getIntForUser(cr,
+ Settings.System.POWER_MENU_AIRPLANE_ENABLED, 1, UserHandle.USER_CURRENT) == 1;
+ if (showAirplaneMode) {
mItems.add(mAirplaneModeOn);
}
// next: bug report, if enabled
- if (Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.BUGREPORT_IN_POWER_MENU, 0) != 0) {
+ boolean showBugReport = Settings.Secure.getIntForUser(cr,
+ Settings.Secure.BUGREPORT_IN_POWER_MENU, 0, UserHandle.USER_CURRENT) != 0;
+ if (showBugReport) {
mItems.add(
new SinglePressAction(com.android.internal.R.drawable.stat_sys_adb,
R.string.global_action_bug_report) {
@@ -440,15 +453,16 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
}
// next: optionally add a list of users to switch to
- if (Settings.System.getInt(mContext.getContentResolver(),
- Settings.System.POWER_MENU_USER_ENABLED, 0) == 1) {
+ boolean showUsers = Settings.System.getIntForUser(cr,
+ Settings.System.POWER_MENU_USER_ENABLED, 0, UserHandle.USER_CURRENT) == 1;
+ if (showUsers) {
addUsersToMenu(mItems);
}
// last: silent mode
- if ((Settings.System.getInt(mContext.getContentResolver(),
- Settings.System.POWER_MENU_SOUND_ENABLED, 1) == 1) &&
- (SHOW_SILENT_TOGGLE)) {
+ boolean showSoundMode = SHOW_SILENT_TOGGLE && Settings.System.getIntForUser(cr,
+ Settings.System.POWER_MENU_SOUND_ENABLED, 1, UserHandle.USER_CURRENT) == 1;
+ if (showSoundMode) {
mItems.add(mSilentModeAction);
}
@@ -1198,10 +1212,10 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
}
private void onExpandDesktopModeChanged() {
- boolean expandDesktopModeOn = Settings.System.getInt(
+ boolean expandDesktopModeOn = Settings.System.getIntForUser(
mContext.getContentResolver(),
Settings.System.EXPANDED_DESKTOP_STATE,
- 0) == 1;
+ 0, UserHandle.USER_CURRENT) == 1;
mExpandDesktopModeOn.updateState(expandDesktopModeOn ? ToggleAction.State.On : ToggleAction.State.Off);
}
@@ -1226,10 +1240,10 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
* Change the expand desktop mode system setting
*/
private void changeExpandDesktopModeSystemSetting(boolean on) {
- Settings.System.putInt(
+ Settings.System.putIntForUser(
mContext.getContentResolver(),
Settings.System.EXPANDED_DESKTOP_STATE,
- on ? 1 : 0);
+ on ? 1 : 0, UserHandle.USER_CURRENT);
}
private static final class GlobalActionsDialog extends Dialog implements DialogInterface {
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index b1df302..f620c6d 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -659,24 +659,35 @@ public class PhoneWindowManager implements WindowManagerPolicy {
Settings.System.EXPANDED_DESKTOP_STATE), false, this,
UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(
+ Settings.System.EXPANDED_DESKTOP_STYLE), false, this,
+ UserHandle.USER_ALL);
+ resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.ACCELEROMETER_ROTATION_ANGLES), false, this,
UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(
- Settings.System.KEY_HOME_LONG_PRESS_ACTION), false, this);
+ Settings.System.KEY_HOME_LONG_PRESS_ACTION), false, this,
+ UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(
- Settings.System.KEY_MENU_ACTION), false, this);
+ Settings.System.KEY_MENU_ACTION), false, this,
+ UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(
- Settings.System.KEY_MENU_LONG_PRESS_ACTION), false, this);
+ Settings.System.KEY_MENU_LONG_PRESS_ACTION), false, this,
+ UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(
- Settings.System.KEY_ASSIST_ACTION), false, this);
+ Settings.System.KEY_ASSIST_ACTION), false, this,
+ UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(
- Settings.System.KEY_ASSIST_LONG_PRESS_ACTION), false, this);
+ Settings.System.KEY_ASSIST_LONG_PRESS_ACTION), false, this,
+ UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(
- Settings.System.KEY_APP_SWITCH_ACTION), false, this);
+ Settings.System.KEY_APP_SWITCH_ACTION), false, this,
+ UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(
- Settings.System.KEY_APP_SWITCH_LONG_PRESS_ACTION), false, this);
+ Settings.System.KEY_APP_SWITCH_LONG_PRESS_ACTION), false, this,
+ UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(
- Settings.System.HARDWARE_KEY_REBINDING), false, this);
+ Settings.System.HARDWARE_KEY_REBINDING), false, this,
+ UserHandle.USER_ALL);
updateSettings();
}
@@ -909,8 +920,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
final VolumePanel volumePanel = new VolumePanel(ThemeUtils.createUiContext(mContext),
(AudioService) getAudioService());
if (ringerMode == AudioManager.RINGER_MODE_NORMAL) {
- boolean vibrateSetting = Settings.System.getInt(mContext.getContentResolver(),
- Settings.System.VIBRATE_WHEN_RINGING, 0) != 0;
+ boolean vibrateSetting = Settings.System.getIntForUser(mContext.getContentResolver(),
+ Settings.System.VIBRATE_WHEN_RINGING, 0, UserHandle.USER_CURRENT) != 0;
am.setRingerMode(vibrateSetting ? AudioManager.RINGER_MODE_VIBRATE :
AudioManager.RINGER_MODE_SILENT);
} else {
@@ -1340,8 +1351,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mVolBtnMusicControls = (Settings.System.getIntForUser(resolver,
Settings.System.VOLBTN_MUSIC_CONTROLS, 1, UserHandle.USER_CURRENT) == 1);
- boolean keyRebindingEnabled = Settings.System.getInt(resolver,
- Settings.System.HARDWARE_KEY_REBINDING, 0) == 1;
+ boolean keyRebindingEnabled = Settings.System.getIntForUser(resolver,
+ Settings.System.HARDWARE_KEY_REBINDING, 0, UserHandle.USER_CURRENT) == 1;
mHasMenuKeyEnabled = false;
@@ -1373,40 +1384,49 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} else {
if (mHasHomeKey) {
if (mHasAppSwitchKey) {
- mLongPressOnHomeBehavior = Settings.System.getInt(resolver,
- Settings.System.KEY_HOME_LONG_PRESS_ACTION, KEY_ACTION_NOTHING);
+ mLongPressOnHomeBehavior = Settings.System.getIntForUser(resolver,
+ Settings.System.KEY_HOME_LONG_PRESS_ACTION,
+ KEY_ACTION_NOTHING, UserHandle.USER_CURRENT);
} else {
- mLongPressOnHomeBehavior = Settings.System.getInt(resolver,
- Settings.System.KEY_HOME_LONG_PRESS_ACTION, KEY_ACTION_APP_SWITCH);
+ mLongPressOnHomeBehavior = Settings.System.getIntForUser(resolver,
+ Settings.System.KEY_HOME_LONG_PRESS_ACTION,
+ KEY_ACTION_APP_SWITCH, UserHandle.USER_CURRENT);
}
mHasMenuKeyEnabled = (mLongPressOnHomeBehavior == KEY_ACTION_MENU);
}
if (mHasMenuKey) {
- mPressOnMenuBehavior = Settings.System.getInt(resolver,
- Settings.System.KEY_MENU_ACTION, KEY_ACTION_MENU);
+ mPressOnMenuBehavior = Settings.System.getIntForUser(resolver,
+ Settings.System.KEY_MENU_ACTION,
+ KEY_ACTION_MENU, UserHandle.USER_CURRENT);
if (mHasAssistKey) {
- mLongPressOnMenuBehavior = Settings.System.getInt(resolver,
- Settings.System.KEY_MENU_LONG_PRESS_ACTION, KEY_ACTION_NOTHING);
+ mLongPressOnMenuBehavior = Settings.System.getIntForUser(resolver,
+ Settings.System.KEY_MENU_LONG_PRESS_ACTION,
+ KEY_ACTION_NOTHING, UserHandle.USER_CURRENT);
} else {
- mLongPressOnMenuBehavior = Settings.System.getInt(resolver,
- Settings.System.KEY_MENU_LONG_PRESS_ACTION, KEY_ACTION_SEARCH);
+ mLongPressOnMenuBehavior = Settings.System.getIntForUser(resolver,
+ Settings.System.KEY_MENU_LONG_PRESS_ACTION,
+ KEY_ACTION_SEARCH, UserHandle.USER_CURRENT);
}
mHasMenuKeyEnabled |= (mPressOnMenuBehavior == KEY_ACTION_MENU) ||
(mLongPressOnMenuBehavior == KEY_ACTION_MENU);
}
if (mHasAssistKey) {
- mPressOnAssistBehavior = Settings.System.getInt(resolver,
- Settings.System.KEY_ASSIST_ACTION, KEY_ACTION_SEARCH);
- mLongPressOnAssistBehavior = Settings.System.getInt(resolver,
- Settings.System.KEY_ASSIST_LONG_PRESS_ACTION, KEY_ACTION_VOICE_SEARCH);
+ mPressOnAssistBehavior = Settings.System.getIntForUser(resolver,
+ Settings.System.KEY_ASSIST_ACTION,
+ KEY_ACTION_SEARCH, UserHandle.USER_CURRENT);
+ mLongPressOnAssistBehavior = Settings.System.getIntForUser(resolver,
+ Settings.System.KEY_ASSIST_LONG_PRESS_ACTION,
+ KEY_ACTION_VOICE_SEARCH, UserHandle.USER_CURRENT);
mHasMenuKeyEnabled |= (mPressOnAssistBehavior == KEY_ACTION_MENU) ||
(mLongPressOnAssistBehavior == KEY_ACTION_MENU);
}
if (mHasAppSwitchKey) {
- mPressOnAppSwitchBehavior = Settings.System.getInt(resolver,
- Settings.System.KEY_APP_SWITCH_ACTION, KEY_ACTION_APP_SWITCH);
- mLongPressOnAppSwitchBehavior = Settings.System.getInt(resolver,
- Settings.System.KEY_APP_SWITCH_LONG_PRESS_ACTION, KEY_ACTION_NOTHING);
+ mPressOnAppSwitchBehavior = Settings.System.getIntForUser(resolver,
+ Settings.System.KEY_APP_SWITCH_ACTION,
+ KEY_ACTION_APP_SWITCH, UserHandle.USER_CURRENT);
+ mLongPressOnAppSwitchBehavior = Settings.System.getIntForUser(resolver,
+ Settings.System.KEY_APP_SWITCH_LONG_PRESS_ACTION,
+ KEY_ACTION_NOTHING, UserHandle.USER_CURRENT);
mHasMenuKeyEnabled |= (mPressOnAppSwitchBehavior == KEY_ACTION_MENU) ||
(mLongPressOnAppSwitchBehavior == KEY_ACTION_MENU);
}
@@ -1443,8 +1463,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
updateOrientationListenerLp();
}
- mUserRotationAngles = Settings.System.getInt(resolver,
- Settings.System.ACCELEROMETER_ROTATION_ANGLES, -1);
+ mUserRotationAngles = Settings.System.getIntForUser(resolver,
+ Settings.System.ACCELEROMETER_ROTATION_ANGLES, -1, UserHandle.USER_CURRENT);
if (mSystemReady) {
int pointerLocation = Settings.System.getIntForUser(resolver,
@@ -2438,8 +2458,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
return -1;
} else if (keyCode == KeyEvent.KEYCODE_BACK) {
- if (Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.KILL_APP_LONGPRESS_BACK, 0) == 1) {
+ if (Settings.Secure.getIntForUser(mContext.getContentResolver(),
+ Settings.Secure.KILL_APP_LONGPRESS_BACK, 0, UserHandle.USER_CURRENT) == 1) {
if (down && repeatCount == 0) {
mHandler.postDelayed(mBackLongPress, mBackKillTimeout);
}