Loading media/java/android/media/projection/IMediaProjection.aidl +7 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,13 @@ interface IMediaProjection { + ".permission.MANAGE_MEDIA_PROJECTION)") int getTaskId(); /** * Returns the displayId identifying the display to record. This only applies to full screen * recording. */ int getDisplayId(); /** * Updates the {@link LaunchCookie} identifying the task to record. */ Loading media/java/android/media/projection/IMediaProjectionManager.aidl +3 −2 Original line number Diff line number Diff line Loading @@ -46,14 +46,15 @@ interface IMediaProjectionManager { boolean hasProjectionPermission(int processUid, String packageName); /** * Returns a new {@link IMediaProjection} instance associated with the given package. * Returns a new {@link IMediaProjection} instance associated with the given package for the * given display id. * * @param processUid the process UID as returned by {@link android.os.Process.myUid()}. */ @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") IMediaProjection createProjection(int processUid, String packageName, int type, boolean permanentGrant); boolean permanentGrant, int displayId); /** * Returns the current {@link IMediaProjection} instance associated with the given Loading media/java/android/media/projection/MediaProjection.java +13 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package android.media.projection; import static android.view.Display.DEFAULT_DISPLAY; import static com.android.media.projection.flags.Flags.mediaProjectionConnectedDisplay; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.compat.CompatChanges; Loading Loading @@ -85,13 +87,23 @@ public final class MediaProjection { public MediaProjection(Context context, IMediaProjection impl, DisplayManager displayManager) { mContext = context; mImpl = impl; mDisplayManager = displayManager; try { mImpl.start(new MediaProjectionCallback()); if (mediaProjectionConnectedDisplay()) { int displayId = mImpl.getDisplayId(); if (displayId != DEFAULT_DISPLAY) { mDisplayId = displayId; Log.v(TAG, "Created MediaProjection for display " + mDisplayId); return; } } } 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; final UserManager userManager = context.getSystemService(UserManager.class); mDisplayId = userManager.isVisibleBackgroundUsersSupported() Loading media/tests/projection/src/android/media/projection/FakeIMediaProjection.java +6 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.annotation.EnforcePermission; import android.app.ActivityOptions.LaunchCookie; import android.os.PermissionEnforcer; import android.os.RemoteException; import android.view.Display; /** * The connection between MediaProjection and system server is represented by IMediaProjection; Loading @@ -32,6 +33,7 @@ public final class FakeIMediaProjection extends IMediaProjection.Stub { boolean mIsStarted = false; LaunchCookie mLaunchCookie = null; IMediaProjectionCallback mIMediaProjectionCallback = null; int mDisplayId = Display.DEFAULT_DISPLAY; FakeIMediaProjection(PermissionEnforcer enforcer) { super(enforcer); Loading Loading @@ -93,6 +95,10 @@ public final class FakeIMediaProjection extends IMediaProjection.Stub { return mTaskId; } public int getDisplayId() { return mDisplayId; } @Override @EnforcePermission(MANAGE_MEDIA_PROJECTION) public void setLaunchCookie(LaunchCookie launchCookie) throws RemoteException { Loading packages/SystemUI/multivalentTests/src/com/android/systemui/screenrecord/RecordingServiceTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -310,6 +310,13 @@ public class RecordingServiceTest extends SysuiTestCase { verify(mNotificationManager).cancelAsUser(any(), anyInt(), any()); } @Test public void testSecondaryDisplayRecording() throws IOException { Intent startIntent = RecordingService.getStartIntent(mContext, 0, 0, false, 200, null); assertEquals(startIntent.getIntExtra("extra_displayId", -1), 200); } private void assertUpdateState(boolean state) { // Then the state is set to not recording, and we cancel the notification // non SYSTEM user doesn't have the reference to the correct controller, Loading Loading
media/java/android/media/projection/IMediaProjection.aidl +7 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,13 @@ interface IMediaProjection { + ".permission.MANAGE_MEDIA_PROJECTION)") int getTaskId(); /** * Returns the displayId identifying the display to record. This only applies to full screen * recording. */ int getDisplayId(); /** * Updates the {@link LaunchCookie} identifying the task to record. */ Loading
media/java/android/media/projection/IMediaProjectionManager.aidl +3 −2 Original line number Diff line number Diff line Loading @@ -46,14 +46,15 @@ interface IMediaProjectionManager { boolean hasProjectionPermission(int processUid, String packageName); /** * Returns a new {@link IMediaProjection} instance associated with the given package. * Returns a new {@link IMediaProjection} instance associated with the given package for the * given display id. * * @param processUid the process UID as returned by {@link android.os.Process.myUid()}. */ @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") IMediaProjection createProjection(int processUid, String packageName, int type, boolean permanentGrant); boolean permanentGrant, int displayId); /** * Returns the current {@link IMediaProjection} instance associated with the given Loading
media/java/android/media/projection/MediaProjection.java +13 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package android.media.projection; import static android.view.Display.DEFAULT_DISPLAY; import static com.android.media.projection.flags.Flags.mediaProjectionConnectedDisplay; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.compat.CompatChanges; Loading Loading @@ -85,13 +87,23 @@ public final class MediaProjection { public MediaProjection(Context context, IMediaProjection impl, DisplayManager displayManager) { mContext = context; mImpl = impl; mDisplayManager = displayManager; try { mImpl.start(new MediaProjectionCallback()); if (mediaProjectionConnectedDisplay()) { int displayId = mImpl.getDisplayId(); if (displayId != DEFAULT_DISPLAY) { mDisplayId = displayId; Log.v(TAG, "Created MediaProjection for display " + mDisplayId); return; } } } 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; final UserManager userManager = context.getSystemService(UserManager.class); mDisplayId = userManager.isVisibleBackgroundUsersSupported() Loading
media/tests/projection/src/android/media/projection/FakeIMediaProjection.java +6 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.annotation.EnforcePermission; import android.app.ActivityOptions.LaunchCookie; import android.os.PermissionEnforcer; import android.os.RemoteException; import android.view.Display; /** * The connection between MediaProjection and system server is represented by IMediaProjection; Loading @@ -32,6 +33,7 @@ public final class FakeIMediaProjection extends IMediaProjection.Stub { boolean mIsStarted = false; LaunchCookie mLaunchCookie = null; IMediaProjectionCallback mIMediaProjectionCallback = null; int mDisplayId = Display.DEFAULT_DISPLAY; FakeIMediaProjection(PermissionEnforcer enforcer) { super(enforcer); Loading Loading @@ -93,6 +95,10 @@ public final class FakeIMediaProjection extends IMediaProjection.Stub { return mTaskId; } public int getDisplayId() { return mDisplayId; } @Override @EnforcePermission(MANAGE_MEDIA_PROJECTION) public void setLaunchCookie(LaunchCookie launchCookie) throws RemoteException { Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/screenrecord/RecordingServiceTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -310,6 +310,13 @@ public class RecordingServiceTest extends SysuiTestCase { verify(mNotificationManager).cancelAsUser(any(), anyInt(), any()); } @Test public void testSecondaryDisplayRecording() throws IOException { Intent startIntent = RecordingService.getStartIntent(mContext, 0, 0, false, 200, null); assertEquals(startIntent.getIntExtra("extra_displayId", -1), 200); } private void assertUpdateState(boolean state) { // Then the state is set to not recording, and we cancel the notification // non SYSTEM user doesn't have the reference to the correct controller, Loading