summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xservices/java/com/android/server/wm/WindowManagerService.java22
-rw-r--r--services/java/com/android/server/wm/WindowState.java23
-rw-r--r--services/java/com/android/server/wm/WindowStateAnimator.java5
3 files changed, 45 insertions, 5 deletions
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index c1884dabb0bb..76a5f1ebc382 100755
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -318,15 +318,25 @@ public class WindowManagerService extends IWindowManager.Stub
final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- mPolicy.enableKeyguard(true);
- synchronized(mKeyguardTokenWatcher) {
- // lazily evaluate this next time we're asked to disable keyguard
- mAllowDisableKeyguard = ALLOW_DISABLE_UNKNOWN;
- mKeyguardDisabled = false;
+ final String action = intent.getAction();
+ if (DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED.equals(action)) {
+ mPolicy.enableKeyguard(true);
+ synchronized(mKeyguardTokenWatcher) {
+ // lazily evaluate this next time we're asked to disable keyguard
+ mAllowDisableKeyguard = ALLOW_DISABLE_UNKNOWN;
+ mKeyguardDisabled = false;
+ }
+ } else if (Intent.ACTION_USER_SWITCHED.equals(action)) {
+ final int newUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
+ Slog.v(TAG, "Switching user from " + mCurrentUserId + " to " + newUserId);
+ mCurrentUserId = newUserId;
}
}
};
+ // Current user when multi-user is enabled. Don't show windows of non-current user.
+ int mCurrentUserId;
+
final Context mContext;
final boolean mHaveInputMethods;
@@ -908,6 +918,8 @@ public class WindowManagerService extends IWindowManager.Stub
// Track changes to DevicePolicyManager state so we can enable/disable keyguard.
IntentFilter filter = new IntentFilter();
filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
+ // Track user switching.
+ filter.addAction(Intent.ACTION_USER_SWITCHED);
mContext.registerReceiver(mBroadcastReceiver, filter);
mHoldingScreenWakeLock = pmc.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK
diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java
index 43ff3987e5cf..ae641a30d66d 100644
--- a/services/java/com/android/server/wm/WindowState.java
+++ b/services/java/com/android/server/wm/WindowState.java
@@ -22,6 +22,9 @@ import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
+import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
+import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
+import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import com.android.server.input.InputWindowHandle;
@@ -34,6 +37,7 @@ import android.graphics.RectF;
import android.graphics.Region;
import android.os.IBinder;
import android.os.RemoteException;
+import android.os.UserHandle;
import android.util.Slog;
import android.view.DisplayInfo;
import android.view.Gravity;
@@ -257,6 +261,9 @@ final class WindowState implements WindowManagerPolicy.WindowState {
DisplayContent mDisplayContent;
+ // UserId of the owner. Don't display windows of non-current user.
+ final int mOwnerUserId;
+
WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token,
WindowState attachedWindow, int seq, WindowManager.LayoutParams a,
int viewVisibility, final DisplayContent displayContent) {
@@ -264,6 +271,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
mSession = s;
mClient = c;
mToken = token;
+ mOwnerUserId = UserHandle.getUserId(s.mUid);
mAttrs.copyFrom(a);
mViewVisibility = viewVisibility;
mDisplayContent = displayContent;
@@ -894,6 +902,11 @@ final class WindowState implements WindowManagerPolicy.WindowState {
}
boolean showLw(boolean doAnimation, boolean requestAnim) {
+ if (isOtherUsersAppWindow()) {
+ Slog.w(TAG, "Current user " + mService.mCurrentUserId + " trying to display "
+ + this + ", type " + mAttrs.type + ", belonging to " + mOwnerUserId);
+ return false;
+ }
if (mPolicyVisibility && mPolicyVisibilityAfterAnim) {
// Already showing.
return false;
@@ -970,6 +983,16 @@ final class WindowState implements WindowManagerPolicy.WindowState {
return mClient.asBinder().isBinderAlive();
}
+ boolean isOtherUsersAppWindow() {
+ final int type = mAttrs.type;
+ if ((mOwnerUserId != mService.mCurrentUserId)
+ && (type >= TYPE_BASE_APPLICATION) && (type <= LAST_APPLICATION_WINDOW)
+ && (type != TYPE_APPLICATION_STARTING)) {
+ return true;
+ }
+ return false;
+ }
+
private static void applyInsets(Region outRegion, Rect frame, Rect inset) {
outRegion.set(
frame.left + inset.left, frame.top + inset.top,
diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java
index d931426a3bed..b213b291cd1c 100644
--- a/services/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/java/com/android/server/wm/WindowStateAnimator.java
@@ -1300,6 +1300,11 @@ class WindowStateAnimator {
// This must be called while inside a transaction.
boolean performShowLocked() {
+ if (mWin.isOtherUsersAppWindow()) {
+ Slog.w(TAG, "Current user " + mService.mCurrentUserId + " trying to display "
+ + this + ", type " + mWin.mAttrs.type + ", belonging to " + mWin.mOwnerUserId);
+ return false;
+ }
if (DEBUG_VISIBILITY || (DEBUG_STARTING_WINDOW &&
mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING)) {
RuntimeException e = null;