summaryrefslogtreecommitdiff
path: root/core/java/android/window/WindowContextController.java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2021-11-11 14:13:01 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-11-11 14:13:01 +0000
commit60422ba05a75feebeee8fff425846a1250f7c521 (patch)
treee0b968b7bb25f01d08cad66838ba64f0933ed12a /core/java/android/window/WindowContextController.java
parentbf925d3b2f9cb7bc8da7c86fd7ef8803c25dd3ea (diff)
parent930739c45adc046d281de50ab7fa71b963c25785 (diff)
Merge "Revert "[RESTRICT AUTOMERGE] Associate SystemUiContext with DisplayContent"" into sc-v2-dev
Diffstat (limited to 'core/java/android/window/WindowContextController.java')
-rw-r--r--core/java/android/window/WindowContextController.java39
1 files changed, 35 insertions, 4 deletions
diff --git a/core/java/android/window/WindowContextController.java b/core/java/android/window/WindowContextController.java
index 17b675f93f86..5aa623388574 100644
--- a/core/java/android/window/WindowContextController.java
+++ b/core/java/android/window/WindowContextController.java
@@ -19,10 +19,13 @@ package android.window;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
+import android.content.res.Configuration;
import android.os.Bundle;
import android.os.IBinder;
+import android.os.RemoteException;
import android.view.IWindowManager;
import android.view.WindowManager.LayoutParams.WindowType;
+import android.view.WindowManagerGlobal;
import com.android.internal.annotations.VisibleForTesting;
@@ -35,6 +38,7 @@ import com.android.internal.annotations.VisibleForTesting;
* @hide
*/
public class WindowContextController {
+ private final IWindowManager mWms;
/**
* {@code true} to indicate that the {@code mToken} is associated with a
* {@link com.android.server.wm.DisplayArea}. Note that {@code mToken} is able to attach a
@@ -52,7 +56,14 @@ public class WindowContextController {
* {@link Context#getWindowContextToken()}.
*/
public WindowContextController(@NonNull WindowTokenClient token) {
+ this(token, WindowManagerGlobal.getWindowManagerService());
+ }
+
+ /** Used for test only. DO NOT USE it in production code. */
+ @VisibleForTesting
+ public WindowContextController(@NonNull WindowTokenClient token, IWindowManager mockWms) {
mToken = token;
+ mWms = mockWms;
}
/**
@@ -69,7 +80,19 @@ public class WindowContextController {
throw new IllegalStateException("A Window Context can be only attached to "
+ "a DisplayArea once.");
}
- mAttachedToDisplayArea = mToken.attachToDisplayArea(type, displayId, options);
+ try {
+ final Configuration configuration = mWms.attachWindowContextToDisplayArea(mToken, type,
+ displayId, options);
+ if (configuration != null) {
+ mAttachedToDisplayArea = true;
+ // Send the DisplayArea's configuration to WindowContext directly instead of
+ // waiting for dispatching from WMS.
+ mToken.onConfigurationChanged(configuration, displayId,
+ false /* shouldReportConfigChange */);
+ }
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/**
@@ -97,14 +120,22 @@ public class WindowContextController {
throw new IllegalStateException("The Window Context should have been attached"
+ " to a DisplayArea.");
}
- mToken.attachToWindowToken(windowToken);
+ try {
+ mWms.attachWindowContextToWindowToken(mToken, windowToken);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
/** Detaches the window context from the node it's currently associated with. */
public void detachIfNeeded() {
if (mAttachedToDisplayArea) {
- mToken.detachFromWindowContainerIfNeeded();
- mAttachedToDisplayArea = false;
+ try {
+ mWms.detachWindowContextFromWindowContainer(mToken);
+ mAttachedToDisplayArea = false;
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
}
}
}