Merge "Don't consider PACKAGE_USAGE_STATS permission." into tm-dev am: 4bc2075b9f am: afba0fb8b1 am: 6549a44ea3

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

Change-Id: Id45eb8d4cf198fd31218bf437132f028d030abb6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Sudheer Shanka
2022-05-18 21:01:57 +00:00
committed by Automerger Merge Worker
2 changed files with 11 additions and 43 deletions

View File

@@ -13588,13 +13588,8 @@ public class ActivityManagerService extends IActivityManager.Stub
}
if (brOptions.getIdForResponseEvent() > 0) {
// STOPSHIP (206518114): Temporarily check for PACKAGE_USAGE_STATS permission as
// well until the clients switch to using the new permission.
if (checkPermission(android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS,
callingPid, callingUid) != PERMISSION_GRANTED) {
enforceUsageStatsPermission(callerPackage, callingUid, callingPid,
"recordResponseEventWhileInBackground()");
}
enforcePermission(android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS,
callingPid, callingUid, "recordResponseEventWhileInBackground");
}
}

View File

@@ -2776,18 +2776,9 @@ public class UsageStatsService extends SystemService implements
throw new IllegalArgumentException("id needs to be >=0");
}
final int result = getContext().checkCallingOrSelfPermission(
android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS);
// STOPSHIP (206518114): Temporarily check for PACKAGE_USAGE_STATS permission as well
// until the clients switch to using the new permission.
if (result != PackageManager.PERMISSION_GRANTED) {
if (!hasPermission(callingPackage)) {
throw new SecurityException(
"Caller does not have the permission needed to call this API; "
+ "callingPackage=" + callingPackage
+ ", callingUid=" + Binder.getCallingUid());
}
}
getContext().enforceCallingOrSelfPermission(
android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS,
"queryBroadcastResponseStats");
final int callingUid = Binder.getCallingUid();
userId = ActivityManager.handleIncomingUser(Binder.getCallingPid(), callingUid,
userId, false /* allowAll */, false /* requireFull */,
@@ -2809,18 +2800,9 @@ public class UsageStatsService extends SystemService implements
}
final int result = getContext().checkCallingOrSelfPermission(
android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS);
// STOPSHIP (206518114): Temporarily check for PACKAGE_USAGE_STATS permission as well
// until the clients switch to using the new permission.
if (result != PackageManager.PERMISSION_GRANTED) {
if (!hasPermission(callingPackage)) {
throw new SecurityException(
"Caller does not have the permission needed to call this API; "
+ "callingPackage=" + callingPackage
+ ", callingUid=" + Binder.getCallingUid());
}
}
getContext().enforceCallingOrSelfPermission(
android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS,
"clearBroadcastResponseStats");
final int callingUid = Binder.getCallingUid();
userId = ActivityManager.handleIncomingUser(Binder.getCallingPid(), callingUid,
userId, false /* allowAll */, false /* requireFull */,
@@ -2833,18 +2815,9 @@ public class UsageStatsService extends SystemService implements
public void clearBroadcastEvents(@NonNull String callingPackage, @UserIdInt int userId) {
Objects.requireNonNull(callingPackage);
final int result = getContext().checkCallingOrSelfPermission(
android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS);
// STOPSHIP (206518114): Temporarily check for PACKAGE_USAGE_STATS permission as well
// until the clients switch to using the new permission.
if (result != PackageManager.PERMISSION_GRANTED) {
if (!hasPermission(callingPackage)) {
throw new SecurityException(
"Caller does not have the permission needed to call this API; "
+ "callingPackage=" + callingPackage
+ ", callingUid=" + Binder.getCallingUid());
}
}
getContext().enforceCallingOrSelfPermission(
android.Manifest.permission.ACCESS_BROADCAST_RESPONSE_STATS,
"clearBroadcastEvents");
final int callingUid = Binder.getCallingUid();
userId = ActivityManager.handleIncomingUser(Binder.getCallingPid(), callingUid,
userId, false /* allowAll */, false /* requireFull */,