commit | 54c9c90f27710a57329e79029383516c0cc1e7a5 | [log] [tgz] |
---|---|---|
author | Remi NGUYEN VAN <reminv@google.com> | Tue Apr 02 02:23:09 2024 +0000 |
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | Tue Apr 02 02:23:09 2024 +0000 |
tree | 105bac6132df99949775f61125df5009071b3ff9 | |
parent | da9dfa22073629b9388d8f26eb27950daa687530 [diff] | |
parent | 9b7fea5eeedbe29f62cfa5097a5b84cd142cccdb [diff] |
Merge "Obtain BluetoothAdapter through BluetoothManager" into main
diff --git a/Tethering/src/com/android/networkstack/tethering/TetheringDependencies.java b/Tethering/src/com/android/networkstack/tethering/TetheringDependencies.java index 9dfd225..3f86056 100644 --- a/Tethering/src/com/android/networkstack/tethering/TetheringDependencies.java +++ b/Tethering/src/com/android/networkstack/tethering/TetheringDependencies.java
@@ -156,6 +156,7 @@ /** * Get a reference to BluetoothAdapter to be used by tethering. */ + @Nullable public abstract BluetoothAdapter getBluetoothAdapter(); /**
diff --git a/Tethering/src/com/android/networkstack/tethering/TetheringService.java b/Tethering/src/com/android/networkstack/tethering/TetheringService.java index aa73819..623f502 100644 --- a/Tethering/src/com/android/networkstack/tethering/TetheringService.java +++ b/Tethering/src/com/android/networkstack/tethering/TetheringService.java
@@ -30,6 +30,7 @@ import android.app.Service; import android.bluetooth.BluetoothAdapter; +import android.bluetooth.BluetoothManager; import android.content.Context; import android.content.Intent; import android.net.IIntResultListener; @@ -377,7 +378,11 @@ @Override public BluetoothAdapter getBluetoothAdapter() { - return BluetoothAdapter.getDefaultAdapter(); + final BluetoothManager btManager = getSystemService(BluetoothManager.class); + if (btManager == null) { + return null; + } + return btManager.getAdapter(); } }; }