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

Commit 86d67a4f authored by Craig Mautner's avatar Craig Mautner
Browse files

Move Recents into home stack.

Allows Recents activity to occupy a special place in the window/stack
hierarchy.

Change-Id: Ic11c94a075f70c7ba68bd554cd3e5fc6b7c407e7
parent 11462cc0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8486,7 +8486,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            Iterator<ActivityRecord> it = mHomeProcess.activities.iterator();
            while (it.hasNext()) {
                ActivityRecord r = it.next();
                if (r.isHomeActivity) {
                if (r.isHomeActivity()) {
                    Log.i(TAG, "Clearing package preferred activities from " + r.packageName);
                    try {
                        ActivityThread.getPackageManager()
+33 −11
Original line number Diff line number Diff line
@@ -74,7 +74,12 @@ final class ActivityRecord {
    final boolean fullscreen; // covers the full screen?
    final boolean noDisplay;  // activity is not displayed?
    final boolean componentSpecified;  // did caller specifiy an explicit component?
    final boolean isHomeActivity; // do we consider this to be a home activity?

    static final int APPLICATION_ACTIVITY_TYPE = 0;
    static final int HOME_ACTIVITY_TYPE = 1;
    static final int RECENTS_ACTIVITY_TYPE = 2;
    final int mActivityType;

    final String baseDir;   // where activity source (resources etc) located
    final String resDir;   // where public activity source (public resources etc) located
    final String dataDir;   // where activity data should go
@@ -158,7 +163,7 @@ final class ActivityRecord {
        pw.print(prefix); pw.print("dataDir="); pw.println(dataDir);
        pw.print(prefix); pw.print("stateNotNeeded="); pw.print(stateNotNeeded);
                pw.print(" componentSpecified="); pw.print(componentSpecified);
                pw.print(" isHomeActivity="); pw.println(isHomeActivity);
                pw.print(" mActivityType="); pw.println(mActivityType);
        pw.print(prefix); pw.print("compat="); pw.print(compat);
                pw.print(" labelRes=0x"); pw.print(Integer.toHexString(labelRes));
                pw.print(" icon=0x"); pw.print(Integer.toHexString(icon));
@@ -436,8 +441,7 @@ final class ActivityRecord {
            // activity as being home...  really, we don't care about
            // doing anything special with something that comes from
            // the core framework package.
            isHomeActivity =
                    (!_componentSpecified || _launchedFromUid == Process.myUid()
            if ((!_componentSpecified || _launchedFromUid == Process.myUid()
                    || _launchedFromUid == 0) &&
                    Intent.ACTION_MAIN.equals(_intent.getAction()) &&
                    _intent.hasCategory(Intent.CATEGORY_HOME) &&
@@ -445,8 +449,14 @@ final class ActivityRecord {
                    _intent.getData() == null &&
                    _intent.getType() == null &&
                    (intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) != 0 &&
                    !ResolverActivity.class.getName().equals(realActivity.getClassName());
                    !ResolverActivity.class.getName().equals(realActivity.getClassName())) {
                // This sure looks like a home activity!
                mActivityType = HOME_ACTIVITY_TYPE;
            } else if (realActivity.getClassName().contains("com.android.systemui.recent")) {
                mActivityType = RECENTS_ACTIVITY_TYPE;
            } else {
                mActivityType = APPLICATION_ACTIVITY_TYPE;
            }

            immersive = (aInfo.flags & ActivityInfo.FLAG_IMMERSIVE) != 0;
        } else {
@@ -460,7 +470,7 @@ final class ActivityRecord {
            packageName = null;
            fullscreen = true;
            noDisplay = false;
            isHomeActivity = false;
            mActivityType = APPLICATION_ACTIVITY_TYPE;
            immersive = false;
        }
    }
@@ -515,6 +525,18 @@ final class ActivityRecord {
        return inHistory;
    }

    boolean isHomeActivity() {
        return mActivityType == HOME_ACTIVITY_TYPE;
    }

    boolean isRecentsActivity() {
        return mActivityType == RECENTS_ACTIVITY_TYPE;
    }

    boolean isApplicationActivity() {
        return mActivityType == APPLICATION_ACTIVITY_TYPE;
    }

    void makeFinishing() {
        if (!finishing) {
            finishing = true;
@@ -580,7 +602,6 @@ final class ActivityRecord {
     * method will be called at the proper time.
     */
    final void deliverNewIntentLocked(int callingUid, Intent intent) {
        boolean sent = false;
        // The activity now gets access to the data associated with this Intent.
        service.grantUriPermissionFromIntentLocked(callingUid, packageName,
                intent, getUriPermissionsLocked());
@@ -589,6 +610,7 @@ final class ActivityRecord {
        // device is sleeping, then all activities are stopped, so in that
        // case we will deliver it if this is the current top activity on its
        // stack.
        boolean unsent = true;
        if ((state == ActivityState.RESUMED || (service.mSleeping
                        && task.stack.topRunningActivityLocked(null) == this))
                && app != null && app.thread != null) {
@@ -597,7 +619,7 @@ final class ActivityRecord {
                intent = new Intent(intent);
                ar.add(intent);
                app.thread.scheduleNewIntent(ar, appToken);
                sent = true;
                unsent = false;
            } catch (RemoteException e) {
                Slog.w(ActivityManagerService.TAG,
                        "Exception thrown sending new intent to " + this, e);
@@ -606,7 +628,7 @@ final class ActivityRecord {
                        "Exception thrown sending new intent to " + this, e);
            }
        }
        if (!sent) {
        if (unsent) {
            addNewIntentLocked(new Intent(intent));
        }
    }
+4 −2
Original line number Diff line number Diff line
@@ -2251,7 +2251,7 @@ final class ActivityStack {
                if (r.state == ActivityState.RESUMED
                        || r.state == ActivityState.PAUSING
                        || r.state == ActivityState.PAUSED) {
                    if (!r.isHomeActivity || mService.mHomeProcess != r.app) {
                    if (!r.isHomeActivity() || mService.mHomeProcess != r.app) {
                        Slog.w(TAG, "  Force finishing activity "
                                + r.intent.getComponent().flattenToShortString());
                        finishActivityLocked(r, Activity.RESULT_CANCELED, null, "crashed", false);
@@ -2932,7 +2932,7 @@ final class ActivityStack {

        final int numTasks = mTaskHistory.size();
        final int index = mTaskHistory.indexOf(tr);
        if (numTasks == 0 || index < 0 || index == numTasks - 1)  {
        if (numTasks == 0 || index < 0)  {
            // nothing to do!
            if (reason != null &&
                    (reason.intent.getFlags()&Intent.FLAG_ACTIVITY_NO_ANIMATION) != 0) {
@@ -2943,6 +2943,8 @@ final class ActivityStack {
            return;
        }

        mStackSupervisor.moveHomeStack(isHomeStack());

        // Shift all activities with this task up to the top
        // of the stack, keeping them in the same internal order.
        mTaskHistory.remove(tr);
+5 −5
Original line number Diff line number Diff line
@@ -251,11 +251,11 @@ public class ActivityStackSupervisor {
            return;
        }
        if ((sourceRecord == null && getLastStack() == mHomeStack) ||
                (sourceRecord != null && sourceRecord.isHomeActivity)) {
                (sourceRecord != null && sourceRecord.isHomeActivity())) {
            if (r == null) {
                r = stack.topRunningActivityLocked(null);
            }
            if (r != null && !r.isHomeActivity && r.isRootActivity()) {
            if (r != null && !r.isHomeActivity() && r.isRootActivity()) {
                r.mLaunchHomeTaskNext = true;
            }
        }
@@ -839,7 +839,7 @@ public class ActivityStackSupervisor {
                        r.userId, System.identityHashCode(r),
                        r.task.taskId, r.shortComponentName);
            }
            if (r.isHomeActivity) {
            if (r.isHomeActivity()) {
                mService.mHomeProcess = app;
            }
            mService.ensurePackageDexOpt(r.intent.getComponent().getPackageName());
@@ -1160,7 +1160,7 @@ public class ActivityStackSupervisor {
    }

    ActivityStack getCorrectStack(ActivityRecord r) {
        if (!r.isHomeActivity || (r.task != null && !r.task.isHomeTask())) {
        if (r.isApplicationActivity() || (r.task != null && r.task.isApplicationTask())) {
            int stackNdx;
            for (stackNdx = mStacks.size() - 1; stackNdx > 0; --stackNdx) {
                if (mStacks.get(stackNdx).mCurrentUser == mCurrentUser) {
@@ -1182,7 +1182,7 @@ public class ActivityStackSupervisor {
        if (r == null) {
            return;
        }
        if (r.isHomeActivity || (r.task != null && r.task.isHomeTask())) {
        if (!r.isApplicationActivity() || (r.task != null && !r.task.isApplicationTask())) {
            if (mStackState != STACK_STATE_HOME_IN_FRONT) {
                mStackState = STACK_STATE_HOME_TO_FRONT;
            }
+4 −4
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ class TaskRecord extends ThumbnailHolder {
    /** Current stack */
    ActivityStack stack;

    private boolean mHomeTask;
    private boolean mApplicationTask;

    TaskRecord(int _taskId, ActivityInfo info, Intent _intent, ActivityStack _stack) {
        taskId = _taskId;
@@ -164,7 +164,7 @@ class TaskRecord extends ThumbnailHolder {
            // Was not previously in list.
            numFullscreen++;
        }
        mHomeTask = r.isHomeActivity;
        mApplicationTask = r.isApplicationActivity();
        mActivities.add(index, r);
    }

@@ -316,8 +316,8 @@ class TaskRecord extends ThumbnailHolder {
        return subtask.activity;
    }

    boolean isHomeTask() {
        return mHomeTask;
    boolean isApplicationTask() {
        return mApplicationTask;
    }

    public TaskAccessInfo getTaskAccessInfoLocked(boolean inclThumbs) {