AppWithAdminGrantedPermissionsLister.java revision 01cfb9d8c54dd2c888cea15987e7644e8a78a3e0
1/*
2 * Copyright (C) 2017 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.applications;
18
19import android.app.admin.DevicePolicyManager;
20import android.content.pm.ApplicationInfo;
21import android.content.pm.IPackageManager;
22import android.os.UserManager;
23
24import com.android.settingslib.wrapper.PackageManagerWrapper;
25
26/**
27 * Lists installed apps across all users that have been granted one or more specific permissions by
28 * the admin.
29 */
30public abstract class AppWithAdminGrantedPermissionsLister extends AppLister {
31    private final String[] mPermissions;
32    private final IPackageManager mPackageManagerService;
33    private final DevicePolicyManager mDevicePolicyManager;
34
35    public AppWithAdminGrantedPermissionsLister(String[] permissions,
36            PackageManagerWrapper packageManager, IPackageManager packageManagerService,
37            DevicePolicyManager devicePolicyManager, UserManager userManager) {
38        super(packageManager, userManager);
39        mPermissions = permissions;
40        mPackageManagerService = packageManagerService;
41        mDevicePolicyManager = devicePolicyManager;
42    }
43
44    @Override
45    protected boolean includeInCount(ApplicationInfo info) {
46        return AppWithAdminGrantedPermissionsCounter.includeInCount(mPermissions,
47                mDevicePolicyManager, mPm, mPackageManagerService, info);
48    }
49}
50