Debian Codegraph @

core/java/android/app/admin/DevicePolicyCache.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2018 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 package android.app.admin;
17
18 import android.annotation.UserIdInt;
19
20 import com.android.server.LocalServices;
21
22 /**
23 * Stores a copy of the set of device policies maintained by {@link DevicePolicyManager} that
24 * can be accessed from any place without risking dead locks.
25 *
26 * @hide
27 */
28 public abstract class DevicePolicyCache {
29 protected DevicePolicyCache() {
30 }
31
32 /**
33 * @return the instance.
34 */
35 public static DevicePolicyCache getInstance() {
36 final DevicePolicyManagerInternal dpmi =
37 LocalServices.getService(DevicePolicyManagerInternal.class);
38 return (dpmi != null) ? dpmi.getDevicePolicyCache() : EmptyDevicePolicyCache.INSTANCE;
39 }
40
41 /**
42 * See {@link DevicePolicyManager#getScreenCaptureDisabled}
43 */
44 public abstract boolean isScreenCaptureAllowed(@UserIdInt int userHandle);
45
46 /**
47 * Caches {@link DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} of the
48 * given user with {@code null} passed in as argument.
49 */
50 public abstract int getPasswordQuality(@UserIdInt int userHandle);
51
52 /**
53 * Caches {@link DevicePolicyManager#getPermissionPolicy(android.content.ComponentName)} of
54 * the given user.
55 */
56 public abstract int getPermissionPolicy(@UserIdInt int userHandle);
57
58 /**
59 * Caches {@link DevicePolicyManager#canAdminGrantSensorsPermissionsForUser(int)} for the
60 * given user.
61 */
62 public abstract boolean canAdminGrantSensorsPermissionsForUser(@UserIdInt int userHandle);
63
64
65 /**
66 * Empty implementation.
67 */
68 private static class EmptyDevicePolicyCache extends DevicePolicyCache {
69 private static final EmptyDevicePolicyCache INSTANCE = new EmptyDevicePolicyCache();
70
71 @Override
72 public boolean isScreenCaptureAllowed(int userHandle) {
73 return true;
74 }
75
76 @Override
77 public int getPasswordQuality(int userHandle) {
78 return DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
79 }
80
81 @Override
82 public int getPermissionPolicy(int userHandle) {
83 return DevicePolicyManager.PERMISSION_POLICY_PROMPT;
84 }
85
86 @Override
87 public boolean canAdminGrantSensorsPermissionsForUser(int userHandle) {
88 return false;
89 }
90 }
91 }