blob: 93afb4376cf293a6add1599caa6837d9a714da46 [file] [log] [blame]
Makoto Onuki068c54a2015-10-13 14:34:03 -07001/*
Amith Yamasaniea1b9d72016-05-27 15:57:38 +00002 * Copyright (C) 2016 The Android Open Source Project
Makoto Onuki068c54a2015-10-13 14:34:03 -07003 *
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
Amith Yamasaniea1b9d72016-05-27 15:57:38 +000014 * limitations under the License
Makoto Onuki068c54a2015-10-13 14:34:03 -070015 */
16package android.os;
17
Makoto Onuki1a2cd742015-11-16 13:51:27 -080018import android.annotation.NonNull;
19import android.annotation.Nullable;
phweisse9c44062016-02-10 12:57:38 +010020import android.content.pm.UserInfo;
Oleksandr Peletskyi7f1f1df2016-01-18 15:40:21 +010021import android.graphics.Bitmap;
Makoto Onuki1a2cd742015-11-16 13:51:27 -080022
Makoto Onuki068c54a2015-10-13 14:34:03 -070023/**
24 * @hide Only for use within the system server.
25 */
26public abstract class UserManagerInternal {
Makoto Onukid45a4a22015-11-02 17:17:38 -080027 public interface UserRestrictionsListener {
28 /**
29 * Called when a user restriction changes.
30 *
31 * @param userId target user id
32 * @param newRestrictions new user restrictions
33 * @param prevRestrictions user restrictions that were previously set
34 */
35 void onUserRestrictionsChanged(int userId, Bundle newRestrictions, Bundle prevRestrictions);
36 }
37
Makoto Onuki068c54a2015-10-13 14:34:03 -070038 /**
Makoto Onuki1a2cd742015-11-16 13:51:27 -080039 * Called by {@link com.android.server.devicepolicy.DevicePolicyManagerService}
40 * to set per-user as well as global user restrictions.
Makoto Onuki068c54a2015-10-13 14:34:03 -070041 *
Makoto Onuki1a2cd742015-11-16 13:51:27 -080042 * @param userId target user id for the local restrictions.
43 * @param localRestrictions per-user restrictions.
44 * Caller must not change it once passed to this method.
45 * @param globalRestrictions global restrictions set by DO. Must be null when PO changed user
46 * restrictions, in which case global restrictions won't change.
47 * Caller must not change it once passed to this method.
Makoto Onuki068c54a2015-10-13 14:34:03 -070048 */
Makoto Onuki1a2cd742015-11-16 13:51:27 -080049 public abstract void setDevicePolicyUserRestrictions(int userId,
50 @NonNull Bundle localRestrictions, @Nullable Bundle globalRestrictions);
Makoto Onuki068c54a2015-10-13 14:34:03 -070051 /**
52 * Returns the "base" user restrictions.
53 *
54 * Used by {@link com.android.server.devicepolicy.DevicePolicyManagerService} for upgrading
55 * from MNC.
56 */
57 public abstract Bundle getBaseUserRestrictions(int userId);
58
59 /**
60 * Called by {@link com.android.server.devicepolicy.DevicePolicyManagerService} for upgrading
61 * from MNC.
62 */
63 public abstract void setBaseUserRestrictionsByDpmsForMigration(int userId,
64 Bundle baseRestrictions);
Makoto Onukid45a4a22015-11-02 17:17:38 -080065
66 /** Return a user restriction. */
67 public abstract boolean getUserRestriction(int userId, String key);
68
69 /** Adds a listener to user restriction changes. */
70 public abstract void addUserRestrictionsListener(UserRestrictionsListener listener);
71
72 /** Remove a {@link UserRestrictionsListener}. */
73 public abstract void removeUserRestrictionsListener(UserRestrictionsListener listener);
Makoto Onukie7927da2015-11-25 10:05:17 -080074
75 /**
76 * Called by {@link com.android.server.devicepolicy.DevicePolicyManagerService} to update
77 * whether the device is managed by device owner.
78 */
79 public abstract void setDeviceManaged(boolean isManaged);
80
81 /**
82 * Called by {@link com.android.server.devicepolicy.DevicePolicyManagerService} to update
83 * whether the user is managed by profile owner.
84 */
85 public abstract void setUserManaged(int userId, boolean isManaged);
Oleksandr Peletskyi7f1f1df2016-01-18 15:40:21 +010086
87 /**
88 * Called by {@link com.android.server.devicepolicy.DevicePolicyManagerService} to omit
89 * restriction check, because DevicePolicyManager must always be able to set user icon
90 * regardless of any restriction.
91 * Also called by {@link com.android.server.pm.UserManagerService} because the logic of setting
92 * the icon is in this method.
93 */
94 public abstract void setUserIcon(int userId, Bitmap bitmap);
Lenka Trochtovaf348e8e2016-01-07 17:20:34 +010095
96 /**
97 * Called by {@link com.android.server.devicepolicy.DevicePolicyManagerService} to inform the
98 * user manager whether all users should be created ephemeral.
99 */
100 public abstract void setForceEphemeralUsers(boolean forceEphemeralUsers);
101
102 /**
103 * Switches to the system user and deletes all other users.
104 *
105 * <p>Called by the {@link com.android.server.devicepolicy.DevicePolicyManagerService} when
106 * the force-ephemeral-users policy is toggled on to make sure there are no pre-existing
107 * non-ephemeral users left.
108 */
109 public abstract void removeAllUsers();
phweisse9c44062016-02-10 12:57:38 +0100110
111 /**
Lenka Trochtova1ddda472016-02-12 10:42:12 +0100112 * Called by the activity manager when the ephemeral user goes to background and its removal
113 * starts as a result.
114 *
115 * <p>It marks the ephemeral user as disabled in order to prevent it from being re-entered
116 * before its removal finishes.
117 *
118 * @param userId the ID of the ephemeral user.
119 */
120 public abstract void onEphemeralUserStop(int userId);
121
122 /**
phweisse9c44062016-02-10 12:57:38 +0100123 * Same as UserManager.createUser(), but bypasses the check for DISALLOW_ADD_USER.
124 *
125 * <p>Called by the {@link com.android.server.devicepolicy.DevicePolicyManagerService} when
126 * createAndManageUser is called by the device owner.
127 */
128 public abstract UserInfo createUserEvenWhenDisallowed(String name, int flags);
Fyodor Kupolov6c915ea2016-05-09 19:10:53 -0700129
130 /**
131 * Return whether the given user is running in an
Amith Yamasaniea1b9d72016-05-27 15:57:38 +0000132 * {@code UserState.STATE_RUNNING_UNLOCKING} or
133 * {@code UserState.STATE_RUNNING_UNLOCKED} state.
Fyodor Kupolov6c915ea2016-05-09 19:10:53 -0700134 */
135 public abstract boolean isUserUnlockingOrUnlocked(int userId);
136
137 /**
Amith Yamasaniea1b9d72016-05-27 15:57:38 +0000138 * Return whether the given user is running
Fyodor Kupolov6c915ea2016-05-09 19:10:53 -0700139 */
Amith Yamasaniea1b9d72016-05-27 15:57:38 +0000140 public abstract boolean isUserRunning(int userId);
141
142 /**
143 * Set user's running state
144 */
145 public abstract void setUserState(int userId, int userState);
146
147 /**
148 * Remove user's running state
149 */
150 public abstract void removeUserState(int userId);
Makoto Onuki068c54a2015-10-13 14:34:03 -0700151}