Refactor Bluetooth scan mode APIs
Removed setScanMode(int, long), setScanMode(int mode) is now a SystemApi. Made getDiscoverableTimeout a public API. setDiscoverableTimeout is now SystemApi. Discoverable timeout is now in seconds everywhere. Tag: #feature Bug: 195150096 Test: Manual Change-Id: Iee0a80b382f601a81f14afd7224637b88fbdf7ce
This commit is contained in:
@@ -31,6 +31,8 @@ import androidx.preference.Preference;
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.bluetooth.BluetoothDiscoverableTimeoutReceiver;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* BluetoothDiscoverableEnabler is a helper to manage the "Discoverable"
|
||||
* checkbox. It sets/unsets discoverability and keeps track of how much time
|
||||
@@ -136,9 +138,8 @@ final class BluetoothDiscoverableEnabler implements Preference.OnPreferenceClick
|
||||
int timeout = getDiscoverableTimeout();
|
||||
long endTimestamp = System.currentTimeMillis() + timeout * 1000L;
|
||||
LocalBluetoothPreferences.persistDiscoverableEndTimestamp(mContext, endTimestamp);
|
||||
|
||||
mBluetoothAdapter
|
||||
.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE, timeout);
|
||||
mBluetoothAdapter.setDiscoverableTimeout(Duration.ofSeconds(timeout));
|
||||
mBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
|
||||
updateCountdownSummary();
|
||||
|
||||
Log.d(TAG, "setEnabled(): enabled = " + enable + "timeout = " + timeout);
|
||||
|
Reference in New Issue
Block a user