From df6e980e3f63eb0f6f9eb437fa925d5009cd9c44 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Thu, 26 May 2011 14:20:23 -0700 Subject: [PATCH] Add new supports-screens attributes for declaring the compatible screens. Change-Id: I40d57e4354e48accc1027c9f90916ea73eb5190d android:requiresSmallestWidthDp provides the smallest supported width. android:compatibleWidthLimitDp provides the largest compatible width. --- api/current.xml | 44 ++++- core/java/android/app/ActivityThread.java | 2 +- .../android/content/pm/ApplicationInfo.java | 24 +++ .../android/content/pm/PackageParser.java | 7 + .../content/res/CompatibilityInfo.java | 168 ++++++++++-------- core/res/res/values/attrs_manifest.xml | 24 +++ core/res/res/values/public.xml | 12 +- .../android/server/am/CompatModePackages.java | 8 +- .../android/test/dpi/DpiTestActivity.java | 3 +- 9 files changed, 214 insertions(+), 78 deletions(-) diff --git a/api/current.xml b/api/current.xml index b0886788ad702..efcde72d173d4 100644 --- a/api/current.xml +++ b/api/current.xml @@ -3128,6 +3128,17 @@ visibility="public" > + + + + + + + + - + + + + + - + + + + + + + diff --git a/services/java/com/android/server/am/CompatModePackages.java b/services/java/com/android/server/am/CompatModePackages.java index 1277bca5ed518..221b59b8307a3 100644 --- a/services/java/com/android/server/am/CompatModePackages.java +++ b/services/java/com/android/server/am/CompatModePackages.java @@ -119,13 +119,15 @@ public class CompatModePackages { public CompatibilityInfo compatibilityInfoForPackageLocked(ApplicationInfo ai) { return new CompatibilityInfo(ai, mService.mConfiguration.screenLayout, + mService.mConfiguration.smallestScreenWidthDp, (getPackageFlags(ai.packageName)&COMPAT_FLAG_ENABLED) != 0); } public int computeCompatModeLocked(ApplicationInfo ai) { boolean enabled = (getPackageFlags(ai.packageName)&COMPAT_FLAG_ENABLED) != 0; CompatibilityInfo info = new CompatibilityInfo(ai, - mService.mConfiguration.screenLayout, enabled); + mService.mConfiguration.screenLayout, + mService.mConfiguration.smallestScreenWidthDp, enabled); if (info.alwaysSupportsScreen()) { return ActivityManager.COMPAT_MODE_NEVER; } @@ -315,6 +317,7 @@ public class CompatModePackages { final IPackageManager pm = AppGlobals.getPackageManager(); final int screenLayout = mService.mConfiguration.screenLayout; + final int smallestScreenWidthDp = mService.mConfiguration.smallestScreenWidthDp; final Iterator> it = pkgs.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = it.next(); @@ -331,7 +334,8 @@ public class CompatModePackages { if (ai == null) { continue; } - CompatibilityInfo info = new CompatibilityInfo(ai, screenLayout, false); + CompatibilityInfo info = new CompatibilityInfo(ai, screenLayout, + smallestScreenWidthDp, false); if (info.alwaysSupportsScreen()) { continue; } diff --git a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java index 2a40c570a5f69..01c1c70f3f2af 100644 --- a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java +++ b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java @@ -63,7 +63,8 @@ public class DpiTestActivity extends Activity { | ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS | ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES; app.getResources().setCompatibilityInfo(new CompatibilityInfo(ai, - getResources().getConfiguration().screenLayout, false)); + getResources().getConfiguration().screenLayout, + getResources().getConfiguration().smallestScreenWidthDp, false)); } } catch (PackageManager.NameNotFoundException e) { throw new RuntimeException("ouch", e);