diff options
author | John Spurlock <jspurlock@google.com> | 2013-05-15 09:38:10 -0400 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2013-05-15 10:13:34 -0400 |
commit | 55dbdf68f966d5218a265086f848f60d5a75c13f (patch) | |
tree | 29e31864101f0fea03114139c0df76a8aee4e64d /src/com/android/settings/SecuritySettings.java | |
parent | 00dc15d9dab780e9a61d1b3a20446d6519b5b076 (diff) | |
download | packages_apps_Settings-55dbdf68f966d5218a265086f848f60d5a75c13f.zip packages_apps_Settings-55dbdf68f966d5218a265086f848f60d5a75c13f.tar.gz packages_apps_Settings-55dbdf68f966d5218a265086f848f60d5a75c13f.tar.bz2 |
Hide notification listeners setting if no listeners.
Hide the new notification listeners management setting when
no listeners using this API are available.
Bug: 8454150
Change-Id: Iae9f975e7b5a3cdf55ff7d0c6aea7e84166d53b3
Diffstat (limited to 'src/com/android/settings/SecuritySettings.java')
-rw-r--r-- | src/com/android/settings/SecuritySettings.java | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java index 535d881..948aded 100644 --- a/src/com/android/settings/SecuritySettings.java +++ b/src/com/android/settings/SecuritySettings.java @@ -82,6 +82,7 @@ public class SecuritySettings extends SettingsPreferenceFragment private static final String KEY_NOTIFICATION_ACCESS = "manage_notification_access"; private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive"; + private PackageManager mPM; DevicePolicyManager mDPM; private ChooseLockSettingsHelper mChooseLockSettingsHelper; @@ -111,6 +112,7 @@ public class SecuritySettings extends SettingsPreferenceFragment mLockPatternUtils = new LockPatternUtils(getActivity()); + mPM = getActivity().getPackageManager(); mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE); mChooseLockSettingsHelper = new ChooseLockSettingsHelper(getActivity()); @@ -281,15 +283,24 @@ public class SecuritySettings extends SettingsPreferenceFragment } } - final int n = getNumEnabledNotificationListeners(); mNotificationAccess = findPreference(KEY_NOTIFICATION_ACCESS); - if (n == 0) { - mNotificationAccess.setSummary(getResources().getString( - R.string.manage_notification_access_summary_zero)); - } else { - mNotificationAccess.setSummary(String.format(getResources().getQuantityString( - R.plurals.manage_notification_access_summary_nonzero, - n, n))); + if (mNotificationAccess != null) { + final int total = NotificationAccessSettings.getListenersCount(mPM); + if (total == 0) { + if (deviceAdminCategory != null) { + deviceAdminCategory.removePreference(mNotificationAccess); + } + } else { + final int n = getNumEnabledNotificationListeners(); + if (n == 0) { + mNotificationAccess.setSummary(getResources().getString( + R.string.manage_notification_access_summary_zero)); + } else { + mNotificationAccess.setSummary(String.format(getResources().getQuantityString( + R.plurals.manage_notification_access_summary_nonzero, + n, n))); + } + } } return root; |