diff options
| author | Charles Chen <charlesccchen@google.com> | 2020-11-06 16:24:52 +0800 |
|---|---|---|
| committer | Charles Chen <charlesccchen@google.com> | 2021-03-24 11:26:52 +0800 |
| commit | 9c614d10b8840e1fca83a9948c7ee748afa26283 (patch) | |
| tree | c7e4a247ae62ce27569b9b209267cc3833b58e4b /core/java/android/window/WindowContext.java | |
| parent | f48ece487503bee929ffb4dae9e9c82e89c659d2 (diff) | |
Introduce WindowContextController
This CL extracts the logic which is going to share with
WindowProviderService. It is also the preparation to introduce
WindowProviderService.
Bug: 159767464
Test: atest WindowContextControllerTest
Change-Id: Ib5a4cc8d7853bb01bde1081af091d1069865e3a0
Diffstat (limited to 'core/java/android/window/WindowContext.java')
| -rw-r--r-- | core/java/android/window/WindowContext.java | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/core/java/android/window/WindowContext.java b/core/java/android/window/WindowContext.java index bff2252e3b6d..375f4cf63c3b 100644 --- a/core/java/android/window/WindowContext.java +++ b/core/java/android/window/WindowContext.java @@ -27,10 +27,7 @@ import android.content.ContextWrapper; 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; -import android.view.WindowManagerGlobal; import com.android.internal.annotations.VisibleForTesting; @@ -48,13 +45,11 @@ import java.lang.ref.Reference; @UiContext public class WindowContext extends ContextWrapper { private final WindowManager mWindowManager; - private final IWindowManager mWms; - private final @NonNull IBinder mToken; private final @WindowManager.LayoutParams.WindowType int mType; private final @Nullable Bundle mOptions; - private boolean mListenerRegistered; private final ComponentCallbacksController mCallbacksController = new ComponentCallbacksController(); + private final WindowContextController mController; /** * Default constructor. Will generate a {@link WindowTokenClient} and attach this context to @@ -69,9 +64,9 @@ public class WindowContext extends ContextWrapper { mType = type; mOptions = options; - mWms = WindowManagerGlobal.getWindowManagerService(); - mToken = getWindowContextToken(); mWindowManager = createWindowContextWindowManager(this); + IBinder token = getWindowContextToken(); + mController = new WindowContextController(token); Reference.reachabilityFence(this); } @@ -81,12 +76,7 @@ public class WindowContext extends ContextWrapper { * to receive configuration changes of the associated {@link WindowManager} node. */ public void registerWithServer() { - try { - mListenerRegistered = mWms.registerWindowContextListener(mToken, mType, getDisplayId(), - mOptions); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } + mController.registerListener(mType, getDisplayId(), mOptions); } @Override @@ -106,14 +96,7 @@ public class WindowContext extends ContextWrapper { /** Used for test to invoke because we can't invoke finalize directly. */ @VisibleForTesting public void release() { - if (mListenerRegistered) { - mListenerRegistered = false; - try { - mWms.unregisterWindowContextListener(mToken); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } - } + mController.unregisterListenerIfNeeded(); destroy(); } |
