diff options
author | Mitsuru Oshima <oshima@google.com> | 2009-06-09 21:16:08 -0700 |
---|---|---|
committer | Mitsuru Oshima <oshima@google.com> | 2009-06-10 15:22:17 -0700 |
commit | e5fb328825995aa33b5b7ecf8b5bee2b17f81715 (patch) | |
tree | 4b6ca87aaf21dd587e1d033f5ba3318c4329698f /services/java/com/android/server/PackageManagerService.java | |
parent | ca436e24dec0fa258a8a756c3e7d07bcb096c5b3 (diff) | |
download | frameworks_base-e5fb328825995aa33b5b7ecf8b5bee2b17f81715.zip frameworks_base-e5fb328825995aa33b5b7ecf8b5bee2b17f81715.tar.gz frameworks_base-e5fb328825995aa33b5b7ecf8b5bee2b17f81715.tar.bz2 |
resolution support fix/improvement
* adding compatibility menu
* backup gravity
* set expanable=true if the screen size is hvga * density.
* added "supports any density" mode. I'll add sdk check later.
* disallow to catch orientation change event if the app is not expandable. This
was causing layout problem under non-expandable mode. I discussed this with Mike C
and we agreed to do this approach for now. We'll revisit if this causes problem to
a lot of applications.
Diffstat (limited to 'services/java/com/android/server/PackageManagerService.java')
-rw-r--r-- | services/java/com/android/server/PackageManagerService.java | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java index 6a2e62f..0d142da 100644 --- a/services/java/com/android/server/PackageManagerService.java +++ b/services/java/com/android/server/PackageManagerService.java @@ -58,6 +58,8 @@ import android.content.pm.ProviderInfo; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.pm.Signature; +import android.content.res.CompatibilityInfo; +import android.content.res.Configuration; import android.net.Uri; import android.os.Binder; import android.os.Build; @@ -259,6 +261,7 @@ class PackageManagerService extends IPackageManager.Stub { final ResolveInfo mResolveInfo = new ResolveInfo(); ComponentName mResolveComponentName; PackageParser.Package mPlatformPackage; + private boolean mCompatibilityModeEnabled = true; public static final IPackageManager main(Context context, boolean factoryTest) { PackageManagerService m = new PackageManagerService(context, factoryTest); @@ -509,7 +512,7 @@ class PackageManagerService extends IPackageManager.Stub { } // synchronized (mPackages) } // synchronized (mInstallLock) } - + @Override public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { @@ -885,7 +888,11 @@ class PackageManagerService extends IPackageManager.Stub { + ": " + p); if (p != null) { // Note: isEnabledLP() does not apply here - always return info - return PackageParser.generateApplicationInfo(p, flags); + ApplicationInfo appInfo = PackageParser.generateApplicationInfo(p, flags); + if (!mCompatibilityModeEnabled) { + appInfo.disableCompatibilityMode(); + } + return appInfo; } if ("android".equals(packageName)||"system".equals(packageName)) { return mAndroidApplication; @@ -952,10 +959,35 @@ class PackageManagerService extends IPackageManager.Stub { public ActivityInfo getActivityInfo(ComponentName component, int flags) { synchronized (mPackages) { PackageParser.Activity a = mActivities.mActivities.get(component); - if (Config.LOGV) Log.v( - TAG, "getActivityInfo " + component + ": " + a); + + if (Config.LOGV) Log.v(TAG, "getActivityInfo " + component + ": " + a); if (a != null && mSettings.isEnabledLP(a.info, flags)) { - return PackageParser.generateActivityInfo(a, flags); + ActivityInfo ainfo = PackageParser.generateActivityInfo(a, flags); + if (ainfo != null && (flags & PackageManager.GET_EXPANDABLE) != 0) { + ApplicationInfo appInfo = getApplicationInfo(component.getPackageName(), + PackageManager.GET_EXPANDABLE | PackageManager.GET_SUPPORTS_DENSITIES); + if (appInfo != null && !appInfo.expandable) { + // Check if the screen size is same as what the application expect. + CompatibilityInfo info = new CompatibilityInfo(appInfo); + DisplayMetrics metrics = new DisplayMetrics(); + metrics.setTo(mMetrics); + int orientation = mMetrics.widthPixels > mMetrics.heightPixels ? + Configuration.ORIENTATION_LANDSCAPE : + Configuration.ORIENTATION_PORTRAIT; + metrics.updateMetrics(info, orientation); + if (!info.mExpandable) { + // Don't allow an app that cannot expand to handle rotation. + ainfo.configChanges &= ~ ActivityInfo.CONFIG_ORIENTATION; + } else { + appInfo.expandable = true; + } + if (DEBUG_SETTINGS) { + Log.d(TAG, "component=" + component + + ", expandable:" + appInfo.expandable); + } + } + } + return ainfo; } if (mResolveComponentName.equals(component)) { return mResolveActivity; @@ -4709,6 +4741,14 @@ class PackageManagerService extends IPackageManager.Stub { public void systemReady() { mSystemReady = true; + + // Read the compatibilty setting when the system is ready. + mCompatibilityModeEnabled = android.provider.Settings.System.getInt( + mContext.getContentResolver(), + android.provider.Settings.System.COMPATIBILITY_MODE, 1) == 1; + if (DEBUG_SETTINGS) { + Log.d(TAG, "compatibility mode:" + mCompatibilityModeEnabled); + } } public boolean isSafeMode() { |