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

Commit 8c6fb772 authored by dakinola's avatar dakinola
Browse files

Add logs to identify more virtual display error states and media projection stop states

Bug: 290540247
Test: N/A
Change-Id: Ic3cc9ecff0d27e973925addb7cf4a87a430c2666
parent 7b9199ce
Loading
Loading
Loading
Loading
+12 −24
Original line number Diff line number Diff line
@@ -427,12 +427,6 @@
      "group": "WM_DEBUG_BACK_PREVIEW",
      "at": "com\/android\/server\/wm\/BackNavigationController.java"
    },
    "-1715268616": {
      "message": "Last window, removing starting window %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_STARTING_WINDOW",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "-1710206702": {
      "message": "Display id=%d is frozen while keyguard locked, return %d",
      "level": "VERBOSE",
@@ -691,6 +685,12 @@
      "group": "WM_DEBUG_WINDOW_TRANSITIONS",
      "at": "com\/android\/server\/wm\/Transition.java"
    },
    "-1449515133": {
      "message": "Content Recording: stopping active projection for display %d",
      "level": "ERROR",
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/ContentRecorder.java"
    },
    "-1443029505": {
      "message": "SAFE MODE ENABLED (menu=%d s=%d dpad=%d trackball=%d)",
      "level": "INFO",
@@ -1279,6 +1279,12 @@
      "group": "WM_DEBUG_STATES",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "-921346089": {
      "message": "Content Recording: Unable to tell MediaProjectionManagerService to stop the active projection for display %d: %s",
      "level": "ERROR",
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/ContentRecorder.java"
    },
    "-917215012": {
      "message": "%s: caller %d is using old GET_TASKS but privileged; allowing",
      "level": "WARN",
@@ -2227,12 +2233,6 @@
      "group": "WM_DEBUG_CONFIGURATION",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "-88873335": {
      "message": "Content Recording: Unable to tell MediaProjectionManagerService to stop the active projection: %s",
      "level": "ERROR",
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/ContentRecorder.java"
    },
    "-87705714": {
      "message": "findFocusedWindow: focusedApp=null using new focus @ %s",
      "level": "VERBOSE",
@@ -4057,12 +4057,6 @@
      "group": "WM_DEBUG_WINDOW_TRANSITIONS",
      "at": "com\/android\/server\/wm\/Transition.java"
    },
    "1671994402": {
      "message": "Nulling last startingData",
      "level": "VERBOSE",
      "group": "WM_DEBUG_STARTING_WINDOW",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "1674747211": {
      "message": "%s forcing orientation to %d for display id=%d",
      "level": "VERBOSE",
@@ -4243,12 +4237,6 @@
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "1853793312": {
      "message": "Notify removed startingWindow %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_STARTING_WINDOW",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "1856783490": {
      "message": "resumeTopActivity: Restarting %s",
      "level": "DEBUG",
+23 −7
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ public final class MediaProjection {
        try {
            mImpl.start(new MediaProjectionCallback());
        } catch (RemoteException e) {
            Log.e(TAG, "Content Recording: Failed to start media projection", e);
            throw new RuntimeException("Failed to start media projection", e);
        }
        mDisplayManager = displayManager;
@@ -105,11 +106,18 @@ public final class MediaProjection {
     * @see #unregisterCallback
     */
    public void registerCallback(@NonNull Callback callback, @Nullable Handler handler) {
        try {
            final Callback c = Objects.requireNonNull(callback);
            if (handler == null) {
                handler = new Handler();
            }
            mCallbacks.put(c, new CallbackRecord(c, handler));
        } catch (NullPointerException e) {
            Log.e(TAG, "Content Recording: cannot register null Callback", e);
            throw e;
        } catch (RuntimeException e) {
            Log.e(TAG, "Content Recording: failed to create new Handler to register Callback", e);
        }
    }

    /**
@@ -120,8 +128,13 @@ public final class MediaProjection {
     * @see #registerCallback
     */
    public void unregisterCallback(@NonNull Callback callback) {
        try {
            final Callback c = Objects.requireNonNull(callback);
            mCallbacks.remove(c);
        } catch (NullPointerException e) {
            Log.d(TAG, "Content Recording: cannot unregister null Callback", e);
            throw e;
        }
    }

    /**
@@ -203,9 +216,11 @@ public final class MediaProjection {
            @Nullable VirtualDisplay.Callback callback, @Nullable Handler handler) {
        if (shouldMediaProjectionRequireCallback()) {
            if (mCallbacks.isEmpty()) {
                throw new IllegalStateException(
                final IllegalStateException e = new IllegalStateException(
                        "Must register a callback before starting capture, to manage resources in"
                                + " response to MediaProjection states.");
                Log.e(TAG, "Content Recording: no callback registered for virtual display", e);
                throw e;
            }
        }
        final VirtualDisplayConfig.Builder builder = new VirtualDisplayConfig.Builder(name, width,
@@ -272,6 +287,7 @@ public final class MediaProjection {
     */
    public void stop() {
        try {
            Log.d(TAG, "Content Recording: stopping projection");
            mImpl.stop();
        } catch (RemoteException e) {
            Log.e(TAG, "Unable to stop projection", e);
+3 −0
Original line number Diff line number Diff line
@@ -256,6 +256,7 @@ public final class MediaProjectionManager {
     */
    public void stopActiveProjection() {
        try {
            Log.d(TAG, "Content Recording: stopping active projection");
            mService.stopActiveProjection();
        } catch (RemoteException e) {
            Log.e(TAG, "Unable to stop the currently active media projection", e);
@@ -269,6 +270,7 @@ public final class MediaProjectionManager {
     */
    public void addCallback(@NonNull Callback callback, @Nullable Handler handler) {
        if (callback == null) {
            Log.w(TAG, "Content Recording: cannot add null callback");
            throw new IllegalArgumentException("callback must not be null");
        }
        CallbackDelegate delegate = new CallbackDelegate(callback, handler);
@@ -286,6 +288,7 @@ public final class MediaProjectionManager {
     */
    public void removeCallback(@NonNull Callback callback) {
        if (callback == null) {
            Log.w(TAG, "ContentRecording: cannot remove null callback");
            throw new IllegalArgumentException("callback must not be null");
        }
        CallbackDelegate delegate = mCallbacks.remove(callback);
+12 −1
Original line number Diff line number Diff line
@@ -1546,6 +1546,7 @@ public final class DisplayManagerService extends SystemService {
                if (displayId != Display.INVALID_DISPLAY && virtualDevice != null && dwpc != null) {
                    mDisplayWindowPolicyControllers.put(
                            displayId, Pair.create(virtualDevice, dwpc));
                    Slog.d(TAG, "Virtual Display: successfully created virtual display");
                }
            }

@@ -1592,19 +1593,25 @@ public final class DisplayManagerService extends SystemService {
                    if (!getProjectionService().setContentRecordingSession(session, projection)) {
                        // Unable to start mirroring, so release VirtualDisplay. Projection service
                        // handles stopping the projection.
                        Slog.w(TAG, "Content Recording: failed to start mirroring - "
                                + "releasing virtual display " + displayId);
                        releaseVirtualDisplayInternal(callback.asBinder());
                        return Display.INVALID_DISPLAY;
                    } else if (projection != null) {
                        // Indicate that this projection has been used to record, and can't be used
                        // again.
                        Slog.d(TAG, "Content Recording: notifying MediaProjection of successful"
                                + " VirtualDisplay creation.");
                        projection.notifyVirtualDisplayCreated(displayId);
                    }
                } catch (RemoteException e) {
                    Slog.e(TAG, "Unable to tell MediaProjectionManagerService to set the "
                            + "content recording session", e);
                    return displayId;
                }
                Slog.d(TAG, "Virtual Display: successfully set up virtual display "
                        + displayId);
            }

            return displayId;
        } finally {
            Binder.restoreCallingIdentity(secondToken);
@@ -1628,10 +1635,13 @@ public final class DisplayManagerService extends SystemService {
            return -1;
        }


        Slog.d(TAG, "Virtual Display: creating DisplayDevice with VirtualDisplayAdapter");
        DisplayDevice device = mVirtualDisplayAdapter.createVirtualDisplayLocked(
                callback, projection, callingUid, packageName, surface, flags,
                virtualDisplayConfig);
        if (device == null) {
            Slog.w(TAG, "Virtual Display: VirtualDisplayAdapter failed to create DisplayDevice");
            return -1;
        }

@@ -1709,6 +1719,7 @@ public final class DisplayManagerService extends SystemService {

            DisplayDevice device =
                    mVirtualDisplayAdapter.releaseVirtualDisplayLocked(appToken);
            Slog.d(TAG, "Virtual Display: Display Device released");
            if (device != null) {
                // TODO: multi-display - handle virtual displays the same as other display adapters.
                mDisplayDeviceRepo.onDisplayDeviceEvent(device,
+4 −0
Original line number Diff line number Diff line
@@ -141,9 +141,12 @@ public class VirtualDisplayAdapter extends DisplayAdapter {
        try {
            if (projection != null) {
                projection.registerCallback(mediaProjectionCallback);
                Slog.d(TAG, "Virtual Display: registered media projection callback for new "
                        + "VirtualDisplayDevice");
            }
            appToken.linkToDeath(device, 0);
        } catch (RemoteException ex) {
            Slog.e(TAG, "Virtual Display: error while setting up VirtualDisplayDevice", ex);
            mVirtualDisplayDevices.remove(appToken);
            device.destroyLocked(false);
            return null;
@@ -439,6 +442,7 @@ public class VirtualDisplayAdapter extends DisplayAdapter {
        }

        public void stopLocked() {
            Slog.d(TAG, "Virtual Display: stopping device " + mName);
            setSurfaceLocked(null);
            mStopped = true;
        }
Loading