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

Commit 2c5a552c authored by Daniel Akinola's avatar Daniel Akinola
Browse files

Update MediaProjection logging atoms for new windowing metrics

Add fields to track target position & size, and stop reason + log stop reason and updates to bound

Bug: 341319250
Test: atest MediaProjectionManagerServiceTest
Test: atest ContentRecorderTests
Test: atest MediaProjectionMetricsLoggerTest
Flag: EXEMPT bugfix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:d6615c072b30ff766d17f94cdbd2d66b5e37f376)
Merged-In: I456f974bf37af39882ef011bf60f724670ea8dae
Change-Id: I456f974bf37af39882ef011bf60f724670ea8dae
parent 4f2b4539
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -17,13 +17,14 @@
package android.media.projection;

import android.media.projection.IMediaProjectionCallback;
import android.media.projection.StopReason;
import android.os.IBinder;
import android.app.ActivityOptions.LaunchCookie;

/** {@hide} */
interface IMediaProjection {
    void start(IMediaProjectionCallback callback);
    void stop();
    void stop(StopReason stopReason);

    boolean canProjectAudio();
    boolean canProjectVideo();
+10 −7
Original line number Diff line number Diff line
@@ -16,11 +16,13 @@

package android.media.projection;

import android.graphics.Rect;
import android.media.projection.IMediaProjection;
import android.media.projection.IMediaProjectionCallback;
import android.media.projection.IMediaProjectionWatcherCallback;
import android.media.projection.MediaProjectionInfo;
import android.media.projection.ReviewGrantedConsentResult;
import android.media.projection.StopReason;
import android.os.IBinder;
import android.view.ContentRecordingSession;

@@ -106,12 +108,7 @@ interface IMediaProjectionManager {
    @EnforcePermission("MANAGE_MEDIA_PROJECTION")
    @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
            + ".permission.MANAGE_MEDIA_PROJECTION)")
    void stopActiveProjection();

    @EnforcePermission("MANAGE_MEDIA_PROJECTION")
    @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
            + ".permission.MANAGE_MEDIA_PROJECTION)")
    void notifyActiveProjectionCapturedContentResized(int width, int height);
    void stopActiveProjection(in StopReason stopReason);

    @EnforcePermission("MANAGE_MEDIA_PROJECTION")
    @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
@@ -226,5 +223,11 @@ interface IMediaProjectionManager {
    @EnforcePermission("MANAGE_MEDIA_PROJECTION")
    @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
            + ".permission.MANAGE_MEDIA_PROJECTION)")
    void notifyWindowingModeChanged(int contentToRecord, int targetProcessUid, int windowingMode);
    oneway void notifyWindowingModeChanged(int contentToRecord, int targetProcessUid, int windowingMode);

    @EnforcePermission("MANAGE_MEDIA_PROJECTION")
    @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
            + ".permission.MANAGE_MEDIA_PROJECTION)")
    oneway void notifyCaptureBoundsChanged(int contentToRecord, int targetProcessUid,
            in Rect captureBounds);
}
+1 −1
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ public final class MediaProjection {
    public void stop() {
        try {
            Log.d(TAG, "Content Recording: stopping projection");
            mImpl.stop();
            mImpl.stop(StopReason.STOP_HOST_APP);
        } catch (RemoteException e) {
            Log.e(TAG, "Unable to stop projection", e);
        }
+2 −2
Original line number Diff line number Diff line
@@ -297,10 +297,10 @@ public final class MediaProjectionManager {
     * Stop the current projection if there is one.
     * @hide
     */
    public void stopActiveProjection() {
    public void stopActiveProjection(@StopReason int stopReason) {
        try {
            Log.d(TAG, "Content Recording: stopping active projection");
            mService.stopActiveProjection();
            mService.stopActiveProjection(stopReason);
        } catch (RemoteException e) {
            Log.e(TAG, "Unable to stop the currently active media projection", e);
        }
+36 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media.projection;

/**
 * Identifies the reason for a MediaProjection being stopped (for metric logging purposes)
 * @hide
 */
@Backing(type="int")
enum StopReason {
    STOP_UNKNOWN = 0,
    STOP_HOST_APP = 1,
    STOP_TARGET_REMOVED = 2,
    STOP_DEVICE_LOCKED = 3,
    STOP_PRIVACY_CHIP = 4,
    STOP_QS_TILE = 5,
    STOP_USER_SWITCH = 6,
    STOP_FOREGROUND_SERVICE_CHANGE = 7,
    STOP_NEW_PROJECTION = 8,
    STOP_NEW_MEDIA_ROUTE = 9,
    STOP_ERROR = 10,
}
Loading