Clean up app default flag
Flag: EXEMPT clean up flag Bug: 375291719 Test: atest UserAspectRatioManagerTest Change-Id: I00cd2677aaca14f01f1a04b736151c74b97e3179
This commit is contained in:
@@ -72,7 +72,6 @@ public class UserAspectRatioManager {
|
|||||||
"enable_app_compat_user_aspect_ratio_fullscreen";
|
"enable_app_compat_user_aspect_ratio_fullscreen";
|
||||||
private static final boolean DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_FULLSCREEN = true;
|
private static final boolean DEFAULT_VALUE_ENABLE_USER_ASPECT_RATIO_FULLSCREEN = true;
|
||||||
|
|
||||||
final boolean mIsUserMinAspectRatioAppDefaultFlagEnabled = Flags.userMinAspectRatioAppDefault();
|
|
||||||
private final boolean mIgnoreActivityOrientationRequest;
|
private final boolean mIgnoreActivityOrientationRequest;
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
@@ -252,8 +251,7 @@ public class UserAspectRatioManager {
|
|||||||
boolean isOverrideToFullscreenEnabled(String pkgName, int userId) {
|
boolean isOverrideToFullscreenEnabled(String pkgName, int userId) {
|
||||||
Boolean appAllowsOrientationOverride = readComponentProperty(mContext.getPackageManager(),
|
Boolean appAllowsOrientationOverride = readComponentProperty(mContext.getPackageManager(),
|
||||||
pkgName, PROPERTY_COMPAT_ALLOW_ORIENTATION_OVERRIDE);
|
pkgName, PROPERTY_COMPAT_ALLOW_ORIENTATION_OVERRIDE);
|
||||||
return mIsUserMinAspectRatioAppDefaultFlagEnabled
|
return hasAspectRatioOption(USER_MIN_ASPECT_RATIO_FULLSCREEN, pkgName)
|
||||||
&& hasAspectRatioOption(USER_MIN_ASPECT_RATIO_FULLSCREEN, pkgName)
|
|
||||||
&& !FALSE.equals(appAllowsOrientationOverride)
|
&& !FALSE.equals(appAllowsOrientationOverride)
|
||||||
&& (isFullscreenCompatChangeEnabled(pkgName, userId)
|
&& (isFullscreenCompatChangeEnabled(pkgName, userId)
|
||||||
|| isUniversalResizeable(pkgName, userId));
|
|| isUniversalResizeable(pkgName, userId));
|
||||||
@@ -326,7 +324,6 @@ public class UserAspectRatioManager {
|
|||||||
throw new RuntimeException("config_userAspectRatioOverrideValues options must have"
|
throw new RuntimeException("config_userAspectRatioOverrideValues options must have"
|
||||||
+ " USER_MIN_ASPECT_RATIO_UNSET value");
|
+ " USER_MIN_ASPECT_RATIO_UNSET value");
|
||||||
}
|
}
|
||||||
if (mIsUserMinAspectRatioAppDefaultFlagEnabled) {
|
|
||||||
userMinAspectRatioMap.put(USER_MIN_ASPECT_RATIO_APP_DEFAULT,
|
userMinAspectRatioMap.put(USER_MIN_ASPECT_RATIO_APP_DEFAULT,
|
||||||
userMinAspectRatioMap.get(USER_MIN_ASPECT_RATIO_UNSET));
|
userMinAspectRatioMap.get(USER_MIN_ASPECT_RATIO_UNSET));
|
||||||
mUserAspectRatioOrder.put(USER_MIN_ASPECT_RATIO_APP_DEFAULT,
|
mUserAspectRatioOrder.put(USER_MIN_ASPECT_RATIO_APP_DEFAULT,
|
||||||
@@ -335,7 +332,6 @@ public class UserAspectRatioManager {
|
|||||||
mUserAspectRatioA11yMap.put(USER_MIN_ASPECT_RATIO_APP_DEFAULT,
|
mUserAspectRatioA11yMap.put(USER_MIN_ASPECT_RATIO_APP_DEFAULT,
|
||||||
mUserAspectRatioA11yMap.get(USER_MIN_ASPECT_RATIO_UNSET));
|
mUserAspectRatioA11yMap.get(USER_MIN_ASPECT_RATIO_UNSET));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return userMinAspectRatioMap;
|
return userMinAspectRatioMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,7 +31,7 @@ import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO
|
|||||||
|
|
||||||
import static com.android.settings.applications.appcompat.UserAspectRatioManager.KEY_ENABLE_USER_ASPECT_RATIO_FULLSCREEN;
|
import static com.android.settings.applications.appcompat.UserAspectRatioManager.KEY_ENABLE_USER_ASPECT_RATIO_FULLSCREEN;
|
||||||
import static com.android.settings.applications.appcompat.UserAspectRatioManager.KEY_ENABLE_USER_ASPECT_RATIO_SETTINGS;
|
import static com.android.settings.applications.appcompat.UserAspectRatioManager.KEY_ENABLE_USER_ASPECT_RATIO_SETTINGS;
|
||||||
import static com.android.window.flags.Flags.FLAG_USER_MIN_ASPECT_RATIO_APP_DEFAULT;
|
import static com.android.window.flags.Flags.FLAG_UNIVERSAL_RESIZABLE_BY_DEFAULT;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@@ -54,6 +54,7 @@ import android.content.pm.LauncherApps;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.platform.test.annotations.DisableFlags;
|
||||||
import android.platform.test.flag.junit.SetFlagsRule;
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
import android.provider.DeviceConfig;
|
import android.provider.DeviceConfig;
|
||||||
|
|
||||||
@@ -102,7 +103,6 @@ public class UserAspectRatioManagerTest {
|
|||||||
when(mContext.getResources()).thenReturn(mResources);
|
when(mContext.getResources()).thenReturn(mResources);
|
||||||
when(mContext.getSystemService(LauncherApps.class)).thenReturn(launcherApps);
|
when(mContext.getSystemService(LauncherApps.class)).thenReturn(launcherApps);
|
||||||
enableAllDefaultAspectRatioOptions();
|
enableAllDefaultAspectRatioOptions();
|
||||||
mSetFlagsRule.disableFlags(FLAG_USER_MIN_ASPECT_RATIO_APP_DEFAULT);
|
|
||||||
|
|
||||||
mUtils = new FakeUserAspectRatioManager(mContext, mIPm);
|
mUtils = new FakeUserAspectRatioManager(mContext, mIPm);
|
||||||
|
|
||||||
@@ -318,19 +318,6 @@ public class UserAspectRatioManagerTest {
|
|||||||
assertThrows(RuntimeException.class, () -> new FakeUserAspectRatioManager(mContext, mIPm));
|
assertThrows(RuntimeException.class, () -> new FakeUserAspectRatioManager(mContext, mIPm));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetUserMinAspectRatioMapping_appDefaultFlagEnabled() {
|
|
||||||
// Flag is disabled by default, app default not loaded
|
|
||||||
assertFalse(mUtils.hasAspectRatioOption(USER_MIN_ASPECT_RATIO_APP_DEFAULT, mPackageName));
|
|
||||||
|
|
||||||
mSetFlagsRule.enableFlags(FLAG_USER_MIN_ASPECT_RATIO_APP_DEFAULT);
|
|
||||||
mUtils = new FakeUserAspectRatioManager(mContext, mIPm);
|
|
||||||
|
|
||||||
assertTrue(mUtils.hasAspectRatioOption(USER_MIN_ASPECT_RATIO_APP_DEFAULT, mPackageName));
|
|
||||||
assertThat(getUserMinAspectRatioEntry(USER_MIN_ASPECT_RATIO_APP_DEFAULT, mPackageName))
|
|
||||||
.isEqualTo(getUserMinAspectRatioEntry(USER_MIN_ASPECT_RATIO_UNSET, mPackageName));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertUnsetIsFullscreen() {
|
private void assertUnsetIsFullscreen() {
|
||||||
// Fullscreen option is pre-selected
|
// Fullscreen option is pre-selected
|
||||||
assertThat(getUserMinAspectRatioEntry(USER_MIN_ASPECT_RATIO_UNSET, mPackageName))
|
assertThat(getUserMinAspectRatioEntry(USER_MIN_ASPECT_RATIO_UNSET, mPackageName))
|
||||||
@@ -406,14 +393,8 @@ public class UserAspectRatioManagerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsOverrideToFullscreenEnabled_flagDisabled_returnsFalse() {
|
@DisableFlags({FLAG_UNIVERSAL_RESIZABLE_BY_DEFAULT})
|
||||||
mUtils.setFullscreenCompatChange(true);
|
|
||||||
assertFalse(mUtils.isOverrideToFullscreenEnabled(mPackageName, mContext.getUserId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testIsOverrideToFullscreenEnabledUnivRes_flagDisabled_returnsFalse() {
|
public void testIsOverrideToFullscreenEnabledUnivRes_flagDisabled_returnsFalse() {
|
||||||
mUtils.setFullscreenCompatChange(true);
|
|
||||||
assertFalse(mUtils.isOverrideToFullscreenEnabled(mPackageName, mContext.getUserId()));
|
assertFalse(mUtils.isOverrideToFullscreenEnabled(mPackageName, mContext.getUserId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,20 +407,12 @@ public class UserAspectRatioManagerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setIsOverrideToFullscreenEnabledBecauseCompatChange(boolean enabled) {
|
private void setIsOverrideToFullscreenEnabledBecauseCompatChange(boolean enabled) {
|
||||||
if (enabled) {
|
|
||||||
mSetFlagsRule.enableFlags(FLAG_USER_MIN_ASPECT_RATIO_APP_DEFAULT);
|
|
||||||
mUtils = new FakeUserAspectRatioManager(mContext, mIPm);
|
|
||||||
}
|
|
||||||
mUtils.setFullscreenCompatChange(enabled);
|
mUtils.setFullscreenCompatChange(enabled);
|
||||||
when(mUtils.hasAspectRatioOption(USER_MIN_ASPECT_RATIO_FULLSCREEN, mPackageName))
|
when(mUtils.hasAspectRatioOption(USER_MIN_ASPECT_RATIO_FULLSCREEN, mPackageName))
|
||||||
.thenReturn(enabled);
|
.thenReturn(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setIsOverrideToFullscreenEnabledBecauseUniversalResizeable(boolean enabled) {
|
private void setIsOverrideToFullscreenEnabledBecauseUniversalResizeable(boolean enabled) {
|
||||||
if (enabled) {
|
|
||||||
mSetFlagsRule.enableFlags(FLAG_USER_MIN_ASPECT_RATIO_APP_DEFAULT);
|
|
||||||
mUtils = new FakeUserAspectRatioManager(mContext, mIPm);
|
|
||||||
}
|
|
||||||
mUtils.setUniversalResizeable(enabled);
|
mUtils.setUniversalResizeable(enabled);
|
||||||
when(mUtils.hasAspectRatioOption(USER_MIN_ASPECT_RATIO_FULLSCREEN, mPackageName))
|
when(mUtils.hasAspectRatioOption(USER_MIN_ASPECT_RATIO_FULLSCREEN, mPackageName))
|
||||||
.thenReturn(enabled);
|
.thenReturn(enabled);
|
||||||
|
Reference in New Issue
Block a user