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

Commit a4b0b8d2 authored by Tracy Zhou's avatar Tracy Zhou
Browse files

Get rid of usage of Context#getDisplayNoVerify() in

SurfaceViewRequestReceiver

Fixes: 149790106
Test: manual
Change-Id: I903f95317acd05cb6f40343a126194a8a4e41c0b
parent 75463684
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.shared.system;

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 @@ public class SurfaceViewRequestReceiver {
        if (mSurfaceControlViewHost != null) {
            mSurfaceControlViewHost.die();
        }

        SurfaceControl surfaceControl = SurfaceViewRequestUtils.getSurfaceControl(bundle);
        if (surfaceControl != null) {
            if (viewSize == null) {
@@ -70,8 +72,10 @@ public class SurfaceViewRequestReceiver {
            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(),
+12 −4
Original line number Diff line number Diff line
@@ -26,30 +26,38 @@ import android.view.SurfaceView;
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() {}
}