blob: ebaf4648d80af16ff654fe794347bc7d9b840181 [file] [log] [blame]
Svetoslav976e8bd2014-07-16 15:12:03 -07001/*
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
17package android.app.admin;
18
Pavel Grafov28939982017-10-03 15:11:52 +010019import android.annotation.UserIdInt;
Sudheer Shanka7a9c34b2016-03-11 12:25:51 -080020import android.content.Intent;
Suprabh Shukla8bea73e2016-03-09 13:01:18 -080021
Svetoslav976e8bd2014-07-16 15:12:03 -070022import java.util.List;
23
24/**
25 * Device policy manager local system service interface.
26 *
27 * @hide Only for use within the system server.
28 */
29public abstract class DevicePolicyManagerInternal {
30
31 /**
Svet Ganov6bd70252014-08-20 09:47:47 -070032 * Listener for changes in the white-listed packages to show cross-profile
33 * widgets.
34 */
35 public interface OnCrossProfileWidgetProvidersChangeListener {
36
37 /**
38 * Called when the white-listed packages to show cross-profile widgets
39 * have changed for a given user.
40 *
41 * @param profileId The profile for which the white-listed packages changed.
42 * @param packages The white-listed packages.
43 */
44 public void onCrossProfileWidgetProvidersChanged(int profileId, List<String> packages);
45 }
46
47 /**
Svetoslav976e8bd2014-07-16 15:12:03 -070048 * Gets the packages whose widget providers are white-listed to be
49 * available in the parent user.
50 *
Makoto Onuki26704952016-06-13 14:50:11 -070051 * <p>This takes the DPMS lock. DO NOT call from PM/UM/AM with their lock held.
52 *
Svetoslav976e8bd2014-07-16 15:12:03 -070053 * @param profileId The profile id.
54 * @return The list of packages if such or empty list if there are
55 * no white-listed packages or the profile id is not a managed
56 * profile.
57 */
58 public abstract List<String> getCrossProfileWidgetProviders(int profileId);
Svet Ganov6bd70252014-08-20 09:47:47 -070059
60 /**
61 * Adds a listener for changes in the white-listed packages to show
62 * cross-profile app widgets.
63 *
Makoto Onuki26704952016-06-13 14:50:11 -070064 * <p>This takes the DPMS lock. DO NOT call from PM/UM/AM with their lock held.
65 *
Svet Ganov6bd70252014-08-20 09:47:47 -070066 * @param listener The listener to add.
67 */
68 public abstract void addOnCrossProfileWidgetProvidersChangeListener(
69 OnCrossProfileWidgetProvidersChangeListener listener);
Zoltan Szatmary-Ban1181ed82015-02-23 17:20:20 +000070
71 /**
72 * Checks if an app with given uid is an active device admin of its user and has the policy
73 * specified.
Makoto Onuki26704952016-06-13 14:50:11 -070074 *
75 * <p>This takes the DPMS lock. DO NOT call from PM/UM/AM with their lock held.
76 *
Zoltan Szatmary-Ban1181ed82015-02-23 17:20:20 +000077 * @param uid App uid.
78 * @param reqPolicy Required policy, for policies see {@link DevicePolicyManager}.
79 * @return true if the uid is an active admin with the given policy.
80 */
81 public abstract boolean isActiveAdminWithPolicy(int uid, int reqPolicy);
Suprabh Shuklad0452522016-03-02 14:33:10 -080082
83 /**
Nicolas Prevot709a63d2016-06-09 13:14:00 +010084 * Creates an intent to show the admin support dialog to say that an action is disallowed by
85 * the device/profile owner.
Sudheer Shanka7a9c34b2016-03-11 12:25:51 -080086 *
Makoto Onuki26704952016-06-13 14:50:11 -070087 * <p>This method does not take the DPMS lock. Safe to be called from anywhere.
Nicolas Prevot709a63d2016-06-09 13:14:00 +010088 * @param userId The user where the action is disallowed.
89 * @param useDefaultIfNoAdmin If true, a non-null intent will be returned, even if we couldn't
90 * find a profile/device owner.
Sudheer Shanka7a9c34b2016-03-11 12:25:51 -080091 * @return The intent to trigger the admin support dialog.
92 */
Nicolas Prevot709a63d2016-06-09 13:14:00 +010093 public abstract Intent createShowAdminSupportIntent(int userId, boolean useDefaultIfNoAdmin);
94
95 /**
96 * Creates an intent to show the admin support dialog showing the admin who has set a user
97 * restriction.
98 *
99 * <p>This method does not take the DPMS lock. Safe to be called from anywhere.
100 * @param userId The user where the user restriction is set.
101 * @return The intent to trigger the admin support dialog, or null if the user restriction is
102 * not enforced by the profile/device owner.
103 */
104 public abstract Intent createUserRestrictionSupportIntent(int userId, String userRestriction);
Benjamin Franzdabae882017-08-08 12:33:19 +0100105
106 /**
107 * Returns whether this user/profile is affiliated with the device.
108 *
109 * <p>
110 * By definition, the user that the device owner runs on is always affiliated with the device.
111 * Any other user/profile is considered affiliated with the device if the set specified by its
112 * profile owner via {@link DevicePolicyManager#setAffiliationIds} intersects with the device
113 * owner's.
114 * <p>
115 * Profile owner on the primary user will never be considered as affiliated as there is no
116 * device owner to be affiliated with.
117 */
118 public abstract boolean isUserAffiliatedWithDevice(int userId);
Pavel Grafov28939982017-10-03 15:11:52 +0100119
120 /**
121 * Reports that a profile has changed to use a unified or separate credential.
122 *
123 * @param userId User ID of the profile.
124 */
125 public abstract void reportSeparateProfileChallengeChanged(@UserIdInt int userId);
Andrew Scull1416bd02018-01-05 18:33:58 +0000126
127 /**
128 * Check whether the user could have their password reset in an untrusted manor due to there
129 * being an admin which can call {@link #resetPassword} to reset the password without knowledge
130 * of the previous password.
131 *
132 * @param userId The user in question
133 */
134 public abstract boolean canUserHaveUntrustedCredentialReset(@UserIdInt int userId);
Vladislav Kuzkokovfef75ee2018-01-22 23:37:14 +0100135
136 /**
137 * Return text of error message if printing is disabled.
138 * Called by Print Service when printing is disabled by PO or DO when printing is attempted.
139 *
140 * @param userId The user in question
141 * @return localized error message
142 */
143 public abstract CharSequence getPrintingDisabledReasonForUser(@UserIdInt int userId);
Svetoslav976e8bd2014-07-16 15:12:03 -0700144}