summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hai Zhang <zhanghai@google.com> 2019-07-12 16:24:06 -0700
committer android-build-merger <android-build-merger@google.com> 2019-07-12 16:24:06 -0700
commit5871e724de0c34b01ee02e7e68aaca2cd919d917 (patch)
tree7b6ddffdf5efe15855abf5c2b16489d54c223bc6
parent36cc070c24b39778d21209f70e2ed2fab47e7777 (diff)
parent0cdc7e9b9865cc08b44ca7c4f7b90061a18e4e64 (diff)
Merge "Pass EXTRA_CALLING_PACKAGE for legacy change default dialer/SMS intents." into qt-dev
am: 0cdc7e9b98 Change-Id: I92dea20d2f0dbab7938cc2e1c4763827e71880e9
-rw-r--r--services/core/java/com/android/server/policy/PermissionPolicyService.java21
1 files changed, 13 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/policy/PermissionPolicyService.java b/services/core/java/com/android/server/policy/PermissionPolicyService.java
index 037293f9536c..a569bffef141 100644
--- a/services/core/java/com/android/server/policy/PermissionPolicyService.java
+++ b/services/core/java/com/android/server/policy/PermissionPolicyService.java
@@ -798,7 +798,7 @@ public final class PermissionPolicyService extends SystemService {
@Override
public boolean checkStartActivity(@NonNull Intent intent, int callingUid,
@Nullable String callingPackage) {
- if (callingPackage != null && isActionRemovedForCallingPackage(intent.getAction(),
+ if (callingPackage != null && isActionRemovedForCallingPackage(intent, callingUid,
callingPackage)) {
Slog.w(LOG_TAG, "Action Removed: starting " + intent.toString() + " from "
+ callingPackage + " (uid=" + callingUid + ")");
@@ -811,8 +811,9 @@ public final class PermissionPolicyService extends SystemService {
* Check if the intent action is removed for the calling package (often based on target SDK
* version). If the action is removed, we'll silently cancel the activity launch.
*/
- private boolean isActionRemovedForCallingPackage(@Nullable String action,
+ private boolean isActionRemovedForCallingPackage(@NonNull Intent intent, int callingUid,
@NonNull String callingPackage) {
+ String action = intent.getAction();
if (action == null) {
return false;
}
@@ -821,15 +822,19 @@ public final class PermissionPolicyService extends SystemService {
case Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT: {
ApplicationInfo applicationInfo;
try {
- applicationInfo = getContext().getPackageManager().getApplicationInfo(
- callingPackage, 0);
+ applicationInfo = getContext().getPackageManager().getApplicationInfoAsUser(
+ callingPackage, 0, UserHandle.getUserId(callingUid));
+ if (applicationInfo.targetSdkVersion >= Build.VERSION_CODES.Q) {
+ // Applications targeting Q or higher should use
+ // RoleManager.createRequestRoleIntent() instead.
+ return true;
+ }
} catch (PackageManager.NameNotFoundException e) {
Slog.i(LOG_TAG, "Cannot find application info for " + callingPackage);
- return false;
}
- // Applications targeting Q should use RoleManager.createRequestRoleIntent()
- // instead.
- return applicationInfo.targetSdkVersion >= Build.VERSION_CODES.Q;
+ // Make sure RequestRoleActivity can know the calling package if we allow it.
+ intent.putExtra(Intent.EXTRA_CALLING_PACKAGE, callingPackage);
+ return false;
}
default:
return false;