diff options
| -rw-r--r-- | core/java/android/content/pm/ApplicationInfo.java | 14 | ||||
| -rw-r--r-- | core/java/android/content/pm/PackageParser.java | 18 |
2 files changed, 32 insertions, 0 deletions
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java index 9b99bbfe8880..adc99d39d876 100644 --- a/core/java/android/content/pm/ApplicationInfo.java +++ b/core/java/android/content/pm/ApplicationInfo.java @@ -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)); diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index cf4c0fae6f16..ad1ed554a7a4 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -2387,10 +2387,28 @@ 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 * error message. |