diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index e439beda923..d972e077fdf 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -1124,5 +1124,18 @@ public final class Utils extends com.android.settingslib.Utils { } return false; } + + public static CharSequence getApplicationLabel(Context context, String packageName) { + try { + final ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo( + packageName, + PackageManager.MATCH_DISABLED_COMPONENTS + | PackageManager.MATCH_UNINSTALLED_PACKAGES); + return appInfo.loadLabel(context.getPackageManager()); + } catch (PackageManager.NameNotFoundException e) { + Log.w(TAG, "Unable to find info for package: " + packageName); + } + return null; + } } diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java index 1ef304f74ff..8ad29532721 100755 --- a/src/com/android/settings/applications/InstalledAppDetails.java +++ b/src/com/android/settings/applications/InstalledAppDetails.java @@ -904,25 +904,37 @@ public class InstalledAppDetails extends AppInfoBase } } + addAppInstallerInfoPref(screen); + } + + private void addAppInstallerInfoPref(PreferenceScreen screen) { final String installerPackageName = getContext().getPackageManager().getInstallerPackageName(mPackageName); - if (installerPackageName != null) { - final Intent intent = new Intent(Intent.ACTION_SHOW_APP_INFO) - .setPackage(installerPackageName); - final Intent result = resolveIntent(intent); - if (result != null) { - result.putExtra(Intent.EXTRA_PACKAGE_NAME, mPackageName); - PreferenceCategory category = new PreferenceCategory(getPrefContext()); - category.setTitle(R.string.app_install_details_group_title); - screen.addPreference(category); - Preference pref = new Preference(getPrefContext()); - pref.setTitle(R.string.app_install_details_title); - pref.setKey("app_info_store"); - pref.setSummary(getString(R.string.app_install_details_summary, mAppEntry.label)); - pref.setIntent(result); - category.addPreference(pref); - } + if (installerPackageName == null) { + return; } + final CharSequence installerLabel = Utils.getApplicationLabel(getContext(), + installerPackageName); + if (installerLabel == null) { + return; + } + PreferenceCategory category = new PreferenceCategory(getPrefContext()); + category.setTitle(R.string.app_install_details_group_title); + screen.addPreference(category); + Preference pref = new Preference(getPrefContext()); + pref.setTitle(R.string.app_install_details_title); + pref.setKey("app_info_store"); + pref.setSummary(getString(R.string.app_install_details_summary, installerLabel)); + final Intent intent = new Intent(Intent.ACTION_SHOW_APP_INFO) + .setPackage(installerPackageName); + final Intent result = resolveIntent(intent); + if (result != null) { + result.putExtra(Intent.EXTRA_PACKAGE_NAME, mPackageName); + pref.setIntent(result); + } else { + pref.setEnabled(false); + } + category.addPreference(pref); } private boolean hasPermission(String permission) {