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

Commit e4a0c572 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Allow stacks to hold tasks on various sizes.

Tasks are now resizeable just like stacks. Adjusting the size
of a stack will also adjust the size of all it's containing
tasks. This model allows us to be more flexible
in using stacks as workspaces (like you would have in a
desktop environment) and tasks as the resizeable windows
within the workspace.

Also added "adb shell dumpsys window visible-apps" for
getting the list of visible app windows.

Bug: 22068114
Bug: 19182363

Change-Id: I5bf77063252a5abae4e327f6fc42e607091749f9
parent 905d51a2
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -1789,6 +1789,7 @@ public class ActivityManager {
        public Rect bounds = new Rect();
        public int[] taskIds;
        public String[] taskNames;
        public Rect[] taskBounds;
        public int displayId;

        @Override
@@ -1805,6 +1806,14 @@ public class ActivityManager {
            dest.writeInt(bounds.bottom);
            dest.writeIntArray(taskIds);
            dest.writeStringArray(taskNames);
            final int boundsCount = taskBounds == null ? 0 : taskBounds.length;
            dest.writeInt(boundsCount);
            for (int i = 0; i < boundsCount; i++) {
                dest.writeInt(taskBounds[i].left);
                dest.writeInt(taskBounds[i].top);
                dest.writeInt(taskBounds[i].right);
                dest.writeInt(taskBounds[i].bottom);
            }
            dest.writeInt(displayId);
        }

@@ -1814,6 +1823,17 @@ public class ActivityManager {
                    source.readInt(), source.readInt(), source.readInt(), source.readInt());
            taskIds = source.createIntArray();
            taskNames = source.createStringArray();
            final int boundsCount = source.readInt();
            if (boundsCount > 0) {
                taskBounds = new Rect[boundsCount];
                for (int i = 0; i < boundsCount; i++) {
                    taskBounds[i] = new Rect();
                    taskBounds[i].set(
                            source.readInt(), source.readInt(), source.readInt(), source.readInt());
                }
            } else {
                taskBounds = null;
            }
            displayId = source.readInt();
        }

@@ -1844,7 +1864,11 @@ public class ActivityManager {
            prefix = prefix + "  ";
            for (int i = 0; i < taskIds.length; ++i) {
                sb.append(prefix); sb.append("taskId="); sb.append(taskIds[i]);
                        sb.append(": "); sb.append(taskNames[i]); sb.append("\n");
                        sb.append(": "); sb.append(taskNames[i]);
                        if (taskBounds != null) {
                            sb.append(" bounds="); sb.append(taskBounds[i].toShortString());
                        }
                        sb.append("\n");
            }
            return sb.toString();
        }
+44 −0
Original line number Diff line number Diff line
@@ -799,6 +799,14 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case SET_FOCUSED_TASK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int taskId = data.readInt();
            setFocusedStack(taskId);
            reply.writeNoException();
            return true;
        }

        case REGISTER_TASK_STACK_LISTENER_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
@@ -2429,6 +2437,15 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case GET_TASK_BOUNDS_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int taskId = data.readInt();
            Rect r = getTaskBounds(taskId);
            reply.writeNoException();
            r.writeToParcel(reply, 0);
            return true;
        }

        case GET_TASK_DESCRIPTION_ICON_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            String filename = data.readString();
