From 2848b50f8bc7baa710b77341e20272010380430b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 6 May 2014 23:15:51 -0400 Subject: [PATCH] catch NameNotFoundException when looking up installer name If an application was installed via ADB, then it won't have an installer package/name set. Therefore, looking up the label will cause a NameNotFoundException, which should be ignored and not passed to the method that called App() since it does not refer to the packageName that the method is trying to look up, but instead the packageName of the missing installer app. --- src/org/fdroid/fdroid/data/App.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/org/fdroid/fdroid/data/App.java b/src/org/fdroid/fdroid/data/App.java index ebed22717..0d6fdc904 100644 --- a/src/org/fdroid/fdroid/data/App.java +++ b/src/org/fdroid/fdroid/data/App.java @@ -188,11 +188,19 @@ public class App extends ValueObject implements Comparable { String installerPackageName = pm.getInstallerPackageName(packageName); - ApplicationInfo installerAppInfo = pm.getApplicationInfo(installerPackageName, - PackageManager.GET_META_DATA); - CharSequence installerPackageLabel = installerAppInfo.loadLabel(pm); + CharSequence installerPackageLabel = null; + if (!TextUtils.isEmpty(installerPackageName)) { + try { + ApplicationInfo installerAppInfo = pm.getApplicationInfo(installerPackageName, + PackageManager.GET_META_DATA); + installerPackageLabel = installerAppInfo.loadLabel(pm); + } catch (NameNotFoundException e) { + Log.d(getClass().getCanonicalName(), e.getMessage()); + } + } if (TextUtils.isEmpty(installerPackageLabel)) installerPackageLabel = installerPackageName; + CharSequence appDescription = appInfo.loadDescription(pm); if (TextUtils.isEmpty(appDescription)) this.summary = "(installed by " + installerPackageLabel + ")";