UserAspectRatioManager call AtivityRecord#canBeUniversalResizeable
instead of duplicating the method locally. Fix: 374903057 Flag: EXEMPT same behavior Test: UserAspectRatioManagerTest Change-Id: I7b362bf9aaf06e1af0288e0ce8c43e7c3b3472e3
This commit is contained in:
@@ -33,10 +33,10 @@ import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO
|
||||
|
||||
import static java.lang.Boolean.FALSE;
|
||||
|
||||
import android.app.ActivityTaskManager;
|
||||
import android.app.AppGlobals;
|
||||
import android.app.compat.CompatChanges;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.IPackageManager;
|
||||
import android.content.pm.LauncherApps;
|
||||
@@ -53,7 +53,6 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.window.flags.Flags;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
@@ -80,13 +79,15 @@ public class UserAspectRatioManager {
|
||||
private final Map<Integer, String> mUserAspectRatioMap;
|
||||
private final Map<Integer, CharSequence> mUserAspectRatioA11yMap;
|
||||
private final SparseIntArray mUserAspectRatioOrder;
|
||||
private final ActivityTaskManager mActivityTaskManager;
|
||||
|
||||
public UserAspectRatioManager(@NonNull Context context) {
|
||||
this(context, AppGlobals.getPackageManager());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
UserAspectRatioManager(@NonNull Context context, @NonNull IPackageManager pm) {
|
||||
UserAspectRatioManager(@NonNull Context context, @NonNull IPackageManager pm,
|
||||
@NonNull ActivityTaskManager activityTaskManager) {
|
||||
mContext = context;
|
||||
mIPm = pm;
|
||||
mUserAspectRatioA11yMap = new ArrayMap<>();
|
||||
@@ -94,8 +95,13 @@ public class UserAspectRatioManager {
|
||||
mUserAspectRatioMap = getUserMinAspectRatioMapping();
|
||||
mIgnoreActivityOrientationRequest = getValueFromDeviceConfig(
|
||||
"ignore_activity_orientation_request", false);
|
||||
mActivityTaskManager = activityTaskManager;
|
||||
|
||||
}
|
||||
|
||||
UserAspectRatioManager(@NonNull Context context, @NonNull IPackageManager pm) {
|
||||
this(context, pm, ActivityTaskManager.getInstance());
|
||||
}
|
||||
/**
|
||||
* Whether user aspect ratio settings is enabled for device.
|
||||
*/
|
||||
@@ -117,24 +123,6 @@ public class UserAspectRatioManager {
|
||||
? aspectRatio : USER_MIN_ASPECT_RATIO_UNSET;
|
||||
}
|
||||
|
||||
// TODO b/374903057 reuse method from ActivityRecord
|
||||
boolean isUniversalResizeable(@NonNull String packageName, int userId) {
|
||||
try {
|
||||
final ApplicationInfo info = mIPm.getApplicationInfo(
|
||||
packageName, 0 /* flags */, userId);
|
||||
if (info == null || info.category == ApplicationInfo.CATEGORY_GAME) {
|
||||
return false;
|
||||
}
|
||||
final boolean compatEnabled = Flags.universalResizableByDefault()
|
||||
&& info.isChangeEnabled(ActivityInfo.UNIVERSAL_RESIZABLE_BY_DEFAULT);
|
||||
return compatEnabled || mIgnoreActivityOrientationRequest;
|
||||
} catch (RemoteException e) {
|
||||
Log.e("UserAspectRatioManager", "Could not access application info for "
|
||||
+ packageName + ":\n" + e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return corresponding string for {@link PackageManager.UserMinAspectRatio} value
|
||||
*/
|
||||
@@ -249,12 +237,20 @@ public class UserAspectRatioManager {
|
||||
* or app is universal resizeable, and app has not opted-out from the treatment
|
||||
*/
|
||||
boolean isOverrideToFullscreenEnabled(String pkgName, int userId) {
|
||||
Boolean appAllowsOrientationOverride = readComponentProperty(mContext.getPackageManager(),
|
||||
pkgName, PROPERTY_COMPAT_ALLOW_ORIENTATION_OVERRIDE);
|
||||
return hasAspectRatioOption(USER_MIN_ASPECT_RATIO_FULLSCREEN, pkgName)
|
||||
&& !FALSE.equals(appAllowsOrientationOverride)
|
||||
&& (isFullscreenCompatChangeEnabled(pkgName, userId)
|
||||
|| isUniversalResizeable(pkgName, userId));
|
||||
try {
|
||||
Boolean appAllowsOrientationOverride = readComponentProperty(
|
||||
mContext.getPackageManager(), pkgName,
|
||||
PROPERTY_COMPAT_ALLOW_ORIENTATION_OVERRIDE);
|
||||
final ApplicationInfo info = mIPm.getApplicationInfo(pkgName, 0 /* flags */, userId);
|
||||
return hasAspectRatioOption(USER_MIN_ASPECT_RATIO_FULLSCREEN, pkgName)
|
||||
&& !FALSE.equals(appAllowsOrientationOverride)
|
||||
&& (isFullscreenCompatChangeEnabled(pkgName, userId)
|
||||
|| (info != null && mActivityTaskManager.canBeUniversalResizeable(info)));
|
||||
} catch (RemoteException e) {
|
||||
Log.e("UserAspectRatioManager", "Could not access application info for "
|
||||
+ pkgName + ":\n" + e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isFullscreenCompatChangeEnabled(String pkgName, int userId) {
|
||||
|
Reference in New Issue
Block a user