• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 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.NotificationListenerService;
23 
24 import com.android.settings.R;
25 
26 public class NotificationAccessSettings extends ManagedServiceSettings {
27     private static final String TAG = NotificationAccessSettings.class.getSimpleName();
28     private static final Config CONFIG = getNotificationListenerConfig();
29 
getNotificationListenerConfig()30     private static Config getNotificationListenerConfig() {
31         final Config c = new Config();
32         c.tag = TAG;
33         c.setting = Settings.Secure.ENABLED_NOTIFICATION_LISTENERS;
34         c.intentAction = NotificationListenerService.SERVICE_INTERFACE;
35         c.permission = android.Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE;
36         c.noun = "notification listener";
37         c.warningDialogTitle = R.string.notification_listener_security_warning_title;
38         c.warningDialogSummary = R.string.notification_listener_security_warning_summary;
39         c.emptyText = R.string.no_notification_listeners;
40         return c;
41     }
42 
43     @Override
getConfig()44     protected Config getConfig() {
45         return CONFIG;
46     }
47 
getListenersCount(PackageManager pm)48     public static int getListenersCount(PackageManager pm) {
49         return getServicesCount(CONFIG, pm);
50     }
51 
getEnabledListenersCount(Context context)52     public static int getEnabledListenersCount(Context context) {
53         return getEnabledServicesCount(CONFIG, context);
54     }
55 }
56