|
22 | 22 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; |
23 | 23 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; |
24 | 24 | import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; |
| 25 | +import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; |
| 26 | +import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; |
| 27 | +import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; |
25 | 28 |
|
26 | 29 | import com.android.server.input.InputWindowHandle; |
27 | 30 |
|
|
34 | 37 | import android.graphics.Region; |
35 | 38 | import android.os.IBinder; |
36 | 39 | import android.os.RemoteException; |
| 40 | +import android.os.UserHandle; |
37 | 41 | import android.util.Slog; |
38 | 42 | import android.view.DisplayInfo; |
39 | 43 | import android.view.Gravity; |
@@ -257,13 +261,17 @@ final class WindowState implements WindowManagerPolicy.WindowState { |
257 | 261 |
|
258 | 262 | DisplayContent mDisplayContent; |
259 | 263 |
|
| 264 | + // UserId of the owner. Don't display windows of non-current user. |
| 265 | + final int mOwnerUserId; |
| 266 | + |
260 | 267 | WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token, |
261 | 268 | WindowState attachedWindow, int seq, WindowManager.LayoutParams a, |
262 | 269 | int viewVisibility, final DisplayContent displayContent) { |
263 | 270 | mService = service; |
264 | 271 | mSession = s; |
265 | 272 | mClient = c; |
266 | 273 | mToken = token; |
| 274 | + mOwnerUserId = UserHandle.getUserId(s.mUid); |
267 | 275 | mAttrs.copyFrom(a); |
268 | 276 | mViewVisibility = viewVisibility; |
269 | 277 | mDisplayContent = displayContent; |
@@ -894,6 +902,11 @@ public boolean showLw(boolean doAnimation) { |
894 | 902 | } |
895 | 903 |
|
896 | 904 | boolean showLw(boolean doAnimation, boolean requestAnim) { |
| 905 | + if (isOtherUsersAppWindow()) { |
| 906 | + Slog.w(TAG, "Current user " + mService.mCurrentUserId + " trying to display " |
| 907 | + + this + ", type " + mAttrs.type + ", belonging to " + mOwnerUserId); |
| 908 | + return false; |
| 909 | + } |
897 | 910 | if (mPolicyVisibility && mPolicyVisibilityAfterAnim) { |
898 | 911 | // Already showing. |
899 | 912 | return false; |
@@ -970,6 +983,16 @@ public boolean isAlive() { |
970 | 983 | return mClient.asBinder().isBinderAlive(); |
971 | 984 | } |
972 | 985 |
|
| 986 | + boolean isOtherUsersAppWindow() { |
| 987 | + final int type = mAttrs.type; |
| 988 | + if ((mOwnerUserId != mService.mCurrentUserId) |
| 989 | + && (type >= TYPE_BASE_APPLICATION) && (type <= LAST_APPLICATION_WINDOW) |
| 990 | + && (type != TYPE_APPLICATION_STARTING)) { |
| 991 | + return true; |
| 992 | + } |
| 993 | + return false; |
| 994 | + } |
| 995 | + |
973 | 996 | private static void applyInsets(Region outRegion, Rect frame, Rect inset) { |
974 | 997 | outRegion.set( |
975 | 998 | frame.left + inset.left, frame.top + inset.top, |
|
0 commit comments