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

Commit 643ba812 authored by Stefan Kuhne's avatar Stefan Kuhne Committed by Android (Google) Code Review
Browse files

Merge "Apps which do not support density cannot be resized"

parents 6fd63e4d 7e85eb02
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
@@ -2387,9 +2387,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