@@ -3520,6 +3537,18 @@ class ActivityManagerProxy implements IActivityManager
        return focusedStackId;
    }
    @Override
    public void setFocusedTask(int taskId) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(taskId);
        mRemote.transact(SET_FOCUSED_TASK_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }
    @Override
    public void registerTaskStackListener(ITaskStackListener listener) throws RemoteException
    {
        Parcel data = Parcel.obtain();
@@ -5789,6 +5818,21 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }

    @Override
    public Rect getTaskBounds(int taskId) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(taskId);
        mRemote.transact(GET_TASK_BOUNDS_TRANSACTION, data, reply, 0);
        reply.readException();
        Rect rect = Rect.CREATOR.createFromParcel(reply);
        data.recycle();
        reply.recycle();
        return rect;
    }

    @Override
    public Bitmap getTaskDescriptionIcon(String filename) throws RemoteException {
        Parcel data = Parcel.obtain();
+4 −2
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ public interface IActivityManager extends IInterface {
    public boolean isInHomeStack(int taskId) throws RemoteException;
    public void setFocusedStack(int stackId) throws RemoteException;
    public int getFocusedStackId() throws RemoteException;
    public void setFocusedTask(int taskId) throws RemoteException;
    public void registerTaskStackListener(ITaskStackListener listener) throws RemoteException;
    public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException;
    public ContentProviderHolder getContentProvider(IApplicationThread caller,
@@ -486,6 +487,7 @@ public interface IActivityManager extends IInterface {
            throws RemoteException;
    public void setTaskResizeable(int taskId, boolean resizeable) throws RemoteException;
    public void resizeTask(int taskId, Rect bounds) throws RemoteException;
    public Rect getTaskBounds(int taskId) throws RemoteException;
    public Bitmap getTaskDescriptionIcon(String filename) throws RemoteException;

    public void startInPlaceAnimationOnFrontMostApplication(ActivityOptions opts)
@@ -752,7 +754,7 @@ public interface IActivityManager extends IInterface {
    int GET_PACKAGE_ASK_SCREEN_COMPAT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+127;
    int SET_PACKAGE_ASK_SCREEN_COMPAT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+128;
    int SWITCH_USER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+129;
    int ___AVAILABLE_1___ = IBinder.FIRST_CALL_TRANSACTION+130;
    int SET_FOCUSED_TASK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+130;
    int REMOVE_TASK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+131;
    int REGISTER_PROCESS_OBSERVER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+132;
    int UNREGISTER_PROCESS_OBSERVER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+133;
@@ -804,7 +806,7 @@ public interface IActivityManager extends IInterface {
    int RELEASE_PERSISTABLE_URI_PERMISSION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+180;
    int GET_PERSISTED_URI_PERMISSIONS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+181;
    int APP_NOT_RESPONDING_VIA_PROVIDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+182;
    // Available
    int GET_TASK_BOUNDS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+183;
    int GET_ACTIVITY_DISPLAY_ID_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+184;
    int DELETE_ACTIVITY_CONTAINER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+185;
    int SET_PROCESS_MEMORY_TRIM_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+186;
+14 −24
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ import com.android.systemui.R;
import com.android.systemui.recents.Constants;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsAppWidgetHost;
import com.android.systemui.recents.RecentsConfiguration;

import java.io.IOException;
import java.util.ArrayList;
@@ -255,42 +256,31 @@ public class SystemServicesProxy {
        return false;
    }

    /** Get the bounds of a stack / task. */
    public Rect getTaskBounds(int stackId) {
        ActivityManager.StackInfo info = getAllStackInfos().get(stackId);
        if (info != null)
          return info.bounds;
        return new Rect();
    }

    /** Resize a given task. */
    public void resizeTask(int taskId, Rect bounds) {
        if (mIam == null) return;
    /** Get the bounds of a task. */
    public Rect getTaskBounds(int taskId) {
        if (mIam == null) return null;

        try {
            mIam.resizeTask(taskId, bounds);
            return mIam.getTaskBounds(taskId);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        return null;
    }

    /** Returns the stack info for all stacks. */
    public SparseArray<ActivityManager.StackInfo> getAllStackInfos() {
        if (mIam == null) return new SparseArray<ActivityManager.StackInfo>();
    /** Resize a given task. */
    public void resizeTask(int taskId, Rect bounds) {
        if (mIam == null) return;

        try {
            SparseArray<ActivityManager.StackInfo> stacks =
                    new SparseArray<ActivityManager.StackInfo>();
            List<ActivityManager.StackInfo> infos = mIam.getAllStackInfos();
            int stackCount = infos.size();
            for (int i = 0; i < stackCount; i++) {
                ActivityManager.StackInfo info = infos.get(i);
                stacks.put(info.stackId, info);
            }
            return stacks;
            if (RecentsConfiguration.getInstance().multiStackEnabled) {
                // In debug mode, we force all task to be resizeable regardless of the
                // current app configuration.
                mIam.setTaskResizeable(taskId, true);
            }
            mIam.resizeTask(taskId, bounds);
        } catch (RemoteException e) {
            e.printStackTrace();
            return new SparseArray<ActivityManager.StackInfo>();
        }
    }

+1 −7
Original line number Diff line number Diff line
@@ -172,19 +172,13 @@ public class RecentsTaskLoadPlan {
        }

        // Initialize the stacks
        SparseArray<ActivityManager.StackInfo> stackInfos = mSystemServicesProxy.getAllStackInfos();
        mStacks.clear();
        int stackCount = stacksTasks.size();
        for (int i = 0; i < stackCount; i++) {
            int stackId = stacksTasks.keyAt(i);
            ActivityManager.StackInfo info = stackInfos.get(stackId);
            ArrayList<Task> stackTasks = stacksTasks.valueAt(i);
            TaskStack stack = new TaskStack(stackId);
            if (Constants.DebugFlags.App.EnableMultiStackToSingleStack) {
            stack.setBounds(displayBounds, displayBounds);
            } else {
                stack.setBounds(info.bounds, displayBounds);
            }
            stack.setTasks(stackTasks);
            stack.createAffiliatedGroupings(mConfig);
            mStacks.put(stackId, stack);
Loading