Loading libs/WindowManager/Shell/src/com/android/wm/shell/common/ComponentUtils.kt +7 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.common import android.app.PendingIntent import android.app.TaskInfo import android.content.ComponentName import android.content.Intent import com.android.wm.shell.ShellTaskOrganizer Loading @@ -34,7 +35,11 @@ object ComponentUtils { /** Retrieves the package name from a [taskId]. */ @JvmStatic fun getPackageName(taskId: Int, taskOrganizer: ShellTaskOrganizer): String? { val taskInfo = taskOrganizer.getRunningTaskInfo(taskId) return getPackageName(taskInfo?.baseIntent) val taskInfo = taskOrganizer.getRunningTaskInfo(taskId) ?: return null return getPackageName(taskInfo) } /** Retrieves the package name from a [TaskInfo]. */ @JvmStatic fun getPackageName(taskInfo: TaskInfo): String? = getPackageName(taskInfo.baseIntent) } libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +13 −5 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ import com.android.wm.shell.RootTaskDisplayAreaOrganizer; import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.apptoweb.AppToWebGenericLinksParser; import com.android.wm.shell.apptoweb.AssistContentRequester; import com.android.wm.shell.common.ComponentUtils; import com.android.wm.shell.common.DisplayChangeController; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.DisplayInsetsController; Loading Loading @@ -1926,14 +1927,21 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, // instances, then refer to the list's size and reuse the list for Manage Windows menu. final IActivityTaskManager activityTaskManager = ActivityTaskManager.getService(); try { // TODO(b/389184897): Move the following into a helper method of // RecentsTasksController, similar to #findTaskInBackground. final String packageName = ComponentUtils.getPackageName(info); return activityTaskManager.getRecentTasks(Integer.MAX_VALUE, ActivityManager.RECENT_WITH_EXCLUDED, info.userId).getList().stream().filter( recentTaskInfo -> (recentTaskInfo.taskId != info.taskId && recentTaskInfo.baseActivity != null && recentTaskInfo.baseActivity.getPackageName() .equals(info.baseActivity.getPackageName()) ) recentTaskInfo -> { if (recentTaskInfo.taskId == info.taskId) { return false; } final String recentTaskPackageName = ComponentUtils.getPackageName(recentTaskInfo); return packageName != null && packageName.equals(recentTaskPackageName); } ).toList().size(); } catch (RemoteException e) { throw new RuntimeException(e); Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/common/ComponentUtils.kt +7 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.common import android.app.PendingIntent import android.app.TaskInfo import android.content.ComponentName import android.content.Intent import com.android.wm.shell.ShellTaskOrganizer Loading @@ -34,7 +35,11 @@ object ComponentUtils { /** Retrieves the package name from a [taskId]. */ @JvmStatic fun getPackageName(taskId: Int, taskOrganizer: ShellTaskOrganizer): String? { val taskInfo = taskOrganizer.getRunningTaskInfo(taskId) return getPackageName(taskInfo?.baseIntent) val taskInfo = taskOrganizer.getRunningTaskInfo(taskId) ?: return null return getPackageName(taskInfo) } /** Retrieves the package name from a [TaskInfo]. */ @JvmStatic fun getPackageName(taskInfo: TaskInfo): String? = getPackageName(taskInfo.baseIntent) }
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +13 −5 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ import com.android.wm.shell.RootTaskDisplayAreaOrganizer; import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.apptoweb.AppToWebGenericLinksParser; import com.android.wm.shell.apptoweb.AssistContentRequester; import com.android.wm.shell.common.ComponentUtils; import com.android.wm.shell.common.DisplayChangeController; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.DisplayInsetsController; Loading Loading @@ -1926,14 +1927,21 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, // instances, then refer to the list's size and reuse the list for Manage Windows menu. final IActivityTaskManager activityTaskManager = ActivityTaskManager.getService(); try { // TODO(b/389184897): Move the following into a helper method of // RecentsTasksController, similar to #findTaskInBackground. final String packageName = ComponentUtils.getPackageName(info); return activityTaskManager.getRecentTasks(Integer.MAX_VALUE, ActivityManager.RECENT_WITH_EXCLUDED, info.userId).getList().stream().filter( recentTaskInfo -> (recentTaskInfo.taskId != info.taskId && recentTaskInfo.baseActivity != null && recentTaskInfo.baseActivity.getPackageName() .equals(info.baseActivity.getPackageName()) ) recentTaskInfo -> { if (recentTaskInfo.taskId == info.taskId) { return false; } final String recentTaskPackageName = ComponentUtils.getPackageName(recentTaskInfo); return packageName != null && packageName.equals(recentTaskPackageName); } ).toList().size(); } catch (RemoteException e) { throw new RuntimeException(e); Loading