Merge "Fix issue #38393543: Not allowed to start service Intent" into oc-dev

am: ad6dde65ff

Change-Id: Ife26f513fa6d04771148a3965171822874854828
This commit is contained in:
Dianne Hackborn
2017-05-22 20:09:29 +00:00
committed by android-build-merger
5 changed files with 19 additions and 11 deletions

View File

@@ -4719,7 +4719,9 @@ public class Activity extends ContextThemeWrapper
resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver()); resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver());
} }
int result = ActivityManager.getService() int result = ActivityManager.getService()
.startActivityIntentSender(mMainThread.getApplicationThread(), intent, .startActivityIntentSender(mMainThread.getApplicationThread(),
intent != null ? intent.getTarget() : null,
intent != null ? intent.getWhitelistToken() : null,
fillInIntent, resolvedType, mToken, who, fillInIntent, resolvedType, mToken, who,
requestCode, flagsMask, flagsValues, options); requestCode, flagsMask, flagsValues, options);
if (result == ActivityManager.START_CANCELED) { if (result == ActivityManager.START_CANCELED) {

View File

@@ -926,7 +926,9 @@ class ContextImpl extends Context {
resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver()); resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver());
} }
int result = ActivityManager.getService() int result = ActivityManager.getService()
.startActivityIntentSender(mMainThread.getApplicationThread(), intent, .startActivityIntentSender(mMainThread.getApplicationThread(),
intent != null ? intent.getTarget() : null,
intent != null ? intent.getWhitelistToken() : null,
fillInIntent, resolvedType, null, null, fillInIntent, resolvedType, null, null,
0, flagsMask, flagsValues, options); 0, flagsMask, flagsValues, options);
if (result == ActivityManager.START_CANCELED) { if (result == ActivityManager.START_CANCELED) {

View File

@@ -236,8 +236,8 @@ interface IActivityManager {
Debug.MemoryInfo[] getProcessMemoryInfo(in int[] pids); Debug.MemoryInfo[] getProcessMemoryInfo(in int[] pids);
void killApplicationProcess(in String processName, int uid); void killApplicationProcess(in String processName, int uid);
int startActivityIntentSender(in IApplicationThread caller, int startActivityIntentSender(in IApplicationThread caller,
in IntentSender intent, in Intent fillInIntent, in String resolvedType, in IIntentSender target, in IBinder whitelistToken, in Intent fillInIntent,
in IBinder resultTo, in String resultWho, int requestCode, in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode,
int flagsMask, int flagsValues, in Bundle options); int flagsMask, int flagsValues, in Bundle options);
void overridePendingTransition(in IBinder token, in String packageName, void overridePendingTransition(in IBinder token, in String packageName,
int enterAnim, int exitAnim); int enterAnim, int exitAnim);

View File

@@ -360,6 +360,11 @@ public class IntentSender implements Parcelable {
return mTarget; return mTarget;
} }
/** @hide */
public IBinder getWhitelistToken() {
return mWhitelistToken;
}
/** @hide */ /** @hide */
public IntentSender(IIntentSender target) { public IntentSender(IIntentSender target) {
mTarget = target; mTarget = target;

View File

@@ -4587,9 +4587,9 @@ public class ActivityManagerService extends IActivityManager.Stub
} }
@Override @Override
public int startActivityIntentSender(IApplicationThread caller, IntentSender intent, public int startActivityIntentSender(IApplicationThread caller, IIntentSender target,
Intent fillInIntent, String resolvedType, IBinder resultTo, String resultWho, IBinder whitelistToken, Intent fillInIntent, String resolvedType, IBinder resultTo,
int requestCode, int flagsMask, int flagsValues, Bundle bOptions) String resultWho, int requestCode, int flagsMask, int flagsValues, Bundle bOptions)
throws TransactionTooLargeException { throws TransactionTooLargeException {
enforceNotIsolatedCaller("startActivityIntentSender"); enforceNotIsolatedCaller("startActivityIntentSender");
// Refuse possible leaked file descriptors // Refuse possible leaked file descriptors
@@ -4597,12 +4597,11 @@ public class ActivityManagerService extends IActivityManager.Stub
throw new IllegalArgumentException("File descriptors passed in Intent"); throw new IllegalArgumentException("File descriptors passed in Intent");
} }
IIntentSender sender = intent.getTarget(); if (!(target instanceof PendingIntentRecord)) {
if (!(sender instanceof PendingIntentRecord)) {
throw new IllegalArgumentException("Bad PendingIntent object"); throw new IllegalArgumentException("Bad PendingIntent object");
} }
PendingIntentRecord pir = (PendingIntentRecord)sender; PendingIntentRecord pir = (PendingIntentRecord)target;
synchronized (this) { synchronized (this) {
// If this is coming from the currently resumed activity, it is // If this is coming from the currently resumed activity, it is
@@ -4613,7 +4612,7 @@ public class ActivityManagerService extends IActivityManager.Stub
mAppSwitchesAllowedTime = 0; mAppSwitchesAllowedTime = 0;
} }
} }
int ret = pir.sendInner(0, fillInIntent, resolvedType, null, null, null, int ret = pir.sendInner(0, fillInIntent, resolvedType, whitelistToken, null, null,
resultTo, resultWho, requestCode, flagsMask, flagsValues, bOptions, null); resultTo, resultWho, requestCode, flagsMask, flagsValues, bOptions, null);
return ret; return ret;
} }