Merge "Get rid of usage of Context#getDisplayNoVerify() in SurfaceViewRequestReceiver" into rvc-dev
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/SurfaceViewRequestReceiver.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/SurfaceViewRequestReceiver.java
index 29100ef..8bd7c79 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/SurfaceViewRequestReceiver.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/SurfaceViewRequestReceiver.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.graphics.PixelFormat;
+import android.hardware.display.DisplayManager;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Size;
@@ -59,6 +60,7 @@
if (mSurfaceControlViewHost != null) {
mSurfaceControlViewHost.die();
}
+
SurfaceControl surfaceControl = SurfaceViewRequestUtils.getSurfaceControl(bundle);
if (surfaceControl != null) {
if (viewSize == null) {
@@ -70,8 +72,10 @@
WindowlessWindowManager windowlessWindowManager =
new WindowlessWindowManager(context.getResources().getConfiguration(),
surfaceControl, hostToken);
+ DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
mSurfaceControlViewHost = new SurfaceControlViewHost(context,
- context.getDisplayNoVerify(), windowlessWindowManager);
+ dm.getDisplay(SurfaceViewRequestUtils.getDisplayId(bundle)),
+ windowlessWindowManager);
WindowManager.LayoutParams layoutParams =
new WindowManager.LayoutParams(
viewSize.getWidth(),
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/SurfaceViewRequestUtils.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/SurfaceViewRequestUtils.java
index 4409276..6742a4d 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/SurfaceViewRequestUtils.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/SurfaceViewRequestUtils.java
@@ -26,30 +26,38 @@
public class SurfaceViewRequestUtils {
private static final String KEY_HOST_TOKEN = "host_token";
private static final String KEY_SURFACE_CONTROL = "surface_control";
+ private static final String KEY_DISPLAY_ID = "display_id";
/** Creates a SurfaceView based bundle that stores the input host token and surface control. */
public static Bundle createSurfaceBundle(SurfaceView surfaceView) {
Bundle bundle = new Bundle();
bundle.putBinder(KEY_HOST_TOKEN, surfaceView.getHostToken());
bundle.putParcelable(KEY_SURFACE_CONTROL, surfaceView.getSurfaceControl());
+ bundle.putInt(KEY_DISPLAY_ID, surfaceView.getDisplay().getDisplayId());
return bundle;
}
/**
* Retrieves the SurfaceControl from a bundle created by
* {@link #createSurfaceBundle(SurfaceView)}.
- **/
+ */
public static SurfaceControl getSurfaceControl(Bundle bundle) {
return bundle.getParcelable(KEY_SURFACE_CONTROL);
}
/**
- * Retrieves the input token from a bundle created by
- * {@link #createSurfaceBundle(SurfaceView)}.
- **/
+ * Retrieves the input token from a bundle created by {@link #createSurfaceBundle(SurfaceView)}.
+ */
public static @Nullable IBinder getHostToken(Bundle bundle) {
return bundle.getBinder(KEY_HOST_TOKEN);
}
+ /**
+ * Retrieves the display id from a bundle created by {@link #createSurfaceBundle(SurfaceView)}.
+ */
+ public static int getDisplayId(Bundle bundle) {
+ return bundle.getInt(KEY_DISPLAY_ID);
+ }
+
private SurfaceViewRequestUtils() {}
}