summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorPavel Grafov <pgrafov@google.com>2017-01-18 11:15:20 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-01-18 11:15:28 +0000
commiteaed75d923c132f7bb7679d3246a89eff78e6811 (patch)
treeddad6f4c15c10bf4573bf2f422310b602594fe4e /core/java/android
parent311c5d485439cc441ef7bfd6b0304da318fc5edc (diff)
parent6a40f09083fc52acc3309d0b04401fca02df6372 (diff)
Merge "Make ENSURE_VERIFY_APPS global even when set by PO."
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/os/IUserManager.aidl2
-rw-r--r--core/java/android/os/UserManager.aidl20
-rw-r--r--core/java/android/os/UserManager.java94
-rw-r--r--core/java/android/os/UserManagerInternal.java26
4 files changed, 129 insertions, 13 deletions
diff --git a/core/java/android/os/IUserManager.aidl b/core/java/android/os/IUserManager.aidl
index 9513854c1e29..1c2588ada181 100644
--- a/core/java/android/os/IUserManager.aidl
+++ b/core/java/android/os/IUserManager.aidl
@@ -19,6 +19,7 @@ package android.os;
import android.os.Bundle;
import android.os.PersistableBundle;
+import android.os.UserManager;
import android.content.pm.UserInfo;
import android.content.IntentSender;
import android.content.RestrictionEntry;
@@ -61,6 +62,7 @@ interface IUserManager {
int getUserSerialNumber(int userHandle);
int getUserHandle(int userSerialNumber);
int getUserRestrictionSource(String restrictionKey, int userHandle);
+ List<UserManager.EnforcingUser> getUserRestrictionSources(String restrictionKey, int userHandle);
Bundle getUserRestrictions(int userHandle);
boolean hasBaseUserRestriction(String restrictionKey, int userHandle);
boolean hasUserRestriction(in String restrictionKey, int userHandle);
diff --git a/core/java/android/os/UserManager.aidl b/core/java/android/os/UserManager.aidl
new file mode 100644
index 000000000000..2611b0f36141
--- /dev/null
+++ b/core/java/android/os/UserManager.aidl
@@ -0,0 +1,20 @@
+/*
+**
+** Copyright 2016, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+package android.os;
+
+parcelable UserManager.EnforcingUser; \ No newline at end of file
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 3478eaa83982..efacb205c36d 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -1187,7 +1187,9 @@ public class UserManager {
* @return The source of user restriction. Any combination of {@link #RESTRICTION_NOT_SET},
* {@link #RESTRICTION_SOURCE_SYSTEM}, {@link #RESTRICTION_SOURCE_DEVICE_OWNER}
* and {@link #RESTRICTION_SOURCE_PROFILE_OWNER}
+ * @deprecated use {@link #getUserRestrictionSources(String, int)} instead.
*/
+ @Deprecated
@SystemApi
@UserRestrictionSource
public int getUserRestrictionSource(String restrictionKey, UserHandle userHandle) {
@@ -1199,6 +1201,25 @@ public class UserManager {
}
/**
+ * @hide
+ *
+ * Returns a list of users who set a user restriction on a given user.
+ * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
+ * @param restrictionKey the string key representing the restriction
+ * @param userHandle the UserHandle of the user for whom to retrieve the restrictions.
+ * @return a list of user ids enforcing this restriction.
+ */
+ @SystemApi
+ public List<EnforcingUser> getUserRestrictionSources(
+ String restrictionKey, UserHandle userHandle) {
+ try {
+ return mService.getUserRestrictionSources(restrictionKey, userHandle.getIdentifier());
+ } catch (RemoteException re) {
+ throw re.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Returns the user-wide restrictions imposed on this user.
* @return a Bundle containing all the restrictions.
*/
@@ -2310,8 +2331,8 @@ public class UserManager {
* @hide
* Checks if any uninitialized user has the specific seed account name and type.
*
- * @param mAccountName The account name to check for
- * @param mAccountType The account type of the account to check for
+ * @param accountName The account name to check for
+ * @param accountType The account type of the account to check for
* @return whether the seed account was found
*/
public boolean someUserHasSeedAccount(String accountName, String accountType) {
@@ -2321,4 +2342,73 @@ public class UserManager {
throw re.rethrowFromSystemServer();
}
}
+
+ /**
+ * @hide
+ * User that enforces a restriction.
+ *
+ * @see #getUserRestrictionSources(String, UserHandle)
+ */
+ @SystemApi
+ public static final class EnforcingUser implements Parcelable {
+ private final @UserIdInt int userId;
+ private final @UserRestrictionSource int userRestrictionSource;
+
+ /**
+ * @hide
+ */
+ public EnforcingUser(
+ @UserIdInt int userId, @UserRestrictionSource int userRestrictionSource) {
+ this.userId = userId;
+ this.userRestrictionSource = userRestrictionSource;
+ }
+
+ private EnforcingUser(Parcel in) {
+ userId = in.readInt();
+ userRestrictionSource = in.readInt();
+ }
+
+ public static final Creator<EnforcingUser> CREATOR = new Creator<EnforcingUser>() {
+ @Override
+ public EnforcingUser createFromParcel(Parcel in) {
+ return new EnforcingUser(in);
+ }
+
+ @Override
+ public EnforcingUser[] newArray(int size) {
+ return new EnforcingUser[size];
+ }
+ };
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(userId);
+ dest.writeInt(userRestrictionSource);
+ }
+
+ /**
+ * Returns an id of the enforcing user.
+ *
+ * <p> Will be UserHandle.USER_NULL when restriction is set by the system.
+ */
+ public UserHandle getUserHandle() {
+ return UserHandle.of(userId);
+ }
+
+ /**
+ * Returns the status of the enforcing user.
+ *
+ * <p> One of {@link #RESTRICTION_SOURCE_SYSTEM},
+ * {@link #RESTRICTION_SOURCE_DEVICE_OWNER} and
+ * {@link #RESTRICTION_SOURCE_PROFILE_OWNER}
+ */
+ public @UserRestrictionSource int getUserRestrictionSource() {
+ return userRestrictionSource;
+ }
+ }
}
diff --git a/core/java/android/os/UserManagerInternal.java b/core/java/android/os/UserManagerInternal.java
index 466a7e35be68..97da5889a186 100644
--- a/core/java/android/os/UserManagerInternal.java
+++ b/core/java/android/os/UserManagerInternal.java
@@ -15,7 +15,6 @@
*/
package android.os;
-import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.pm.UserInfo;
import android.graphics.Bitmap;
@@ -24,6 +23,10 @@ import android.graphics.Bitmap;
* @hide Only for use within the system server.
*/
public abstract class UserManagerInternal {
+ public static final int CAMERA_NOT_DISABLED = 0;
+ public static final int CAMERA_DISABLED_LOCALLY = 1;
+ public static final int CAMERA_DISABLED_GLOBALLY = 2;
+
public interface UserRestrictionsListener {
/**
* Called when a user restriction changes.
@@ -36,18 +39,19 @@ public abstract class UserManagerInternal {
}
/**
- * Called by {@link com.android.server.devicepolicy.DevicePolicyManagerService}
- * to set per-user as well as global user restrictions.
+ * Called by {@link com.android.server.devicepolicy.DevicePolicyManagerService} to set
+ * restrictions enforced by the user.
*
* @param userId target user id for the local restrictions.
- * @param localRestrictions per-user restrictions.
- * Caller must not change it once passed to this method.
- * @param globalRestrictions global restrictions set by DO. Must be null when PO changed user
- * restrictions, in which case global restrictions won't change.
- * Caller must not change it once passed to this method.
- */
- public abstract void setDevicePolicyUserRestrictions(int userId,
- @NonNull Bundle localRestrictions, @Nullable Bundle globalRestrictions);
+ * @param restrictions a bundle of user restrictions.
+ * @param isDeviceOwner whether {@code userId} corresponds to device owner user id.
+ * @param cameraRestrictionScope is camera disabled and if so what is the scope of restriction.
+ * Should be one of {@link #CAMERA_NOT_DISABLED}, {@link #CAMERA_DISABLED_LOCALLY} or
+ * {@link #CAMERA_DISABLED_GLOBALLY}
+ */
+ public abstract void setDevicePolicyUserRestrictions(int userId, @Nullable Bundle restrictions,
+ boolean isDeviceOwner, int cameraRestrictionScope);
+
/**
* Returns the "base" user restrictions.
*