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

Commit 7e85eb02 authored by skuhne@google.com's avatar skuhne@google.com
Browse files

Apps which do not support density cannot be resized

This is to prevent apps which do not support density
(so essentially pre-Doughnut) from being resized and / or
windowed in free form mode.

These apps are rendered into a smaller sized buffer and
then scaled onto the screen. Using freeform window mode with
these apps uncovered many different problems.

Bug: 33843467
Test: Pre-N as well as Pre-Doughnut applications are presented
properly in free form mode. (Pre-Doughnut cannot be windowed /
resized, many M apps can).
Change-Id: I3c0eb3681486dc85ace15955432d79200743bce3
parent 388ef5df
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ import java.util.Arrays;
import java.util.Comparator;
import java.util.Objects;

import static android.os.Build.VERSION_CODES.DONUT;

/**
 * Information you can retrieve about a particular application.  This
 * corresponds to information collected from the AndroidManifest.xml's
@@ -1085,6 +1087,18 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
                FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
    }

    /**
     * Is using compatibility mode for non densty aware legacy applications.
     *
     * @hide
     */
    public boolean usesCompatibilityMode() {
        return targetSdkVersion < DONUT ||
                (flags & (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
                 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
                 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS)) == 0;
    }

    /** {@hide} */
    public void initForUser(int userId) {
        uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
+18 −0
Original line number Diff line number Diff line
@@ -2369,9 +2369,27 @@ public class PackageParser {
            pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES;
        }

        // At this point we can check if an application is not supporting densities and hence
        // cannot be windowed / resized. Note that an SDK version of 0 is common for
        // pre-Doughnut applications.
        if (pkg.applicationInfo.usesCompatibilityMode()) {
            adjustPackageToBeUnresizeable(pkg);
        }
        return pkg;
    }

    /**
     * This is a pre-density application which will get scaled - instead of being pixel perfect.
     * This type of application is not resizable.
     *
     * @param pkg The package which needs to be marked as unresizable.
     */
    private void adjustPackageToBeUnresizeable(Package pkg) {
        for (Activity a : pkg.activities) {
            a.info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
        }
    }

    /**
     * Computes the targetSdkVersion to use at runtime. If the package is not
     * compatible with this platform, populates {@code outError[0]} with an