Merge "Revert "Don't offer the BT sharing option to the user if BT is disallowed."" am: 0b9a18d21e am: 2d0ad3a9e7
am: e81838f7e1
Change-Id: I62d424e92e10c1604938349e94ae38938557130c
This commit is contained in:
@@ -218,11 +218,6 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
@Override
|
@Override
|
||||||
public void onUserRestrictionsChanged(int userId, Bundle newRestrictions,
|
public void onUserRestrictionsChanged(int userId, Bundle newRestrictions,
|
||||||
Bundle prevRestrictions) {
|
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 =
|
final boolean bluetoothDisallowed =
|
||||||
newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH);
|
newRestrictions.getBoolean(UserManager.DISALLOW_BLUETOOTH);
|
||||||
if ((mEnable || mEnableExternal) && bluetoothDisallowed) {
|
if ((mEnable || mEnableExternal) && bluetoothDisallowed) {
|
||||||
@@ -233,7 +228,6 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
// when from system.
|
// when from system.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateOppLauncherComponentState(bluetoothDisallowed);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -960,9 +954,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
|||||||
UserManagerInternal userManagerInternal =
|
UserManagerInternal userManagerInternal =
|
||||||
LocalServices.getService(UserManagerInternal.class);
|
LocalServices.getService(UserManagerInternal.class);
|
||||||
userManagerInternal.addUserRestrictionsListener(mUserRestrictionsListener);
|
userManagerInternal.addUserRestrictionsListener(mUserRestrictionsListener);
|
||||||
final boolean isBluetoothDisallowed = isBluetoothDisallowed();
|
if (isBluetoothDisallowed()) {
|
||||||
updateOppLauncherComponentState(isBluetoothDisallowed);
|
|
||||||
if (isBluetoothDisallowed) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mEnableExternal && isBluetoothPersistedStateOnBluetooth()) {
|
if (mEnableExternal && isBluetoothPersistedStateOnBluetooth()) {
|
||||||
@@ -2019,24 +2011,6 @@ 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
|
@Override
|
||||||
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
|
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
|
||||||
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
|
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
|
||||||
|
|||||||
Reference in New Issue
Block a user