diff options
author | Suchi Amalapurapu <asuchitra@google.com> | 2010-02-09 03:45:40 -0800 |
---|---|---|
committer | Suchi Amalapurapu <asuchitra@google.com> | 2010-02-10 08:59:08 -0800 |
commit | 117818e4f171b1fd9daa05349c48f61388f04567 (patch) | |
tree | 2bb350a719caf06727a410ce662c46a28c45fb72 /core/java/android/content | |
parent | 596ce7fbfe5a81a4270949448c08dcb3a684cc3a (diff) | |
download | frameworks_base-117818e4f171b1fd9daa05349c48f61388f04567.zip frameworks_base-117818e4f171b1fd9daa05349c48f61388f04567.tar.gz frameworks_base-117818e4f171b1fd9daa05349c48f61388f04567.tar.bz2 |
Add new manifest option for install location
Change recommendAppInstallLocation api
add code to parse new attribute.
Define flags in PackageInfo
Add new settings attributes for enabling setting and value for install location
Some tests
The policy for install location: if explicitly set in manifest as internal only we try to install the app only on internal storage. if set to preferExternal, we try to install it on sdcard if possible. If not we fall back to internal.
If the user enables setting SET_INSTALL_LOCATION(which will always
be set to false in final release builds) and sets a prefered location, we try
to honour it.
Diffstat (limited to 'core/java/android/content')
-rw-r--r-- | core/java/android/content/pm/PackageInfo.java | 30 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageManager.java | 9 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageParser.java | 6 |
3 files changed, 41 insertions, 4 deletions
diff --git a/core/java/android/content/pm/PackageInfo.java b/core/java/android/content/pm/PackageInfo.java index a8ce889..c003355 100644 --- a/core/java/android/content/pm/PackageInfo.java +++ b/core/java/android/content/pm/PackageInfo.java @@ -131,6 +131,34 @@ public class PackageInfo implements Parcelable { * The features that this application has said it requires. */ public FeatureInfo[] reqFeatures; + + /** + * Constant corresponding to <code>auto</code> in + * the {@link android.R.attr#installLocation} attribute. + * @hide + */ + public static final int INSTALL_LOCATION_AUTO = 0; + /** + * Constant corresponding to <code>internalOnly</code> in + * the {@link android.R.attr#installLocation} attribute. + * @hide + */ + public static final int INSTALL_LOCATION_INTERNAL_ONLY = 1; + /** + * Constant corresponding to <code>preferExternal</code> in + * the {@link android.R.attr#installLocation} attribute. + * @hide + */ + public static final int INSTALL_LOCATION_PREFER_EXTERNAL = 2; + /** + * The launch mode style requested by the activity. From the + * {@link android.R.attr#installLocation} attribute, one of + * {@link #INSTALL_LOCATION_AUTO}, + * {@link #INSTALL_LOCATION_INTERNAL_ONLY}, + * {@link #INSTALL_LOCATION_PREFER_EXTERNAL} + * @hide + */ + public int installLocation = INSTALL_LOCATION_INTERNAL_ONLY; public PackageInfo() { } @@ -168,6 +196,7 @@ public class PackageInfo implements Parcelable { dest.writeTypedArray(signatures, parcelableFlags); dest.writeTypedArray(configPreferences, parcelableFlags); dest.writeTypedArray(reqFeatures, parcelableFlags); + dest.writeInt(installLocation); } public static final Parcelable.Creator<PackageInfo> CREATOR @@ -202,5 +231,6 @@ public class PackageInfo implements Parcelable { signatures = source.createTypedArray(Signature.CREATOR); configPreferences = source.createTypedArray(ConfigurationInfo.CREATOR); reqFeatures = source.createTypedArray(FeatureInfo.CREATOR); + installLocation = source.readInt(); } } diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index fca8588..a61eab9 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -630,10 +630,11 @@ public abstract class PackageManager { /** * Determines best place to install an application: either SD or internal FLASH. - * Tweak the algorithm for best results. - * @param appInfo ApplicationInfo object of the package to install. + * If applications explicitly set installLocation in their manifest, that + * preference takes precedence. If not a recommended location is returned + * based on current available storage on internal flash or sdcard. + * @param pkgInfo PackageParser.Package of the package that is to be installed. * Call utility method to obtain. - * @param packageURI URI identifying the package's APK file. * @return {@link INSTALL_ON_INTERNAL_FLASH} if it is best to install package on internal * storage, {@link INSTALL_ON_SDCARD} if it is best to install package on SD card, * and {@link INSTALL_FAILED_INSUFFICIENT_STORAGE} if insufficient space to safely install @@ -642,7 +643,7 @@ public abstract class PackageManager { * This recommendation does take into account the package's own flags. * @hide */ - public abstract int recommendAppInstallLocation(ApplicationInfo appInfo, Uri packageURI); + public abstract int recommendAppInstallLocation(PackageParser.Package pkg); /** * Retrieve overall information about an application package that is diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index b31df32..0a6195f 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -177,6 +177,7 @@ public class PackageParser { pi.sharedUserId = p.mSharedUserId; pi.sharedUserLabel = p.mSharedUserLabel; pi.applicationInfo = p.applicationInfo; + pi.installLocation = p.installLocation; if ((flags&PackageManager.GET_GIDS) != 0) { pi.gids = gids; } @@ -709,6 +710,9 @@ public class PackageParser { com.android.internal.R.styleable.AndroidManifest_sharedUserLabel, 0); } sa.recycle(); + pkg.installLocation = sa.getInteger( + com.android.internal.R.styleable.AndroidManifest_installLocation, + PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY); // Resource boolean are -1, so 1 means we don't know the value. int supportsSmallScreens = 1; @@ -2610,6 +2614,8 @@ public class PackageParser { */ public ArrayList<FeatureInfo> reqFeatures = null; + public int installLocation; + public Package(String _name) { packageName = _name; applicationInfo.packageName = _name; |