summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-09-15 19:33:48 -0700
committerDianne Hackborn <hackbod@google.com>2012-09-15 23:58:55 -0700
commit5dc5a00e7ebadc085ded7e29feacd17e53698486 (patch)
tree8ab1c5a18136c424da04509b8274e581fe1f0edc /policy
parent494ac35c27a0960f57b00bf8457f1956ecf149a2 (diff)
downloadframeworks_base-5dc5a00e7ebadc085ded7e29feacd17e53698486.zip
frameworks_base-5dc5a00e7ebadc085ded7e29feacd17e53698486.tar.gz
frameworks_base-5dc5a00e7ebadc085ded7e29feacd17e53698486.tar.bz2
More multi-user stuff.
- New public APIs to find out when a user goes to the foreground, background, and is first initializing. - New activity manager callback to be involved in the user switch process, allowing other services to let it know when it is safe to stop freezing the screen. - Wallpaper service now implements this to handle its user switch, telling the activity manager when it is done. (Currently this is only handling the old wallpaper going away, we need a little more work to correctly wait for the new wallpaper to get added.) - Lock screen now implements the callback to do its user switch. It also now locks itself when this happens, instead of relying on some other entity making sure it is locked. - Pre-boot broadcasts now go to all users. - WallpaperManager now has an API to find out if a named wallpaper is in use by any users. Change-Id: I27877aef1d82126c0a1428c3d1861619ee5f8653
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/GlobalActions.java1
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java33
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java7
3 files changed, 34 insertions, 7 deletions
diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java
index 753b864..d8e361f 100644
--- a/policy/src/com/android/internal/policy/impl/GlobalActions.java
+++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java
@@ -300,7 +300,6 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
public void onPress() {
try {
ActivityManagerNative.getDefault().switchUser(user.id);
- WindowManagerGlobal.getWindowManagerService().lockNow();
} catch (RemoteException re) {
Log.e(TAG, "Couldn't switch user " + re);
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
index c48e2d7..4524c94 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
@@ -16,6 +16,8 @@
package com.android.internal.policy.impl.keyguard;
+import android.app.ActivityManagerNative;
+import android.app.IUserSwitchObserver;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -32,7 +34,9 @@ import static android.os.BatteryManager.EXTRA_HEALTH;
import android.media.AudioManager;
import android.os.BatteryManager;
import android.os.Handler;
+import android.os.IRemoteCallback;
import android.os.Message;
+import android.os.RemoteException;
import android.provider.Settings;
import com.android.internal.telephony.IccCardConstants;
@@ -136,7 +140,7 @@ public class KeyguardUpdateMonitor {
handleDevicePolicyManagerStateChanged();
break;
case MSG_USER_SWITCHED:
- handleUserSwitched(msg.arg1);
+ handleUserSwitched(msg.arg1, (IRemoteCallback)msg.obj);
break;
case MSG_USER_REMOVED:
handleUserRemoved(msg.arg1);
@@ -183,9 +187,6 @@ public class KeyguardUpdateMonitor {
} else if (DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED
.equals(action)) {
mHandler.sendMessage(mHandler.obtainMessage(MSG_DPM_STATE_CHANGED));
- } else if (Intent.ACTION_USER_SWITCHED.equals(action)) {
- mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHED,
- intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0), 0));
} else if (Intent.ACTION_USER_REMOVED.equals(action)) {
mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_REMOVED,
intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0), 0));
@@ -325,9 +326,25 @@ public class KeyguardUpdateMonitor {
filter.addAction(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION);
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
- filter.addAction(Intent.ACTION_USER_SWITCHED);
filter.addAction(Intent.ACTION_USER_REMOVED);
context.registerReceiver(mBroadcastReceiver, filter);
+
+ try {
+ ActivityManagerNative.getDefault().registerUserSwitchObserver(
+ new IUserSwitchObserver.Stub() {
+ @Override
+ public void onUserSwitching(int newUserId, IRemoteCallback reply) {
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHED,
+ newUserId, 0, reply));
+ }
+ @Override
+ public void onUserSwitchComplete(int newUserId) throws RemoteException {
+ }
+ });
+ } catch (RemoteException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
private void watchForDeviceProvisioning() {
@@ -375,13 +392,17 @@ public class KeyguardUpdateMonitor {
/**
* Handle {@link #MSG_USER_SWITCHED}
*/
- protected void handleUserSwitched(int userId) {
+ protected void handleUserSwitched(int userId, IRemoteCallback reply) {
for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) {
cb.onUserSwitched(userId);
}
}
+ try {
+ reply.sendResult(null);
+ } catch (RemoteException e) {
+ }
}
/**
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
index 1f0f5ef..372b0fc 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
@@ -48,6 +48,7 @@ import android.util.EventLog;
import android.util.Log;
import android.view.KeyEvent;
import android.view.WindowManager;
+import android.view.WindowManagerGlobal;
import android.view.WindowManagerPolicy;
@@ -300,6 +301,12 @@ public class KeyguardViewMediator {
synchronized (KeyguardViewMediator.this) {
resetStateLocked();
}
+ // We should always go back to the locked state when a user
+ // switch happens. Is there a more direct way to do this?
+ try {
+ WindowManagerGlobal.getWindowManagerService().lockNow();
+ } catch (RemoteException e) {
+ }
}
@Override