summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/content/pm/PackageInfo.java2
-rwxr-xr-xcore/java/android/content/pm/PackageInfoLite.aidl20
-rw-r--r--core/java/android/content/pm/PackageInfoLite.java63
-rw-r--r--core/java/android/content/pm/PackageParser.java77
-rwxr-xr-xcore/java/com/android/internal/app/IMediaContainerService.aidl3
-rw-r--r--core/java/com/android/internal/content/PackageHelper.java2
6 files changed, 158 insertions, 9 deletions
diff --git a/core/java/android/content/pm/PackageInfo.java b/core/java/android/content/pm/PackageInfo.java
index c003355..0964425 100644
--- a/core/java/android/content/pm/PackageInfo.java
+++ b/core/java/android/content/pm/PackageInfo.java
@@ -151,7 +151,7 @@ public class PackageInfo implements Parcelable {
*/
public static final int INSTALL_LOCATION_PREFER_EXTERNAL = 2;
/**
- * The launch mode style requested by the activity. From the
+ * The install location requested by the activity. From the
* {@link android.R.attr#installLocation} attribute, one of
* {@link #INSTALL_LOCATION_AUTO},
* {@link #INSTALL_LOCATION_INTERNAL_ONLY},
diff --git a/core/java/android/content/pm/PackageInfoLite.aidl b/core/java/android/content/pm/PackageInfoLite.aidl
new file mode 100755
index 0000000..2c80942
--- /dev/null
+++ b/core/java/android/content/pm/PackageInfoLite.aidl
@@ -0,0 +1,20 @@
+/* //device/java/android/android/view/WindowManager.aidl
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+package android.content.pm;
+
+parcelable PackageInfoLite;
diff --git a/core/java/android/content/pm/PackageInfoLite.java b/core/java/android/content/pm/PackageInfoLite.java
new file mode 100644
index 0000000..2f38ece
--- /dev/null
+++ b/core/java/android/content/pm/PackageInfoLite.java
@@ -0,0 +1,63 @@
+package android.content.pm;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Basic information about a package as specified in its manifest.
+ * Utility class used in PackageManager methods
+ * @hide
+ */
+public class PackageInfoLite implements Parcelable {
+ /**
+ * The name of this package. From the <manifest> tag's "name"
+ * attribute.
+ */
+ public String packageName;
+
+ /**
+ * Specifies the recommended install location. Can be one of
+ * {@link #PackageHelper.RECOMMEND_INSTALL_INTERNAL} to install on internal storage
+ * {@link #PackageHelper.RECOMMEND_INSTALL_EXTERNAL} to install on external media
+ * {@link PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE} for storage errors
+ * {@link PackageHelper.RECOMMEND_FAILED_INVALID_APK} for parse errors.
+ */
+ public int recommendedInstallLocation;
+ public int installLocation;
+
+ public PackageInfoLite() {
+ }
+
+ public String toString() {
+ return "PackageInfoLite{"
+ + Integer.toHexString(System.identityHashCode(this))
+ + " " + packageName + "}";
+ }
+
+ public int describeContents() {
+ return 0;
+ }
+
+ public void writeToParcel(Parcel dest, int parcelableFlags) {
+ dest.writeString(packageName);
+ dest.writeInt(recommendedInstallLocation);
+ dest.writeInt(installLocation);
+ }
+
+ public static final Parcelable.Creator<PackageInfoLite> CREATOR
+ = new Parcelable.Creator<PackageInfoLite>() {
+ public PackageInfoLite createFromParcel(Parcel source) {
+ return new PackageInfoLite(source);
+ }
+
+ public PackageInfoLite[] newArray(int size) {
+ return new PackageInfoLite[size];
+ }
+ };
+
+ private PackageInfoLite(Parcel source) {
+ packageName = source.readString();
+ recommendedInstallLocation = source.readInt();
+ installLocation = source.readInt();
+ }
+} \ No newline at end of file
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 7a0337cd..5da7fd1 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -136,7 +136,20 @@ public class PackageParser {
enabledRes = _enabledRes;
}
}
-
+
+ /* Light weight package info.
+ * @hide
+ */
+ public static class PackageLite {
+ public String packageName;
+ public int installLocation;
+ public String mScanPath;
+ public PackageLite(String packageName, int installLocation) {
+ this.packageName = packageName;
+ this.installLocation = installLocation;
+ }
+ }
+
private ParsePackageItemArgs mParseInstrumentationArgs;
private ParseComponentArgs mParseActivityArgs;
private ParseComponentArgs mParseActivityAliasArgs;
@@ -562,7 +575,14 @@ public class PackageParser {
return true;
}
- public static String parsePackageName(String packageFilePath, int flags) {
+ /*
+ * Utility method that retrieves just the package name and install
+ * location from the apk location at the given file path.
+ * @param packageFilePath file location of the apk
+ * @param flags Special parse flags
+ * @return PackageLite object with package information.
+ */
+ public static PackageLite parsePackageLite(String packageFilePath, int flags) {
XmlResourceParser parser = null;
AssetManager assmgr = null;
try {
@@ -577,9 +597,9 @@ public class PackageParser {
}
AttributeSet attrs = parser;
String errors[] = new String[1];
- String packageName = null;
+ PackageLite packageLite = null;
try {
- packageName = parsePackageName(parser, attrs, flags, errors);
+ packageLite = parsePackageLite(parser, attrs, flags, errors);
} catch (IOException e) {
Log.w(TAG, packageFilePath, e);
} catch (XmlPullParserException e) {
@@ -588,11 +608,11 @@ public class PackageParser {
if (parser != null) parser.close();
if (assmgr != null) assmgr.close();
}
- if (packageName == null) {
- Log.e(TAG, "parsePackageName error: " + errors[0]);
+ if (packageLite == null) {
+ Log.e(TAG, "parsePackageLite error: " + errors[0]);
return null;
}
- return packageName;
+ return packageLite;
}
private static String validateName(String name, boolean requiresSeparator) {
@@ -656,6 +676,49 @@ public class PackageParser {
return pkgName.intern();
}
+ private static PackageLite parsePackageLite(XmlPullParser parser,
+ AttributeSet attrs, int flags, String[] outError)
+ throws IOException, XmlPullParserException {
+
+ int type;
+ while ((type=parser.next()) != parser.START_TAG
+ && type != parser.END_DOCUMENT) {
+ ;
+ }
+
+ if (type != parser.START_TAG) {
+ outError[0] = "No start tag found";
+ return null;
+ }
+ if ((flags&PARSE_CHATTY) != 0 && Config.LOGV) Log.v(
+ TAG, "Root element name: '" + parser.getName() + "'");
+ if (!parser.getName().equals("manifest")) {
+ outError[0] = "No <manifest> tag";
+ return null;
+ }
+ String pkgName = attrs.getAttributeValue(null, "package");
+ if (pkgName == null || pkgName.length() == 0) {
+ outError[0] = "<manifest> does not specify package";
+ return null;
+ }
+ String nameError = validateName(pkgName, true);
+ if (nameError != null && !"android".equals(pkgName)) {
+ outError[0] = "<manifest> specifies bad package name \""
+ + pkgName + "\": " + nameError;
+ return null;
+ }
+ int installLocation = PackageInfo.INSTALL_LOCATION_AUTO;
+ for (int i = 0; i < attrs.getAttributeCount(); i++) {
+ String attr = attrs.getAttributeName(i);
+ if (attr.equals("installLocation")) {
+ installLocation = attrs.getAttributeIntValue(i,
+ PackageInfo.INSTALL_LOCATION_AUTO);
+ break;
+ }
+ }
+ return new PackageLite(pkgName.intern(), installLocation);
+ }
+
/**
* Temporary.
*/
diff --git a/core/java/com/android/internal/app/IMediaContainerService.aidl b/core/java/com/android/internal/app/IMediaContainerService.aidl
index c0e9587..fd1fd58 100755
--- a/core/java/com/android/internal/app/IMediaContainerService.aidl
+++ b/core/java/com/android/internal/app/IMediaContainerService.aidl
@@ -18,6 +18,7 @@ package com.android.internal.app;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
+import android.content.pm.PackageInfoLite;
interface IMediaContainerService {
String copyResourceToContainer(in Uri packageURI,
@@ -25,5 +26,5 @@ interface IMediaContainerService {
String key, String resFileName);
boolean copyResource(in Uri packageURI,
in ParcelFileDescriptor outStream);
- int getRecommendedInstallLocation(in Uri fileUri);
+ PackageInfoLite getMinimalPackageInfo(in Uri fileUri);
} \ No newline at end of file
diff --git a/core/java/com/android/internal/content/PackageHelper.java b/core/java/com/android/internal/content/PackageHelper.java
index 04a10b9..de6a175 100644
--- a/core/java/com/android/internal/content/PackageHelper.java
+++ b/core/java/com/android/internal/content/PackageHelper.java
@@ -36,6 +36,8 @@ public class PackageHelper {
public static final int RECOMMEND_INSTALL_EXTERNAL = 2;
public static final int RECOMMEND_FAILED_INSUFFICIENT_STORAGE = -1;
public static final int RECOMMEND_FAILED_INVALID_APK = -2;
+ public static final int RECOMMEND_FAILED_INVALID_LOCATION = -3;
+ public static final int RECOMMEND_FAILED_ALREADY_EXISTS = -4;
private static final boolean localLOGV = true;
private static final String TAG = "PackageHelper";