1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.settings.notification;
18 
19 import android.content.Context;
20 import android.content.pm.PackageManager;
21 import android.provider.Settings;
22 import android.service.notification.ConditionProviderService;
23 
24 import com.android.settings.R;
25 
26 public class ConditionProviderSettings extends ManagedServiceSettings {
27     private static final String TAG = ConditionProviderSettings.class.getSimpleName();
28     private static final Config CONFIG = getConditionProviderConfig();
29 
getConditionProviderConfig()30     private static Config getConditionProviderConfig() {
31         final Config c = new Config();
32         c.tag = TAG;
33         c.setting = Settings.Secure.ENABLED_CONDITION_PROVIDERS;
34         c.intentAction = ConditionProviderService.SERVICE_INTERFACE;
35         c.permission = android.Manifest.permission.BIND_CONDITION_PROVIDER_SERVICE;
36         c.noun = "condition provider";
37         c.warningDialogTitle = R.string.condition_provider_security_warning_title;
38         c.warningDialogSummary = R.string.condition_provider_security_warning_summary;
39         c.emptyText = R.string.no_condition_providers;
40         return c;
41     }
42 
43     @Override
getConfig()44     protected Config getConfig() {
45         return CONFIG;
46     }
47 
getProviderCount(PackageManager pm)48     public static int getProviderCount(PackageManager pm) {
49         return getServicesCount(CONFIG, pm);
50     }
51 
getEnabledProviderCount(Context context)52     public static int getEnabledProviderCount(Context context) {
53         return getEnabledServicesCount(CONFIG, context);
54     }
55 }
56