Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -31754,6 +31754,7 @@ package android.os { field public static final java.lang.String DISALLOW_APPS_CONTROL = "no_control_apps"; field public static final java.lang.String DISALLOW_AUTOFILL = "no_autofill"; field public static final java.lang.String DISALLOW_BLUETOOTH = "no_bluetooth"; field public static final java.lang.String DISALLOW_BLUETOOTH_SHARING = "no_bluetooth_sharing"; field public static final java.lang.String DISALLOW_CONFIG_BLUETOOTH = "no_config_bluetooth"; field public static final java.lang.String DISALLOW_CONFIG_CELL_BROADCASTS = "no_config_cell_broadcasts"; field public static final java.lang.String DISALLOW_CONFIG_CREDENTIALS = "no_config_credentials"; api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -34622,6 +34622,7 @@ package android.os { field public static final java.lang.String DISALLOW_APPS_CONTROL = "no_control_apps"; field public static final java.lang.String DISALLOW_AUTOFILL = "no_autofill"; field public static final java.lang.String DISALLOW_BLUETOOTH = "no_bluetooth"; field public static final java.lang.String DISALLOW_BLUETOOTH_SHARING = "no_bluetooth_sharing"; field public static final java.lang.String DISALLOW_CONFIG_BLUETOOTH = "no_config_bluetooth"; field public static final java.lang.String DISALLOW_CONFIG_CELL_BROADCASTS = "no_config_cell_broadcasts"; field public static final java.lang.String DISALLOW_CONFIG_CREDENTIALS = "no_config_credentials"; api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -31893,6 +31893,7 @@ package android.os { field public static final java.lang.String DISALLOW_APPS_CONTROL = "no_control_apps"; field public static final java.lang.String DISALLOW_AUTOFILL = "no_autofill"; field public static final java.lang.String DISALLOW_BLUETOOTH = "no_bluetooth"; field public static final java.lang.String DISALLOW_BLUETOOTH_SHARING = "no_bluetooth_sharing"; field public static final java.lang.String DISALLOW_CONFIG_BLUETOOTH = "no_config_bluetooth"; field public static final java.lang.String DISALLOW_CONFIG_CELL_BROADCASTS = "no_config_cell_broadcasts"; field public static final java.lang.String DISALLOW_CONFIG_CREDENTIALS = "no_config_credentials"; core/java/android/os/UserManager.java +18 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ import java.util.List; */ public class UserManager { private static String TAG = "UserManager"; private static final String TAG = "UserManager"; private final IUserManager mService; private final Context mContext; Loading Loading @@ -217,6 +217,23 @@ public class UserManager { */ public static final String DISALLOW_BLUETOOTH = "no_bluetooth"; /** * Specifies if bluetooth sharing is disallowed on the device. Device owner and profile owner * can set this restriction. When it is set by device owner, all users on this device will be * affected. * * <p>Default is <code>true</code> for managed profiles and false for otherwise. When a device * upgrades to {@link android.os.Build.VERSION_CODES#O}, the system sets it for all existing * managed profiles. * * <p>Key for user restrictions. * <p>Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) * @see #getUserRestrictions() */ public static final String DISALLOW_BLUETOOTH_SHARING = "no_bluetooth_sharing"; /** * Specifies if a user is disallowed from transferring files over * USB. This can only be set by device owners and profile owners on the primary user. Loading services/core/java/com/android/server/BluetoothManagerService.java +27 −30 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server; import android.Manifest; import android.app.ActivityManager; import android.app.AppGlobals; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothProfile; import android.bluetooth.IBluetooth; Loading @@ -37,11 +38,11 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.UserInfo; import android.database.ContentObserver; import android.os.Binder; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; Loading @@ -50,7 +51,6 @@ import android.os.Message; import android.os.Process; import android.os.RemoteCallbackList; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.os.UserHandle; import android.os.UserManager; Loading @@ -61,15 +61,15 @@ import android.provider.Settings.SettingNotFoundException; import android.util.Slog; import com.android.internal.util.DumpUtils; import com.android.server.pm.PackageManagerService; import com.android.server.pm.UserRestrictionsUtils; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.HashMap; import java.util.LinkedList; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; class BluetoothManagerService extends IBluetoothManager.Stub { Loading Loading @@ -120,7 +120,6 @@ class BluetoothManagerService extends IBluetoothManager.Stub { private static final int MESSAGE_ADD_PROXY_DELAYED = 400; private static final int MESSAGE_BIND_PROFILE_SERVICE = 401; private static final int MAX_SAVE_RETRIES = 3; private static final int MAX_ERROR_RESTART_RETRIES = 6; // Bluetooth persisted setting is off Loading Loading @@ -223,22 +222,25 @@ class BluetoothManagerService extends IBluetoothManager.Stub { @Override public void onUserRestrictionsChanged(int userId, Bundle newRestrictions, Bundle prevRestrictions) { if (!newRestrictions.containsKey(UserManager.DISALLOW_BLUETOOTH) && !prevRestrictions.containsKey(UserManager.DISALLOW_BLUETOOTH)) { // The relevant restriction has not changed - do nothing. return; if (!UserRestrictionsUtils.restrictionsChanged(prevRestrictions, newRestrictions, UserManager.DISALLOW_BLUETOOTH, UserManager.DISALLOW_BLUETOOTH_SHARING)) { return; // No relevant changes, nothing to do. } final boolean bluetoothDisallowed = newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH); if ((mEnable || mEnableExternal) && bluetoothDisallowed) { final boolean disallowed = newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH); // DISALLOW_BLUETOOTH is a global restriction that can only be set by DO or PO on the // system user, so we only look at the system user. if (userId == UserHandle.USER_SYSTEM && disallowed && (mEnable || mEnableExternal)) { try { disable(null, true); disable(null /* packageName */, true /* persist */); } catch (RemoteException e) { Slog.w(TAG, "Exception when disabling Bluetooth from UserRestrictionsListener", e); Slog.w(TAG, "Exception when disabling Bluetooth", e); } } updateOppLauncherComponentState(bluetoothDisallowed); final boolean sharingDisallowed = disallowed || newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH_SHARING); updateOppLauncherComponentState(userId, sharingDisallowed); } }; Loading Loading @@ -983,11 +985,6 @@ class BluetoothManagerService extends IBluetoothManager.Stub { LocalServices.getService(UserManagerInternal.class); userManagerInternal.addUserRestrictionsListener(mUserRestrictionsListener); final boolean isBluetoothDisallowed = isBluetoothDisallowed(); PackageManagerService packageManagerService = (PackageManagerService) ServiceManager.getService("package"); if (packageManagerService != null && !packageManagerService.isOnlyCoreApps()) { updateOppLauncherComponentState(isBluetoothDisallowed); } if (isBluetoothDisallowed) { return; } Loading Loading @@ -2063,21 +2060,21 @@ class BluetoothManagerService extends IBluetoothManager.Stub { /** * Disables BluetoothOppLauncherActivity component, so the Bluetooth sharing option is not * offered to the user if Bluetooth is disallowed. Puts the component to its default state if * Bluetooth is not disallowed. * offered to the user if Bluetooth or sharing is disallowed. Puts the component to its default * state if Bluetooth is not disallowed. * * @param bluetoothDisallowed whether the {@link UserManager.DISALLOW_BLUETOOTH} user * restriction was set. * @param userId user to disable bluetooth sharing for. * @param bluetoothSharingDisallowed whether bluetooth sharing is disallowed. */ private void updateOppLauncherComponentState(boolean bluetoothDisallowed) { private void updateOppLauncherComponentState(int userId, boolean bluetoothSharingDisallowed) { final ComponentName oppLauncherComponent = new ComponentName("com.android.bluetooth", "com.android.bluetooth.opp.BluetoothOppLauncherActivity"); final int newState = bluetoothDisallowed final int newState = bluetoothSharingDisallowed ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED : PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; try { mContext.getPackageManager() .setComponentEnabledSetting(oppLauncherComponent, newState, 0); final IPackageManager imp = AppGlobals.getPackageManager(); imp.setComponentEnabledSetting(oppLauncherComponent, newState, 0 /* flags */, userId); } catch (Exception e) { // The component was not found, do nothing. } Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -31754,6 +31754,7 @@ package android.os { field public static final java.lang.String DISALLOW_APPS_CONTROL = "no_control_apps"; field public static final java.lang.String DISALLOW_AUTOFILL = "no_autofill"; field public static final java.lang.String DISALLOW_BLUETOOTH = "no_bluetooth"; field public static final java.lang.String DISALLOW_BLUETOOTH_SHARING = "no_bluetooth_sharing"; field public static final java.lang.String DISALLOW_CONFIG_BLUETOOTH = "no_config_bluetooth"; field public static final java.lang.String DISALLOW_CONFIG_CELL_BROADCASTS = "no_config_cell_broadcasts"; field public static final java.lang.String DISALLOW_CONFIG_CREDENTIALS = "no_config_credentials";
api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -34622,6 +34622,7 @@ package android.os { field public static final java.lang.String DISALLOW_APPS_CONTROL = "no_control_apps"; field public static final java.lang.String DISALLOW_AUTOFILL = "no_autofill"; field public static final java.lang.String DISALLOW_BLUETOOTH = "no_bluetooth"; field public static final java.lang.String DISALLOW_BLUETOOTH_SHARING = "no_bluetooth_sharing"; field public static final java.lang.String DISALLOW_CONFIG_BLUETOOTH = "no_config_bluetooth"; field public static final java.lang.String DISALLOW_CONFIG_CELL_BROADCASTS = "no_config_cell_broadcasts"; field public static final java.lang.String DISALLOW_CONFIG_CREDENTIALS = "no_config_credentials";
api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -31893,6 +31893,7 @@ package android.os { field public static final java.lang.String DISALLOW_APPS_CONTROL = "no_control_apps"; field public static final java.lang.String DISALLOW_AUTOFILL = "no_autofill"; field public static final java.lang.String DISALLOW_BLUETOOTH = "no_bluetooth"; field public static final java.lang.String DISALLOW_BLUETOOTH_SHARING = "no_bluetooth_sharing"; field public static final java.lang.String DISALLOW_CONFIG_BLUETOOTH = "no_config_bluetooth"; field public static final java.lang.String DISALLOW_CONFIG_CELL_BROADCASTS = "no_config_cell_broadcasts"; field public static final java.lang.String DISALLOW_CONFIG_CREDENTIALS = "no_config_credentials";
core/java/android/os/UserManager.java +18 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ import java.util.List; */ public class UserManager { private static String TAG = "UserManager"; private static final String TAG = "UserManager"; private final IUserManager mService; private final Context mContext; Loading Loading @@ -217,6 +217,23 @@ public class UserManager { */ public static final String DISALLOW_BLUETOOTH = "no_bluetooth"; /** * Specifies if bluetooth sharing is disallowed on the device. Device owner and profile owner * can set this restriction. When it is set by device owner, all users on this device will be * affected. * * <p>Default is <code>true</code> for managed profiles and false for otherwise. When a device * upgrades to {@link android.os.Build.VERSION_CODES#O}, the system sets it for all existing * managed profiles. * * <p>Key for user restrictions. * <p>Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) * @see #getUserRestrictions() */ public static final String DISALLOW_BLUETOOTH_SHARING = "no_bluetooth_sharing"; /** * Specifies if a user is disallowed from transferring files over * USB. This can only be set by device owners and profile owners on the primary user. Loading
services/core/java/com/android/server/BluetoothManagerService.java +27 −30 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server; import android.Manifest; import android.app.ActivityManager; import android.app.AppGlobals; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothProfile; import android.bluetooth.IBluetooth; Loading @@ -37,11 +38,11 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.UserInfo; import android.database.ContentObserver; import android.os.Binder; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; Loading @@ -50,7 +51,6 @@ import android.os.Message; import android.os.Process; import android.os.RemoteCallbackList; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.os.UserHandle; import android.os.UserManager; Loading @@ -61,15 +61,15 @@ import android.provider.Settings.SettingNotFoundException; import android.util.Slog; import com.android.internal.util.DumpUtils; import com.android.server.pm.PackageManagerService; import com.android.server.pm.UserRestrictionsUtils; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.HashMap; import java.util.LinkedList; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; class BluetoothManagerService extends IBluetoothManager.Stub { Loading Loading @@ -120,7 +120,6 @@ class BluetoothManagerService extends IBluetoothManager.Stub { private static final int MESSAGE_ADD_PROXY_DELAYED = 400; private static final int MESSAGE_BIND_PROFILE_SERVICE = 401; private static final int MAX_SAVE_RETRIES = 3; private static final int MAX_ERROR_RESTART_RETRIES = 6; // Bluetooth persisted setting is off Loading Loading @@ -223,22 +222,25 @@ class BluetoothManagerService extends IBluetoothManager.Stub { @Override public void onUserRestrictionsChanged(int userId, Bundle newRestrictions, Bundle prevRestrictions) { if (!newRestrictions.containsKey(UserManager.DISALLOW_BLUETOOTH) && !prevRestrictions.containsKey(UserManager.DISALLOW_BLUETOOTH)) { // The relevant restriction has not changed - do nothing. return; if (!UserRestrictionsUtils.restrictionsChanged(prevRestrictions, newRestrictions, UserManager.DISALLOW_BLUETOOTH, UserManager.DISALLOW_BLUETOOTH_SHARING)) { return; // No relevant changes, nothing to do. } final boolean bluetoothDisallowed = newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH); if ((mEnable || mEnableExternal) && bluetoothDisallowed) { final boolean disallowed = newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH); // DISALLOW_BLUETOOTH is a global restriction that can only be set by DO or PO on the // system user, so we only look at the system user. if (userId == UserHandle.USER_SYSTEM && disallowed && (mEnable || mEnableExternal)) { try { disable(null, true); disable(null /* packageName */, true /* persist */); } catch (RemoteException e) { Slog.w(TAG, "Exception when disabling Bluetooth from UserRestrictionsListener", e); Slog.w(TAG, "Exception when disabling Bluetooth", e); } } updateOppLauncherComponentState(bluetoothDisallowed); final boolean sharingDisallowed = disallowed || newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH_SHARING); updateOppLauncherComponentState(userId, sharingDisallowed); } }; Loading Loading @@ -983,11 +985,6 @@ class BluetoothManagerService extends IBluetoothManager.Stub { LocalServices.getService(UserManagerInternal.class); userManagerInternal.addUserRestrictionsListener(mUserRestrictionsListener); final boolean isBluetoothDisallowed = isBluetoothDisallowed(); PackageManagerService packageManagerService = (PackageManagerService) ServiceManager.getService("package"); if (packageManagerService != null && !packageManagerService.isOnlyCoreApps()) { updateOppLauncherComponentState(isBluetoothDisallowed); } if (isBluetoothDisallowed) { return; } Loading Loading @@ -2063,21 +2060,21 @@ class BluetoothManagerService extends IBluetoothManager.Stub { /** * Disables BluetoothOppLauncherActivity component, so the Bluetooth sharing option is not * offered to the user if Bluetooth is disallowed. Puts the component to its default state if * Bluetooth is not disallowed. * offered to the user if Bluetooth or sharing is disallowed. Puts the component to its default * state if Bluetooth is not disallowed. * * @param bluetoothDisallowed whether the {@link UserManager.DISALLOW_BLUETOOTH} user * restriction was set. * @param userId user to disable bluetooth sharing for. * @param bluetoothSharingDisallowed whether bluetooth sharing is disallowed. */ private void updateOppLauncherComponentState(boolean bluetoothDisallowed) { private void updateOppLauncherComponentState(int userId, boolean bluetoothSharingDisallowed) { final ComponentName oppLauncherComponent = new ComponentName("com.android.bluetooth", "com.android.bluetooth.opp.BluetoothOppLauncherActivity"); final int newState = bluetoothDisallowed final int newState = bluetoothSharingDisallowed ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED : PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; try { mContext.getPackageManager() .setComponentEnabledSetting(oppLauncherComponent, newState, 0); final IPackageManager imp = AppGlobals.getPackageManager(); imp.setComponentEnabledSetting(oppLauncherComponent, newState, 0 /* flags */, userId); } catch (Exception e) { // The component was not found, do nothing. } Loading