Loading core/java/android/view/WindowManager.java +11 −3 Original line number Diff line number Diff line Loading @@ -1426,8 +1426,9 @@ public interface WindowManager extends ViewManager { "android.window.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE"; /** * Activity-level {@link android.content.pm.PackageManager.Property PackageManager.Property} * that specifies whether this activity can declare or request * Application or Activity level * {@link android.content.pm.PackageManager.Property PackageManager.Property} * that specifies whether this package or activity can declare or request * {@link android.R.attr#screenOrientation fixed orientation}, * {@link android.R.attr#minAspectRatio max aspect ratio}, * {@link android.R.attr#maxAspectRatio min aspect ratio} Loading @@ -1438,6 +1439,13 @@ public interface WindowManager extends ViewManager { * * <p><b>Syntax:</b> * <pre> * <application> * <property * android:name="android.window.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE" * android:value="false"/> * </application> * </pre>or * <pre> * <activity> * <property * android:name="android.window.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY" Loading @@ -1446,7 +1454,7 @@ public interface WindowManager extends ViewManager { * </pre> * @hide */ // TODO(b/357141415): Make this public API. // TODO(b/357141415): Remove this from sdk 37 String PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY = "android.window.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY"; Loading services/core/java/com/android/server/wm/AppCompatController.java +10 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,16 @@ class AppCompatController { mAppCompatSizeCompatModePolicy = new AppCompatSizeCompatModePolicy(mActivityRecord, mAppCompatOverrides); mAllowRestrictedResizability = AppCompatUtils.asLazy(() -> { // Application level. try { if (packageManager.getProperty(PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY, mActivityRecord.packageName).getBoolean()) { return true; } } catch (PackageManager.NameNotFoundException e) { // Fall through. } // Activity level. try { return packageManager.getPropertyAsUser( PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY, Loading services/core/java/com/android/server/wm/DesktopAppCompatAspectRatioPolicy.java +6 −4 Original line number Diff line number Diff line Loading @@ -196,10 +196,11 @@ public class DesktopAppCompatAspectRatioPolicy { if (!aspectRatioOverrides.shouldOverrideMinAspectRatio() && !AppCompatCameraPolicy.shouldOverrideMinAspectRatioForCamera(mActivityRecord)) { if (mActivityRecord.isUniversalResizeable()) { final float minAspectRatio = info.getMinAspectRatio(); if (minAspectRatio == 0 || mActivityRecord.isUniversalResizeable()) { return 0; } return info.getMinAspectRatio(); return minAspectRatio; } if (info.isChangeEnabled(OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_ONLY) Loading Loading @@ -242,10 +243,11 @@ public class DesktopAppCompatAspectRatioPolicy { if (mTransparentPolicy.isRunning()) { return mTransparentPolicy.getInheritedMaxAspectRatio(); } if (mActivityRecord.isUniversalResizeable()) { final float maxAspectRatio = mActivityRecord.info.getMaxAspectRatio(); if (maxAspectRatio == 0 || mActivityRecord.isUniversalResizeable()) { return 0; } return mActivityRecord.info.getMaxAspectRatio(); return maxAspectRatio; } /** Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +14 −0 Original line number Diff line number Diff line Loading @@ -4928,6 +4928,7 @@ public class SizeCompatTests extends WindowTestsBase { spyOn(pm); final PackageManager.Property property = new PackageManager.Property("propertyName", true /* value */, name.getPackageName(), name.getClassName()); // Activity level. try { doReturn(property).when(pm).getPropertyAsUser( WindowManager.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY, Loading @@ -4938,6 +4939,19 @@ public class SizeCompatTests extends WindowTestsBase { final ActivityRecord optOutActivity = new ActivityBuilder(mAtm) .setComponent(name).setTask(mTask).build(); assertFalse(optOutActivity.isUniversalResizeable()); // Application level. try { doReturn(property).when(pm).getProperty( WindowManager.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY, name.getPackageName()); } catch (PackageManager.NameNotFoundException e) { throw new RuntimeException(e); } final ActivityRecord optOutAppActivity = new ActivityBuilder(mAtm) .setComponent(getUniqueComponentName(mContext.getPackageName())) .setTask(mTask).build(); assertFalse(optOutAppActivity.isUniversalResizeable()); } Loading Loading
core/java/android/view/WindowManager.java +11 −3 Original line number Diff line number Diff line Loading @@ -1426,8 +1426,9 @@ public interface WindowManager extends ViewManager { "android.window.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE"; /** * Activity-level {@link android.content.pm.PackageManager.Property PackageManager.Property} * that specifies whether this activity can declare or request * Application or Activity level * {@link android.content.pm.PackageManager.Property PackageManager.Property} * that specifies whether this package or activity can declare or request * {@link android.R.attr#screenOrientation fixed orientation}, * {@link android.R.attr#minAspectRatio max aspect ratio}, * {@link android.R.attr#maxAspectRatio min aspect ratio} Loading @@ -1438,6 +1439,13 @@ public interface WindowManager extends ViewManager { * * <p><b>Syntax:</b> * <pre> * <application> * <property * android:name="android.window.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE" * android:value="false"/> * </application> * </pre>or * <pre> * <activity> * <property * android:name="android.window.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY" Loading @@ -1446,7 +1454,7 @@ public interface WindowManager extends ViewManager { * </pre> * @hide */ // TODO(b/357141415): Make this public API. // TODO(b/357141415): Remove this from sdk 37 String PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY = "android.window.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY"; Loading
services/core/java/com/android/server/wm/AppCompatController.java +10 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,16 @@ class AppCompatController { mAppCompatSizeCompatModePolicy = new AppCompatSizeCompatModePolicy(mActivityRecord, mAppCompatOverrides); mAllowRestrictedResizability = AppCompatUtils.asLazy(() -> { // Application level. try { if (packageManager.getProperty(PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY, mActivityRecord.packageName).getBoolean()) { return true; } } catch (PackageManager.NameNotFoundException e) { // Fall through. } // Activity level. try { return packageManager.getPropertyAsUser( PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY, Loading
services/core/java/com/android/server/wm/DesktopAppCompatAspectRatioPolicy.java +6 −4 Original line number Diff line number Diff line Loading @@ -196,10 +196,11 @@ public class DesktopAppCompatAspectRatioPolicy { if (!aspectRatioOverrides.shouldOverrideMinAspectRatio() && !AppCompatCameraPolicy.shouldOverrideMinAspectRatioForCamera(mActivityRecord)) { if (mActivityRecord.isUniversalResizeable()) { final float minAspectRatio = info.getMinAspectRatio(); if (minAspectRatio == 0 || mActivityRecord.isUniversalResizeable()) { return 0; } return info.getMinAspectRatio(); return minAspectRatio; } if (info.isChangeEnabled(OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_ONLY) Loading Loading @@ -242,10 +243,11 @@ public class DesktopAppCompatAspectRatioPolicy { if (mTransparentPolicy.isRunning()) { return mTransparentPolicy.getInheritedMaxAspectRatio(); } if (mActivityRecord.isUniversalResizeable()) { final float maxAspectRatio = mActivityRecord.info.getMaxAspectRatio(); if (maxAspectRatio == 0 || mActivityRecord.isUniversalResizeable()) { return 0; } return mActivityRecord.info.getMaxAspectRatio(); return maxAspectRatio; } /** Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +14 −0 Original line number Diff line number Diff line Loading @@ -4928,6 +4928,7 @@ public class SizeCompatTests extends WindowTestsBase { spyOn(pm); final PackageManager.Property property = new PackageManager.Property("propertyName", true /* value */, name.getPackageName(), name.getClassName()); // Activity level. try { doReturn(property).when(pm).getPropertyAsUser( WindowManager.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY, Loading @@ -4938,6 +4939,19 @@ public class SizeCompatTests extends WindowTestsBase { final ActivityRecord optOutActivity = new ActivityBuilder(mAtm) .setComponent(name).setTask(mTask).build(); assertFalse(optOutActivity.isUniversalResizeable()); // Application level. try { doReturn(property).when(pm).getProperty( WindowManager.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY, name.getPackageName()); } catch (PackageManager.NameNotFoundException e) { throw new RuntimeException(e); } final ActivityRecord optOutAppActivity = new ActivityBuilder(mAtm) .setComponent(getUniqueComponentName(mContext.getPackageName())) .setTask(mTask).build(); assertFalse(optOutAppActivity.isUniversalResizeable()); } Loading