Loading core/java/com/android/internal/app/IntentForwarderActivity.java +5 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ import android.widget.Toast; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.app.chooser.TargetInfo; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; Loading Loading @@ -352,6 +353,7 @@ public class IntentForwarderActivity extends Activity { findViewById(R.id.use_same_profile_browser).setOnClickListener(v -> finish()); findViewById(R.id.button_open).setOnClickListener(v -> { TargetInfo.refreshIntentCreatorToken(launchIntent); startActivityAsCaller( launchIntent, ActivityOptions.makeCustomAnimation( Loading Loading @@ -476,6 +478,7 @@ public class IntentForwarderActivity extends Activity { private void startActivityAsCaller(Intent newIntent, int userId) { try { TargetInfo.refreshIntentCreatorToken(newIntent); startActivityAsCaller( newIntent, /* options= */ null, Loading @@ -502,6 +505,7 @@ public class IntentForwarderActivity extends Activity { return; } sanitizeIntent(innerIntent); TargetInfo.refreshIntentCreatorToken(intentReceived); startActivityAsCaller(intentReceived, null, false, getUserId()); finish(); } Loading @@ -525,6 +529,7 @@ public class IntentForwarderActivity extends Activity { if (singleTabOnly) { intentReceived.putExtra(EXTRA_RESTRICT_TO_SINGLE_USER, true); } TargetInfo.refreshIntentCreatorToken(intentReceived); startActivityAsCaller(intentReceived, null, false, userId); finish(); } Loading core/java/com/android/internal/app/chooser/DisplayResolveInfo.java +2 −0 Original line number Diff line number Diff line Loading @@ -173,6 +173,7 @@ public class DisplayResolveInfo implements TargetInfo, Parcelable { @Override public boolean startAsCaller(ResolverActivity activity, Bundle options, int userId) { TargetInfo.prepareIntentForCrossProfileLaunch(mResolvedIntent, userId); TargetInfo.refreshIntentCreatorToken(mResolvedIntent); activity.startActivityAsCaller(mResolvedIntent, options, false, userId); return true; } Loading @@ -180,6 +181,7 @@ public class DisplayResolveInfo implements TargetInfo, Parcelable { @Override public boolean startAsUser(Activity activity, Bundle options, UserHandle user) { TargetInfo.prepareIntentForCrossProfileLaunch(mResolvedIntent, user.getIdentifier()); TargetInfo.refreshIntentCreatorToken(mResolvedIntent); activity.startActivityAsUser(mResolvedIntent, options, user); return false; } Loading core/java/com/android/internal/app/chooser/SelectableTargetInfo.java +1 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,7 @@ public final class SelectableTargetInfo implements ChooserTargetInfo { intent.setComponent(mChooserTarget.getComponentName()); intent.putExtras(mChooserTarget.getIntentExtras()); TargetInfo.prepareIntentForCrossProfileLaunch(intent, userId); TargetInfo.refreshIntentCreatorToken(intent); // Important: we will ignore the target security checks in ActivityManager // if and only if the ChooserTarget's target package is the same package Loading core/java/com/android/internal/app/chooser/TargetInfo.java +20 −0 Original line number Diff line number Diff line Loading @@ -17,13 +17,17 @@ package com.android.internal.app.chooser; import static android.security.Flags.preventIntentRedirect; import android.app.Activity; import android.app.ActivityManager; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.ResolveInfo; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.RemoteException; import android.os.UserHandle; import com.android.internal.app.ResolverActivity; Loading Loading @@ -141,4 +145,20 @@ public interface TargetInfo { intent.fixUris(currentUserId); } } /** * refreshes intent's creatorToken with its current intent key fields. This allows * ChooserActivity to still keep original creatorToken's creator uid after making changes to * the intent and still keep it valid. * @param intent the intent's creatorToken needs to up refreshed. */ static void refreshIntentCreatorToken(Intent intent) { if (!preventIntentRedirect()) return; try { intent.setCreatorToken(ActivityManager.getService().refreshIntentCreatorToken( intent.cloneForCreatorToken())); } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); } } } Loading
core/java/com/android/internal/app/IntentForwarderActivity.java +5 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ import android.widget.Toast; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.app.chooser.TargetInfo; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; Loading Loading @@ -352,6 +353,7 @@ public class IntentForwarderActivity extends Activity { findViewById(R.id.use_same_profile_browser).setOnClickListener(v -> finish()); findViewById(R.id.button_open).setOnClickListener(v -> { TargetInfo.refreshIntentCreatorToken(launchIntent); startActivityAsCaller( launchIntent, ActivityOptions.makeCustomAnimation( Loading Loading @@ -476,6 +478,7 @@ public class IntentForwarderActivity extends Activity { private void startActivityAsCaller(Intent newIntent, int userId) { try { TargetInfo.refreshIntentCreatorToken(newIntent); startActivityAsCaller( newIntent, /* options= */ null, Loading @@ -502,6 +505,7 @@ public class IntentForwarderActivity extends Activity { return; } sanitizeIntent(innerIntent); TargetInfo.refreshIntentCreatorToken(intentReceived); startActivityAsCaller(intentReceived, null, false, getUserId()); finish(); } Loading @@ -525,6 +529,7 @@ public class IntentForwarderActivity extends Activity { if (singleTabOnly) { intentReceived.putExtra(EXTRA_RESTRICT_TO_SINGLE_USER, true); } TargetInfo.refreshIntentCreatorToken(intentReceived); startActivityAsCaller(intentReceived, null, false, userId); finish(); } Loading
core/java/com/android/internal/app/chooser/DisplayResolveInfo.java +2 −0 Original line number Diff line number Diff line Loading @@ -173,6 +173,7 @@ public class DisplayResolveInfo implements TargetInfo, Parcelable { @Override public boolean startAsCaller(ResolverActivity activity, Bundle options, int userId) { TargetInfo.prepareIntentForCrossProfileLaunch(mResolvedIntent, userId); TargetInfo.refreshIntentCreatorToken(mResolvedIntent); activity.startActivityAsCaller(mResolvedIntent, options, false, userId); return true; } Loading @@ -180,6 +181,7 @@ public class DisplayResolveInfo implements TargetInfo, Parcelable { @Override public boolean startAsUser(Activity activity, Bundle options, UserHandle user) { TargetInfo.prepareIntentForCrossProfileLaunch(mResolvedIntent, user.getIdentifier()); TargetInfo.refreshIntentCreatorToken(mResolvedIntent); activity.startActivityAsUser(mResolvedIntent, options, user); return false; } Loading
core/java/com/android/internal/app/chooser/SelectableTargetInfo.java +1 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,7 @@ public final class SelectableTargetInfo implements ChooserTargetInfo { intent.setComponent(mChooserTarget.getComponentName()); intent.putExtras(mChooserTarget.getIntentExtras()); TargetInfo.prepareIntentForCrossProfileLaunch(intent, userId); TargetInfo.refreshIntentCreatorToken(intent); // Important: we will ignore the target security checks in ActivityManager // if and only if the ChooserTarget's target package is the same package Loading
core/java/com/android/internal/app/chooser/TargetInfo.java +20 −0 Original line number Diff line number Diff line Loading @@ -17,13 +17,17 @@ package com.android.internal.app.chooser; import static android.security.Flags.preventIntentRedirect; import android.app.Activity; import android.app.ActivityManager; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.ResolveInfo; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.RemoteException; import android.os.UserHandle; import com.android.internal.app.ResolverActivity; Loading Loading @@ -141,4 +145,20 @@ public interface TargetInfo { intent.fixUris(currentUserId); } } /** * refreshes intent's creatorToken with its current intent key fields. This allows * ChooserActivity to still keep original creatorToken's creator uid after making changes to * the intent and still keep it valid. * @param intent the intent's creatorToken needs to up refreshed. */ static void refreshIntentCreatorToken(Intent intent) { if (!preventIntentRedirect()) return; try { intent.setCreatorToken(ActivityManager.getService().refreshIntentCreatorToken( intent.cloneForCreatorToken())); } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); } } }