Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b08d91c authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Add a method for querying universal resizability of packages" into main

parents b5664e8e 9c7c9e67
Loading
Loading
Loading
Loading
+30 −12
Original line number Diff line number Diff line
@@ -3212,18 +3212,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     * will be ignored.
     */
    boolean isUniversalResizeable() {
        if (info.applicationInfo.category == ApplicationInfo.CATEGORY_GAME) {
            return false;
        }
        final boolean compatEnabled = Flags.universalResizableByDefault()
                && mDisplayContent != null && mDisplayContent.getConfiguration()
        final boolean isLargeScreen = mDisplayContent != null && mDisplayContent.getConfiguration()
                .smallestScreenWidthDp >= WindowManager.LARGE_SCREEN_SMALLEST_SCREEN_WIDTH_DP
                && mDisplayContent.getIgnoreOrientationRequest()
                && info.isChangeEnabled(ActivityInfo.UNIVERSAL_RESIZABLE_BY_DEFAULT);
        if (!compatEnabled && !mWmService.mConstants.mIgnoreActivityOrientationRequest) {
            return false;
        }
        if (mWmService.mConstants.isPackageOptOutIgnoreActivityOrientationRequest(packageName)) {
                && mDisplayContent.getIgnoreOrientationRequest();
        if (!canBeUniversalResizeable(info.applicationInfo, mWmService, isLargeScreen,
                true /* forActivity */)) {
            return false;
        }
        if (mAppCompatController.mAllowRestrictedResizability.getAsBoolean()) {
@@ -3234,6 +3227,31 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                .userPreferenceCompatibleWithNonResizability();
    }

    /**
     * Returns {@code true} if the fixed orientation, aspect ratio, resizability of the application
     * can be ignored.
     */
    static boolean canBeUniversalResizeable(ApplicationInfo appInfo, WindowManagerService wms,
            boolean isLargeScreen, boolean forActivity) {
        if (appInfo.category == ApplicationInfo.CATEGORY_GAME) {
            return false;
        }
        final boolean compatEnabled = isLargeScreen && Flags.universalResizableByDefault()
                && appInfo.isChangeEnabled(ActivityInfo.UNIVERSAL_RESIZABLE_BY_DEFAULT);
        if (!compatEnabled && !wms.mConstants.mIgnoreActivityOrientationRequest) {
            return false;
        }
        if (wms.mConstants.isPackageOptOutIgnoreActivityOrientationRequest(appInfo.packageName)) {
            return false;
        }
        if (forActivity) {
            // The caller will check both application and activity level property.
            return true;
        }
        return !AppCompatController.allowRestrictedResizability(wms.mContext.getPackageManager(),
                appInfo.packageName);
    }

    boolean isResizeable() {
        return mAtmService.mForceResizableActivities
                || ActivityInfo.isResizeableMode(info.resizeMode)
+11 −7
Original line number Diff line number Diff line
@@ -77,14 +77,9 @@ class AppCompatController {
                mAppCompatOverrides);
        mAllowRestrictedResizability = AppCompatUtils.asLazy(() -> {
            // Application level.
            try {
                if (packageManager.getProperty(PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY,
                        mActivityRecord.packageName).getBoolean()) {
            if (allowRestrictedResizability(packageManager, mActivityRecord.packageName)) {
                return true;
            }
            } catch (PackageManager.NameNotFoundException e) {
                // Fall through.
            }
            // Activity level.
            try {
                return packageManager.getPropertyAsUser(
@@ -98,6 +93,15 @@ class AppCompatController {
        });
    }

    static boolean allowRestrictedResizability(PackageManager pm, String packageName) {
        try {
            return pm.getProperty(PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY, packageName)
                    .getBoolean();
        } catch (PackageManager.NameNotFoundException e) {
            return false;
        }
    }

    @NonNull
    TransparentPolicy getTransparentPolicy() {
        return mTransparentPolicy;
+4 −0
Original line number Diff line number Diff line
@@ -4899,6 +4899,8 @@ public class SizeCompatTests extends WindowTestsBase {
        prepareLimitedBounds(mActivity, maxAspect, minAspect,
                ActivityInfo.SCREEN_ORIENTATION_NOSENSOR, true /* isUnresizable */);

        assertTrue(ActivityRecord.canBeUniversalResizeable(mActivity.info.applicationInfo,
                mWm, true /* isLargeScreen */, false /* forActivity */));
        assertTrue(mActivity.isUniversalResizeable());
        assertTrue(mActivity.isResizeable());
        assertFalse(mActivity.shouldCreateAppCompatDisplayInsets());
@@ -4953,6 +4955,8 @@ public class SizeCompatTests extends WindowTestsBase {
                .setComponent(getUniqueComponentName(mContext.getPackageName()))
                .setTask(mTask).build();
        assertFalse(optOutAppActivity.isUniversalResizeable());
        assertFalse(ActivityRecord.canBeUniversalResizeable(mActivity.info.applicationInfo,
                mWm, true /* isLargeScreen */, false /* forActivity */));
    }