Android 12系统源码_SystemUI(六)显示和隐藏最近任务
前言
最近任务作为移动
一、显示最近任务
1、调用CommandQueue的showRecentApps和hideRecentApps方法可以实现最近任务的显示和隐藏。
/frameworks//base/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
public class CommandQueue extends IStatusBar.Stub implementsCallbackController<Callbacks>,DisplayManager.DisplayListener {public interface Callbacks {default void showRecentApps(boolean triggeredFromAltTab) { }default void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { }default void toggleRecentApps() { }}
}
2、Recents和最近任务显示隐藏相关的方法如下所示:
/frameworks/base/packages/SystemUI/src/com/android/systemui/recents/Recents.java
public class Recents extends SystemUI implements CommandQueue.Callbacks {private final RecentsImplementation mImpl;private final CommandQueue mCommandQueue;public Recents(Context context, RecentsImplementation impl, CommandQueue commandQueue) {super(context);mImpl = impl;mCommandQueue = commandQueue;}@Overridepublic void start() {mCommandQueue.addCallback(this);mImpl.onStart(mContext);}//显示最近任务@Overridepublic void showRecentApps(boolean triggeredFromAltTab) {// Ensure the device has been provisioned before allowing the user to interact with// recentsif (!isUserSetup()) {return;}android.util.Log.d("SystemUI.Recents", "showRecentApps: triggeredFromAltTab = " + triggeredFromAltTab);mImpl.showRecentApps(triggeredFromAltTab);}//隐藏最近任务@Overridepublic void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {// Ensure the device has been provisioned before allowing the user to interact with// recentsif (!isUserSetup()) {return;}android.util.Log.d("SystemUI.Recents", "hideRecentApps triggeredFromAltTab = "+ triggeredFromAltTab + " triggeredFromHomeKey" + triggeredFromHomeKey);mImpl.hideRecentApps(triggeredFromAltTab, triggeredFromHomeKey);}//切换最近应用@Overridepublic void toggleRecentApps() {// Ensure the device has been provisioned before allowing the user to interact with// recentsif (!isUserSetup()) {return;}android.util.Log.d("SystemUI.Recents", "toggleRecentApps");mImpl.toggleRecentApps();}}