summaryrefslogtreecommitdiffstats
path: root/policy/src
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2012-03-22 16:16:17 -0700
committerAmith Yamasani <yamasani@google.com>2012-03-27 11:23:01 -0700
commit135936072b24b090fb63940aea41b408d855a4f3 (patch)
treec10e6a7642df4246937bb6fbd7277b642daf3eee /policy/src
parent0c44525a4888de321c9497204d59c8515f828499 (diff)
downloadframeworks_base-135936072b24b090fb63940aea41b408d855a4f3.zip
frameworks_base-135936072b24b090fb63940aea41b408d855a4f3.tar.gz
frameworks_base-135936072b24b090fb63940aea41b408d855a4f3.tar.bz2
User management and switching
Broadcast intents that get sent out when users are added/removed/switched. More work on generating user-specific information in package manager queries. APIs to update user name and query a user by id. Removed Package.mSetStopped and mSetEnabled, since they're not user specific. User removal: - Cleanup ActivityManager, PackageManager, WallpaperManager, AppWidgetService and AccountManager. - Shutdown processes belonging to the user. Don't show vibrate option in long-press power if there's no vibrator. Lock the screen when switching users, to force unlocking. Change-Id: Ib23a721cb75285eef5fd6ba8c7272462764038fa
Diffstat (limited to 'policy/src')
-rw-r--r--policy/src/com/android/internal/policy/impl/GlobalActions.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java
index bcba3c2..4ebabd3 100644
--- a/policy/src/com/android/internal/policy/impl/GlobalActions.java
+++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java
@@ -23,6 +23,7 @@ import com.android.internal.R;
import android.app.ActivityManagerNative;
import android.app.AlertDialog;
+import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
@@ -31,14 +32,18 @@ import android.content.IntentFilter;
import android.content.pm.UserInfo;
import android.media.AudioManager;
import android.os.Handler;
+import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
+import android.os.ServiceManager;
import android.os.SystemProperties;
+import android.os.Vibrator;
import android.provider.Settings;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.util.Log;
+import android.view.IWindowManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -77,6 +82,8 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
private ToggleAction.State mAirplaneState = ToggleAction.State.Off;
private boolean mIsWaitingForEcmExit = false;
+ private IWindowManager mIWindowManager;
+
/**
* @param context everything needs a context :(
*/
@@ -119,7 +126,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
* @return A new dialog.
*/
private AlertDialog createDialog() {
- mSilentModeAction = new SilentModeAction(mAudioManager, mHandler);
+ mSilentModeAction = new SilentModeAction(mContext, mAudioManager, mHandler);
mAirplaneModeOn = new ToggleAction(
R.drawable.ic_lock_airplane_mode,
@@ -200,6 +207,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
public void onPress() {
try {
ActivityManagerNative.getDefault().switchUser(user.id);
+ getWindowManager().lockNow();
} catch (RemoteException re) {
Log.e(TAG, "Couldn't switch user " + re);
}
@@ -540,10 +548,15 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
private final AudioManager mAudioManager;
private final Handler mHandler;
+ private final boolean mHasVibrator;
+ private final Context mContext;
- SilentModeAction(AudioManager audioManager, Handler handler) {
+ SilentModeAction(Context context, AudioManager audioManager, Handler handler) {
mAudioManager = audioManager;
mHandler = handler;
+ mContext = context;
+ Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
+ mHasVibrator = vibrator != null && vibrator.hasVibrator();
}
private int ringerModeToIndex(int ringerMode) {
@@ -567,6 +580,9 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
// Set up click handler
itemView.setTag(i);
itemView.setOnClickListener(this);
+ if (itemView.getId() == R.id.option2 && !mHasVibrator) {
+ itemView.setVisibility(View.GONE);
+ }
}
return v;
}
@@ -667,4 +683,12 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
intent.putExtra("state", on);
mContext.sendBroadcast(intent);
}
+
+ private IWindowManager getWindowManager() {
+ if (mIWindowManager == null) {
+ IBinder b = ServiceManager.getService(Context.WINDOW_SERVICE);
+ mIWindowManager = IWindowManager.Stub.asInterface(b);
+ }
+ return mIWindowManager;
+ }
}