DO NOT MERGE. Grant MMS Uri permissions as the calling UID. am: 3eddf40675
am: 14b308de91
Change-Id: I428dcaa5e44364d30a51392c224ad68a6e455e2b
This commit is contained in:
@@ -60,6 +60,13 @@ public abstract class ActivityManagerInternal {
|
|||||||
*/
|
*/
|
||||||
public static final int APP_TRANSITION_TIMEOUT = 3;
|
public static final int APP_TRANSITION_TIMEOUT = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Grant Uri permissions from one app to another. This method only extends
|
||||||
|
* permission grants if {@code callingUid} has permission to them.
|
||||||
|
*/
|
||||||
|
public abstract void grantUriPermissionFromIntent(int callingUid, String targetPkg,
|
||||||
|
Intent intent, int targetUserId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify that calling app has access to the given provider.
|
* Verify that calling app has access to the given provider.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.android.server;
|
package com.android.server;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.app.ActivityManagerInternal;
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
@@ -499,13 +500,21 @@ public class MmsServiceBroker extends SystemService {
|
|||||||
*/
|
*/
|
||||||
private Uri adjustUriForUserAndGrantPermission(Uri contentUri, String action,
|
private Uri adjustUriForUserAndGrantPermission(Uri contentUri, String action,
|
||||||
int permission) {
|
int permission) {
|
||||||
|
final Intent grantIntent = new Intent();
|
||||||
|
grantIntent.setData(contentUri);
|
||||||
|
grantIntent.setFlags(permission);
|
||||||
|
|
||||||
|
final int callingUid = Binder.getCallingUid();
|
||||||
final int callingUserId = UserHandle.getCallingUserId();
|
final int callingUserId = UserHandle.getCallingUserId();
|
||||||
if (callingUserId != UserHandle.USER_SYSTEM) {
|
if (callingUserId != UserHandle.USER_SYSTEM) {
|
||||||
contentUri = ContentProvider.maybeAddUserId(contentUri, callingUserId);
|
contentUri = ContentProvider.maybeAddUserId(contentUri, callingUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
long token = Binder.clearCallingIdentity();
|
long token = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
mContext.grantUriPermission(PHONE_PACKAGE_NAME, contentUri, permission);
|
LocalServices.getService(ActivityManagerInternal.class)
|
||||||
|
.grantUriPermissionFromIntent(callingUid, PHONE_PACKAGE_NAME,
|
||||||
|
grantIntent, UserHandle.USER_SYSTEM);
|
||||||
|
|
||||||
// Grant permission for the carrier app.
|
// Grant permission for the carrier app.
|
||||||
Intent intent = new Intent(action);
|
Intent intent = new Intent(action);
|
||||||
@@ -514,7 +523,9 @@ public class MmsServiceBroker extends SystemService {
|
|||||||
List<String> carrierPackages = telephonyManager.getCarrierPackageNamesForIntent(
|
List<String> carrierPackages = telephonyManager.getCarrierPackageNamesForIntent(
|
||||||
intent);
|
intent);
|
||||||
if (carrierPackages != null && carrierPackages.size() == 1) {
|
if (carrierPackages != null && carrierPackages.size() == 1) {
|
||||||
mContext.grantUriPermission(carrierPackages.get(0), contentUri, permission);
|
LocalServices.getService(ActivityManagerInternal.class)
|
||||||
|
.grantUriPermissionFromIntent(callingUid, carrierPackages.get(0),
|
||||||
|
grantIntent, UserHandle.USER_SYSTEM);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(token);
|
Binder.restoreCallingIdentity(token);
|
||||||
|
|||||||
@@ -21935,6 +21935,15 @@ public final class ActivityManagerService extends ActivityManagerNative
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final class LocalService extends ActivityManagerInternal {
|
private final class LocalService extends ActivityManagerInternal {
|
||||||
|
@Override
|
||||||
|
public void grantUriPermissionFromIntent(int callingUid, String targetPkg, Intent intent,
|
||||||
|
int targetUserId) {
|
||||||
|
synchronized (ActivityManagerService.this) {
|
||||||
|
ActivityManagerService.this.grantUriPermissionFromIntentLocked(callingUid,
|
||||||
|
targetPkg, intent, null, targetUserId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String checkContentProviderAccess(String authority, int userId) {
|
public String checkContentProviderAccess(String authority, int userId) {
|
||||||
return ActivityManagerService.this.checkContentProviderAccess(authority, userId);
|
return ActivityManagerService.this.checkContentProviderAccess(authority, userId);
|
||||||
|
|||||||
Reference in New Issue
Block a user