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

Commit 1affbbc5 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Launch home activity in home stack if coming from ResolverActivity

ResolverActivity launches activities it resolves as the initial caller.
In the case of the home intent it can be sys-ui, but only the system
server is currently allow to launch things into the home stack, so the
resolved home activity is placed in non-home stack. This wasn’t a
visible problem in fullscreen mode as the user would notice since
everything is fullscreen, however it is very visible in multi-window mode.
We now allow home activities to be places in the home stack if it is coming
from the ResolverActivity.

Bug: 28487506
Change-Id: I68f81da68a207efab9ce911fa6661bd573f1e949
parent f4810f55
Loading
Loading
Loading
Loading
+33 −17
Original line number Diff line number Diff line
@@ -592,7 +592,7 @@ final class ActivityRecord {
            ActivityRecord _resultTo, String _resultWho, int _reqCode,
            boolean _componentSpecified, boolean _rootVoiceInteraction,
            ActivityStackSupervisor supervisor,
            ActivityContainer container, ActivityOptions options) {
            ActivityContainer container, ActivityOptions options, ActivityRecord sourceRecord) {
        service = _service;
        appToken = new Token(this, service);
        info = aInfo;
@@ -705,21 +705,7 @@ final class ActivityRecord {
            noDisplay = ent != null && ent.array.getBoolean(
                    com.android.internal.R.styleable.Window_windowNoDisplay, false);

            if ((!_componentSpecified || _launchedFromUid == Process.myUid()
                    || _launchedFromUid == 0) &&
                    Intent.ACTION_MAIN.equals(_intent.getAction()) &&
                    _intent.hasCategory(Intent.CATEGORY_HOME) &&
                    _intent.getCategories().size() == 1 &&
                    _intent.getData() == null &&
                    _intent.getType() == null &&
                    !isResolverActivity()) {
                // This sure looks like a home activity!
                mActivityType = HOME_ACTIVITY_TYPE;
            } else if (realActivity.getClassName().contains(RECENTS_PACKAGE_NAME)) {
                mActivityType = RECENTS_ACTIVITY_TYPE;
            } else {
                mActivityType = APPLICATION_ACTIVITY_TYPE;
            }
            setActivityType(_componentSpecified, _launchedFromUid, _intent, sourceRecord);

            immersive = (aInfo.flags & ActivityInfo.FLAG_IMMERSIVE) != 0;

@@ -740,6 +726,36 @@ final class ActivityRecord {
        }
    }

    private boolean isHomeIntent(Intent intent) {
        return Intent.ACTION_MAIN.equals(intent.getAction())
                && intent.hasCategory(Intent.CATEGORY_HOME)
                && intent.getCategories().size() == 1
                && intent.getData() == null
                && intent.getType() == null;
    }

    private boolean canLaunchHomeActivity(int uid, ActivityRecord sourceRecord) {
        if (uid == Process.myUid() || uid == 0) {
            // System process can launch home activity.
            return true;
        }
        // Resolver activity can launch home activity.
        return sourceRecord != null && sourceRecord.isResolverActivity();
    }

    private void setActivityType(boolean componentSpecified,
            int launchedFromUid, Intent intent, ActivityRecord sourceRecord) {
        if ((!componentSpecified || canLaunchHomeActivity(launchedFromUid, sourceRecord))
                && isHomeIntent(intent) && !isResolverActivity()) {
            // This sure looks like a home activity!
            mActivityType = HOME_ACTIVITY_TYPE;
        } else if (realActivity.getClassName().contains(RECENTS_PACKAGE_NAME)) {
            mActivityType = RECENTS_ACTIVITY_TYPE;
        } else {
            mActivityType = APPLICATION_ACTIVITY_TYPE;
        }
    }

    void setTask(TaskRecord newTask, TaskRecord taskToAffiliateWith) {
        if (task != null && task.removeActivity(this) && task != newTask && task.stack != null) {
            task.stack.removeTask(task, "setTask");
@@ -1473,7 +1489,7 @@ final class ActivityRecord {
        }
        final ActivityRecord r = new ActivityRecord(service, /*caller*/null, launchedFromUid,
                launchedFromPackage, intent, resolvedType, aInfo, service.getConfiguration(),
                null, null, 0, componentSpecified, false, stackSupervisor, null, null);
                null, null, 0, componentSpecified, false, stackSupervisor, null, null, null);

        r.persistentState = persistentState;
        r.taskDescription = taskDescription;
+1 −1
Original line number Diff line number Diff line
@@ -492,7 +492,7 @@ class ActivityStarter {
        ActivityRecord r = new ActivityRecord(mService, callerApp, callingUid, callingPackage,
                intent, resolvedType, aInfo, mService.mConfiguration, resultRecord, resultWho,
                requestCode, componentSpecified, voiceSession != null, mSupervisor, container,
                options);
                options, sourceRecord);
        if (outActivity != null) {
            outActivity[0] = r;
        }