diff options
| author | 2023-09-11 08:30:40 +0000 | |
|---|---|---|
| committer | 2023-09-11 08:30:40 +0000 | |
| commit | 0584e02a88ae4c7578b373f7af5cea219ee2cc4b (patch) | |
| tree | 9e57e7892d84ae562370c6ae3390e8c8dfae1572 | |
| parent | 3f87fbe0854b73e12dac51c23b34e296a1b2cb4e (diff) | |
| parent | 6884adcf790cb57dc2d5cc558c0291cd3eeccad2 (diff) | |
Merge "Fallback to default display if initial one is detached" into udc-dev am: 1f7b255b0b am: 6884adcf79
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24499331
Change-Id: I067255228460ed48c30c94f4579fec389f242ff9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | core/java/android/window/WindowProviderService.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/core/java/android/window/WindowProviderService.java b/core/java/android/window/WindowProviderService.java index f2ae973500af..611da3cec5c6 100644 --- a/core/java/android/window/WindowProviderService.java +++ b/core/java/android/window/WindowProviderService.java @@ -34,6 +34,7 @@ import android.content.res.Configuration; import android.hardware.display.DisplayManager; import android.os.Bundle; import android.os.IBinder; +import android.util.Log; import android.view.Display; import android.view.WindowManager; import android.view.WindowManager.LayoutParams.WindowType; @@ -52,6 +53,8 @@ import android.view.WindowManagerImpl; @UiContext public abstract class WindowProviderService extends Service implements WindowProvider { + private static final String TAG = WindowProviderService.class.getSimpleName(); + private final Bundle mOptions; private final WindowTokenClient mWindowToken = new WindowTokenClient(); private final WindowContextController mController = new WindowContextController(mWindowToken); @@ -194,8 +197,16 @@ public abstract class WindowProviderService extends Service implements WindowPro public final Context createServiceBaseContext(ActivityThread mainThread, LoadedApk packageInfo) { final Context context = super.createServiceBaseContext(mainThread, packageInfo); - final Display display = context.getSystemService(DisplayManager.class) - .getDisplay(getInitialDisplayId()); + final DisplayManager displayManager = context.getSystemService(DisplayManager.class); + final int initialDisplayId = getInitialDisplayId(); + Display display = displayManager.getDisplay(initialDisplayId); + // Fallback to use the default display if the initial display to start WindowProviderService + // is detached. + if (display == null) { + Log.e(TAG, "Display with id " + initialDisplayId + " not found, falling back to " + + "DEFAULT_DISPLAY"); + display = displayManager.getDisplay(DEFAULT_DISPLAY); + } return context.createTokenContext(mWindowToken, display); } |