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
17package com.android.settings.notification;
18
19import android.content.Context;
20import android.content.pm.PackageManager;
21import android.provider.Settings;
22import android.service.notification.NotificationListenerService;
23
24import com.android.settings.R;
25
26public class NotificationAccessSettings extends ManagedServiceSettings {
27    private static final String TAG = NotificationAccessSettings.class.getSimpleName();
28    private static final Config CONFIG = getNotificationListenerConfig();
29
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
44    protected Config getConfig() {
45        return CONFIG;
46    }
47
48    public static int getListenersCount(PackageManager pm) {
49        return getServicesCount(CONFIG, pm);
50    }
51
52    public static int getEnabledListenersCount(Context context) {
53        return getEnabledServicesCount(CONFIG, context);
54    }
55}
56