Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6aabe49 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fallback to default display if initial one is detached" into...

Merge "Fallback to default display if initial one is detached" into udc-qpr-dev am: 6f69b19c am: d6fb3480

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23580097



Change-Id: I7936d523d0e9c5f2ebe050a6e1efe8ea63f7722d
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 8c1ea99f d6fb3480
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -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);
    }