Skip to content

Commit d2ef34d

Browse files
adampThe Android Automerger
authored andcommitted
Backport ChooserTarget package source check from N
Fix a bug where a ChooserTargetService could supply a ChooserTarget pointing at a non-exported activity outside of its own package and have it launch. Bug 28384423 Change-Id: I3f5854f91c5695ad9253d71055ef58224df47008
1 parent ec2fc50 commit d2ef34d

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

core/java/com/android/internal/app/ChooserActivity.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,19 @@ public boolean startAsCaller(Activity activity, Bundle options, int userId) {
656656
}
657657
intent.setComponent(mChooserTarget.getComponentName());
658658
intent.putExtras(mChooserTarget.getIntentExtras());
659-
activity.startActivityAsCaller(intent, options, true, userId);
659+
660+
// Important: we will ignore the target security checks in ActivityManager
661+
// if and only if the ChooserTarget's target package is the same package
662+
// where we got the ChooserTargetService that provided it. This lets a
663+
// ChooserTargetService provide a non-exported or permission-guarded target
664+
// to the chooser for the user to pick.
665+
//
666+
// If mSourceInfo is null, we got this ChooserTarget from the caller or elsewhere
667+
// so we'll obey the caller's normal security checks.
668+
final boolean ignoreTargetSecurity = mSourceInfo != null
669+
&& mSourceInfo.getResolvedComponentName().getPackageName()
670+
.equals(mChooserTarget.getComponentName().getPackageName());
671+
activity.startActivityAsCaller(intent, options, ignoreTargetSecurity, userId);
660672
return true;
661673
}
662674

0 commit comments

Comments
 (0)