Merge changes I13495cad,I3a44c4c4,I15bff230,I8a492866,Ia7ffe34a
* changes: [Pair hearing devices] Add pair hearing device functionality [Pair hearing devices] Extract common behavior in BluetoothPairingDetail into Base class [Pair hearing devices] Add "Hearing devices" to show connected hearing devices [Pair hearing devices] Add "Saved devices" to show bonded but not connected hearing devices [Audio routing] Setup basic structure for audio routing page
This commit is contained in:
@@ -42,6 +42,9 @@ import com.android.settingslib.bluetooth.BluetoothUtils.ErrorListener;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager.BluetoothManagerCallback;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
/**
|
||||
* Utils is a helper class that contains constants for various
|
||||
* Android resource IDs, debug logging flags, and static methods
|
||||
@@ -132,6 +135,24 @@ public final class Utils {
|
||||
return LocalBluetoothManager.getInstance(context, mOnInitCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a {@link LocalBluetoothManager}.
|
||||
*
|
||||
* To avoid StrictMode ThreadPolicy violation, will get it in another thread.
|
||||
*/
|
||||
public static LocalBluetoothManager getLocalBluetoothManager(Context context) {
|
||||
final FutureTask<LocalBluetoothManager> localBtManagerFutureTask = new FutureTask<>(
|
||||
// Avoid StrictMode ThreadPolicy violation
|
||||
() -> getLocalBtManager(context));
|
||||
try {
|
||||
localBtManagerFutureTask.run();
|
||||
return localBtManagerFutureTask.get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
Log.w(TAG, "Error getting LocalBluetoothManager.", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String createRemoteName(Context context, BluetoothDevice device) {
|
||||
String mRemoteName = device != null ? device.getAlias() : null;
|
||||
|
||||
|
Reference in New Issue
Block a user