Loading core/java/android/app/ContextImpl.java +4 −1 Original line number Diff line number Diff line Loading @@ -2721,10 +2721,13 @@ class ContextImpl extends Context { // need to override their display in ResourcesManager. baseContext.mForceDisplayOverrideInResources = false; baseContext.mContextType = CONTEXT_TYPE_WINDOW_CONTEXT; baseContext.mDisplay = display; final Resources windowContextResources = createWindowContextResources(baseContext); baseContext.setResources(windowContextResources); // Associate the display with window context resources so that configuration update from // the server side will also apply to the display's metrics. baseContext.mDisplay = ResourcesManager.getInstance() .getAdjustedDisplay(display.getDisplayId(), windowContextResources); return baseContext; } Loading core/java/android/view/IWindowManager.aidl +3 −2 Original line number Diff line number Diff line Loading @@ -814,9 +814,10 @@ interface IWindowManager * @param displayId The display associated with the window context * @param options A bundle used to pass window-related options and choose the right DisplayArea * * @return {@code true} if the WindowContext is attached to the DisplayArea successfully. * @return the DisplayArea's {@link android.app.res.Configuration} if the WindowContext is * attached to the DisplayArea successfully. {@code null}, otherwise. */ boolean attachWindowContextToDisplayArea(IBinder clientToken, int type, int displayId, Configuration attachWindowContextToDisplayArea(IBinder clientToken, int type, int displayId, in Bundle options); /** Loading core/java/android/window/WindowContext.java +1 −2 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.content.Context; import android.content.ContextWrapper; import android.content.res.Configuration; import android.os.Bundle; import android.os.IBinder; import android.view.WindowManager; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -67,7 +66,7 @@ public class WindowContext extends ContextWrapper { mType = type; mOptions = options; mWindowManager = createWindowContextWindowManager(this); IBinder token = getWindowContextToken(); WindowTokenClient token = (WindowTokenClient) getWindowContextToken(); mController = new WindowContextController(token); Reference.reachabilityFence(this); Loading core/java/android/window/WindowContextController.java +13 −7 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ 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; Loading Loading @@ -46,7 +47,7 @@ public class WindowContextController { @VisibleForTesting public boolean mAttachedToDisplayArea; @NonNull private final IBinder mToken; private final WindowTokenClient mToken; /** * Window Context Controller constructor Loading @@ -54,14 +55,13 @@ public class WindowContextController { * @param token The token used to attach to a window manager node. It is usually from * {@link Context#getWindowContextToken()}. */ public WindowContextController(@NonNull IBinder token) { mToken = token; mWms = WindowManagerGlobal.getWindowManagerService(); public WindowContextController(@NonNull WindowTokenClient token) { this(token, WindowManagerGlobal.getWindowManagerService()); } /** Used for test only. DO NOT USE it in production code. */ @VisibleForTesting public WindowContextController(@NonNull IBinder token, IWindowManager mockWms) { public WindowContextController(@NonNull WindowTokenClient token, IWindowManager mockWms) { mToken = token; mWms = mockWms; } Loading @@ -81,8 +81,14 @@ public class WindowContextController { + "a DisplayArea once."); } try { mAttachedToDisplayArea = mWms.attachWindowContextToDisplayArea(mToken, type, displayId, options); 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); } } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading core/java/android/window/WindowTokenClient.java +12 −3 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.content.res.Configuration; import android.os.Bundle; import android.os.IBinder; import com.android.internal.annotations.VisibleForTesting; import java.lang.ref.WeakReference; /** Loading @@ -33,7 +35,7 @@ import java.lang.ref.WeakReference; * {@link Context#getWindowContextToken() the token of non-Activity UI Contexts}. * * @see WindowContext * @see android.view.IWindowManager#registerWindowContextListener(IBinder, int, int, Bundle) * @see android.view.IWindowManager#attachWindowContextToDisplayArea(IBinder, int, int, Bundle) * * @hide */ Loading @@ -50,8 +52,8 @@ public class WindowTokenClient extends IWindowToken.Stub { * Attaches {@code context} to this {@link WindowTokenClient}. Each {@link WindowTokenClient} * can only attach one {@link Context}. * <p>This method must be called before invoking * {@link android.view.IWindowManager#registerWindowContextListener(IBinder, int, int, * Bundle, boolean)}.<p/> * {@link android.view.IWindowManager#attachWindowContextToDisplayArea(IBinder, int, int, * Bundle)}.<p/> * * @param context context to be attached * @throws IllegalStateException if attached context has already existed. Loading @@ -63,6 +65,13 @@ public class WindowTokenClient extends IWindowToken.Stub { mContextRef = new WeakReference<>(context); } /** * Called when {@link Configuration} updates from the server side receive. * * @param newConfig the updated {@link Configuration} * @param newDisplayId the updated {@link android.view.Display} ID */ @VisibleForTesting @Override public void onConfigurationChanged(Configuration newConfig, int newDisplayId) { final Context context = mContextRef.get(); Loading Loading
core/java/android/app/ContextImpl.java +4 −1 Original line number Diff line number Diff line Loading @@ -2721,10 +2721,13 @@ class ContextImpl extends Context { // need to override their display in ResourcesManager. baseContext.mForceDisplayOverrideInResources = false; baseContext.mContextType = CONTEXT_TYPE_WINDOW_CONTEXT; baseContext.mDisplay = display; final Resources windowContextResources = createWindowContextResources(baseContext); baseContext.setResources(windowContextResources); // Associate the display with window context resources so that configuration update from // the server side will also apply to the display's metrics. baseContext.mDisplay = ResourcesManager.getInstance() .getAdjustedDisplay(display.getDisplayId(), windowContextResources); return baseContext; } Loading
core/java/android/view/IWindowManager.aidl +3 −2 Original line number Diff line number Diff line Loading @@ -814,9 +814,10 @@ interface IWindowManager * @param displayId The display associated with the window context * @param options A bundle used to pass window-related options and choose the right DisplayArea * * @return {@code true} if the WindowContext is attached to the DisplayArea successfully. * @return the DisplayArea's {@link android.app.res.Configuration} if the WindowContext is * attached to the DisplayArea successfully. {@code null}, otherwise. */ boolean attachWindowContextToDisplayArea(IBinder clientToken, int type, int displayId, Configuration attachWindowContextToDisplayArea(IBinder clientToken, int type, int displayId, in Bundle options); /** Loading
core/java/android/window/WindowContext.java +1 −2 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.content.Context; import android.content.ContextWrapper; import android.content.res.Configuration; import android.os.Bundle; import android.os.IBinder; import android.view.WindowManager; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -67,7 +66,7 @@ public class WindowContext extends ContextWrapper { mType = type; mOptions = options; mWindowManager = createWindowContextWindowManager(this); IBinder token = getWindowContextToken(); WindowTokenClient token = (WindowTokenClient) getWindowContextToken(); mController = new WindowContextController(token); Reference.reachabilityFence(this); Loading
core/java/android/window/WindowContextController.java +13 −7 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ 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; Loading Loading @@ -46,7 +47,7 @@ public class WindowContextController { @VisibleForTesting public boolean mAttachedToDisplayArea; @NonNull private final IBinder mToken; private final WindowTokenClient mToken; /** * Window Context Controller constructor Loading @@ -54,14 +55,13 @@ public class WindowContextController { * @param token The token used to attach to a window manager node. It is usually from * {@link Context#getWindowContextToken()}. */ public WindowContextController(@NonNull IBinder token) { mToken = token; mWms = WindowManagerGlobal.getWindowManagerService(); public WindowContextController(@NonNull WindowTokenClient token) { this(token, WindowManagerGlobal.getWindowManagerService()); } /** Used for test only. DO NOT USE it in production code. */ @VisibleForTesting public WindowContextController(@NonNull IBinder token, IWindowManager mockWms) { public WindowContextController(@NonNull WindowTokenClient token, IWindowManager mockWms) { mToken = token; mWms = mockWms; } Loading @@ -81,8 +81,14 @@ public class WindowContextController { + "a DisplayArea once."); } try { mAttachedToDisplayArea = mWms.attachWindowContextToDisplayArea(mToken, type, displayId, options); 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); } } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
core/java/android/window/WindowTokenClient.java +12 −3 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.content.res.Configuration; import android.os.Bundle; import android.os.IBinder; import com.android.internal.annotations.VisibleForTesting; import java.lang.ref.WeakReference; /** Loading @@ -33,7 +35,7 @@ import java.lang.ref.WeakReference; * {@link Context#getWindowContextToken() the token of non-Activity UI Contexts}. * * @see WindowContext * @see android.view.IWindowManager#registerWindowContextListener(IBinder, int, int, Bundle) * @see android.view.IWindowManager#attachWindowContextToDisplayArea(IBinder, int, int, Bundle) * * @hide */ Loading @@ -50,8 +52,8 @@ public class WindowTokenClient extends IWindowToken.Stub { * Attaches {@code context} to this {@link WindowTokenClient}. Each {@link WindowTokenClient} * can only attach one {@link Context}. * <p>This method must be called before invoking * {@link android.view.IWindowManager#registerWindowContextListener(IBinder, int, int, * Bundle, boolean)}.<p/> * {@link android.view.IWindowManager#attachWindowContextToDisplayArea(IBinder, int, int, * Bundle)}.<p/> * * @param context context to be attached * @throws IllegalStateException if attached context has already existed. Loading @@ -63,6 +65,13 @@ public class WindowTokenClient extends IWindowToken.Stub { mContextRef = new WeakReference<>(context); } /** * Called when {@link Configuration} updates from the server side receive. * * @param newConfig the updated {@link Configuration} * @param newDisplayId the updated {@link android.view.Display} ID */ @VisibleForTesting @Override public void onConfigurationChanged(Configuration newConfig, int newDisplayId) { final Context context = mContextRef.get(); Loading