Bluetooth Settings Policy Transparency

If handleStateChanged() is called after
maybeEnforceRestriction, the disabled switch will be
enabled again, only to be disabled when the user touches it.

Bug: 37737621
Test: make RunSettingsRoboTests -j40 ROBOTEST_FILTER=*BluetoothEnablerTest

Change-Id: I3086806dfd6d911d6d7fca1f1d30fa7d8b8757d1
This commit is contained in:
phweiss
2017-06-02 19:04:56 +02:00
parent 84040fdb8b
commit df4bb2a84f
2 changed files with 24 additions and 3 deletions

View File

@@ -106,7 +106,7 @@ public final class BluetoothEnabler implements SwitchWidgetController.OnSwitchCh
mContext = context;
}
maybeEnforceRestrictions();
final boolean restricted = maybeEnforceRestrictions();
if (mLocalAdapter == null) {
mSwitchWidget.setEnabled(false);
@@ -114,7 +114,9 @@ public final class BluetoothEnabler implements SwitchWidgetController.OnSwitchCh
}
// Bluetooth state is not sticky, so set it manually
handleStateChanged(mLocalAdapter.getBluetoothState());
if (!restricted) {
handleStateChanged(mLocalAdapter.getBluetoothState());
}
mSwitchWidget.startListening();
mContext.registerReceiver(mReceiver, mIntentFilter);