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

Commit 5a75a3f0 authored by Daniel Akinola's avatar Daniel Akinola Committed by Automerger Merge Worker
Browse files

Merge "Add logs to identify more virtual display error states and media...

Merge "Add logs to identify more virtual display error states and media projection stop states" into udc-qpr-dev am: e729480e am: 4ddc45d3

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



Change-Id: I585ef0951ae7ca393f845dbe463d77eb10b0bd08
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 19b663cd 4ddc45d3
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -691,6 +691,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",
@@ -1285,6 +1291,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",
@@ -2233,12 +2245,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",
+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
@@ -1547,6 +1547,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");
                }
            }

@@ -1593,19 +1594,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);
@@ -1629,10 +1636,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;
        }

@@ -1710,6 +1720,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
@@ -147,9 +147,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;
@@ -445,6 +448,7 @@ public class VirtualDisplayAdapter extends DisplayAdapter {
        }

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