From 937df1cb6f6482ddcdbac769ec6b4069bd9151f7 Mon Sep 17 00:00:00 2001 From: Danny Baumann Date: Thu, 1 Aug 2013 09:43:31 +0200 Subject: Also remove preferences if app is installed, but disabled. Change-Id: I7f23e7a05c336bd16cda3426c7b31922cb92e1b2 JIRA:CYAN-1861 --- .../android/settings/SettingsPreferenceFragment.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java index 3a225f3..421d048 100644 --- a/src/com/android/settings/SettingsPreferenceFragment.java +++ b/src/com/android/settings/SettingsPreferenceFragment.java @@ -22,6 +22,7 @@ import android.app.Fragment; import android.content.ContentResolver; import android.content.DialogInterface; import android.content.Intent; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.net.Uri; @@ -323,15 +324,26 @@ public class SettingsPreferenceFragment extends PreferenceFragment implements Di Matcher matcher = pattern.matcher(intentUri); String packageName = matcher.find() ? matcher.group(1) : null; + boolean available = true; + if (packageName != null) { try { - getPackageManager().getPackageInfo(packageName, 0); + PackageInfo pi = getPackageManager().getPackageInfo(packageName, 0); + if (!pi.applicationInfo.enabled) { + Log.e(TAG, "package " + packageName + " disabled, hiding preference."); + available = false; + } } catch (NameNotFoundException e) { Log.e(TAG, "package " + packageName + " not installed, hiding preference."); - parent.removePreference(preference); - return true; + available = false; } } + + if (!available) { + parent.removePreference(preference); + return true; + } + return false; } } -- cgit v1.1