Refactor permissions code for bluetooth controller enabler am: a8db5ccea8 am: b32159f242
am: 0d337881ad
Change-Id: I99e0d6509d49cf31aa17b9e340bd985ec574531b
This commit is contained in:
@@ -210,12 +210,7 @@ public final class BluetoothEnabler implements SwitchWidgetController.OnSwitchCh
|
||||
*/
|
||||
@VisibleForTesting
|
||||
boolean maybeEnforceRestrictions() {
|
||||
EnforcedAdmin admin = mRestrictionUtils.checkIfRestrictionEnforced(
|
||||
mContext, UserManager.DISALLOW_BLUETOOTH);
|
||||
if (admin == null) {
|
||||
admin = mRestrictionUtils.checkIfRestrictionEnforced(
|
||||
mContext, UserManager.DISALLOW_CONFIG_BLUETOOTH);
|
||||
}
|
||||
EnforcedAdmin admin = getEnforcedAdmin(mRestrictionUtils, mContext);
|
||||
mSwitchWidget.setDisabledByAdmin(admin);
|
||||
if (admin != null) {
|
||||
mSwitchWidget.setChecked(false);
|
||||
@@ -227,4 +222,15 @@ public final class BluetoothEnabler implements SwitchWidgetController.OnSwitchCh
|
||||
return admin != null;
|
||||
}
|
||||
|
||||
public static EnforcedAdmin getEnforcedAdmin(RestrictionUtils mRestrictionUtils,
|
||||
Context mContext) {
|
||||
EnforcedAdmin admin = mRestrictionUtils.checkIfRestrictionEnforced(
|
||||
mContext, UserManager.DISALLOW_BLUETOOTH);
|
||||
if (admin == null) {
|
||||
admin = mRestrictionUtils.checkIfRestrictionEnforced(
|
||||
mContext, UserManager.DISALLOW_CONFIG_BLUETOOTH);
|
||||
}
|
||||
return admin;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user