diff options
5 files changed, 253 insertions, 87 deletions
diff --git a/core/java/android/service/wallpaper/IWallpaperConnection.aidl b/core/java/android/service/wallpaper/IWallpaperConnection.aidl index 3c3ef0c0e9eb..a976d0e40423 100644 --- a/core/java/android/service/wallpaper/IWallpaperConnection.aidl +++ b/core/java/android/service/wallpaper/IWallpaperConnection.aidl @@ -24,8 +24,8 @@ import android.app.WallpaperColors; * @hide */ interface IWallpaperConnection { - void attachEngine(IWallpaperEngine engine); - void engineShown(IWallpaperEngine engine); + void attachEngine(IWallpaperEngine engine, int displayId); + void engineShown(IWallpaperEngine engine); ParcelFileDescriptor setWallpaper(String name); void onWallpaperColorsChanged(in WallpaperColors colors); } diff --git a/core/java/android/service/wallpaper/IWallpaperService.aidl b/core/java/android/service/wallpaper/IWallpaperService.aidl index 5fd015781981..99a81f503a95 100644 --- a/core/java/android/service/wallpaper/IWallpaperService.aidl +++ b/core/java/android/service/wallpaper/IWallpaperService.aidl @@ -24,6 +24,6 @@ import android.service.wallpaper.IWallpaperConnection; */ oneway interface IWallpaperService { void attach(IWallpaperConnection connection, - IBinder windowToken, int windowType, boolean isPreview, - int reqWidth, int reqHeight, in Rect padding); + IBinder windowToken, int windowType, boolean isPreview, + int reqWidth, int reqHeight, in Rect padding, int displayId); } diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 4bd86a44a8ed..6f51becfbf03 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -24,7 +24,6 @@ import android.app.Service; import android.app.WallpaperColors; import android.app.WallpaperInfo; import android.app.WallpaperManager; -import android.content.Context; import android.content.Intent; import android.content.res.TypedArray; import android.graphics.Bitmap; @@ -806,7 +805,7 @@ public abstract class WallpaperService extends Service { com.android.internal.R.style.Animation_Wallpaper; mInputChannel = new InputChannel(); if (mSession.addToDisplay(mWindow, mWindow.mSeq, mLayout, View.VISIBLE, - Display.DEFAULT_DISPLAY, mWinFrame, mContentInsets, mStableInsets, + mDisplay.getDisplayId(), mWinFrame, mContentInsets, mStableInsets, mOutsets, mDisplayCutout, mInputChannel) < 0) { Log.w(TAG, "Failed to add window while updating wallpaper surface."); return; @@ -1015,7 +1014,15 @@ public abstract class WallpaperService extends Service { if (mDestroyed) { return; } - + + mDisplayManager = getSystemService(DisplayManager.class); + mDisplay = mDisplayManager.getDisplay(wrapper.mDisplayId); + if (mDisplay == null) { + // TODO(b/115486823) Ignore this engine. + Log.e(TAG, "Attaching to a non-existent display: " + wrapper.mDisplayId); + return; + } + mIWallpaperEngine = wrapper; mCaller = wrapper.mCaller; mConnection = wrapper.mConnection; @@ -1027,10 +1034,7 @@ public abstract class WallpaperService extends Service { mWindow.setSession(mSession); mLayout.packageName = getPackageName(); - - mDisplayManager = (DisplayManager)getSystemService(Context.DISPLAY_SERVICE); mDisplayManager.registerDisplayListener(mDisplayListener, mCaller.getHandler()); - mDisplay = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY); mDisplayState = mDisplay.getState(); if (DEBUG) Log.v(TAG, "onCreate(): " + this); @@ -1268,12 +1272,14 @@ public abstract class WallpaperService extends Service { int mReqWidth; int mReqHeight; final Rect mDisplayPadding = new Rect(); + int mDisplayId; Engine mEngine; IWallpaperEngineWrapper(WallpaperService context, IWallpaperConnection conn, IBinder windowToken, - int windowType, boolean isPreview, int reqWidth, int reqHeight, Rect padding) { + int windowType, boolean isPreview, int reqWidth, int reqHeight, Rect padding, + int displayId) { mCaller = new HandlerCaller(context, context.getMainLooper(), this, true); mConnection = conn; mWindowToken = windowToken; @@ -1282,6 +1288,7 @@ public abstract class WallpaperService extends Service { mReqWidth = reqWidth; mReqHeight = reqHeight; mDisplayPadding.set(padding); + mDisplayId = displayId; Message msg = mCaller.obtainMessage(DO_ATTACH); mCaller.sendMessage(msg); @@ -1353,7 +1360,7 @@ public abstract class WallpaperService extends Service { switch (message.what) { case DO_ATTACH: { try { - mConnection.attachEngine(this); + mConnection.attachEngine(this, mDisplayId); } catch (RemoteException e) { Log.w(TAG, "Wallpaper host disappeared", e); return; @@ -1453,9 +1460,10 @@ public abstract class WallpaperService extends Service { @Override public void attach(IWallpaperConnection conn, IBinder windowToken, - int windowType, boolean isPreview, int reqWidth, int reqHeight, Rect padding) { + int windowType, boolean isPreview, int reqWidth, int reqHeight, Rect padding, + int displayId) { new IWallpaperEngineWrapper(mTarget, conn, windowToken, - windowType, isPreview, reqWidth, reqHeight, padding); + windowType, isPreview, reqWidth, reqHeight, padding, displayId); } } diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index 479f427fb96f..409d2b43f694 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -18,6 +18,7 @@ package com.android.server.wallpaper; import static android.app.WallpaperManager.FLAG_LOCK; import static android.app.WallpaperManager.FLAG_SYSTEM; +import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_AUTO; import static android.os.ParcelFileDescriptor.MODE_CREATE; import static android.os.ParcelFileDescriptor.MODE_READ_ONLY; import static android.os.ParcelFileDescriptor.MODE_READ_WRITE; @@ -56,6 +57,7 @@ import android.graphics.BitmapFactory; import android.graphics.BitmapRegionDecoder; import android.graphics.Color; import android.graphics.Rect; +import android.hardware.display.DisplayManager; import android.os.Binder; import android.os.Bundle; import android.os.Environment; @@ -118,6 +120,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.function.Consumer; public class WallpaperManagerService extends IWallpaperManager.Stub implements IWallpaperManagerService { @@ -640,6 +643,43 @@ public class WallpaperManagerService extends IWallpaperManager.Stub final IPackageManager mIPackageManager; final MyPackageMonitor mMonitor; final AppOpsManager mAppOpsManager; + + private final DisplayManager mDisplayManager; + private final DisplayManager.DisplayListener mDisplayListener = + new DisplayManager.DisplayListener() { + + @Override + public void onDisplayAdded(int displayId) { + synchronized (mLock) { + if (mLastWallpaper != null) { + final WallpaperConnection.DisplayConnector connector = + mLastWallpaper.connection.getDisplayConnectorOrCreate(displayId); + if (connector == null) return; + + connector.connectLocked(mLastWallpaper.connection, mLastWallpaper); + } + } + } + + @Override + public void onDisplayRemoved(int displayId) { + synchronized (mLock) { + if (mLastWallpaper != null) { + final WallpaperConnection.DisplayConnector connector = + mLastWallpaper.connection.getDisplayConnectorOrCreate(displayId); + if (connector == null) return; + connector.disconnectLocked(); + mLastWallpaper.connection.removeDisplayConnector(displayId); + } + } + } + + @Override + public void onDisplayChanged(int displayId) { + // TODO(b/115486823) Review that do we need to handle display changes. + } + }; + /** * Map of color listeners per user id. * The key will be the id of a user or UserHandle.USER_ALL - for wildcard listeners. @@ -775,20 +815,96 @@ public class WallpaperManagerService extends IWallpaperManager.Stub class WallpaperConnection extends IWallpaperConnection.Stub implements ServiceConnection { + /** + * Collect needed info for a display. + */ + private final class DisplayConnector { + final int mDisplayId; + final Binder mToken = new Binder(); + IWallpaperEngine mEngine; + boolean mDimensionsChanged; + boolean mPaddingChanged; + + DisplayConnector(int displayId) { + mDisplayId = displayId; + } + + void ensureStatusHandled() { + if (mDimensionsChanged) { + try { + mEngine.setDesiredSize(mWallpaper.width, mWallpaper.height); + } catch (RemoteException e) { + Slog.w(TAG, "Failed to set wallpaper dimensions", e); + } + mDimensionsChanged = false; + } + if (mPaddingChanged) { + try { + mEngine.setDisplayPadding(mWallpaper.padding); + } catch (RemoteException e) { + Slog.w(TAG, "Failed to set wallpaper padding", e); + } + mPaddingChanged = false; + } + } + + void connectLocked(WallpaperConnection connection, WallpaperData wallpaper) { + if (DEBUG) Slog.v(TAG, "Adding window token: " + mToken); + try { + mIWindowManager.addWindowToken(mToken, TYPE_WALLPAPER, mDisplayId); + } catch (RemoteException e) { + Slog.e(TAG, "Failed add wallpaper window token on display " + mDisplayId, e); + return; + } + + try { + // TODO(b/115486823) Consider the size of non-default display + connection.mService.attach(connection, mToken, TYPE_WALLPAPER, false, + wallpaper.width, wallpaper.height, + wallpaper.padding, mDisplayId); + } catch (RemoteException e) { + Slog.w(TAG, "Failed attaching wallpaper on display", e); + // TODO(b/115486823) Failed when attaching a new engine, however, other engines + // may still working. Should we abandon them all or just ignore this one. + if (mLastWallpaper != null && !mLastWallpaper.wallpaperUpdating) { + bindWallpaperComponentLocked(null /* componentName */, false /* force */, + false /* fromUser */, wallpaper, null /* reply */); + } + } + } + + void disconnectLocked() { + if (DEBUG) Slog.v(TAG, "Removing window token: " + mToken); + try { + mIWindowManager.removeWindowToken(mToken, mDisplayId); + } catch (RemoteException e) { + } + try { + if (mEngine != null) { + mEngine.destroy(); + } + } catch (RemoteException e) { + } + mEngine = null; + } + } + + /** + * A map for each display. + * Use {@link #getDisplayConnectorOrCreate(int displayId)} to ensure the display is usable. + */ + private SparseArray<DisplayConnector> mDisplayConnector = new SparseArray<>(); + /** Time in milliseconds until we expect the wallpaper to reconnect (unless we're in the * middle of an update). If exceeded, the wallpaper gets reset to the system default. */ private static final long WALLPAPER_RECONNECT_TIMEOUT_MS = 10000; final WallpaperInfo mInfo; - final Binder mToken = new Binder(); IWallpaperService mService; - IWallpaperEngine mEngine; WallpaperData mWallpaper; + final int mClientUid; IRemoteCallback mReply; - boolean mDimensionsChanged = false; - boolean mPaddingChanged = false; - private Runnable mResetRunnable = () -> { synchronized (mLock) { if (mShuttingDown) { @@ -809,9 +925,55 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } }; - public WallpaperConnection(WallpaperInfo info, WallpaperData wallpaper) { + WallpaperConnection(WallpaperInfo info, WallpaperData wallpaper, int clientUid) { mInfo = info; mWallpaper = wallpaper; + mClientUid = clientUid; + initDisplayState(); + } + + private void initDisplayState() { + final Display[] displays = mDisplayManager.getDisplays(); + for (Display display : displays) { + if (isUsableDisplay(display)) { + final int displayId = display.getDisplayId(); + mDisplayConnector.append(displayId, new DisplayConnector(displayId)); + } + } + } + + // TODO(b/115486823) Support the system decorations change at runtime. + private boolean isUsableDisplay(Display display) { + return display != null && display.hasAccess(mClientUid) + // TODO(b/114338689) Use WindowManager.supportsSystemDecorations when ready + && (display.supportsSystemDecorations() + || display.getDisplayId() == DEFAULT_DISPLAY); + } + + void forEachDisplayConnector(Consumer<DisplayConnector> action) { + for (int i = mDisplayConnector.size() - 1; i >= 0; i--) { + final DisplayConnector connector = mDisplayConnector.get(i); + action.accept(connector); + } + } + + DisplayConnector getDisplayConnectorOrCreate(int displayId) { + DisplayConnector connector = mDisplayConnector.get(displayId); + if (connector == null) { + final Display display = mDisplayManager.getDisplay(displayId); + if (isUsableDisplay(display)) { + connector = new DisplayConnector(displayId); + mDisplayConnector.append(displayId, connector); + } + } + return connector; + } + + void removeDisplayConnector(int displayId) { + final DisplayConnector connector = mDisplayConnector.get(displayId); + if (connector != null) { + mDisplayConnector.remove(displayId); + } } @Override @@ -839,7 +1001,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub + mWallpaper.wallpaperComponent); } mService = null; - mEngine = null; + forEachDisplayConnector(connector -> connector.mEngine = null); if (mWallpaper.connection == this) { // There is an inherent ordering race between this callback and the // package monitor that receives notice that a package is being updated, @@ -863,7 +1025,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub fgHandler.removeCallbacks(mResetRunnable); fgHandler.postDelayed(mResetRunnable, WALLPAPER_RECONNECT_TIMEOUT_MS); if (DEBUG_LIVE) { - Slog.i(TAG, "Started wallpaper reconnect timeout for " + mWallpaper.wallpaperComponent); + Slog.i(TAG, + "Started wallpaper reconnect timeout for " + mWallpaper.wallpaperComponent); } } @@ -943,39 +1106,38 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } @Override - public void attachEngine(IWallpaperEngine engine) { + public void attachEngine(IWallpaperEngine engine, int displayId) { synchronized (mLock) { - mEngine = engine; - if (mDimensionsChanged) { + final DisplayConnector connector = getDisplayConnectorOrCreate(displayId); + if (connector == null) { try { - mEngine.setDesiredSize(mWallpaper.width, mWallpaper.height); + engine.destroy(); } catch (RemoteException e) { - Slog.w(TAG, "Failed to set wallpaper dimensions", e); + Slog.w(TAG, "Failed to destroy engine", e); } - mDimensionsChanged = false; + return; } - if (mPaddingChanged) { + connector.mEngine = engine; + connector.ensureStatusHandled(); + + // TODO(multi-display) TBD. + if (mInfo != null && mInfo.supportsAmbientMode() && displayId == DEFAULT_DISPLAY) { try { - mEngine.setDisplayPadding(mWallpaper.padding); + connector.mEngine.setInAmbientMode(mInAmbientMode, false /* animated */); } catch (RemoteException e) { - Slog.w(TAG, "Failed to set wallpaper padding", e); + Slog.w(TAG, "Failed to set ambient mode state", e); } - mPaddingChanged = false; } - if (mInfo != null && mInfo.supportsAmbientMode()) { + // TODO(b/115486823) Extends for secondary display. + if (displayId == DEFAULT_DISPLAY) { try { - mEngine.setInAmbientMode(mInAmbientMode, false /* animated */); + // This will trigger onComputeColors in the wallpaper engine. + // It's fine to be locked in here since the binder is oneway. + connector.mEngine.requestWallpaperColors(); } catch (RemoteException e) { - Slog.w(TAG, "Failed to set ambient mode state", e); + Slog.w(TAG, "Failed to request wallpaper colors", e); } } - try { - // This will trigger onComputeColors in the wallpaper engine. - // It's fine to be locked in here since the binder is oneway. - mEngine.requestWallpaperColors(); - } catch (RemoteException e) { - Slog.w(TAG, "Failed to request wallpaper colors", e); - } } } @@ -1162,6 +1324,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub ServiceManager.getService(Context.WINDOW_SERVICE)); mIPackageManager = AppGlobals.getPackageManager(); mAppOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE); + mDisplayManager = mContext.getSystemService(DisplayManager.class); + mDisplayManager.registerDisplayListener(mDisplayListener, null /* handler */); mMonitor = new MyPackageMonitor(); mColorsChangedListeners = new SparseArray<>(); } @@ -1541,6 +1705,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub return false; } + // TODO(b/115486823) Extends this method with specific display. public void setDimensionHints(int width, int height, String callingPackage) throws RemoteException { checkPermission(android.Manifest.permission.SET_WALLPAPER_HINTS); @@ -1560,10 +1725,12 @@ public class WallpaperManagerService extends IWallpaperManager.Stub saveSettingsLocked(userId); if (mCurrentUserId != userId) return; // Don't change the properties now if (wallpaper.connection != null) { - if (wallpaper.connection.mEngine != null) { + // TODO(b/115486823) Extends this method with specific display. + final IWallpaperEngine engine = wallpaper.connection + .getDisplayConnectorOrCreate(DEFAULT_DISPLAY).mEngine; + if (engine != null) { try { - wallpaper.connection.mEngine.setDesiredSize( - width, height); + engine.setDesiredSize(width, height); } catch (RemoteException e) { } notifyCallbacksLocked(wallpaper); @@ -1571,7 +1738,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub // We've attached to the service but the engine hasn't attached back to us // yet. This means it will be created with the previous dimensions, so we // need to update it to the new dimensions once it attaches. - wallpaper.connection.mDimensionsChanged = true; + // TODO(b/115486823) Extends this method with specific display. + wallpaper.connection.getDisplayConnectorOrCreate(DEFAULT_DISPLAY) + .mDimensionsChanged = true; } } } @@ -1600,6 +1769,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } } + // TODO(b/115486823) Extends this method with specific display. public void setDisplayPadding(Rect padding, String callingPackage) { checkPermission(android.Manifest.permission.SET_WALLPAPER_HINTS); if (!isWallpaperSupported(callingPackage)) { @@ -1617,9 +1787,12 @@ public class WallpaperManagerService extends IWallpaperManager.Stub saveSettingsLocked(userId); if (mCurrentUserId != userId) return; // Don't change the properties now if (wallpaper.connection != null) { - if (wallpaper.connection.mEngine != null) { + // TODO(b/115486823) Extends this method with specific display. + final IWallpaperEngine engine = wallpaper.connection + .getDisplayConnectorOrCreate(DEFAULT_DISPLAY).mEngine; + if (engine != null) { try { - wallpaper.connection.mEngine.setDisplayPadding(padding); + engine.setDisplayPadding(padding); } catch (RemoteException e) { } notifyCallbacksLocked(wallpaper); @@ -1627,7 +1800,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub // We've attached to the service but the engine hasn't attached back to us // yet. This means it will be created with the previous dimensions, so we // need to update it to the new dimensions once it attaches. - wallpaper.connection.mPaddingChanged = true; + // TODO(b/115486823) Extends this method with specific display. + wallpaper.connection.getDisplayConnectorOrCreate(DEFAULT_DISPLAY) + .mPaddingChanged = true; } } } @@ -1756,6 +1931,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } } + // TODO(b/115486823) Extends this method with specific display. public void setInAmbientMode(boolean inAmbienMode, boolean animated) { final IWallpaperEngine engine; synchronized (mLock) { @@ -1763,7 +1939,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub final WallpaperData data = mWallpaperMap.get(mCurrentUserId); if (data != null && data.connection != null && data.connection.mInfo != null && data.connection.mInfo.supportsAmbientMode()) { - engine = data.connection.mEngine; + // TODO(b/115486823) Extends this method with specific display. + engine = data.connection.getDisplayConnectorOrCreate(DEFAULT_DISPLAY).mEngine; } else { engine = null; } @@ -2125,7 +2302,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub // Bind the service! if (DEBUG) Slog.v(TAG, "Binding to:" + componentName); - WallpaperConnection newConn = new WallpaperConnection(wi, wallpaper); + final int componentUid = mIPackageManager.getPackageUid(componentName.getPackageName(), + MATCH_DIRECT_BOOT_AUTO, wallpaper.userId); + WallpaperConnection newConn = new WallpaperConnection(wi, wallpaper, componentUid); intent.setComponent(componentName); intent.putExtra(Intent.EXTRA_CLIENT_LABEL, com.android.internal.R.string.wallpaper_binding_label); @@ -2152,14 +2331,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub wallpaper.wallpaperComponent = componentName; wallpaper.connection = newConn; newConn.mReply = reply; - try { - if (wallpaper.userId == mCurrentUserId) { - if (DEBUG) - Slog.v(TAG, "Adding window token: " + newConn.mToken); - mIWindowManager.addWindowToken(newConn.mToken, TYPE_WALLPAPER, DEFAULT_DISPLAY); - mLastWallpaper = wallpaper; - } - } catch (RemoteException e) { + if (wallpaper.userId == mCurrentUserId) { + mLastWallpaper = wallpaper; } } catch (RemoteException e) { String msg = "Remote exception for " + componentName + "\n" + e; @@ -2181,22 +2354,12 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } wallpaper.connection.mReply = null; } - if (wallpaper.connection.mEngine != null) { - try { - wallpaper.connection.mEngine.destroy(); - } catch (RemoteException e) { - } - } mContext.unbindService(wallpaper.connection); - try { - if (DEBUG) - Slog.v(TAG, "Removing window token: " + wallpaper.connection.mToken); - mIWindowManager.removeWindowToken(wallpaper.connection.mToken, DEFAULT_DISPLAY); - } catch (RemoteException e) { - } + wallpaper.connection.forEachDisplayConnector(connector -> connector.disconnectLocked()); wallpaper.connection.mService = null; - wallpaper.connection.mEngine = null; + wallpaper.connection.mDisplayConnector.clear(); wallpaper.connection = null; + if (wallpaper == mLastWallpaper) mLastWallpaper = null; } } @@ -2206,16 +2369,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } void attachServiceLocked(WallpaperConnection conn, WallpaperData wallpaper) { - try { - conn.mService.attach(conn, conn.mToken, - TYPE_WALLPAPER, false, - wallpaper.width, wallpaper.height, wallpaper.padding); - } catch (RemoteException e) { - Slog.w(TAG, "Failed attaching wallpaper; clearing", e); - if (!wallpaper.wallpaperUpdating) { - bindWallpaperComponentLocked(null, false, false, wallpaper, null); - } - } + conn.forEachDisplayConnector(connector-> connector.connectLocked(conn, wallpaper)); } private void notifyCallbacksLocked(WallpaperData wallpaper) { @@ -2801,12 +2955,16 @@ public class WallpaperManagerService extends IWallpaperManager.Stub pw.print(" mInfo.component="); pw.println(conn.mInfo.getComponent()); } - pw.print(" mToken="); - pw.println(conn.mToken); + conn.forEachDisplayConnector(connector -> { + pw.print(" mDisplayId="); + pw.println(connector.mDisplayId); + pw.print(" mToken="); + pw.println(connector.mToken); + pw.print(" mEngine="); + pw.println(connector.mEngine); + }); pw.print(" mService="); pw.println(conn.mService); - pw.print(" mEngine="); - pw.println(conn.mEngine); pw.print(" mLastDiedTime="); pw.println(wallpaper.lastDiedTime - SystemClock.uptimeMillis()); } diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index c47b22fd4082..60f2411bde95 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -2286,7 +2286,7 @@ public class WindowManagerService extends IWindowManager.Stub } synchronized (mGlobalLock) { - final DisplayContent dc = mRoot.getDisplayContent(displayId); + final DisplayContent dc = getDisplayContentOrCreate(displayId, null /* token */); if (dc == null) { Slog.w(TAG_WM, "addWindowToken: Attempted to add token: " + binder + " for non-exiting displayId=" + displayId); |