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

Commit d7af66d0 authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "Move recents CommandQueue callbacks to recents"

parents f2f6961b 764da991
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -21,11 +21,10 @@ import android.view.Display;
import android.view.View;

public interface RecentsComponent {
    void showRecents(boolean triggeredFromAltTab, boolean fromHome);
    void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
    void showRecentApps(boolean triggeredFromAltTab, boolean fromHome);
    void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
    void toggleRecents(Display display);
    void preloadRecents();
    void cancelPreloadingRecents();
    void showNextAffiliatedTask();
    void showPrevAffiliatedTask();

+18 −4
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.recents;

import static com.android.systemui.statusbar.phone.StatusBar.SYSTEM_DIALOG_REASON_RECENT_APPS;

import android.app.ActivityManager;
import android.app.UiModeManager;
import android.content.ComponentName;
@@ -38,6 +40,7 @@ import android.provider.Settings;
import android.util.EventLog;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
import android.widget.Toast;

import com.android.internal.logging.MetricsLogger;
@@ -59,6 +62,7 @@ import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.tv.RecentsTvImpl;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.CommandQueue;

import java.util.ArrayList;
import java.util.HashSet;
@@ -70,7 +74,7 @@ import java.util.Set;
 * users.
 */
public class Recents extends SystemUI
        implements RecentsComponent {
        implements RecentsComponent, CommandQueue.Callbacks {

    private final static String TAG = "Recents";
    private final static boolean DEBUG = false;
@@ -201,6 +205,7 @@ public class Recents extends SystemUI
        sTaskLoader = new RecentsTaskLoader(mContext);
        sConfiguration = new RecentsConfiguration(mContext);
        mHandler = new Handler();
        getComponent(CommandQueue.class).addCallbacks(this);
        UiModeManager uiModeManager = (UiModeManager) mContext.
                getSystemService(Context.UI_MODE_SERVICE);
        if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
@@ -247,7 +252,7 @@ public class Recents extends SystemUI
     * Shows the Recents.
     */
    @Override
    public void showRecents(boolean triggeredFromAltTab, boolean fromHome) {
    public void showRecentApps(boolean triggeredFromAltTab, boolean fromHome) {
        // Ensure the device has been provisioned before allowing the user to interact with
        // recents
        if (!isUserSetup()) {
@@ -257,6 +262,10 @@ public class Recents extends SystemUI
        if (proxyToOverridePackage(ACTION_SHOW_RECENTS)) {
            return;
        }
        try {
            ActivityManager.getService().closeSystemDialogs(SYSTEM_DIALOG_REASON_RECENT_APPS);
        } catch (RemoteException e) {
        }

        int recentsGrowTarget = getComponent(Divider.class).getView().growsRecents();

@@ -287,7 +296,7 @@ public class Recents extends SystemUI
     * Hides the Recents.
     */
    @Override
    public void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
    public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
        // Ensure the device has been provisioned before allowing the user to interact with
        // recents
        if (!isUserSetup()) {
@@ -318,6 +327,11 @@ public class Recents extends SystemUI
        }
    }

    @Override
    public void toggleRecentApps() {
        toggleRecents(mContext.getSystemService(WindowManager.class).getDefaultDisplay());
    }

    /**
     * Toggles the Recents activity.
     */
@@ -387,7 +401,7 @@ public class Recents extends SystemUI
    }

    @Override
    public void cancelPreloadingRecents() {
    public void cancelPreloadRecentApps() {
        // Ensure the device has been provisioned before allowing the user to interact with
        // recents
        if (!isUserSetup()) {
+1 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ public class ShortcutKeyDispatcher extends SystemUI
                List<ActivityManager.RecentTaskInfo> taskList =
                        SystemServicesProxy.getInstance(mContext).getRecentTasks(1,
                                UserHandle.USER_CURRENT, false, new ArraySet<>());
                recents.showRecents(
                recents.showRecentApps(
                        false /* triggeredFromAltTab */,
                        false /* fromHome */);
                if (!taskList.isEmpty()) {
+1 −104
Original line number Diff line number Diff line
@@ -270,8 +270,6 @@ public class StatusBar extends SystemUI implements DemoMode,
    protected static final int MSG_TOGGLE_RECENTS_APPS = 1021;
    protected static final int MSG_PRELOAD_RECENT_APPS = 1022;
    protected static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 1023;
    protected static final int MSG_SHOW_NEXT_AFFILIATED_TASK = 1024;
    protected static final int MSG_SHOW_PREV_AFFILIATED_TASK = 1025;
    protected static final int MSG_TOGGLE_KEYBOARD_SHORTCUTS_MENU = 1026;
    protected static final int MSG_DISMISS_KEYBOARD_SHORTCUTS_MENU = 1027;

@@ -281,8 +279,8 @@ public class StatusBar extends SystemUI implements DemoMode,
    private static final String PERMISSION_SELF = "com.android.systemui.permission.SELF";

    // Should match the values in PhoneWindowManager
    public static final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
    public static final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";
    public static final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";

    private static final String BANNER_ACTION_CANCEL =
            "com.android.systemui.statusbar.banner_action_cancel";
@@ -2760,28 +2758,6 @@ public class StatusBar extends SystemUI implements DemoMode,
        @Override
        public void handleMessage(Message m) {
            switch (m.what) {
                // start old BaseStatusBar.H handling.
                case MSG_SHOW_RECENT_APPS:
                    showRecents(m.arg1 > 0, m.arg2 != 0);
                    break;
                case MSG_HIDE_RECENT_APPS:
                    hideRecents(m.arg1 > 0, m.arg2 > 0);
                    break;
                case MSG_TOGGLE_RECENTS_APPS:
                    toggleRecents();
                    break;
                case MSG_PRELOAD_RECENT_APPS:
                    preloadRecents();
                    break;
                case MSG_CANCEL_PRELOAD_RECENT_APPS:
                    cancelPreloadingRecents();
                    break;
                case MSG_SHOW_NEXT_AFFILIATED_TASK:
                    showRecentsNextAffiliatedTask();
                    break;
                case MSG_SHOW_PREV_AFFILIATED_TASK:
                    showRecentsPreviousAffiliatedTask();
                    break;
                case MSG_TOGGLE_KEYBOARD_SHORTCUTS_MENU:
                    toggleKeyboardShortcuts(m.arg1);
                    break;
@@ -6087,26 +6063,6 @@ public class StatusBar extends SystemUI implements DemoMode,
        }
    }

    @Override
    public void showRecentApps(boolean triggeredFromAltTab, boolean fromHome) {
        int msg = MSG_SHOW_RECENT_APPS;
        mHandler.removeMessages(msg);
        mHandler.obtainMessage(msg, triggeredFromAltTab ? 1 : 0, fromHome ? 1 : 0).sendToTarget();
    }

    @Override
    public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
        int msg = MSG_HIDE_RECENT_APPS;
        mHandler.removeMessages(msg);
        mHandler.obtainMessage(msg, triggeredFromAltTab ? 1 : 0,
                triggeredFromHomeKey ? 1 : 0).sendToTarget();
    }

    @Override
    public void toggleRecentApps() {
        toggleRecents();
    }

    @Override
    public void toggleSplitScreen() {
        toggleSplitScreenMode(-1 /* metricsDockAction */, -1 /* metricsUndockAction */);
@@ -6140,20 +6096,6 @@ public class StatusBar extends SystemUI implements DemoMode,
        mHandler.obtainMessage(msg, deviceId, 0).sendToTarget();
    }

    /** Jumps to the next affiliated task in the group. */
    public void showNextAffiliatedTask() {
        int msg = MSG_SHOW_NEXT_AFFILIATED_TASK;
        mHandler.removeMessages(msg);
        mHandler.sendEmptyMessage(msg);
    }

    /** Jumps to the previous affiliated task in the group. */
    public void showPreviousAffiliatedTask() {
        int msg = MSG_SHOW_PREV_AFFILIATED_TASK;
        mHandler.removeMessages(msg);
        mHandler.sendEmptyMessage(msg);
    }

    protected void sendCloseSystemWindows(String reason) {
        try {
            ActivityManager.getService().closeSystemDialogs(reason);
@@ -6161,33 +6103,6 @@ public class StatusBar extends SystemUI implements DemoMode,
        }
    }

    /** Proxy for RecentsComponent */

    protected void showRecents(boolean triggeredFromAltTab, boolean fromHome) {
        if (mRecents != null) {
            sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS);
            mRecents.showRecents(triggeredFromAltTab, fromHome);
        }
    }

    protected void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
        if (mRecents != null) {
            mRecents.hideRecents(triggeredFromAltTab, triggeredFromHomeKey);
        }
    }

    protected void toggleRecents() {
        if (mRecents != null) {
            mRecents.toggleRecents(mDisplay);
        }
    }

    protected void preloadRecents() {
        if (mRecents != null) {
            mRecents.preloadRecents();
        }
    }

    protected void toggleKeyboardShortcuts(int deviceId) {
        KeyboardShortcuts.toggle(mContext, deviceId);
    }
@@ -6196,24 +6111,6 @@ public class StatusBar extends SystemUI implements DemoMode,
        KeyboardShortcuts.dismiss();
    }

    protected void cancelPreloadingRecents() {
        if (mRecents != null) {
            mRecents.cancelPreloadingRecents();
        }
    }

    protected void showRecentsNextAffiliatedTask() {
        if (mRecents != null) {
            mRecents.showNextAffiliatedTask();
        }
    }

    protected void showRecentsPreviousAffiliatedTask() {
        if (mRecents != null) {
            mRecents.showPrevAffiliatedTask();
        }
    }

    /**
     * Save the current "public" (locked and secure) state of the lockscreen.
     */