Merge "[1/n] Aspect ratio settings app list refinement" into udc-qpr-dev am: a3108d5b14
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/24854937 Change-Id: I9ed3cf613ae4b20c1465403be0c989a00be425fe Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
committed by
Automerger Merge Worker
commit
2595f32076
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.applications.appcompat;
|
||||
|
||||
import static android.os.UserHandle.getUserHandleForUid;
|
||||
import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE;
|
||||
import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE;
|
||||
|
||||
@@ -26,8 +27,8 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.IPackageManager;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.util.ArrayMap;
|
||||
@@ -40,7 +41,6 @@ import com.android.settings.Utils;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -63,15 +63,12 @@ public class UserAspectRatioManager {
|
||||
private final Context mContext;
|
||||
private final IPackageManager mIPm;
|
||||
/** Apps that have launcher entry defined in manifest */
|
||||
private final List<ResolveInfo> mInfoHasLauncherEntryList;
|
||||
private final Map<Integer, String> mUserAspectRatioMap;
|
||||
private final Map<Integer, CharSequence> mUserAspectRatioA11yMap;
|
||||
|
||||
public UserAspectRatioManager(@NonNull Context context) {
|
||||
mContext = context;
|
||||
mIPm = AppGlobals.getPackageManager();
|
||||
mInfoHasLauncherEntryList = mContext.getPackageManager().queryIntentActivities(
|
||||
UserAspectRatioManager.LAUNCHER_ENTRY_INTENT, PackageManager.GET_META_DATA);
|
||||
mUserAspectRatioA11yMap = new ArrayMap<>();
|
||||
mUserAspectRatioMap = getUserMinAspectRatioMapping();
|
||||
}
|
||||
@@ -159,9 +156,7 @@ public class UserAspectRatioManager {
|
||||
Boolean appAllowsUserAspectRatioOverride = readComponentProperty(
|
||||
mContext.getPackageManager(), app.packageName,
|
||||
PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE);
|
||||
boolean hasLauncherEntry = mInfoHasLauncherEntryList.stream()
|
||||
.anyMatch(info -> info.activityInfo.packageName.equals(app.packageName));
|
||||
return !FALSE.equals(appAllowsUserAspectRatioOverride) && hasLauncherEntry;
|
||||
return !FALSE.equals(appAllowsUserAspectRatioOverride) && hasLauncherEntry(app);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,6 +173,15 @@ public class UserAspectRatioManager {
|
||||
DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_FULLSCREEN);
|
||||
}
|
||||
|
||||
LauncherApps getLauncherApps() {
|
||||
return mContext.getSystemService(LauncherApps.class);
|
||||
}
|
||||
|
||||
private boolean hasLauncherEntry(@NonNull ApplicationInfo app) {
|
||||
return !getLauncherApps().getActivityList(app.packageName, getUserHandleForUid(app.uid))
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
private static boolean getValueFromDeviceConfig(String name, boolean defaultValue) {
|
||||
return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_WINDOW_MANAGER, name, defaultValue);
|
||||
}
|
||||
@@ -267,9 +271,4 @@ public class UserAspectRatioManager {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void addInfoHasLauncherEntry(@NonNull ResolveInfo infoHasLauncherEntry) {
|
||||
mInfoHasLauncherEntryList.add(infoHasLauncherEntry);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user