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

Commit 10179b0a authored by Vladimir Komsiyski's avatar Vladimir Komsiyski Committed by Android (Google) Code Review
Browse files

Merge "Do not crash on operations on closed sessions" into main

parents 0cdf848e ab2db055
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.companion.virtual.computercontrol;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.companion.virtual.ActivityPolicyExemption;
import android.companion.virtual.IVirtualDevice;
@@ -171,11 +172,15 @@ final class ComputerControlSessionImpl extends IComputerControlSession.Stub {
    }

    @Override
    @NonNull
    @Nullable
    public IInteractiveMirrorDisplay createInteractiveMirrorDisplay(
            int width, int height, @NonNull Surface surface) throws RemoteException {
        Objects.requireNonNull(surface);
        Display display = DisplayManagerGlobal.getInstance().getRealDisplay(mVirtualDisplayId);
        if (display == null) {
            // The display we're trying to mirror is gone; likely the session is already closed.
            return null;
        }
        DisplayInfo displayInfo = new DisplayInfo();
        display.getDisplayInfo(displayInfo);
        String name = mParams.name + "-display-mirror-" + mMirrorDisplayCounter.getAndIncrement();
+4 −0
Original line number Diff line number Diff line
@@ -86,6 +86,10 @@ final class InteractiveMirrorDisplayImpl extends IInteractiveMirrorDisplay.Stub

    private void createTouchscreen() throws RemoteException {
        Display display = mVirtualDisplay.getDisplay();
        // The display may no longer be valid if the session has been closed.
        if (!display.isValid()) {
            return;
        }
        String touchscreenName = display.getName() + "-touchscreen";
        VirtualTouchscreenConfig virtualTouchscreenConfig =
                new VirtualTouchscreenConfig.Builder(display.getWidth(), display.getHeight())