Move multi-instance suppport checking to ApiWrapper

- It's only used for App Pairs & Taskbar (both limited to quickstep
  launcher, and we need to use hidden api to query the multi-instance
  support per-activity.  This is necessary as there can be apps
  installed for a profile, but not the primary user.

Bug: 391611065
Flag: EXEMPT bugfix
Test: atest WMShellUnitTests
Test: Install a multi-instance app only for the non-primary user,
      ensure that we can see the multi-instance UI for these apps

Change-Id: I9d38f32aa38b27b2bffaa744c3f578423f7c7d86
This commit is contained in:
Winson Chung
2025-01-23 00:07:12 +00:00
parent c36a10604c
commit 4443ff10f6
4 changed files with 33 additions and 44 deletions
+24 -2
View File
@@ -59,10 +59,13 @@ public class ApiWrapper {
LauncherAppComponent::getApiWrapper);
protected final Context mContext;
private final String[] mLegacyMultiInstanceSupportedApps;
@Inject
public ApiWrapper(@ApplicationContext Context context) {
mContext = context;
mLegacyMultiInstanceSupportedApps = context.getResources().getStringArray(
com.android.launcher3.R.array.config_appsSupportMultiInstancesSplit);
}
/**
@@ -157,11 +160,30 @@ public class ApiWrapper {
/**
* Checks if an activity is flagged as non-resizeable.
*/
public boolean isNonResizeableActivity(LauncherActivityInfo lai) {
// Overridden in quickstep
public boolean isNonResizeableActivity(@NonNull LauncherActivityInfo lai) {
// Overridden in Quickstep
return false;
}
/**
* Checks if an activity supports multi-instance.
*/
public boolean supportsMultiInstance(@NonNull LauncherActivityInfo lai) {
// Check app multi-instance properties after V
if (!Utilities.ATLEAST_V) {
return false;
}
// Check the legacy hardcoded allowlist first
for (String pkg : mLegacyMultiInstanceSupportedApps) {
if (pkg.equals(lai.getComponentName().getPackageName())) {
return true;
}
}
// Overridden in Quickstep
return false;
}
/**
* Starts an Activity which can be used to set this Launcher as the HOME app, via a consent
* screen. In case the consent screen cannot be shown, or the user does not set current Launcher