Loading service/java/com/android/server/bluetooth/BluetoothManagerService.java +27 −1 Original line number Diff line number Diff line Loading @@ -217,6 +217,11 @@ 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; } final boolean bluetoothDisallowed = newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH); if ((mEnable || mEnableExternal) && bluetoothDisallowed) { Loading @@ -227,6 +232,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { // when from system. } } updateOppLauncherComponentState(bluetoothDisallowed); } }; Loading Loading @@ -938,7 +944,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub { UserManagerInternal userManagerInternal = LocalServices.getService(UserManagerInternal.class); userManagerInternal.addUserRestrictionsListener(mUserRestrictionsListener); if (isBluetoothDisallowed()) { final boolean isBluetoothDisallowed = isBluetoothDisallowed(); updateOppLauncherComponentState(isBluetoothDisallowed); if (isBluetoothDisallowed) { return; } if (mEnableExternal && isBluetoothPersistedStateOnBluetooth()) { Loading Loading @@ -1995,6 +2003,24 @@ 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. * * @param bluetoothDisallowed whether the {@link UserManager.DISALLOW_BLUETOOTH} user * restriction was set. */ private void updateOppLauncherComponentState(boolean bluetoothDisallowed) { final ComponentName oppLauncherComponent = new ComponentName("com.android.bluetooth", "com.android.bluetooth.opp.BluetoothOppLauncherActivity"); final int newState = bluetoothDisallowed ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED : PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; mContext.getPackageManager() .setComponentEnabledSetting(oppLauncherComponent, newState, 0); } @Override public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG); Loading Loading
service/java/com/android/server/bluetooth/BluetoothManagerService.java +27 −1 Original line number Diff line number Diff line Loading @@ -217,6 +217,11 @@ 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; } final boolean bluetoothDisallowed = newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH); if ((mEnable || mEnableExternal) && bluetoothDisallowed) { Loading @@ -227,6 +232,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { // when from system. } } updateOppLauncherComponentState(bluetoothDisallowed); } }; Loading Loading @@ -938,7 +944,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub { UserManagerInternal userManagerInternal = LocalServices.getService(UserManagerInternal.class); userManagerInternal.addUserRestrictionsListener(mUserRestrictionsListener); if (isBluetoothDisallowed()) { final boolean isBluetoothDisallowed = isBluetoothDisallowed(); updateOppLauncherComponentState(isBluetoothDisallowed); if (isBluetoothDisallowed) { return; } if (mEnableExternal && isBluetoothPersistedStateOnBluetooth()) { Loading Loading @@ -1995,6 +2003,24 @@ 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. * * @param bluetoothDisallowed whether the {@link UserManager.DISALLOW_BLUETOOTH} user * restriction was set. */ private void updateOppLauncherComponentState(boolean bluetoothDisallowed) { final ComponentName oppLauncherComponent = new ComponentName("com.android.bluetooth", "com.android.bluetooth.opp.BluetoothOppLauncherActivity"); final int newState = bluetoothDisallowed ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED : PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; mContext.getPackageManager() .setComponentEnabledSetting(oppLauncherComponent, newState, 0); } @Override public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG); Loading