Loading media/java/android/media/projection/IMediaProjectionManager.aidl +3 −2 Original line number Diff line number Diff line Loading @@ -53,8 +53,9 @@ interface IMediaProjectionManager { * * @param processUid the process UID as returned by {@link android.os.Process.myUid()}. */ @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(anyOf = {" + "android.Manifest.permission.MANAGE_MEDIA_PROJECTION," + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}, conditional = true)") IMediaProjection createProjection(int processUid, String packageName, int type, boolean permanentGrant, int displayId); Loading services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java +10 −5 Original line number Diff line number Diff line Loading @@ -663,13 +663,12 @@ public final class MediaProjectionManagerService extends SystemService String packageName, int type, boolean isPermanentGrant, UserHandle callingUser, int displayId) { MediaProjection projection; ApplicationInfo ai; try { ai = mPackageManager.getApplicationInfoAsUser(packageName, ApplicationInfoFlags.of(0), callingUser); UserHandle.getUserHandleForUid(uid)); } catch (NameNotFoundException e) { throw new IllegalArgumentException("No package matching: " + packageName); } Loading Loading @@ -813,9 +812,15 @@ public final class MediaProjectionManagerService extends SystemService if (packageName == null || packageName.isEmpty()) { throw new IllegalArgumentException("package name must not be empty"); } final UserHandle callingUser = Binder.getCallingUserHandle(); // If the package UID and calling UID don't belong to the same user, we need to use the // package UID for lookups - but only if the caller has the appropriate permission. if (UserHandle.getUserId(processUid) != UserHandle.getCallingUserId()) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, "createProjection"); } return createProjectionInternal( processUid, packageName, type, isPermanentGrant, callingUser, displayId); processUid, packageName, type, isPermanentGrant, displayId); } @Override // Binder call Loading services/tests/servicestests/src/com/android/server/media/projection/MediaProjectionManagerServiceTest.java +0 −7 Original line number Diff line number Diff line Loading @@ -453,7 +453,6 @@ public class MediaProjectionManagerServiceTest { PACKAGE_NAME + "foo", TYPE_MIRRORING, /* isPermanentGrant= */ true, UserHandle.CURRENT, Display.DEFAULT_DISPLAY); assertThat(secondProjection).isNotNull(); Loading Loading @@ -1250,7 +1249,6 @@ public class MediaProjectionManagerServiceTest { PACKAGE_NAME, TYPE_SCREEN_CAPTURE, /* isPermanentGrant= */ false, UserHandle.CURRENT, DEFAULT_DISPLAY); doReturn(AppOpsManager.MODE_DEFAULT).when(mAppOpsManager).unsafeCheckOpRawNoThrow( Loading @@ -1276,7 +1274,6 @@ public class MediaProjectionManagerServiceTest { PACKAGE_NAME, TYPE_SCREEN_CAPTURE, /* isPermanentGrant= */ false, UserHandle.CURRENT, DEFAULT_DISPLAY); doReturn(AppOpsManager.MODE_DEFAULT).when(mAppOpsManager).unsafeCheckOpRawNoThrow( Loading Loading @@ -1308,7 +1305,6 @@ public class MediaProjectionManagerServiceTest { packageName, TYPE_SCREEN_CAPTURE, /* isPermanentGrant= */ false, UserHandle.CURRENT, DEFAULT_DISPLAY); projection.setRecordingOverlay(true); Loading Loading @@ -1341,7 +1337,6 @@ public class MediaProjectionManagerServiceTest { PACKAGE_NAME, TYPE_SCREEN_CAPTURE, /* isPermanentGrant= */ false, UserHandle.CURRENT, DEFAULT_DISPLAY); doReturn(AppOpsManager.MODE_DEFAULT).when(mAppOpsManager).unsafeCheckOpRawNoThrow( Loading @@ -1367,7 +1362,6 @@ public class MediaProjectionManagerServiceTest { PACKAGE_NAME, TYPE_SCREEN_CAPTURE, /* isPermanentGrant= */ false, UserHandle.CURRENT, DEFAULT_DISPLAY); // Start MediaProjection from a different UID Loading Loading @@ -1396,7 +1390,6 @@ public class MediaProjectionManagerServiceTest { PACKAGE_NAME, TYPE_MIRRORING, /* isPermanentGrant= */ false, UserHandle.CURRENT, displayId); } Loading services/tests/servicestests/src/com/android/server/media/projection/MediaProjectionStopControllerTest.java +1 −2 Original line number Diff line number Diff line Loading @@ -420,7 +420,6 @@ public class MediaProjectionStopControllerTest { doReturn(mAppInfo).when(mPackageManager).getApplicationInfoAsUser(Mockito.isNull(), any(ApplicationInfoFlags.class), any(UserHandle.class)); return mService.createProjectionInternal(UID, packageName, MediaProjectionManager.TYPE_SCREEN_CAPTURE, false, mContext.getUser(), INVALID_DISPLAY); MediaProjectionManager.TYPE_SCREEN_CAPTURE, false, INVALID_DISPLAY); } } Loading
media/java/android/media/projection/IMediaProjectionManager.aidl +3 −2 Original line number Diff line number Diff line Loading @@ -53,8 +53,9 @@ interface IMediaProjectionManager { * * @param processUid the process UID as returned by {@link android.os.Process.myUid()}. */ @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(anyOf = {" + "android.Manifest.permission.MANAGE_MEDIA_PROJECTION," + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}, conditional = true)") IMediaProjection createProjection(int processUid, String packageName, int type, boolean permanentGrant, int displayId); Loading
services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java +10 −5 Original line number Diff line number Diff line Loading @@ -663,13 +663,12 @@ public final class MediaProjectionManagerService extends SystemService String packageName, int type, boolean isPermanentGrant, UserHandle callingUser, int displayId) { MediaProjection projection; ApplicationInfo ai; try { ai = mPackageManager.getApplicationInfoAsUser(packageName, ApplicationInfoFlags.of(0), callingUser); UserHandle.getUserHandleForUid(uid)); } catch (NameNotFoundException e) { throw new IllegalArgumentException("No package matching: " + packageName); } Loading Loading @@ -813,9 +812,15 @@ public final class MediaProjectionManagerService extends SystemService if (packageName == null || packageName.isEmpty()) { throw new IllegalArgumentException("package name must not be empty"); } final UserHandle callingUser = Binder.getCallingUserHandle(); // If the package UID and calling UID don't belong to the same user, we need to use the // package UID for lookups - but only if the caller has the appropriate permission. if (UserHandle.getUserId(processUid) != UserHandle.getCallingUserId()) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, "createProjection"); } return createProjectionInternal( processUid, packageName, type, isPermanentGrant, callingUser, displayId); processUid, packageName, type, isPermanentGrant, displayId); } @Override // Binder call Loading
services/tests/servicestests/src/com/android/server/media/projection/MediaProjectionManagerServiceTest.java +0 −7 Original line number Diff line number Diff line Loading @@ -453,7 +453,6 @@ public class MediaProjectionManagerServiceTest { PACKAGE_NAME + "foo", TYPE_MIRRORING, /* isPermanentGrant= */ true, UserHandle.CURRENT, Display.DEFAULT_DISPLAY); assertThat(secondProjection).isNotNull(); Loading Loading @@ -1250,7 +1249,6 @@ public class MediaProjectionManagerServiceTest { PACKAGE_NAME, TYPE_SCREEN_CAPTURE, /* isPermanentGrant= */ false, UserHandle.CURRENT, DEFAULT_DISPLAY); doReturn(AppOpsManager.MODE_DEFAULT).when(mAppOpsManager).unsafeCheckOpRawNoThrow( Loading @@ -1276,7 +1274,6 @@ public class MediaProjectionManagerServiceTest { PACKAGE_NAME, TYPE_SCREEN_CAPTURE, /* isPermanentGrant= */ false, UserHandle.CURRENT, DEFAULT_DISPLAY); doReturn(AppOpsManager.MODE_DEFAULT).when(mAppOpsManager).unsafeCheckOpRawNoThrow( Loading Loading @@ -1308,7 +1305,6 @@ public class MediaProjectionManagerServiceTest { packageName, TYPE_SCREEN_CAPTURE, /* isPermanentGrant= */ false, UserHandle.CURRENT, DEFAULT_DISPLAY); projection.setRecordingOverlay(true); Loading Loading @@ -1341,7 +1337,6 @@ public class MediaProjectionManagerServiceTest { PACKAGE_NAME, TYPE_SCREEN_CAPTURE, /* isPermanentGrant= */ false, UserHandle.CURRENT, DEFAULT_DISPLAY); doReturn(AppOpsManager.MODE_DEFAULT).when(mAppOpsManager).unsafeCheckOpRawNoThrow( Loading @@ -1367,7 +1362,6 @@ public class MediaProjectionManagerServiceTest { PACKAGE_NAME, TYPE_SCREEN_CAPTURE, /* isPermanentGrant= */ false, UserHandle.CURRENT, DEFAULT_DISPLAY); // Start MediaProjection from a different UID Loading Loading @@ -1396,7 +1390,6 @@ public class MediaProjectionManagerServiceTest { PACKAGE_NAME, TYPE_MIRRORING, /* isPermanentGrant= */ false, UserHandle.CURRENT, displayId); } Loading
services/tests/servicestests/src/com/android/server/media/projection/MediaProjectionStopControllerTest.java +1 −2 Original line number Diff line number Diff line Loading @@ -420,7 +420,6 @@ public class MediaProjectionStopControllerTest { doReturn(mAppInfo).when(mPackageManager).getApplicationInfoAsUser(Mockito.isNull(), any(ApplicationInfoFlags.class), any(UserHandle.class)); return mService.createProjectionInternal(UID, packageName, MediaProjectionManager.TYPE_SCREEN_CAPTURE, false, mContext.getUser(), INVALID_DISPLAY); MediaProjectionManager.TYPE_SCREEN_CAPTURE, false, INVALID_DISPLAY); } }