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

Commit 479212cf authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Jeff Sharkey
Browse files

Move getRecentTasks() to ParceledListSlice.

In extreme cases the list of recent tasks can grow beyond the size
of a single Binder transaction.  This change moves over to
ParceledListSlice which handles chunking any large results.

Bug: 29635557
Change-Id: Iaf1227234f5f8c9451f73a6a5c1dc89f2067f05f
parent ae5a14bc
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -1507,7 +1507,7 @@ public class ActivityManager {
            throws SecurityException {
            throws SecurityException {
        try {
        try {
            return ActivityManagerNative.getDefault().getRecentTasks(maxNum,
            return ActivityManagerNative.getDefault().getRecentTasks(maxNum,
                    flags, UserHandle.myUserId());
                    flags, UserHandle.myUserId()).getList();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
@@ -1532,7 +1532,7 @@ public class ActivityManager {
            throws SecurityException {
            throws SecurityException {
        try {
        try {
            return ActivityManagerNative.getDefault().getRecentTasks(maxNum,
            return ActivityManagerNative.getDefault().getRecentTasks(maxNum,
                    flags, userId);
                    flags, userId).getList();
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
+5 −5
Original line number Original line Diff line number Diff line
@@ -683,10 +683,10 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            int maxNum = data.readInt();
            int maxNum = data.readInt();
            int fl = data.readInt();
            int fl = data.readInt();
            int userId = data.readInt();
            int userId = data.readInt();
            List<ActivityManager.RecentTaskInfo> list = getRecentTasks(maxNum,
            ParceledListSlice<ActivityManager.RecentTaskInfo> list = getRecentTasks(maxNum,
                    fl, userId);
                    fl, userId);
            reply.writeNoException();
            reply.writeNoException();
            reply.writeTypedList(list);
            list.writeToParcel(reply, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
            return true;
            return true;
        }
        }


@@ -3740,7 +3740,7 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
        reply.recycle();
        return list;
        return list;
    }
    }
    public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
    public ParceledListSlice<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
            int flags, int userId) throws RemoteException {
            int flags, int userId) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        Parcel reply = Parcel.obtain();
@@ -3750,8 +3750,8 @@ class ActivityManagerProxy implements IActivityManager
        data.writeInt(userId);
        data.writeInt(userId);
        mRemote.transact(GET_RECENT_TASKS_TRANSACTION, data, reply, 0);
        mRemote.transact(GET_RECENT_TASKS_TRANSACTION, data, reply, 0);
        reply.readException();
        reply.readException();
        ArrayList<ActivityManager.RecentTaskInfo> list
        final ParceledListSlice<ActivityManager.RecentTaskInfo> list = ParceledListSlice.CREATOR
            = reply.createTypedArrayList(ActivityManager.RecentTaskInfo.CREATOR);
                .createFromParcel(reply);
        data.recycle();
        data.recycle();
        reply.recycle();
        reply.recycle();
        return list;
        return list;
+1 −1
Original line number Original line Diff line number Diff line
@@ -136,7 +136,7 @@ public interface IActivityManager extends IInterface {
            ActivityManager.TaskDescription description, Bitmap thumbnail) throws RemoteException;
            ActivityManager.TaskDescription description, Bitmap thumbnail) throws RemoteException;
    public Point getAppTaskThumbnailSize() throws RemoteException;
    public Point getAppTaskThumbnailSize() throws RemoteException;
    public List<RunningTaskInfo> getTasks(int maxNum, int flags) throws RemoteException;
    public List<RunningTaskInfo> getTasks(int maxNum, int flags) throws RemoteException;
    public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
    public ParceledListSlice<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
            int flags, int userId) throws RemoteException;
            int flags, int userId) throws RemoteException;
    public ActivityManager.TaskThumbnail getTaskThumbnail(int taskId) throws RemoteException;
    public ActivityManager.TaskThumbnail getTaskThumbnail(int taskId) throws RemoteException;
    public List<RunningServiceInfo> getServices(int maxNum, int flags) throws RemoteException;
    public List<RunningServiceInfo> getServices(int maxNum, int flags) throws RemoteException;
+1 −1
Original line number Original line Diff line number Diff line
@@ -512,7 +512,7 @@ public abstract class BaseStatusBar extends SystemUI implements
                    recentTask = ActivityManagerNative.getDefault().getRecentTasks(1,
                    recentTask = ActivityManagerNative.getDefault().getRecentTasks(1,
                            ActivityManager.RECENT_WITH_EXCLUDED
                            ActivityManager.RECENT_WITH_EXCLUDED
                            | ActivityManager.RECENT_INCLUDE_PROFILES,
                            | ActivityManager.RECENT_INCLUDE_PROFILES,
                            mCurrentUserId);
                            mCurrentUserId).getList();
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                    // Abandon hope activity manager not running.
                    // Abandon hope activity manager not running.
                }
                }
+4 −3
Original line number Original line Diff line number Diff line
@@ -9077,7 +9077,8 @@ public final class ActivityManagerService extends ActivityManagerNative
    }
    }
    @Override
    @Override
    public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags, int userId) {
    public ParceledListSlice<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags,
            int userId) {
        final int callingUid = Binder.getCallingUid();
        final int callingUid = Binder.getCallingUid();
        userId = mUserController.handleIncomingUser(Binder.getCallingPid(), callingUid, userId,
        userId = mUserController.handleIncomingUser(Binder.getCallingPid(), callingUid, userId,
                false, ALLOW_FULL_ONLY, "getRecentTasks", null);
                false, ALLOW_FULL_ONLY, "getRecentTasks", null);
@@ -9093,7 +9094,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            if (!isUserRunning(userId, ActivityManager.FLAG_AND_UNLOCKED)) {
            if (!isUserRunning(userId, ActivityManager.FLAG_AND_UNLOCKED)) {
                Slog.i(TAG, "user " + userId + " is still locked. Cannot load recents");
                Slog.i(TAG, "user " + userId + " is still locked. Cannot load recents");
                return Collections.emptyList();
                return ParceledListSlice.emptyList();
            }
            }
            mRecentTasks.loadUserRecentsLocked(userId);
            mRecentTasks.loadUserRecentsLocked(userId);
@@ -9192,7 +9193,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                    maxNum--;
                    maxNum--;
                }
                }
            }
            }
            return res;
            return new ParceledListSlice<>(res);
        }
        }
    }
    }
Loading