Loading core/api/current.txt +5 −0 Original line number Diff line number Diff line Loading @@ -4429,12 +4429,14 @@ package android.app { method @Deprecated public void finishFromChild(android.app.Activity); method @Nullable public android.app.ActionBar getActionBar(); method public final android.app.Application getApplication(); method @FlaggedApi("android.security.content_uri_permission_apis") @Nullable public android.app.ComponentCaller getCaller(); method @Nullable public android.content.ComponentName getCallingActivity(); method @Nullable public String getCallingPackage(); method public int getChangingConfigurations(); method public android.content.ComponentName getComponentName(); method public android.transition.Scene getContentScene(); method public android.transition.TransitionManager getContentTransitionManager(); method @FlaggedApi("android.security.content_uri_permission_apis") @NonNull public android.app.ComponentCaller getCurrentCaller(); method @Nullable public android.view.View getCurrentFocus(); method @Deprecated public android.app.FragmentManager getFragmentManager(); method @FlaggedApi("android.security.content_uri_permission_apis") @NonNull public android.app.ComponentCaller getInitialCaller(); Loading Loading @@ -4527,6 +4529,7 @@ package android.app { method public boolean onNavigateUp(); method @Deprecated public boolean onNavigateUpFromChild(android.app.Activity); method protected void onNewIntent(android.content.Intent); method @FlaggedApi("android.security.content_uri_permission_apis") public void onNewIntent(@NonNull android.content.Intent, @NonNull android.app.ComponentCaller); method public boolean onOptionsItemSelected(@NonNull android.view.MenuItem); method public void onOptionsMenuClosed(android.view.Menu); method public void onPanelClosed(int, @NonNull android.view.Menu); Loading Loading @@ -4614,6 +4617,7 @@ package android.app { method public void setImmersive(boolean); method public void setInheritShowWhenLocked(boolean); method public void setIntent(android.content.Intent); method @FlaggedApi("android.security.content_uri_permission_apis") public void setIntent(@Nullable android.content.Intent, @Nullable android.app.ComponentCaller); method public void setLocusContext(@Nullable android.content.LocusId, @Nullable android.os.Bundle); method public final void setMediaController(android.media.session.MediaController); method public void setPictureInPictureParams(@NonNull android.app.PictureInPictureParams); Loading Loading @@ -6101,6 +6105,7 @@ package android.app { method public void callActivityOnCreate(android.app.Activity, android.os.Bundle, android.os.PersistableBundle); method public void callActivityOnDestroy(android.app.Activity); method public void callActivityOnNewIntent(android.app.Activity, android.content.Intent); method @FlaggedApi("android.security.content_uri_permission_apis") public void callActivityOnNewIntent(@NonNull android.app.Activity, @NonNull android.content.Intent, @NonNull android.app.ComponentCaller); method public void callActivityOnPause(android.app.Activity); method public void callActivityOnPictureInPictureRequested(@NonNull android.app.Activity); method public void callActivityOnPostCreate(@NonNull android.app.Activity, @Nullable android.os.Bundle); core/java/android/app/Activity.java +142 −9 Original line number Diff line number Diff line Loading @@ -844,7 +844,28 @@ public class Activity extends ContextThemeWrapper private IBinder mToken; private IBinder mAssistToken; private IBinder mShareableActivityToken; /** Initial caller of the activity. Can be retrieved from {@link #getInitialCaller} */ private ComponentCaller mInitialCaller; /** * Caller associated with the Intent from {@link #getIntent}. Can be retrieved from * {@link #getCaller}. * * <p>The value of this field depends on how the activity set its intent: * - If via {@link #setIntent(Intent)}, the caller will be {@code null}. * - If via {@link #setIntent(Intent, ComponentCaller)}, the caller will be set to the passed * caller. */ private ComponentCaller mCaller; /** * Caller associated with an Intent within {@link #onNewIntent}. Can be retrieved from * {@link #getCurrentCaller}, or by overriding {@link #onNewIntent(Intent, ComponentCaller)} and * getting the second argument. * * <p>The value of this field will be {@code null} outside of {@link #onNewIntent}. */ private ComponentCaller mCurrentCaller; @UnsupportedAppUsage private int mIdent; @UnsupportedAppUsage Loading Loading @@ -1117,23 +1138,71 @@ public class Activity extends ContextThemeWrapper private static native String getDlWarning(); /** Return the intent that started this activity. */ /** * Returns the intent that started this activity. * * <p>To keep the Intent instance for future use, call {@link #setIntent(Intent)}, and use * this method to retrieve it. */ public Intent getIntent() { return mIntent; } /** * Change the intent returned by {@link #getIntent}. This holds a * Changes the intent returned by {@link #getIntent}. This holds a * reference to the given intent; it does not copy it. Often used in * conjunction with {@link #onNewIntent}. * conjunction with {@link #onNewIntent(Intent)}. * * @param newIntent The new Intent object to return from getIntent * @param newIntent The new Intent object to return from {@link #getIntent} * * @see #getIntent * @see #onNewIntent * @see #onNewIntent(Intent) */ public void setIntent(Intent newIntent) { internalSetIntent(newIntent, /* newCaller */ null); } /** * Returns the ComponentCaller instance of the app that launched this activity with the intent * from {@link #getIntent()}. To keep the value of the ComponentCaller instance for new intents, * call {@link #setIntent(Intent, ComponentCaller)} instead of {@link #setIntent(Intent)}. * * @return {@link ComponentCaller} instance corresponding to the intent from * {@link #getIntent()}, or {@code null} if the activity was not launched with that * intent * * @see ComponentCaller * @see #getIntent * @see #setIntent(Intent, ComponentCaller) */ @FlaggedApi(android.security.Flags.FLAG_CONTENT_URI_PERMISSION_APIS) public @Nullable ComponentCaller getCaller() { return mCaller; } /** * Changes the intent returned by {@link #getIntent}, and ComponentCaller returned by * {@link #getCaller}. This holds references to the given intent, and ComponentCaller; it does * not copy them. Often used in conjunction with {@link #onNewIntent(Intent)}. To retrieve the * caller from {@link #onNewIntent(Intent)}, use {@link #getCurrentCaller}, otherwise override * {@link #onNewIntent(Intent, ComponentCaller)}. * * @param newIntent The new Intent object to return from {@link #getIntent} * @param newCaller The new {@link ComponentCaller} object to return from * {@link #getCaller} * * @see #getIntent * @see #onNewIntent(Intent, ComponentCaller) * @see #getCaller */ @FlaggedApi(android.security.Flags.FLAG_CONTENT_URI_PERMISSION_APIS) public void setIntent(@Nullable Intent newIntent, @Nullable ComponentCaller newCaller) { internalSetIntent(newIntent, newCaller); } private void internalSetIntent(Intent newIntent, ComponentCaller newCaller) { mIntent = newIntent; mCaller = newCaller; } /** Loading Loading @@ -2284,17 +2353,41 @@ public class Activity extends ContextThemeWrapper * sometime later when activity becomes active again. * * <p>Note that {@link #getIntent} still returns the original Intent. You * can use {@link #setIntent} to update it to this new Intent. * can use {@link #setIntent(Intent)} to update it to this new Intent. * * @param intent The new intent that was started for the activity. * @param intent The new intent that was used to start the activity * * @see #getIntent * @see #setIntent * @see #setIntent(Intent) * @see #onResume */ protected void onNewIntent(Intent intent) { } /** * Same as {@link #onNewIntent(Intent)}, but with an extra parameter for the ComponentCaller * instance associated with the app that sent the intent. * * <p>If you want to retrieve the caller without overriding this method, call * {@link #getCurrentCaller} inside your existing {@link #onNewIntent(Intent)}. * * <p>Note that you should only override one {@link #onNewIntent} method. * * @param intent The new intent that was used to start the activity * @param caller The {@link ComponentCaller} instance associated with the app that sent the * intent * * @see ComponentCaller * @see #onNewIntent(Intent) * @see #getCurrentCaller * @see #setIntent(Intent, ComponentCaller) * @see #getCaller */ @FlaggedApi(android.security.Flags.FLAG_CONTENT_URI_PERMISSION_APIS) public void onNewIntent(@NonNull Intent intent, @NonNull ComponentCaller caller) { onNewIntent(intent); } /** * The hook for {@link ActivityThread} to save the state of this activity. * Loading Loading @@ -7043,6 +7136,35 @@ public class Activity extends ContextThemeWrapper return mInitialCaller; } /** * Returns the ComponentCaller instance of the app that re-launched this activity with a new * intent via {@link #onNewIntent}. * * <p>Note that this method only works within the {@link #onNewIntent} method. If you call this * method outside {@link #onNewIntent}, it will throw an {@link IllegalStateException}. * * <p>You can also retrieve the caller if you override * {@link #onNewIntent(Intent, ComponentCaller)}. * * <p>To keep the ComponentCaller instance for future use, call * {@link #setIntent(Intent, ComponentCaller)}, and use {@link #getCaller} to retrieve it. * * @return {@link ComponentCaller} instance * @throws IllegalStateException if the caller is {@code null}, indicating the method was called * outside {@link #onNewIntent} * @see ComponentCaller * @see #setIntent(Intent, ComponentCaller) * @see #getCaller */ @FlaggedApi(android.security.Flags.FLAG_CONTENT_URI_PERMISSION_APIS) public @NonNull ComponentCaller getCurrentCaller() { if (mCurrentCaller == null) { throw new IllegalStateException("The caller is null because #getCurrentCaller should be" + " called within #onNewIntent method"); } return mCurrentCaller; } /** * Control whether this activity's main window is visible. This is intended * only for the special case of an activity that is not going to show a Loading Loading @@ -8740,6 +8862,7 @@ public class Activity extends ContextThemeWrapper if (android.security.Flags.contentUriPermissionApis()) { mInitialCaller = new ComponentCaller(getActivityToken(), initialCallerInfoAccessToken); mCaller = mInitialCaller; } } Loading Loading @@ -8815,6 +8938,16 @@ public class Activity extends ContextThemeWrapper Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER); } @FlaggedApi(android.security.Flags.FLAG_CONTENT_URI_PERMISSION_APIS) final void performNewIntent(@NonNull Intent intent, @NonNull ComponentCaller caller) { Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "performNewIntent"); mCanEnterPictureInPicture = true; mCurrentCaller = caller; onNewIntent(intent, caller); mCurrentCaller = null; Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER); } final void performStart(String reason) { if (Trace.isTagEnabled(Trace.TRACE_TAG_WINDOW_MANAGER)) { Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "performStart:" Loading core/java/android/app/ActivityClient.java +20 −0 Original line number Diff line number Diff line Loading @@ -299,6 +299,26 @@ public class ActivityClient { } } /** Returns the uid of the app that launched the activity. */ public int getActivityCallerUid(IBinder activityToken, IBinder callerToken) { try { return getActivityClientController().getActivityCallerUid(activityToken, callerToken); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** Returns the package of the app that launched the activity. */ public String getActivityCallerPackage(IBinder activityToken, IBinder callerToken) { try { return getActivityClientController().getActivityCallerPackage(activityToken, callerToken); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** Checks if the app that launched the activity has access to the URI. */ public int checkActivityCallerContentUriPermission(IBinder activityToken, IBinder callerToken, Uri uri, int modeFlags) { Loading core/java/android/app/ActivityThread.java +6 −1 Original line number Diff line number Diff line Loading @@ -4203,9 +4203,14 @@ public final class ActivityThread extends ClientTransactionHandler intent.prepareToEnterProcess(isProtectedComponent(r.activityInfo), r.activity.getAttributionSource()); r.activity.mFragments.noteStateNotSaved(); if (android.security.Flags.contentUriPermissionApis()) { ComponentCaller caller = new ComponentCaller(r.token, intent.mCallerToken); mInstrumentation.callActivityOnNewIntent(r.activity, intent, caller); } else { mInstrumentation.callActivityOnNewIntent(r.activity, intent); } } } @Override public void handleNewIntent(ActivityClientRecord r, List<ReferrerIntent> intents) { Loading core/java/android/app/ComponentCaller.java +4 −5 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.app; import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Intent; import android.content.pm.PackageManager; Loading @@ -24,8 +25,6 @@ import android.net.Uri; import android.os.IBinder; import android.os.Process; import androidx.annotation.NonNull; import java.util.Objects; /** Loading @@ -45,7 +44,7 @@ public final class ComponentCaller { /** * @hide */ public ComponentCaller(@NonNull IBinder activityToken, @Nullable IBinder callerToken) { public ComponentCaller(@Nullable IBinder activityToken, @Nullable IBinder callerToken) { mActivityToken = activityToken; mCallerToken = callerToken; } Loading Loading @@ -83,7 +82,7 @@ public final class ComponentCaller { * @see Activity#getLaunchedFromUid() */ public int getUid() { return ActivityClient.getInstance().getLaunchedFromUid(mActivityToken); return ActivityClient.getInstance().getActivityCallerUid(mActivityToken, mCallerToken); } /** Loading Loading @@ -121,7 +120,7 @@ public final class ComponentCaller { */ @Nullable public String getPackage() { return ActivityClient.getInstance().getLaunchedFromPackage(mActivityToken); return ActivityClient.getInstance().getActivityCallerPackage(mActivityToken, mCallerToken); } /** Loading Loading
core/api/current.txt +5 −0 Original line number Diff line number Diff line Loading @@ -4429,12 +4429,14 @@ package android.app { method @Deprecated public void finishFromChild(android.app.Activity); method @Nullable public android.app.ActionBar getActionBar(); method public final android.app.Application getApplication(); method @FlaggedApi("android.security.content_uri_permission_apis") @Nullable public android.app.ComponentCaller getCaller(); method @Nullable public android.content.ComponentName getCallingActivity(); method @Nullable public String getCallingPackage(); method public int getChangingConfigurations(); method public android.content.ComponentName getComponentName(); method public android.transition.Scene getContentScene(); method public android.transition.TransitionManager getContentTransitionManager(); method @FlaggedApi("android.security.content_uri_permission_apis") @NonNull public android.app.ComponentCaller getCurrentCaller(); method @Nullable public android.view.View getCurrentFocus(); method @Deprecated public android.app.FragmentManager getFragmentManager(); method @FlaggedApi("android.security.content_uri_permission_apis") @NonNull public android.app.ComponentCaller getInitialCaller(); Loading Loading @@ -4527,6 +4529,7 @@ package android.app { method public boolean onNavigateUp(); method @Deprecated public boolean onNavigateUpFromChild(android.app.Activity); method protected void onNewIntent(android.content.Intent); method @FlaggedApi("android.security.content_uri_permission_apis") public void onNewIntent(@NonNull android.content.Intent, @NonNull android.app.ComponentCaller); method public boolean onOptionsItemSelected(@NonNull android.view.MenuItem); method public void onOptionsMenuClosed(android.view.Menu); method public void onPanelClosed(int, @NonNull android.view.Menu); Loading Loading @@ -4614,6 +4617,7 @@ package android.app { method public void setImmersive(boolean); method public void setInheritShowWhenLocked(boolean); method public void setIntent(android.content.Intent); method @FlaggedApi("android.security.content_uri_permission_apis") public void setIntent(@Nullable android.content.Intent, @Nullable android.app.ComponentCaller); method public void setLocusContext(@Nullable android.content.LocusId, @Nullable android.os.Bundle); method public final void setMediaController(android.media.session.MediaController); method public void setPictureInPictureParams(@NonNull android.app.PictureInPictureParams); Loading Loading @@ -6101,6 +6105,7 @@ package android.app { method public void callActivityOnCreate(android.app.Activity, android.os.Bundle, android.os.PersistableBundle); method public void callActivityOnDestroy(android.app.Activity); method public void callActivityOnNewIntent(android.app.Activity, android.content.Intent); method @FlaggedApi("android.security.content_uri_permission_apis") public void callActivityOnNewIntent(@NonNull android.app.Activity, @NonNull android.content.Intent, @NonNull android.app.ComponentCaller); method public void callActivityOnPause(android.app.Activity); method public void callActivityOnPictureInPictureRequested(@NonNull android.app.Activity); method public void callActivityOnPostCreate(@NonNull android.app.Activity, @Nullable android.os.Bundle);
core/java/android/app/Activity.java +142 −9 Original line number Diff line number Diff line Loading @@ -844,7 +844,28 @@ public class Activity extends ContextThemeWrapper private IBinder mToken; private IBinder mAssistToken; private IBinder mShareableActivityToken; /** Initial caller of the activity. Can be retrieved from {@link #getInitialCaller} */ private ComponentCaller mInitialCaller; /** * Caller associated with the Intent from {@link #getIntent}. Can be retrieved from * {@link #getCaller}. * * <p>The value of this field depends on how the activity set its intent: * - If via {@link #setIntent(Intent)}, the caller will be {@code null}. * - If via {@link #setIntent(Intent, ComponentCaller)}, the caller will be set to the passed * caller. */ private ComponentCaller mCaller; /** * Caller associated with an Intent within {@link #onNewIntent}. Can be retrieved from * {@link #getCurrentCaller}, or by overriding {@link #onNewIntent(Intent, ComponentCaller)} and * getting the second argument. * * <p>The value of this field will be {@code null} outside of {@link #onNewIntent}. */ private ComponentCaller mCurrentCaller; @UnsupportedAppUsage private int mIdent; @UnsupportedAppUsage Loading Loading @@ -1117,23 +1138,71 @@ public class Activity extends ContextThemeWrapper private static native String getDlWarning(); /** Return the intent that started this activity. */ /** * Returns the intent that started this activity. * * <p>To keep the Intent instance for future use, call {@link #setIntent(Intent)}, and use * this method to retrieve it. */ public Intent getIntent() { return mIntent; } /** * Change the intent returned by {@link #getIntent}. This holds a * Changes the intent returned by {@link #getIntent}. This holds a * reference to the given intent; it does not copy it. Often used in * conjunction with {@link #onNewIntent}. * conjunction with {@link #onNewIntent(Intent)}. * * @param newIntent The new Intent object to return from getIntent * @param newIntent The new Intent object to return from {@link #getIntent} * * @see #getIntent * @see #onNewIntent * @see #onNewIntent(Intent) */ public void setIntent(Intent newIntent) { internalSetIntent(newIntent, /* newCaller */ null); } /** * Returns the ComponentCaller instance of the app that launched this activity with the intent * from {@link #getIntent()}. To keep the value of the ComponentCaller instance for new intents, * call {@link #setIntent(Intent, ComponentCaller)} instead of {@link #setIntent(Intent)}. * * @return {@link ComponentCaller} instance corresponding to the intent from * {@link #getIntent()}, or {@code null} if the activity was not launched with that * intent * * @see ComponentCaller * @see #getIntent * @see #setIntent(Intent, ComponentCaller) */ @FlaggedApi(android.security.Flags.FLAG_CONTENT_URI_PERMISSION_APIS) public @Nullable ComponentCaller getCaller() { return mCaller; } /** * Changes the intent returned by {@link #getIntent}, and ComponentCaller returned by * {@link #getCaller}. This holds references to the given intent, and ComponentCaller; it does * not copy them. Often used in conjunction with {@link #onNewIntent(Intent)}. To retrieve the * caller from {@link #onNewIntent(Intent)}, use {@link #getCurrentCaller}, otherwise override * {@link #onNewIntent(Intent, ComponentCaller)}. * * @param newIntent The new Intent object to return from {@link #getIntent} * @param newCaller The new {@link ComponentCaller} object to return from * {@link #getCaller} * * @see #getIntent * @see #onNewIntent(Intent, ComponentCaller) * @see #getCaller */ @FlaggedApi(android.security.Flags.FLAG_CONTENT_URI_PERMISSION_APIS) public void setIntent(@Nullable Intent newIntent, @Nullable ComponentCaller newCaller) { internalSetIntent(newIntent, newCaller); } private void internalSetIntent(Intent newIntent, ComponentCaller newCaller) { mIntent = newIntent; mCaller = newCaller; } /** Loading Loading @@ -2284,17 +2353,41 @@ public class Activity extends ContextThemeWrapper * sometime later when activity becomes active again. * * <p>Note that {@link #getIntent} still returns the original Intent. You * can use {@link #setIntent} to update it to this new Intent. * can use {@link #setIntent(Intent)} to update it to this new Intent. * * @param intent The new intent that was started for the activity. * @param intent The new intent that was used to start the activity * * @see #getIntent * @see #setIntent * @see #setIntent(Intent) * @see #onResume */ protected void onNewIntent(Intent intent) { } /** * Same as {@link #onNewIntent(Intent)}, but with an extra parameter for the ComponentCaller * instance associated with the app that sent the intent. * * <p>If you want to retrieve the caller without overriding this method, call * {@link #getCurrentCaller} inside your existing {@link #onNewIntent(Intent)}. * * <p>Note that you should only override one {@link #onNewIntent} method. * * @param intent The new intent that was used to start the activity * @param caller The {@link ComponentCaller} instance associated with the app that sent the * intent * * @see ComponentCaller * @see #onNewIntent(Intent) * @see #getCurrentCaller * @see #setIntent(Intent, ComponentCaller) * @see #getCaller */ @FlaggedApi(android.security.Flags.FLAG_CONTENT_URI_PERMISSION_APIS) public void onNewIntent(@NonNull Intent intent, @NonNull ComponentCaller caller) { onNewIntent(intent); } /** * The hook for {@link ActivityThread} to save the state of this activity. * Loading Loading @@ -7043,6 +7136,35 @@ public class Activity extends ContextThemeWrapper return mInitialCaller; } /** * Returns the ComponentCaller instance of the app that re-launched this activity with a new * intent via {@link #onNewIntent}. * * <p>Note that this method only works within the {@link #onNewIntent} method. If you call this * method outside {@link #onNewIntent}, it will throw an {@link IllegalStateException}. * * <p>You can also retrieve the caller if you override * {@link #onNewIntent(Intent, ComponentCaller)}. * * <p>To keep the ComponentCaller instance for future use, call * {@link #setIntent(Intent, ComponentCaller)}, and use {@link #getCaller} to retrieve it. * * @return {@link ComponentCaller} instance * @throws IllegalStateException if the caller is {@code null}, indicating the method was called * outside {@link #onNewIntent} * @see ComponentCaller * @see #setIntent(Intent, ComponentCaller) * @see #getCaller */ @FlaggedApi(android.security.Flags.FLAG_CONTENT_URI_PERMISSION_APIS) public @NonNull ComponentCaller getCurrentCaller() { if (mCurrentCaller == null) { throw new IllegalStateException("The caller is null because #getCurrentCaller should be" + " called within #onNewIntent method"); } return mCurrentCaller; } /** * Control whether this activity's main window is visible. This is intended * only for the special case of an activity that is not going to show a Loading Loading @@ -8740,6 +8862,7 @@ public class Activity extends ContextThemeWrapper if (android.security.Flags.contentUriPermissionApis()) { mInitialCaller = new ComponentCaller(getActivityToken(), initialCallerInfoAccessToken); mCaller = mInitialCaller; } } Loading Loading @@ -8815,6 +8938,16 @@ public class Activity extends ContextThemeWrapper Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER); } @FlaggedApi(android.security.Flags.FLAG_CONTENT_URI_PERMISSION_APIS) final void performNewIntent(@NonNull Intent intent, @NonNull ComponentCaller caller) { Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "performNewIntent"); mCanEnterPictureInPicture = true; mCurrentCaller = caller; onNewIntent(intent, caller); mCurrentCaller = null; Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER); } final void performStart(String reason) { if (Trace.isTagEnabled(Trace.TRACE_TAG_WINDOW_MANAGER)) { Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "performStart:" Loading
core/java/android/app/ActivityClient.java +20 −0 Original line number Diff line number Diff line Loading @@ -299,6 +299,26 @@ public class ActivityClient { } } /** Returns the uid of the app that launched the activity. */ public int getActivityCallerUid(IBinder activityToken, IBinder callerToken) { try { return getActivityClientController().getActivityCallerUid(activityToken, callerToken); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** Returns the package of the app that launched the activity. */ public String getActivityCallerPackage(IBinder activityToken, IBinder callerToken) { try { return getActivityClientController().getActivityCallerPackage(activityToken, callerToken); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** Checks if the app that launched the activity has access to the URI. */ public int checkActivityCallerContentUriPermission(IBinder activityToken, IBinder callerToken, Uri uri, int modeFlags) { Loading
core/java/android/app/ActivityThread.java +6 −1 Original line number Diff line number Diff line Loading @@ -4203,9 +4203,14 @@ public final class ActivityThread extends ClientTransactionHandler intent.prepareToEnterProcess(isProtectedComponent(r.activityInfo), r.activity.getAttributionSource()); r.activity.mFragments.noteStateNotSaved(); if (android.security.Flags.contentUriPermissionApis()) { ComponentCaller caller = new ComponentCaller(r.token, intent.mCallerToken); mInstrumentation.callActivityOnNewIntent(r.activity, intent, caller); } else { mInstrumentation.callActivityOnNewIntent(r.activity, intent); } } } @Override public void handleNewIntent(ActivityClientRecord r, List<ReferrerIntent> intents) { Loading
core/java/android/app/ComponentCaller.java +4 −5 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.app; import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Intent; import android.content.pm.PackageManager; Loading @@ -24,8 +25,6 @@ import android.net.Uri; import android.os.IBinder; import android.os.Process; import androidx.annotation.NonNull; import java.util.Objects; /** Loading @@ -45,7 +44,7 @@ public final class ComponentCaller { /** * @hide */ public ComponentCaller(@NonNull IBinder activityToken, @Nullable IBinder callerToken) { public ComponentCaller(@Nullable IBinder activityToken, @Nullable IBinder callerToken) { mActivityToken = activityToken; mCallerToken = callerToken; } Loading Loading @@ -83,7 +82,7 @@ public final class ComponentCaller { * @see Activity#getLaunchedFromUid() */ public int getUid() { return ActivityClient.getInstance().getLaunchedFromUid(mActivityToken); return ActivityClient.getInstance().getActivityCallerUid(mActivityToken, mCallerToken); } /** Loading Loading @@ -121,7 +120,7 @@ public final class ComponentCaller { */ @Nullable public String getPackage() { return ActivityClient.getInstance().getLaunchedFromPackage(mActivityToken); return ActivityClient.getInstance().getActivityCallerPackage(mActivityToken, mCallerToken); } /** Loading