am c92342bb: Merge "Add user restrictions for bluetooth, sideloading, usb file transfer" into jb-mr2-dev
* commit 'c92342bb01f67597c45f97bbd0debf8221f0ad0d': Add user restrictions for bluetooth, sideloading, usb file transfer
This commit is contained in:
@@ -16814,6 +16814,9 @@ package android.os {
|
||||
field public static final java.lang.String DISALLOW_MODIFY_ACCOUNTS = "no_modify_accounts";
|
||||
field public static final java.lang.String DISALLOW_SHARE_LOCATION = "no_share_location";
|
||||
field public static final java.lang.String DISALLOW_UNINSTALL_APPS = "no_uninstall_apps";
|
||||
field public static final java.lang.String DISALLOW_INSTALL_UNKNOWN_SOURCES = "no_install_unknown_sources";
|
||||
field public static final java.lang.String DISALLOW_CONFIG_BLUETOOTH = "no_config_bluetooth";
|
||||
field public static final java.lang.String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer";
|
||||
}
|
||||
|
||||
public abstract class Vibrator {
|
||||
|
||||
@@ -86,8 +86,42 @@ public class UserManager {
|
||||
* @see #setUserRestrictions(Bundle)
|
||||
* @see #getUserRestrictions()
|
||||
*/
|
||||
|
||||
public static final String DISALLOW_SHARE_LOCATION = "no_share_location";
|
||||
|
||||
/**
|
||||
* Key for user restrictions. Specifies if a user is disallowed from enabling the
|
||||
* "Unknown Sources" setting, that allows installation of apps from unknown sources.
|
||||
* The default value is <code>false</code>.
|
||||
* <p/>
|
||||
* Type: Boolean
|
||||
* @see #setUserRestrictions(Bundle)
|
||||
* @see #getUserRestrictions()
|
||||
*/
|
||||
public static final String DISALLOW_INSTALL_UNKNOWN_SOURCES = "no_install_unknown_sources";
|
||||
|
||||
/**
|
||||
* Key for user restrictions. Specifies if a user is disallowed from configuring bluetooth.
|
||||
* The default value is <code>false</code>.
|
||||
* <p/>
|
||||
* Type: Boolean
|
||||
* @see #setUserRestrictions(Bundle)
|
||||
* @see #getUserRestrictions()
|
||||
*/
|
||||
public static final String DISALLOW_CONFIG_BLUETOOTH = "no_config_bluetooth";
|
||||
|
||||
|
||||
/**
|
||||
* Key for user restrictions. Specifies if a user is disallowed from transferring files over
|
||||
* USB. The default value is <code>false</code>.
|
||||
* <p/>
|
||||
* Type: Boolean
|
||||
* @see #setUserRestrictions(Bundle)
|
||||
* @see #getUserRestrictions()
|
||||
*/
|
||||
public static final String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer";
|
||||
|
||||
|
||||
/** @hide */
|
||||
public UserManager(Context context, IUserManager service) {
|
||||
mService = service;
|
||||
@@ -130,7 +164,7 @@ public class UserManager {
|
||||
/**
|
||||
* Used to determine whether the user making this call is subject to
|
||||
* teleportations.
|
||||
* @return whether the user making this call is a goat
|
||||
* @return whether the user making this call is a goat
|
||||
*/
|
||||
public boolean isUserAGoat() {
|
||||
return false;
|
||||
@@ -271,6 +305,16 @@ public class UserManager {
|
||||
setUserRestrictions(bundle, userHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* Returns whether the current user has been disallowed from performing certain actions
|
||||
* or setting certain settings.
|
||||
* @param restrictionKey the string key representing the restriction
|
||||
*/
|
||||
public boolean hasUserRestriction(String restrictionKey) {
|
||||
return getUserRestrictions().getBoolean(restrictionKey, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the serial number for a user. This is a device-unique
|
||||
* number assigned to that user; if the user is deleted and then a new
|
||||
@@ -465,7 +509,7 @@ public class UserManager {
|
||||
* Returns the maximum number of users that can be created on this device. A return value
|
||||
* of 1 means that it is a single user device.
|
||||
* @hide
|
||||
* @return a value greater than or equal to 1
|
||||
* @return a value greater than or equal to 1
|
||||
*/
|
||||
public static int getMaxSupportedUsers() {
|
||||
// Don't allow multiple users on certain builds
|
||||
@@ -508,13 +552,6 @@ public class UserManager {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the current user is allowed to toggle location sharing settings.
|
||||
* @hide
|
||||
*/
|
||||
public boolean isLocationSharingToggleAllowed() {
|
||||
return !getUserRestrictions().getBoolean(DISALLOW_SHARE_LOCATION, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
|
||||
@@ -98,11 +98,11 @@ public class SettingsHelper {
|
||||
|
||||
private void setGpsLocation(String value) {
|
||||
UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||
if (! um.isLocationSharingToggleAllowed()) {
|
||||
if (um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
|
||||
return;
|
||||
}
|
||||
final String GPS = LocationManager.GPS_PROVIDER;
|
||||
boolean enabled =
|
||||
boolean enabled =
|
||||
GPS.equals(value) ||
|
||||
value.startsWith(GPS + ",") ||
|
||||
value.endsWith("," + GPS) ||
|
||||
|
||||
@@ -906,6 +906,7 @@ public class AccountManagerService
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateAuthToken(String accountType, String authToken) {
|
||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
||||
Log.v(TAG, "invalidateAuthToken: accountType " + accountType
|
||||
@@ -1351,7 +1352,7 @@ public class AccountManagerService
|
||||
String subtitle = "";
|
||||
if (index > 0) {
|
||||
title = titleAndSubtitle.substring(0, index);
|
||||
subtitle = titleAndSubtitle.substring(index + 1);
|
||||
subtitle = titleAndSubtitle.substring(index + 1);
|
||||
}
|
||||
UserHandle user = new UserHandle(userId);
|
||||
n.setLatestEventInfo(mContext, title, subtitle,
|
||||
@@ -1426,8 +1427,7 @@ public class AccountManagerService
|
||||
checkManageAccountsPermission();
|
||||
|
||||
// Is user disallowed from modifying accounts?
|
||||
if (getUserManager().getUserRestrictions(Binder.getCallingUserHandle())
|
||||
.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false)) {
|
||||
if (getUserManager().hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) {
|
||||
try {
|
||||
response.onError(AccountManager.ERROR_CODE_USER_RESTRICTED,
|
||||
"User is not allowed to add an account!");
|
||||
@@ -2570,9 +2570,7 @@ public class AccountManagerService
|
||||
|
||||
private boolean canUserModifyAccounts(int callingUid) {
|
||||
if (callingUid != android.os.Process.myUid()) {
|
||||
Bundle restrictions = getUserManager().getUserRestrictions(
|
||||
new UserHandle(UserHandle.getUserId(callingUid)));
|
||||
if (restrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false)) {
|
||||
if (getUserManager().hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.RestrictionEntry;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.UserInfo;
|
||||
@@ -619,6 +618,10 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
writeBoolean(serializer, restrictions, UserManager.DISALLOW_INSTALL_APPS);
|
||||
writeBoolean(serializer, restrictions, UserManager.DISALLOW_UNINSTALL_APPS);
|
||||
writeBoolean(serializer, restrictions, UserManager.DISALLOW_SHARE_LOCATION);
|
||||
writeBoolean(serializer, restrictions,
|
||||
UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES);
|
||||
writeBoolean(serializer, restrictions, UserManager.DISALLOW_CONFIG_BLUETOOTH);
|
||||
writeBoolean(serializer, restrictions, UserManager.DISALLOW_USB_FILE_TRANSFER);
|
||||
serializer.endTag(null, TAG_RESTRICTIONS);
|
||||
}
|
||||
serializer.endTag(null, TAG_USER);
|
||||
@@ -735,6 +738,10 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
readBoolean(parser, restrictions, UserManager.DISALLOW_INSTALL_APPS);
|
||||
readBoolean(parser, restrictions, UserManager.DISALLOW_UNINSTALL_APPS);
|
||||
readBoolean(parser, restrictions, UserManager.DISALLOW_SHARE_LOCATION);
|
||||
readBoolean(parser, restrictions,
|
||||
UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES);
|
||||
readBoolean(parser, restrictions, UserManager.DISALLOW_CONFIG_BLUETOOTH);
|
||||
readBoolean(parser, restrictions, UserManager.DISALLOW_USB_FILE_TRANSFER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user