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

Commit e9a5ed80 authored by Louis Chang's avatar Louis Chang
Browse files

Use op package name as the calling package while start activities

Apps with system_uid are allowed to run on other system core
processes. With f9e5c9fe, the component was unable to start activities
since the calling package and the calling uid weren't the same app.

Bug: 169859652
Test: start activity on phone process from a shared system uid package
Change-Id: Ida27c7518fb81cb5a1ac654e86fb1918f962ebf8
parent 4b94029f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5818,7 +5818,7 @@ public class Activity extends ContextThemeWrapper
                intent.migrateExtraStreamToClipData(this);
                intent.prepareToLeaveProcess(this);
                result = ActivityTaskManager.getService()
                    .startActivity(mMainThread.getApplicationThread(), getBasePackageName(),
                    .startActivity(mMainThread.getApplicationThread(), getOpPackageName(),
                            getAttributionTag(), intent,
                            intent.resolveTypeIfNeeded(getContentResolver()), mToken, mEmbeddedID,
                            requestCode, ActivityManager.START_FLAG_ONLY_IF_NEEDED, null, options);
+2 −2
Original line number Diff line number Diff line
@@ -1931,7 +1931,7 @@ public class ActivityManager {
        ArrayList<AppTask> tasks = new ArrayList<AppTask>();
        List<IBinder> appTasks;
        try {
            appTasks = getTaskService().getAppTasks(mContext.getPackageName());
            appTasks = getTaskService().getAppTasks(mContext.getOpPackageName());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -2466,7 +2466,7 @@ public class ActivityManager {
        try {
            ActivityThread thread = ActivityThread.currentActivityThread();
            IApplicationThread appThread = thread.getApplicationThread();
            String packageName = mContext.getPackageName();
            String packageName = mContext.getOpPackageName();
            getTaskService().moveTaskToFront(appThread, packageName, taskId, flags, options);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
+1 −1
Original line number Diff line number Diff line
@@ -1039,7 +1039,7 @@ class ContextImpl extends Context {
    public void startActivityAsUser(Intent intent, Bundle options, UserHandle user) {
        try {
            ActivityTaskManager.getService().startActivityAsUser(
                    mMainThread.getApplicationThread(), getBasePackageName(), getAttributionTag(),
                    mMainThread.getApplicationThread(), getOpPackageName(), getAttributionTag(),
                    intent, intent.resolveTypeIfNeeded(getContentResolver()),
                    null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, options,
                    user.getIdentifier());
+10 −10
Original line number Diff line number Diff line
@@ -1725,7 +1725,7 @@ public class Instrumentation {
            intent.migrateExtraStreamToClipData(who);
            intent.prepareToLeaveProcess(who);
            int result = ActivityTaskManager.getService().startActivity(whoThread,
                    who.getBasePackageName(), who.getAttributionTag(), intent,
                    who.getOpPackageName(), who.getAttributionTag(), intent,
                    intent.resolveTypeIfNeeded(who.getContentResolver()), token,
                    target != null ? target.mEmbeddedID : null, requestCode, 0, null, options);
            checkStartActivityResult(result, intent);
@@ -1797,7 +1797,7 @@ public class Instrumentation {
                resolvedTypes[i] = intents[i].resolveTypeIfNeeded(who.getContentResolver());
            }
            int result = ActivityTaskManager.getService().startActivities(whoThread,
                    who.getBasePackageName(), who.getAttributionTag(), intents, resolvedTypes,
                    who.getOpPackageName(), who.getAttributionTag(), intents, resolvedTypes,
                    token, options, userId);
            checkStartActivityResult(result, intents[0]);
            return result;
@@ -1864,7 +1864,7 @@ public class Instrumentation {
            intent.migrateExtraStreamToClipData(who);
            intent.prepareToLeaveProcess(who);
            int result = ActivityTaskManager.getService().startActivity(whoThread,
                    who.getBasePackageName(), who.getAttributionTag(), intent,
                    who.getOpPackageName(), who.getAttributionTag(), intent,
                    intent.resolveTypeIfNeeded(who.getContentResolver()), token, target,
                    requestCode, 0, null, options);
            checkStartActivityResult(result, intent);
@@ -1931,7 +1931,7 @@ public class Instrumentation {
            intent.migrateExtraStreamToClipData(who);
            intent.prepareToLeaveProcess(who);
            int result = ActivityTaskManager.getService().startActivityAsUser(whoThread,
                    who.getBasePackageName(), who.getAttributionTag(), intent,
                    who.getOpPackageName(), who.getAttributionTag(), intent,
                    intent.resolveTypeIfNeeded(who.getContentResolver()), token, resultWho,
                    requestCode, 0, null, options, user.getIdentifier());
            checkStartActivityResult(result, intent);
@@ -1977,7 +1977,7 @@ public class Instrumentation {
            intent.migrateExtraStreamToClipData(who);
            intent.prepareToLeaveProcess(who);
            int result = ActivityTaskManager.getService()
                .startActivityAsCaller(whoThread, who.getBasePackageName(), intent,
                    .startActivityAsCaller(whoThread, who.getOpPackageName(), intent,
                            intent.resolveTypeIfNeeded(who.getContentResolver()),
                            token, target != null ? target.mEmbeddedID : null,
                            requestCode, 0, null, options, permissionToken,
@@ -2023,7 +2023,7 @@ public class Instrumentation {
        try {
            intent.migrateExtraStreamToClipData(who);
            intent.prepareToLeaveProcess(who);
            int result = appTask.startActivity(whoThread.asBinder(), who.getBasePackageName(),
            int result = appTask.startActivity(whoThread.asBinder(), who.getOpPackageName(),
                    who.getAttributionTag(), intent,
                    intent.resolveTypeIfNeeded(who.getContentResolver()), options);
            checkStartActivityResult(result, intent);
+2 −2
Original line number Diff line number Diff line
@@ -5208,7 +5208,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    final Intent dock = createHomeDockIntent();
                    if (dock != null) {
                        int result = ActivityTaskManager.getService()
                                .startActivityAsUser(null, mContext.getBasePackageName(),
                                .startActivityAsUser(null, mContext.getOpPackageName(),
                                        mContext.getAttributionTag(), dock,
                                        dock.resolveTypeIfNeeded(mContext.getContentResolver()),
                                        null, null, 0,
@@ -5220,7 +5220,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    }
                }
                int result = ActivityTaskManager.getService()
                        .startActivityAsUser(null, mContext.getBasePackageName(),
                        .startActivityAsUser(null, mContext.getOpPackageName(),
                                mContext.getAttributionTag(), mHomeIntent,
                                mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
                                null, null, 0,