Loading core/java/android/provider/Settings.java +0 −5 Original line number Diff line number Diff line Loading @@ -5604,11 +5604,6 @@ public final class Settings { public static final String ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES = "enabled_notification_policy_access_packages"; /** * @hide */ public static final String ENABLED_CONDITION_PROVIDERS = "enabled_condition_providers"; /** @hide */ public static final String BAR_SERVICE_COMPONENT = "bar_service_component"; Loading core/java/android/service/notification/ConditionProviderService.java +2 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,8 @@ import android.util.Log; * the {@link android.Manifest.permission#BIND_CONDITION_PROVIDER_SERVICE} permission * and include an intent filter with the {@link #SERVICE_INTERFACE} action. If you want users to be * able to create and update conditions for this service to monitor, include the * {@link #META_DATA_RULE_TYPE} and {@link #META_DATA_CONFIGURATION_ACTIVITY} tags. For example:</p> * {@link #META_DATA_RULE_TYPE} and {@link #META_DATA_CONFIGURATION_ACTIVITY} tags and request the * {@link android.Manifest.permission#ACCESS_NOTIFICATION_POLICY} permission. For example:</p> * <pre> * <service android:name=".MyConditionProvider" * android:label="@string/service_name" Loading services/core/java/com/android/server/notification/ConditionProviders.java +23 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.notification; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.net.Uri; import android.os.Handler; Loading @@ -29,6 +30,7 @@ import android.service.notification.Condition; import android.service.notification.ConditionProviderService; import android.service.notification.IConditionListener; import android.service.notification.IConditionProvider; import android.text.TextUtils; import android.util.ArrayMap; import android.util.ArraySet; import android.util.Slog; Loading Loading @@ -79,7 +81,7 @@ public class ConditionProviders extends ManagedServices { final Config c = new Config(); c.caption = "condition provider"; c.serviceInterface = ConditionProviderService.SERVICE_INTERFACE; c.secureSettingName = Settings.Secure.ENABLED_CONDITION_PROVIDERS; c.secureSettingName = Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES; c.bindPermission = android.Manifest.permission.BIND_CONDITION_PROVIDER_SERVICE; c.settingsAction = Settings.ACTION_CONDITION_PROVIDER_SETTINGS; c.clientLabel = R.string.condition_provider_service_binding_label; Loading Loading @@ -280,6 +282,26 @@ public class ConditionProviders extends ManagedServices { } } @Override protected ArraySet<ComponentName> loadComponentNamesFromSetting(String settingName, int userId) { final ContentResolver cr = mContext.getContentResolver(); String settingValue = Settings.Secure.getStringForUser( cr, settingName, userId); if (TextUtils.isEmpty(settingValue)) return null; String[] packages = settingValue.split(ENABLED_SERVICES_SEPARATOR); ArraySet<ComponentName> result = new ArraySet<>(packages.length); for (int i = 0; i < packages.length; i++) { if (!TextUtils.isEmpty(packages[i])) { result.addAll(queryPackageForServices(packages[i], userId)); } } return result; } public boolean subscribeIfNecessary(ComponentName component, Uri conditionId) { synchronized (mMutex) { final ConditionRecord r = getRecordLocked(conditionId, component, false /*create*/); Loading services/core/java/com/android/server/notification/ManagedServices.java +21 −12 Original line number Diff line number Diff line Loading @@ -70,7 +70,7 @@ abstract public class ManagedServices { protected final String TAG = getClass().getSimpleName(); protected final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final String ENABLED_SERVICES_SEPARATOR = ":"; protected static final String ENABLED_SERVICES_SEPARATOR = ":"; protected final Context mContext; protected final Object mMutex; Loading Loading @@ -279,7 +279,8 @@ abstract public class ManagedServices { } private ArraySet<ComponentName> loadComponentNamesFromSetting(String settingName, int userId) { protected ArraySet<ComponentName> loadComponentNamesFromSetting(String settingName, int userId) { final ContentResolver cr = mContext.getContentResolver(); String settingValue = Settings.Secure.getStringForUser( cr, Loading Loading @@ -319,7 +320,6 @@ abstract public class ManagedServices { userId); } /** * Remove access for any services that no longer exist. */ Loading @@ -332,18 +332,15 @@ abstract public class ManagedServices { rebuildRestoredPackages(); } private void updateSettingsAccordingToInstalledServices(int userId) { boolean restoredChanged = false; boolean currentChanged = false; Set<ComponentName> restored = loadComponentNamesFromSetting(restoredSettingName(mConfig), userId); Set<ComponentName> current = loadComponentNamesFromSetting(mConfig.secureSettingName, userId); protected Set<ComponentName> queryPackageForServices(String packageName, int userId) { Set<ComponentName> installed = new ArraySet<>(); final PackageManager pm = mContext.getPackageManager(); Intent queryIntent = new Intent(mConfig.serviceInterface); if (!TextUtils.isEmpty(packageName)) { queryIntent.setPackage(packageName); } List<ResolveInfo> installedServices = pm.queryIntentServicesAsUser( new Intent(mConfig.serviceInterface), queryIntent, PackageManager.GET_SERVICES | PackageManager.GET_META_DATA, userId); if (DEBUG) Loading @@ -363,6 +360,18 @@ abstract public class ManagedServices { } installed.add(component); } return installed; } private void updateSettingsAccordingToInstalledServices(int userId) { boolean restoredChanged = false; boolean currentChanged = false; Set<ComponentName> restored = loadComponentNamesFromSetting(restoredSettingName(mConfig), userId); Set<ComponentName> current = loadComponentNamesFromSetting(mConfig.secureSettingName, userId); // Load all services for all packages. Set<ComponentName> installed = queryPackageForServices(null, userId); ArraySet<ComponentName> retained = new ArraySet<>(); Loading Loading
core/java/android/provider/Settings.java +0 −5 Original line number Diff line number Diff line Loading @@ -5604,11 +5604,6 @@ public final class Settings { public static final String ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES = "enabled_notification_policy_access_packages"; /** * @hide */ public static final String ENABLED_CONDITION_PROVIDERS = "enabled_condition_providers"; /** @hide */ public static final String BAR_SERVICE_COMPONENT = "bar_service_component"; Loading
core/java/android/service/notification/ConditionProviderService.java +2 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,8 @@ import android.util.Log; * the {@link android.Manifest.permission#BIND_CONDITION_PROVIDER_SERVICE} permission * and include an intent filter with the {@link #SERVICE_INTERFACE} action. If you want users to be * able to create and update conditions for this service to monitor, include the * {@link #META_DATA_RULE_TYPE} and {@link #META_DATA_CONFIGURATION_ACTIVITY} tags. For example:</p> * {@link #META_DATA_RULE_TYPE} and {@link #META_DATA_CONFIGURATION_ACTIVITY} tags and request the * {@link android.Manifest.permission#ACCESS_NOTIFICATION_POLICY} permission. For example:</p> * <pre> * <service android:name=".MyConditionProvider" * android:label="@string/service_name" Loading
services/core/java/com/android/server/notification/ConditionProviders.java +23 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.notification; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.net.Uri; import android.os.Handler; Loading @@ -29,6 +30,7 @@ import android.service.notification.Condition; import android.service.notification.ConditionProviderService; import android.service.notification.IConditionListener; import android.service.notification.IConditionProvider; import android.text.TextUtils; import android.util.ArrayMap; import android.util.ArraySet; import android.util.Slog; Loading Loading @@ -79,7 +81,7 @@ public class ConditionProviders extends ManagedServices { final Config c = new Config(); c.caption = "condition provider"; c.serviceInterface = ConditionProviderService.SERVICE_INTERFACE; c.secureSettingName = Settings.Secure.ENABLED_CONDITION_PROVIDERS; c.secureSettingName = Settings.Secure.ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES; c.bindPermission = android.Manifest.permission.BIND_CONDITION_PROVIDER_SERVICE; c.settingsAction = Settings.ACTION_CONDITION_PROVIDER_SETTINGS; c.clientLabel = R.string.condition_provider_service_binding_label; Loading Loading @@ -280,6 +282,26 @@ public class ConditionProviders extends ManagedServices { } } @Override protected ArraySet<ComponentName> loadComponentNamesFromSetting(String settingName, int userId) { final ContentResolver cr = mContext.getContentResolver(); String settingValue = Settings.Secure.getStringForUser( cr, settingName, userId); if (TextUtils.isEmpty(settingValue)) return null; String[] packages = settingValue.split(ENABLED_SERVICES_SEPARATOR); ArraySet<ComponentName> result = new ArraySet<>(packages.length); for (int i = 0; i < packages.length; i++) { if (!TextUtils.isEmpty(packages[i])) { result.addAll(queryPackageForServices(packages[i], userId)); } } return result; } public boolean subscribeIfNecessary(ComponentName component, Uri conditionId) { synchronized (mMutex) { final ConditionRecord r = getRecordLocked(conditionId, component, false /*create*/); Loading
services/core/java/com/android/server/notification/ManagedServices.java +21 −12 Original line number Diff line number Diff line Loading @@ -70,7 +70,7 @@ abstract public class ManagedServices { protected final String TAG = getClass().getSimpleName(); protected final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final String ENABLED_SERVICES_SEPARATOR = ":"; protected static final String ENABLED_SERVICES_SEPARATOR = ":"; protected final Context mContext; protected final Object mMutex; Loading Loading @@ -279,7 +279,8 @@ abstract public class ManagedServices { } private ArraySet<ComponentName> loadComponentNamesFromSetting(String settingName, int userId) { protected ArraySet<ComponentName> loadComponentNamesFromSetting(String settingName, int userId) { final ContentResolver cr = mContext.getContentResolver(); String settingValue = Settings.Secure.getStringForUser( cr, Loading Loading @@ -319,7 +320,6 @@ abstract public class ManagedServices { userId); } /** * Remove access for any services that no longer exist. */ Loading @@ -332,18 +332,15 @@ abstract public class ManagedServices { rebuildRestoredPackages(); } private void updateSettingsAccordingToInstalledServices(int userId) { boolean restoredChanged = false; boolean currentChanged = false; Set<ComponentName> restored = loadComponentNamesFromSetting(restoredSettingName(mConfig), userId); Set<ComponentName> current = loadComponentNamesFromSetting(mConfig.secureSettingName, userId); protected Set<ComponentName> queryPackageForServices(String packageName, int userId) { Set<ComponentName> installed = new ArraySet<>(); final PackageManager pm = mContext.getPackageManager(); Intent queryIntent = new Intent(mConfig.serviceInterface); if (!TextUtils.isEmpty(packageName)) { queryIntent.setPackage(packageName); } List<ResolveInfo> installedServices = pm.queryIntentServicesAsUser( new Intent(mConfig.serviceInterface), queryIntent, PackageManager.GET_SERVICES | PackageManager.GET_META_DATA, userId); if (DEBUG) Loading @@ -363,6 +360,18 @@ abstract public class ManagedServices { } installed.add(component); } return installed; } private void updateSettingsAccordingToInstalledServices(int userId) { boolean restoredChanged = false; boolean currentChanged = false; Set<ComponentName> restored = loadComponentNamesFromSetting(restoredSettingName(mConfig), userId); Set<ComponentName> current = loadComponentNamesFromSetting(mConfig.secureSettingName, userId); // Load all services for all packages. Set<ComponentName> installed = queryPackageForServices(null, userId); ArraySet<ComponentName> retained = new ArraySet<>(); Loading