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

Commit 29379ec8 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

TRON refinements for multi-window

Bug: 26013430
Change-Id: I89b139b4ca3e7b6a06d8b5b351d67ffac240f73f
parent 656f6506
Loading
Loading
Loading
Loading
+17 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemApi;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Matrix;
@@ -1305,6 +1306,12 @@ public class ActivityManager {
         */
         */
        public boolean isDockable;
        public boolean isDockable;


        /**
         * The resize mode of the task. See {@link ActivityInfo#resizeMode}.
         * @hide
         */
        public int resizeMode;

        public RecentTaskInfo() {
        public RecentTaskInfo() {
        }
        }


@@ -1349,6 +1356,7 @@ public class ActivityManager {
                dest.writeInt(0);
                dest.writeInt(0);
            }
            }
            dest.writeInt(isDockable ? 1 : 0);
            dest.writeInt(isDockable ? 1 : 0);
            dest.writeInt(resizeMode);
        }
        }


        public void readFromParcel(Parcel source) {
        public void readFromParcel(Parcel source) {
@@ -1372,6 +1380,7 @@ public class ActivityManager {
            bounds = source.readInt() > 0 ?
            bounds = source.readInt() > 0 ?
                    Rect.CREATOR.createFromParcel(source) : null;
                    Rect.CREATOR.createFromParcel(source) : null;
            isDockable = source.readInt() == 1;
            isDockable = source.readInt() == 1;
            resizeMode = source.readInt();
        }
        }


        public static final Creator<RecentTaskInfo> CREATOR
        public static final Creator<RecentTaskInfo> CREATOR
@@ -1560,6 +1569,12 @@ public class ActivityManager {
         */
         */
        public boolean isDockable;
        public boolean isDockable;


        /**
         * The resize mode of the task. See {@link ActivityInfo#resizeMode}.
         * @hide
         */
        public int resizeMode;

        public RunningTaskInfo() {
        public RunningTaskInfo() {
        }
        }


@@ -1583,6 +1598,7 @@ public class ActivityManager {
            dest.writeInt(numActivities);
            dest.writeInt(numActivities);
            dest.writeInt(numRunning);
            dest.writeInt(numRunning);
            dest.writeInt(isDockable ? 1 : 0);
            dest.writeInt(isDockable ? 1 : 0);
            dest.writeInt(resizeMode);
        }
        }


        public void readFromParcel(Parcel source) {
        public void readFromParcel(Parcel source) {
@@ -1599,6 +1615,7 @@ public class ActivityManager {
            numActivities = source.readInt();
            numActivities = source.readInt();
            numRunning = source.readInt();
            numRunning = source.readInt();
            isDockable = source.readInt() != 0;
            isDockable = source.readInt() != 0;
            resizeMode = source.readInt();
        }
        }


        public static final Creator<RunningTaskInfo> CREATOR = new Creator<RunningTaskInfo>() {
        public static final Creator<RunningTaskInfo> CREATOR = new Creator<RunningTaskInfo>() {
+2 −1
Original line number Original line Diff line number Diff line
@@ -32,7 +32,8 @@ public interface RecentsComponent {
    /**
    /**
     * Docks the top-most task and opens recents.
     * Docks the top-most task and opens recents.
     */
     */
    boolean dockTopTask(int dragMode, int stackCreateMode, Rect initialBounds);
    boolean dockTopTask(int dragMode, int stackCreateMode, Rect initialBounds,
            int metricsDockAction);


    /**
    /**
     * Called during a drag-from-navbar-in gesture.
     * Called during a drag-from-navbar-in gesture.
+35 −1
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.ServiceConnection;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Rect;
@@ -36,10 +37,13 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings;
import android.util.EventLog;
import android.util.EventLog;
import android.util.Log;
import android.util.Log;
import android.util.MutableBoolean;
import android.view.Display;
import android.view.Display;
import android.view.View;
import android.view.View;
import android.widget.Toast;
import android.widget.Toast;


import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.systemui.EventLogConstants;
import com.android.systemui.EventLogConstants;
import com.android.systemui.EventLogTags;
import com.android.systemui.EventLogTags;
import com.android.systemui.R;
import com.android.systemui.R;
@@ -78,6 +82,10 @@ public class Recents extends SystemUI
    private final static String ACTION_HIDE_RECENTS = "com.android.systemui.recents.ACTION_HIDE";
    private final static String ACTION_HIDE_RECENTS = "com.android.systemui.recents.ACTION_HIDE";
    private final static String ACTION_TOGGLE_RECENTS = "com.android.systemui.recents.ACTION_TOGGLE";
    private final static String ACTION_TOGGLE_RECENTS = "com.android.systemui.recents.ACTION_TOGGLE";


    private static final String COUNTER_WINDOW_SUPPORTED = "window_enter_supported";
    private static final String COUNTER_WINDOW_UNSUPPORTED = "window_enter_unsupported";
    private static final String COUNTER_WINDOW_INCOMPATIBLE = "window_enter_incompatible";

    private static SystemServicesProxy sSystemServicesProxy;
    private static SystemServicesProxy sSystemServicesProxy;
    private static RecentsDebugFlags sDebugFlags;
    private static RecentsDebugFlags sDebugFlags;
    private static RecentsTaskLoader sTaskLoader;
    private static RecentsTaskLoader sTaskLoader;
@@ -393,7 +401,8 @@ public class Recents extends SystemUI
    }
    }


    @Override
    @Override
    public boolean dockTopTask(int dragMode, int stackCreateMode, Rect initialBounds) {
    public boolean dockTopTask(int dragMode, int stackCreateMode, Rect initialBounds,
            int metricsDockAction) {
        // Ensure the device has been provisioned before allowing the user to interact with
        // Ensure the device has been provisioned before allowing the user to interact with
        // recents
        // recents
        if (!isUserSetup()) {
        if (!isUserSetup()) {
@@ -413,7 +422,12 @@ public class Recents extends SystemUI
        boolean screenPinningActive = ssp.isScreenPinningActive();
        boolean screenPinningActive = ssp.isScreenPinningActive();
        boolean isTopTaskHome = topTask != null && SystemServicesProxy.isHomeStack(topTask.stackId);
        boolean isTopTaskHome = topTask != null && SystemServicesProxy.isHomeStack(topTask.stackId);
        if (topTask != null && !isTopTaskHome && !screenPinningActive) {
        if (topTask != null && !isTopTaskHome && !screenPinningActive) {
            logDockAttempt(mContext, topTask.topActivity, topTask.resizeMode);
            if (topTask.isDockable) {
            if (topTask.isDockable) {
                if (metricsDockAction != -1) {
                    MetricsLogger.action(mContext, metricsDockAction,
                            topTask.topActivity.flattenToShortString());
                }
                if (sSystemServicesProxy.isSystemUser(currentUser)) {
                if (sSystemServicesProxy.isSystemUser(currentUser)) {
                    mImpl.dockTopTask(topTask.id, dragMode, stackCreateMode, initialBounds);
                    mImpl.dockTopTask(topTask.id, dragMode, stackCreateMode, initialBounds);
                } else {
                } else {
@@ -444,6 +458,26 @@ public class Recents extends SystemUI
        }
        }
    }
    }


    public static void logDockAttempt(Context ctx, ComponentName activity, int resizeMode) {
        if (resizeMode == ActivityInfo.RESIZE_MODE_UNRESIZEABLE) {
            MetricsLogger.action(ctx, MetricsEvent.ACTION_WINDOW_DOCK_UNRESIZABLE,
                    activity.flattenToShortString());
        }
        MetricsLogger.count(ctx, getMetricsCounterForResizeMode(resizeMode), 1);
    }

    private static String getMetricsCounterForResizeMode(int resizeMode) {
        switch (resizeMode) {
            case ActivityInfo.RESIZE_MODE_FORCE_RESIZEABLE:
                return COUNTER_WINDOW_UNSUPPORTED;
            case ActivityInfo.RESIZE_MODE_RESIZEABLE:
            case ActivityInfo.RESIZE_MODE_RESIZEABLE_AND_PIPABLE:
                return COUNTER_WINDOW_SUPPORTED;
            default:
                return COUNTER_WINDOW_INCOMPATIBLE;
        }
    }

    @Override
    @Override
    public void onDraggingInRecents(float distanceFromTop) {
    public void onDraggingInRecents(float distanceFromTop) {
        if (sSystemServicesProxy.isSystemUser(mDraggingInRecentsCurrentUser)) {
        if (sSystemServicesProxy.isSystemUser(mDraggingInRecentsCurrentUser)) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -206,7 +206,7 @@ public class RecentsTaskLoadPlan {
            Task task = new Task(taskKey, t.affiliatedTaskId, t.affiliatedTaskColor, icon,
            Task task = new Task(taskKey, t.affiliatedTaskId, t.affiliatedTaskColor, icon,
                    thumbnail, title, titleDescription, dismissDescription, appInfoDescription,
                    thumbnail, title, titleDescription, dismissDescription, appInfoDescription,
                    activityColor, backgroundColor, isLaunchTarget, isStackTask, isSystemApp,
                    activityColor, backgroundColor, isLaunchTarget, isStackTask, isSystemApp,
                    t.isDockable, t.bounds, t.taskDescription);
                    t.isDockable, t.bounds, t.taskDescription, t.resizeMode, t.topActivity);


            allTasks.add(task);
            allTasks.add(task);
            affiliatedTaskCounts.put(taskKey.id, affiliatedTaskCounts.get(taskKey.id, 0) + 1);
            affiliatedTaskCounts.put(taskKey.id, affiliatedTaskCounts.get(taskKey.id, 0) + 1);
+16 −1
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.recents.model;
import android.app.ActivityManager;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.ComponentName;
import android.content.Intent;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.Rect;
@@ -174,6 +175,15 @@ public class Task {
    @ViewDebug.ExportedProperty(category="recents")
    @ViewDebug.ExportedProperty(category="recents")
    public boolean isDockable;
    public boolean isDockable;


    /**
     * Resize mode. See {@link ActivityInfo#resizeMode}.
     */
    @ViewDebug.ExportedProperty(category="recents")
    public int resizeMode;

    @ViewDebug.ExportedProperty(category="recents")
    public ComponentName topActivity;

    private ArrayList<TaskCallbacks> mCallbacks = new ArrayList<>();
    private ArrayList<TaskCallbacks> mCallbacks = new ArrayList<>();


    public Task() {
    public Task() {
@@ -184,7 +194,8 @@ public class Task {
                Bitmap thumbnail, String title, String titleDescription, String dismissDescription,
                Bitmap thumbnail, String title, String titleDescription, String dismissDescription,
                String appInfoDescription, int colorPrimary, int colorBackground,
                String appInfoDescription, int colorPrimary, int colorBackground,
                boolean isLaunchTarget, boolean isStackTask, boolean isSystemApp,
                boolean isLaunchTarget, boolean isStackTask, boolean isSystemApp,
                boolean isDockable, Rect bounds, ActivityManager.TaskDescription taskDescription) {
                boolean isDockable, Rect bounds, ActivityManager.TaskDescription taskDescription,
                int resizeMode, ComponentName topActivity) {
        boolean isInAffiliationGroup = (affiliationTaskId != key.id);
        boolean isInAffiliationGroup = (affiliationTaskId != key.id);
        boolean hasAffiliationGroupColor = isInAffiliationGroup && (affiliationColor != 0);
        boolean hasAffiliationGroupColor = isInAffiliationGroup && (affiliationColor != 0);
        this.key = key;
        this.key = key;
@@ -206,6 +217,8 @@ public class Task {
        this.isStackTask = isStackTask;
        this.isStackTask = isStackTask;
        this.isSystemApp = isSystemApp;
        this.isSystemApp = isSystemApp;
        this.isDockable = isDockable;
        this.isDockable = isDockable;
        this.resizeMode = resizeMode;
        this.topActivity = topActivity;
    }
    }


    /**
    /**
@@ -231,6 +244,8 @@ public class Task {
        this.isStackTask = o.isStackTask;
        this.isStackTask = o.isStackTask;
        this.isSystemApp = o.isSystemApp;
        this.isSystemApp = o.isSystemApp;
        this.isDockable = o.isDockable;
        this.isDockable = o.isDockable;
        this.resizeMode = o.resizeMode;
        this.topActivity = o.topActivity;
    }
    }


    /**
    /**
Loading