summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2014-06-14 18:22:56 -0700
committerJeff Sharkey <jsharkey@android.com>2014-06-15 15:50:25 -0700
commit3c2848cebf9d67e4cdf7bb0101e4a3f7553cc124 (patch)
treeccc56f6527897932c45783e12801f04688503ab1 /src
parenta30350feeff336f372d4a73609f957bf48f24608 (diff)
downloadandroid_packages_apps_PackageInstaller-3c2848cebf9d67e4cdf7bb0101e4a3f7553cc124.tar.gz
android_packages_apps_PackageInstaller-3c2848cebf9d67e4cdf7bb0101e4a3f7553cc124.tar.bz2
android_packages_apps_PackageInstaller-3c2848cebf9d67e4cdf7bb0101e4a3f7553cc124.zip
Follow API refactoring.
Now using exceptions for better control flow. Change-Id: I4432721729f6b1878971c99f5eaaa033194cd8ba
Diffstat (limited to 'src')
-rw-r--r--src/com/android/packageinstaller/PackageUtil.java32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/com/android/packageinstaller/PackageUtil.java b/src/com/android/packageinstaller/PackageUtil.java
index 650e7fb1..9876ba5c 100644
--- a/src/com/android/packageinstaller/PackageUtil.java
+++ b/src/com/android/packageinstaller/PackageUtil.java
@@ -22,6 +22,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageParser;
+import android.content.pm.PackageParser.PackageParserException;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
@@ -49,36 +50,35 @@ public class PackageUtil {
* Utility method to get application information for a given {@link File}
*/
public static ApplicationInfo getApplicationInfo(File sourcePath) {
- final String archiveFilePath = sourcePath.getAbsolutePath();
- PackageParser packageParser = new PackageParser(archiveFilePath);
- File sourceFile = new File(archiveFilePath);
+ PackageParser packageParser = new PackageParser(sourcePath);
DisplayMetrics metrics = new DisplayMetrics();
metrics.setToDefaults();
- PackageParser.Package pkg = packageParser.parsePackage(
- sourceFile, archiveFilePath, metrics, 0);
- if (pkg == null) {
+
+ try {
+ PackageParser.Package pkg = packageParser.parseMonolithicPackage(sourcePath, metrics,
+ 0);
+ return pkg.applicationInfo;
+ } catch (PackageParserException e) {
return null;
}
- return pkg.applicationInfo;
}
/**
* Utility method to get package information for a given {@link File}
*/
public static PackageParser.Package getPackageInfo(File sourceFile) {
- final String archiveFilePath = sourceFile.getAbsolutePath();
- PackageParser packageParser = new PackageParser(archiveFilePath);
+ PackageParser packageParser = new PackageParser(sourceFile);
DisplayMetrics metrics = new DisplayMetrics();
metrics.setToDefaults();
- PackageParser.Package pkg = packageParser.parsePackage(sourceFile,
- archiveFilePath, metrics, 0);
- if (pkg == null) {
- return null;
- }
- if (!packageParser.collectManifestDigest(pkg)) {
+
+ try {
+ PackageParser.Package pkg = packageParser.parseMonolithicPackage(sourceFile, metrics,
+ 0);
+ packageParser.collectManifestDigest(pkg);
+ return pkg;
+ } catch (PackageParserException e) {
return null;
}
- return pkg;
}
public static View initSnippet(View snippetView, CharSequence label, Drawable icon) {