Support addWindow as other user
Support addWindow with the other userId which can be different from Uid.
This can be used when client want to addView for secondary user.
Example:
1. Create context with createContextAsUser or similar method.
2. Get WindowManager with this context.
3. WindowManager#addView
Bug: 151414297
Test: atest WmTests WindowAddRemovePerfTest AddWindowAsUserTest
Change-Id: I13e58d76b1f056f3829bc984c2b61496c8f8d535
diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java
index 7d8a56e..56147f2 100644
--- a/services/core/java/com/android/server/wm/Session.java
+++ b/services/core/java/com/android/server/wm/Session.java
@@ -162,7 +162,19 @@
InsetsState outInsetsState, InsetsSourceControl[] outActiveControls) {
return mService.addWindow(this, window, seq, attrs, viewVisibility, displayId, outFrame,
outContentInsets, outStableInsets, outDisplayCutout, outInputChannel,
- outInsetsState, outActiveControls);
+ outInsetsState, outActiveControls, UserHandle.getUserId(mUid));
+ }
+
+
+ @Override
+ public int addToDisplayAsUser(IWindow window, int seq, WindowManager.LayoutParams attrs,
+ int viewVisibility, int displayId, int userId, Rect outFrame,
+ Rect outContentInsets, Rect outStableInsets,
+ DisplayCutout.ParcelableWrapper outDisplayCutout, InputChannel outInputChannel,
+ InsetsState outInsetsState, InsetsSourceControl[] outActiveControls) {
+ return mService.addWindow(this, window, seq, attrs, viewVisibility, displayId, outFrame,
+ outContentInsets, outStableInsets, outDisplayCutout, outInputChannel,
+ outInsetsState, outActiveControls, userId);
}
@Override
@@ -172,7 +184,7 @@
return mService.addWindow(this, window, seq, attrs, viewVisibility, displayId,
new Rect() /* outFrame */, outContentInsets, outStableInsets,
new DisplayCutout.ParcelableWrapper() /* cutout */, null /* outInputChannel */,
- outInsetsState, null);
+ outInsetsState, null, UserHandle.getUserId(mUid));
}
@Override