Makoto Onuki | 068c54a | 2015-10-13 14:34:03 -0700 | [diff] [blame] | 1 | /* |
Amith Yamasani | ea1b9d7 | 2016-05-27 15:57:38 +0000 | [diff] [blame] | 2 | * Copyright (C) 2016 The Android Open Source Project |
Makoto Onuki | 068c54a | 2015-10-13 14:34:03 -0700 | [diff] [blame] | 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 |
Amith Yamasani | ea1b9d7 | 2016-05-27 15:57:38 +0000 | [diff] [blame] | 14 | * limitations under the License |
Makoto Onuki | 068c54a | 2015-10-13 14:34:03 -0700 | [diff] [blame] | 15 | */ |
| 16 | package android.os; |
| 17 | |
Makoto Onuki | 1a2cd74 | 2015-11-16 13:51:27 -0800 | [diff] [blame] | 18 | import android.annotation.NonNull; |
| 19 | import android.annotation.Nullable; |
phweiss | e9c4406 | 2016-02-10 12:57:38 +0100 | [diff] [blame] | 20 | import android.content.pm.UserInfo; |
Oleksandr Peletskyi | 7f1f1df | 2016-01-18 15:40:21 +0100 | [diff] [blame] | 21 | import android.graphics.Bitmap; |
Makoto Onuki | 1a2cd74 | 2015-11-16 13:51:27 -0800 | [diff] [blame] | 22 | |
Makoto Onuki | 068c54a | 2015-10-13 14:34:03 -0700 | [diff] [blame] | 23 | /** |
| 24 | * @hide Only for use within the system server. |
| 25 | */ |
| 26 | public abstract class UserManagerInternal { |
Makoto Onuki | d45a4a2 | 2015-11-02 17:17:38 -0800 | [diff] [blame] | 27 | 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 Onuki | 068c54a | 2015-10-13 14:34:03 -0700 | [diff] [blame] | 38 | /** |
Makoto Onuki | 1a2cd74 | 2015-11-16 13:51:27 -0800 | [diff] [blame] | 39 | * Called by {@link com.android.server.devicepolicy.DevicePolicyManagerService} |
| 40 | * to set per-user as well as global user restrictions. |
Makoto Onuki | 068c54a | 2015-10-13 14:34:03 -0700 | [diff] [blame] | 41 | * |
Makoto Onuki | 1a2cd74 | 2015-11-16 13:51:27 -0800 | [diff] [blame] | 42 | * @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 Onuki | 068c54a | 2015-10-13 14:34:03 -0700 | [diff] [blame] | 48 | */ |
Makoto Onuki | 1a2cd74 | 2015-11-16 13:51:27 -0800 | [diff] [blame] | 49 | public abstract void setDevicePolicyUserRestrictions(int userId, |
| 50 | @NonNull Bundle localRestrictions, @Nullable Bundle globalRestrictions); |
Makoto Onuki | 068c54a | 2015-10-13 14:34:03 -0700 | [diff] [blame] | 51 | /** |
| 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 Onuki | d45a4a2 | 2015-11-02 17:17:38 -0800 | [diff] [blame] | 65 | |
| 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 Onuki | e7927da | 2015-11-25 10:05:17 -0800 | [diff] [blame] | 74 | |
| 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 Peletskyi | 7f1f1df | 2016-01-18 15:40:21 +0100 | [diff] [blame] | 86 | |
| 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 Trochtova | f348e8e | 2016-01-07 17:20:34 +0100 | [diff] [blame] | 95 | |
| 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(); |
phweiss | e9c4406 | 2016-02-10 12:57:38 +0100 | [diff] [blame] | 110 | |
| 111 | /** |
Lenka Trochtova | 1ddda47 | 2016-02-12 10:42:12 +0100 | [diff] [blame] | 112 | * 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 | /** |
phweiss | e9c4406 | 2016-02-10 12:57:38 +0100 | [diff] [blame] | 123 | * 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 Kupolov | 6c915ea | 2016-05-09 19:10:53 -0700 | [diff] [blame] | 129 | |
| 130 | /** |
| 131 | * Return whether the given user is running in an |
Amith Yamasani | ea1b9d7 | 2016-05-27 15:57:38 +0000 | [diff] [blame] | 132 | * {@code UserState.STATE_RUNNING_UNLOCKING} or |
| 133 | * {@code UserState.STATE_RUNNING_UNLOCKED} state. |
Fyodor Kupolov | 6c915ea | 2016-05-09 19:10:53 -0700 | [diff] [blame] | 134 | */ |
| 135 | public abstract boolean isUserUnlockingOrUnlocked(int userId); |
| 136 | |
| 137 | /** |
Amith Yamasani | ea1b9d7 | 2016-05-27 15:57:38 +0000 | [diff] [blame] | 138 | * Return whether the given user is running |
Fyodor Kupolov | 6c915ea | 2016-05-09 19:10:53 -0700 | [diff] [blame] | 139 | */ |
Amith Yamasani | ea1b9d7 | 2016-05-27 15:57:38 +0000 | [diff] [blame] | 140 | 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 Onuki | 068c54a | 2015-10-13 14:34:03 -0700 | [diff] [blame] | 151 | } |