Backport ChooserTarget package source check from N am: 82b9565bd1 am: 6d5f80d13b

am: 7ac638702d

* commit '7ac638702de3b8af0a02db764adb95f2d10d1524':
  Backport ChooserTarget package source check from N

Change-Id: I9d936089af04cc32a54245d91c17a23569c5fd1c
This commit is contained in:
Adam Powell
2016-05-02 21:26:29 +00:00
committed by android-build-merger

View File

@@ -656,7 +656,19 @@ public class ChooserActivity extends ResolverActivity {
}
intent.setComponent(mChooserTarget.getComponentName());
intent.putExtras(mChooserTarget.getIntentExtras());
activity.startActivityAsCaller(intent, options, true, userId);
// Important: we will ignore the target security checks in ActivityManager
// if and only if the ChooserTarget's target package is the same package
// where we got the ChooserTargetService that provided it. This lets a
// ChooserTargetService provide a non-exported or permission-guarded target
// to the chooser for the user to pick.
//
// If mSourceInfo is null, we got this ChooserTarget from the caller or elsewhere
// so we'll obey the caller's normal security checks.
final boolean ignoreTargetSecurity = mSourceInfo != null
&& mSourceInfo.getResolvedComponentName().getPackageName()
.equals(mChooserTarget.getComponentName().getPackageName());
activity.startActivityAsCaller(intent, options, ignoreTargetSecurity, userId);
return true;
}