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

Commit 66b08f02 authored by Winson Chung's avatar Winson Chung
Browse files

Reduce parceled data size between system & sysui

- SystemUI no longer uses the detailed task info since we exclusively call
  startActivityFromRecents() instead of starting the activity ourselves.
  In addition, all other uses of Task.fillTaskInfo() are currently to
  notify SysUI of task changes (either from the task change notifier or
  task org), and these task infos don't need the full intent extras or
  clip data either.  So we can just push up the code to clear the extras
  into Task.fillTaskInfo() and only partially clone the intent.

Bug: 150242007
Test: atest RecentTasksTest
Test: atest RunningTasksTest
Test: atest TaskOrganizerTests
Change-Id: Idd3d197c7b63d00ae213571a69279dee98256ba0
parent 42e3933e
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -2800,14 +2800,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        userId = handleIncomingUser(Binder.getCallingPid(), callingUid, userId, "getRecentTasks");
        final boolean allowed = isGetTasksAllowed("getRecentTasks", Binder.getCallingPid(),
                callingUid);
        final boolean detailed = checkGetTasksPermission(
                android.Manifest.permission.GET_DETAILED_TASKS, Binder.getCallingPid(),
                UserHandle.getAppId(callingUid))
                == PackageManager.PERMISSION_GRANTED;

        synchronized (mGlobalLock) {
            return mRecentTasks.getRecentTasks(maxNum, flags, allowed, detailed, userId,
                    callingUid);
            return mRecentTasks.getRecentTasks(maxNum, flags, allowed, userId, callingUid);
        }
    }

+5 −12
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ import android.content.pm.ParceledListSlice;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Environment;
import android.os.IBinder;
import android.os.RemoteException;
@@ -874,16 +873,16 @@ class RecentTasks {
     * @return the list of recent tasks for presentation.
     */
    ParceledListSlice<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags,
            boolean getTasksAllowed, boolean getDetailedTasks, int userId, int callingUid) {
            boolean getTasksAllowed, int userId, int callingUid) {
        return new ParceledListSlice<>(getRecentTasksImpl(maxNum, flags, getTasksAllowed,
                getDetailedTasks, userId, callingUid));
                userId, callingUid));
    }

    /**
     * @return the list of recent tasks for presentation.
     */
    private ArrayList<ActivityManager.RecentTaskInfo> getRecentTasksImpl(int maxNum, int flags,
            boolean getTasksAllowed, boolean getDetailedTasks, int userId, int callingUid) {
            boolean getTasksAllowed, int userId, int callingUid) {
        final boolean withExcluded = (flags & RECENT_WITH_EXCLUDED) != 0;

        if (!isUserRunning(userId, FLAG_AND_UNLOCKED)) {
@@ -961,12 +960,7 @@ class RecentTasks {
                continue;
            }

            final ActivityManager.RecentTaskInfo rti = createRecentTaskInfo(task);
            if (!getDetailedTasks) {
                rti.baseIntent.replaceExtras((Bundle) null);
            }

            res.add(rti);
            res.add(createRecentTaskInfo(task));
        }
        return res;
    }
@@ -1745,8 +1739,7 @@ class RecentTasks {
            // Reset the header flag for the next block
            printedHeader = false;
            ArrayList<ActivityManager.RecentTaskInfo> tasks = getRecentTasksImpl(Integer.MAX_VALUE,
                    0, true /* getTasksAllowed */, false /* getDetailedTasks */,
                    mService.getCurrentUserId(), SYSTEM_UID);
                    0, true /* getTasksAllowed */, mService.getCurrentUserId(), SYSTEM_UID);
            for (int i = 0; i < tasks.size(); i++) {
                final ActivityManager.RecentTaskInfo taskInfo = tasks.get(i);
                if (!printedHeader) {
+1 −4
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.util.ArraySet;
import com.android.internal.util.function.pooled.PooledConsumer;
import com.android.internal.util.function.pooled.PooledLambda;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
@@ -44,7 +43,6 @@ class RunningTasks {
            (o1, o2) -> Long.signum(o2.lastActiveTime - o1.lastActiveTime);

    private final TreeSet<Task> mTmpSortedSet = new TreeSet<>(LAST_ACTIVE_TIME_COMPARATOR);
    private final ArrayList<Task> mTmpStackTasks = new ArrayList<>();

    private int mCallingUid;
    private int mUserId;
@@ -132,8 +130,7 @@ class RunningTasks {

    /** Constructs a {@link RunningTaskInfo} from a given {@param task}. */
    private RunningTaskInfo createRunningTaskInfo(Task task) {
        final RunningTaskInfo rti = new RunningTaskInfo();
        task.fillTaskInfo(rti);
        final RunningTaskInfo rti = task.getTaskInfo();
        // Fill in some deprecated values
        rti.id = rti.taskId;
        return rti;
+3 −3
Original line number Diff line number Diff line
@@ -3281,8 +3281,8 @@ class Task extends WindowContainer<WindowContainer> {
    }

    /**
     * Fills in a {@link TaskInfo} with information from this task.
     * @param info the {@link TaskInfo} to fill in
     * Fills in a {@link TaskInfo} with information from this task. Note that the base intent in the
     * task info will not include any extras or clip data.
     */
    void fillTaskInfo(TaskInfo info) {
        getNumRunningActivities(mReuseActivitiesReport);
@@ -3294,7 +3294,7 @@ class Task extends WindowContainer<WindowContainer> {
        final Intent baseIntent = getBaseIntent();
        // Make a copy of base intent because this is like a snapshot info.
        // Besides, {@link RecentTasks#getRecentTasksImpl} may modify it.
        info.baseIntent = baseIntent == null ? new Intent() : new Intent(baseIntent);
        info.baseIntent = baseIntent == null ? new Intent() : baseIntent.cloneFilter();
        info.baseActivity = mReuseActivitiesReport.base != null
                ? mReuseActivitiesReport.base.intent.getComponent()
                : null;
+3 −8
Original line number Diff line number Diff line
@@ -253,8 +253,7 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub
                final int nextId = display.getNextStackId();
                TaskTile tile = new TaskTile(mService, nextId, windowingMode);
                display.addTile(tile);
                RunningTaskInfo out = new RunningTaskInfo();
                tile.fillTaskInfo(out);
                RunningTaskInfo out = tile.getTaskInfo();
                mLastSentTaskInfos.put(tile, out);
                return out;
            }
@@ -412,9 +411,7 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub
                                && !ArrayUtils.contains(activityTypes, as.getActivityType())) {
                            continue;
                        }
                        final RunningTaskInfo info = new RunningTaskInfo();
                        as.fillTaskInfo(info);
                        out.add(info);
                        out.add(as.getTaskInfo());
                    }
                }
                return out;
@@ -447,9 +444,7 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub
                            && !ArrayUtils.contains(activityTypes, task.getActivityType())) {
                        continue;
                    }
                    final RunningTaskInfo info = new RunningTaskInfo();
                    task.fillTaskInfo(info);
                    out.add(info);
                    out.add(task.getTaskInfo());
                }
                return out;
            }
Loading