Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2da5cf9 authored by Hani Kazmi's avatar Hani Kazmi Committed by Android (Google) Code Review
Browse files

Merge "Add method to Activity to allow cross uid launches"

parents 15530467 58f1c99e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4510,6 +4510,7 @@ package android.app {
    method @NonNull public final <T extends android.view.View> T requireViewById(@IdRes int);
    method public final void runOnUiThread(Runnable);
    method public void setActionBar(@Nullable android.widget.Toolbar);
    method public void setAllowCrossUidActivitySwitchFromBelow(boolean);
    method public void setContentTransitionManager(android.transition.TransitionManager);
    method public void setContentView(@LayoutRes int);
    method public void setContentView(android.view.View);
+18 −0
Original line number Diff line number Diff line
@@ -9192,6 +9192,24 @@ public class Activity extends ContextThemeWrapper
        ActivityClient.getInstance().setTurnScreenOn(mToken, turnScreenOn);
    }

    /**
     * Specifies whether the activities below this one in the task can also start other activities
     * or finish the task.
     * <p>
     * Starting from Target SDK Level {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, apps
     * are blocked from starting new activities or finishing their task unless the top activity of
     * such task belong to the same UID for security reasons.
     * <p>
     * Setting this flag to {@code true} will allow the launching app to ignore the restriction if
     * this activity is on top. Apps matching the UID of this activity are always exempt.
     *
     * @param allowed {@code true} to disable the UID restrictions; {@code false} to revert back to
     *                            the default behaviour
     */
    public void setAllowCrossUidActivitySwitchFromBelow(boolean allowed) {
        ActivityClient.getInstance().setAllowCrossUidActivitySwitchFromBelow(mToken, allowed);
    }

    /**
     * Registers remote animations per transition type for this activity.
     *
+8 −0
Original line number Diff line number Diff line
@@ -478,6 +478,14 @@ public class ActivityClient {
        }
    }

    void setAllowCrossUidActivitySwitchFromBelow(IBinder token, boolean allowed) {
        try {
            getActivityClientController().setAllowCrossUidActivitySwitchFromBelow(token, allowed);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

    int setVrMode(IBinder token, boolean enabled, ComponentName packageName) {
        try {
            return getActivityClientController().setVrMode(token, enabled, packageName);
+1 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ interface IActivityClientController {
    oneway void setShowWhenLocked(in IBinder token, boolean showWhenLocked);
    oneway void setInheritShowWhenLocked(in IBinder token, boolean setInheritShownWhenLocked);
    oneway void setTurnScreenOn(in IBinder token, boolean turnScreenOn);
    oneway void setAllowCrossUidActivitySwitchFromBelow(in IBinder token, boolean allowed);
    oneway void reportActivityFullyDrawn(in IBinder token, boolean restoredFromBundle);
    oneway void overrideActivityTransition(IBinder token, boolean open, int enterAnim, int exitAnim,
            int backgroundColor);
+14 −0
Original line number Diff line number Diff line
@@ -1365,6 +1365,20 @@ class ActivityClientController extends IActivityClientController.Stub {
        }
    }

    public void setAllowCrossUidActivitySwitchFromBelow(IBinder token, boolean allowed) {
        final long origId = Binder.clearCallingIdentity();
        try {
            synchronized (mGlobalLock) {
                final ActivityRecord r = ActivityRecord.isInRootTaskLocked(token);
                if (r != null) {
                    r.setAllowCrossUidActivitySwitchFromBelow(allowed);
                }
            }
        } finally {
            Binder.restoreCallingIdentity(origId);
        }
    }

    @Override
    public void reportActivityFullyDrawn(IBinder token, boolean restoredFromBundle) {
        final long origId = Binder.clearCallingIdentity();
Loading