Make bluetooth switch not discoverable via SliceDeepLinkTrampoline

Bug: 244423101
Test: make RunSettingsRoboTests ROBOTEST_FILTER=BluetoothSwitchPreferenceControllerTest
Test: make RunSettingsRoboTests ROBOTEST_FILTER=BluetoothDashboardFragmentTest
Test: manual test by test apk

Change-Id: I13562d227e06627fac33239a9d21fd405a18d012
This commit is contained in:
changbetty
2022-11-07 07:58:14 +00:00
parent a7b9107027
commit c706aa6108
4 changed files with 125 additions and 5 deletions

View File

@@ -45,6 +45,7 @@ public class BluetoothSwitchPreferenceController
private SwitchWidgetController mSwitch;
private Context mContext;
private FooterPreference mFooterPreference;
private boolean mIsAlwaysDiscoverable;
@VisibleForTesting
AlwaysDiscoverable mAlwaysDiscoverable;
@@ -78,7 +79,9 @@ public class BluetoothSwitchPreferenceController
@Override
public void onStart() {
mBluetoothEnabler.resume(mContext);
mAlwaysDiscoverable.start();
if (mIsAlwaysDiscoverable) {
mAlwaysDiscoverable.start();
}
if (mSwitch != null) {
updateText(mSwitch.isChecked());
}
@@ -87,7 +90,19 @@ public class BluetoothSwitchPreferenceController
@Override
public void onStop() {
mBluetoothEnabler.pause();
mAlwaysDiscoverable.stop();
if (mIsAlwaysDiscoverable) {
mAlwaysDiscoverable.stop();
}
}
/**
* Set whether the device can be discovered. By default the value will be {@code false}.
*
* @param isAlwaysDiscoverable {@code true} if the device can be discovered,
* otherwise {@code false}
*/
public void setAlwaysDiscoverable(boolean isAlwaysDiscoverable) {
mIsAlwaysDiscoverable = isAlwaysDiscoverable;
}
@Override