From a94404a89f957c755e0d207e433d1656ebe38215 Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Sun, 18 Aug 2019 07:39:31 -0700 Subject: [PATCH 01/22] Import translations. DO NOT MERGE Auto-generated-cl: translation import Bug: 64712476 Change-Id: I77ea0275cfc385e181171e8eabaa4c7aeadc1a16 (cherry picked from commit 07eca9d081659d389eee129116a1a1e776906888) --- res/values-ja/strings.xml | 2 +- res/values-te/strings.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 27ccaac27de..6171772a063 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -16,7 +16,7 @@ - "ダウンロードマネージャーにアクセスします。" + "ダウンロード マネージャーにアクセスします。" "BluetoothShareマネージャーへのアクセスとそれを利用したファイル転送をアプリに許可します。" "Bluetoothデバイスによるアクセスを許可します。" "Bluetoothデバイスによるアクセスを一時的に許可して、ユーザーの確認を受けずにそのデバイスからこのデバイスにファイルを送信することをアプリに許可します。" diff --git a/res/values-te/strings.xml b/res/values-te/strings.xml index cb26069bfa7..7aaeaa459ff 100644 --- a/res/values-te/strings.xml +++ b/res/values-te/strings.xml @@ -36,7 +36,7 @@ "అంగీకరిస్తున్నాను" "సరే" "\"%1$s\" పంపిన ఇన్‌కమింగ్ ఫైల్‌ను అంగీకరిస్తున్నప్పుడు గడువు సమయం ముగిసింది" - "ఫైల్ స్వీకరణ" + "ఇన్‌క‌మింగ్‌ ఫైల్" "%1$s %2$s ఫైల్ పంపడానికి సిద్ధంగా ఉన్నారు" "బ్లూటూత్ భాగస్వామ్యం: %1$sను స్వీకరిస్తోంది" "బ్లూటూత్ భాగస్వామ్యం: %1$s స్వీకరించబడింది" @@ -104,7 +104,7 @@ "బ్లూటూత్ భాగస్వామ్యం" "%1$s స్వీకరించడం పూర్తయింది." "%1$s పంపడం పూర్తయింది." - "స్వీకృత బదిలీలు" + "ఇన్‌బౌండ్ బదిలీలు" "అవుట్‌బౌండ్ బదిలీలు" "బదిలీ చరిత్ర ఖాళీగా ఉంది." "జాబితా నుండి అన్ని అంశాలు క్లియర్ చేయబడతాయి." From 683a4b5bf75cacfaaa8e4501fadd48ef0f7e5e19 Mon Sep 17 00:00:00 2001 From: Cheney Ni Date: Fri, 23 Aug 2019 23:05:19 +0800 Subject: [PATCH 02/22] AdapterService: Check the PIN code length before using The length is assigned by the framework. We should be better to check again before using, and dropped any unexcepted input. Bug: 139287605 Test: PoC, atest -t BluetoothInstrumentationTests:com.android.bluetooth.btservice Change-Id: Ie2dd01e0b192e7ed1fe4b464618ddfa415dbf15c (cherry picked from commit d6c84aa34962333448e0ed8e4ddbc9de8b73c5ac) --- .../android/bluetooth/btservice/AdapterService.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java index 508eacf684b..53cf7238513 100644 --- a/src/com/android/bluetooth/btservice/AdapterService.java +++ b/src/com/android/bluetooth/btservice/AdapterService.java @@ -2233,6 +2233,12 @@ boolean setPin(BluetoothDevice device, boolean accept, int len, byte[] pinCode) return false; } + if (pinCode.length != len) { + android.util.EventLog.writeEvent(0x534e4554, "139287605", -1, + "PIN code length mismatch"); + return false; + } + StatsLog.write(StatsLog.BLUETOOTH_BOND_STATE_CHANGED, obfuscateAddress(device), 0, device.getType(), BluetoothDevice.BOND_BONDING, @@ -2249,6 +2255,12 @@ boolean setPasskey(BluetoothDevice device, boolean accept, int len, byte[] passk return false; } + if (passkey.length != len) { + android.util.EventLog.writeEvent(0x534e4554, "139287605", -1, + "Passkey length mismatch"); + return false; + } + StatsLog.write(StatsLog.BLUETOOTH_BOND_STATE_CHANGED, obfuscateAddress(device), 0, device.getType(), BluetoothDevice.BOND_BONDING, From 3951034ab2ea3f7e4fe8c5aca24fcf2cb0f6278f Mon Sep 17 00:00:00 2001 From: Alex Cruz Date: Fri, 8 Dec 2017 21:09:35 -0500 Subject: [PATCH 03/22] Fix build error due to missing dependency We're not tracking email common so this causes a build error. If and when we decide to kill off tests completely, then we could revert this but for now, this is the quick fix. Change-Id: I6d5e725dcd7b68038d4cc8a78ae6889fd5021063 --- tests/unit/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/Android.mk b/tests/unit/Android.mk index 98c88d403f0..df666874e2c 100644 --- a/tests/unit/Android.mk +++ b/tests/unit/Android.mk @@ -14,7 +14,7 @@ LOCAL_JAVA_LIBRARIES := \ android.test.mock LOCAL_STATIC_JAVA_LIBRARIES := \ - com.android.emailcommon \ + #com.android.emailcommon \ androidx.test.rules \ mockito-target \ androidx.test.espresso.intents From 826f45a990ab7d6c564c21ca223528c8f25426a0 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Thu, 12 Dec 2019 11:03:14 -0800 Subject: [PATCH 04/22] Enforce BLUETOOTH_PRIVILEGED in setPhonebookAccessPermission Bug: 145130871 Test: POC Merged-In: Ib4985e18de9f6695acc371da78deb240d42671f1 Change-Id: I3b8897166e223179fcbcf8c7a64e0c4d4ca974ef (cherry picked from commit 8d1e8979f56acfe477bd3b84994a716a8391a8eb) --- src/com/android/bluetooth/btservice/AdapterService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java index 53cf7238513..2d3d69e4882 100644 --- a/src/com/android/bluetooth/btservice/AdapterService.java +++ b/src/com/android/bluetooth/btservice/AdapterService.java @@ -2314,6 +2314,8 @@ boolean getSilenceMode(BluetoothDevice device) { } boolean setPhonebookAccessPermission(BluetoothDevice device, int value) { + enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, + "Need BLUETOOTH PRIVILEGED permission"); SharedPreferences pref = getSharedPreferences(PHONEBOOK_ACCESS_PERMISSION_PREFERENCE_FILE, Context.MODE_PRIVATE); SharedPreferences.Editor editor = pref.edit(); From d034c177c56a3797f532e43d3005bfc3a2f55561 Mon Sep 17 00:00:00 2001 From: "slki.shin" Date: Thu, 25 Jul 2019 15:14:43 +0900 Subject: [PATCH 05/22] Fix null pointer exception on AvrcpTargetService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes null pointer exception by simply adding null pointer checker. Problem occurs when sendMediaUpdate() is called just after Avrcp Service is stop()ed. Error Message: java.lang.NullPointerException: Attempt to invoke virtual method ’void com.android.bluetooth.avrcp.AvrcpNativeInterface.sendMediaUpdate(boolean, boolean, boolean)’ on a null object reference Test: Once issue Change-Id: Id42e48faa28ce6c1ec6d4148705d3342261aa6ca Signed-off-by: slki.shin --- src/com/android/bluetooth/avrcp/AvrcpTargetService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/android/bluetooth/avrcp/AvrcpTargetService.java b/src/com/android/bluetooth/avrcp/AvrcpTargetService.java index e2ae494a62a..91d577c7547 100644 --- a/src/com/android/bluetooth/avrcp/AvrcpTargetService.java +++ b/src/com/android/bluetooth/avrcp/AvrcpTargetService.java @@ -68,6 +68,8 @@ class ListCallback implements MediaPlayerList.MediaUpdateCallback, MediaPlayerList.FolderUpdateCallback { @Override public void run(MediaData data) { + if (mNativeInterface == null) return; + boolean metadata = !Objects.equals(mCurrentData.metadata, data.metadata); boolean state = !MediaPlayerWrapper.playstateEquals(mCurrentData.state, data.state); boolean queue = !Objects.equals(mCurrentData.queue, data.queue); @@ -84,6 +86,8 @@ public void run(MediaData data) { @Override public void run(boolean availablePlayers, boolean addressedPlayers, boolean uids) { + if (mNativeInterface == null) return; + mNativeInterface.sendFolderUpdate(availablePlayers, addressedPlayers, uids); } } From d0c4d751a65b435f0a33f92af277f4982e0e0266 Mon Sep 17 00:00:00 2001 From: Michael Bestas Date: Wed, 27 Feb 2019 00:11:55 +0200 Subject: [PATCH 06/22] Bluetooth: Remove unused string resources strings_map.xml was removed in 9905d4a931fb1841afb4a3252954af5751691668 but it was mistakenly added back for some languages in b9b4c8a5d791800f7249f80cd5de0e150ed033f4 Change-Id: Id49aab0526cc571fba60f2e80f56e64b3f1cd9f5 --- res/values-az/strings_map.xml | 15 --------------- res/values-et/strings_map.xml | 15 --------------- res/values-hy/strings_map.xml | 15 --------------- res/values-ka/strings_map.xml | 15 --------------- res/values-km/strings_map.xml | 15 --------------- res/values-lo/strings_map.xml | 15 --------------- res/values-mn/strings_map.xml | 15 --------------- res/values-ms/strings_map.xml | 15 --------------- res/values-ne/strings_map.xml | 15 --------------- res/values-si/strings_map.xml | 15 --------------- 10 files changed, 150 deletions(-) delete mode 100644 res/values-az/strings_map.xml delete mode 100644 res/values-et/strings_map.xml delete mode 100644 res/values-hy/strings_map.xml delete mode 100644 res/values-ka/strings_map.xml delete mode 100644 res/values-km/strings_map.xml delete mode 100644 res/values-lo/strings_map.xml delete mode 100644 res/values-mn/strings_map.xml delete mode 100644 res/values-ms/strings_map.xml delete mode 100644 res/values-ne/strings_map.xml delete mode 100644 res/values-si/strings_map.xml diff --git a/res/values-az/strings_map.xml b/res/values-az/strings_map.xml deleted file mode 100644 index 0b8584e1207..00000000000 --- a/res/values-az/strings_map.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - "%1$s üçün seans açarı daxil edin" - "Bluetooth seans açarı tələb olunur" - "%1$s ilə bağlantı qəbul edərkən fasilə yarandı" - "%1$s ilə seans açarını daxil edərkən fasilə yarandı" - "Obex təsdiqləmə sorğusu" - "Seans Açarı" - "%1$s üçün seans açarı daxil edin" - "Maşın dəsti" - "Naməlum ad" - "Mənim adım" - "000000" - diff --git a/res/values-et/strings_map.xml b/res/values-et/strings_map.xml deleted file mode 100644 index 8fe16424b2b..00000000000 --- a/res/values-et/strings_map.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - "Sisestage seansivõti seadmele %1$s" - "Vajalik Bluetoothi seansivõti" - "Esines ajalõpp ühenduse aktsepteerimiseks seadmega %1$s" - "Esines ajalõpp seansivõtme sisestamiseks seadmele %1$s" - "Obexi autentimise taotlus" - "Seansivõti" - "Sisestage seansivõti seadmele %1$s" - "Autokomplekt" - "Tundmatu nimi" - "Minu nimi" - "000000" - diff --git a/res/values-hy/strings_map.xml b/res/values-hy/strings_map.xml deleted file mode 100644 index 91f2078be59..00000000000 --- a/res/values-hy/strings_map.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - "Մուտքագրեք աշխատաշրջանի բանալին %1$s-ի համար" - "Պահանջվում է Bluetooth-ի աշխատաշրջանի բանալի" - "%1$s-ի հետ կապի ընդունման ժամանակը սպառվեց" - "%1$s-ով աշխատաշրջանի բանալու մուտքագրման ժամանակը սպառվեց" - "Կասեցնել նույնականացման հարցումը" - "Աշխատաշրջանի բանալի" - "Մուտքագրեք աշխատաշրջանի բանալին %1$s-ի համար" - "Carkit" - "Անհայտ անուն" - "Իմ անունը" - "000000" - diff --git a/res/values-ka/strings_map.xml b/res/values-ka/strings_map.xml deleted file mode 100644 index 8e645c4f64a..00000000000 --- a/res/values-ka/strings_map.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - "სესიის გასაღები %1$s-ისთვის" - "აუცილებელია Bluetooth სესიის გასაღები" - "%1$s-თან კავშირის მიღების დრო ამოიწურა" - "%1$s-თან სესიის გასაღების შეყვანის დრო ამოიწურა" - "Obex ავთენტიფიკაციის მოთხოვნა" - "სესიის გასაღები" - "სესიის გასაღები %1$s-ისთვის" - "მანქანის ნაკრები" - "უცნობი სახელი" - "ჩემი სახელი" - "000000" - diff --git a/res/values-km/strings_map.xml b/res/values-km/strings_map.xml deleted file mode 100644 index 8118669863b..00000000000 --- a/res/values-km/strings_map.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - "បញ្ចូល​សោ​សម័យ​សម្រាប់ %1$s" - "បាន​ទាមទារ​សោ​សម័យ​ប៊្លូធូស" - "អស់​ពេល​វេលា​ក្នុង​ការ​ទទួល​យក​ការ​តភ្ជាប់​ជាមួយ %1$s" - "អស់​ពេល​​ដើម្បី​បញ្ចូល​សោ​សម័យ​ជាមួយ %1$s" - "សំណើ​ការ​ផ្ទៀងផ្ទាត់ Obex" - "សោ​សម័យ" - "បញ្ចូល​សោ​សម័យ​សម្រាប់ %1$s" - "Carkit" - "មិន​ស្គាល់​ឈ្មោះ" - "ឈ្មោះ​របស់​ខ្ញុំ" - "000000" - diff --git a/res/values-lo/strings_map.xml b/res/values-lo/strings_map.xml deleted file mode 100644 index dd3a2889ebf..00000000000 --- a/res/values-lo/strings_map.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - "ພິມລະຫັດເຊສຊັນສຳລັບ %1$s" - "ຕ້ອງມີ Bluetooth ລະຫັດເຊສຊັນ" - "ໝົດເວລາທີ່ຈະຮັບການເຊື່ອມຕໍ່ກັບ %1$s" - "ເກີດໝົດເວລາກ່ອນທີ່ຈະໃສ່ລະຫັດເຊສຊັນກັບ %1$s" - "ການຮ້ອງຂໍພິສູດຢືນຢັນໂຕ Obex" - "ກະແຈເຊສຊັສ" - "ພິມລະຫັດເຊສຊັນສຳລັບ %1$s" - "Carkit" - "ບໍ່ຮູ້ຊື່" - "ຊື່ຂອງຂ້ອຍ" - "000000" - diff --git a/res/values-mn/strings_map.xml b/res/values-mn/strings_map.xml deleted file mode 100644 index 45fc07dd457..00000000000 --- a/res/values-mn/strings_map.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - "%1$s-н горимын түлхүүрийг оруулна уу" - "Блютүүт горимын түлхүүр шаардлагатай" - "%1$s-тай холболт хийхийг зөвшөөрөх явцад хугацаа хэтэрсэн байна" - "%1$s-д горимын түлхүүр оруулах явцад хугацаа хэтэрсэн байна" - "Obex гэрчлэлтийн хүсэлт" - "Горимын Түлхүүр" - "%1$s-н горимын түлхүүрийг оруулна уу" - "Carkit" - "Тодорхойгүй нэр" - "Миний нэр" - "000000" - diff --git a/res/values-ms/strings_map.xml b/res/values-ms/strings_map.xml deleted file mode 100644 index afc98d73cfe..00000000000 --- a/res/values-ms/strings_map.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - "Taipkan kunci sesi untuk %1$s" - "Kunci sesi Bluetooth diperlukan" - "Berlaku tamat masa semasa menerima sambungan dengan %1$s" - "Tamat masa berlaku semasa memasukkan kunci sesi dengan %1$s" - "Permintaan pengesahan Obex" - "Kunci Sesi" - "Taipkan kunci sesi untuk %1$s" - "Kit kereta" - "Nama tidak diketahui" - "Nama saya" - "000000" - diff --git a/res/values-ne/strings_map.xml b/res/values-ne/strings_map.xml deleted file mode 100644 index 7584c1ec350..00000000000 --- a/res/values-ne/strings_map.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - "%1$s का लागि सत्र कुञ्जी टाइप गर्नुहोस्" - "ब्लूटूथ सत्र कुञ्जी आवश्यक" - "%1$s सँग जडान स्वीकार गर्न समय सकियो" - "%1$s का साथ सत्र कुञ्जी इनपुट गर्ने समय सकियो" - "Obex प्रमाणिकरण अनुरोध" - "सत्र कुञ्जी" - "%1$s का लागि सत्र कुञ्जी टाइप गर्नुहोस्" - "Carkit" - "अज्ञात नाम" - "मेरो नाम" - "००००००" - diff --git a/res/values-si/strings_map.xml b/res/values-si/strings_map.xml deleted file mode 100644 index 31c2febc809..00000000000 --- a/res/values-si/strings_map.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - "%1$s සඳහා සැසි යතුර ටයිප් කරන්න" - "බ්ලූටූත් සැසි යතුර අවශ්‍යයි" - "%1$s හා සම්බන්ධය පිළිගැනීමට කාල නිමාවක් විය" - "%1$s හා සැසි යතුර ආදානය කිරීමට කාල නිමාවක් විය" - "Obex සත්‍යාපන ඉල්ලීම" - "සැසි යතුර" - "%1$s සඳහා සැසි යතුර ටයිප් කරන්න" - "Carkit" - "නොදන්නා නමකි" - "මගේ නම" - "000000" - From e173a30bd0934b88eb196d0f7796a532941b47d5 Mon Sep 17 00:00:00 2001 From: Nauval Rizky Date: Thu, 23 Jan 2020 02:35:58 +0900 Subject: [PATCH 07/22] Check Null-safeness when switching optional-codecs state When checking the codecs type (if it was SBC or not), there's a chance that they'll throw an NPE and fails to either raise or lowering the SBC priority. Bug: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.bluetooth.BluetoothCodecConfig.isMandatoryCodec()' on a null object reference at com.android.bluetooth.a2dp.A2dpCodecConfig.enableOptionalCodecs(A2dpCodecConfig.java:108) .... java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.bluetooth.BluetoothCodecConfig.isMandatoryCodec()' on a null object reference at com.android.bluetooth.a2dp.A2dpCodecConfig.disableOptionalCodecs(A2dpCodecConfig.java:129) .... Signed-off-by: Nauval Rizky --- src/com/android/bluetooth/a2dp/A2dpCodecConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java b/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java index 918c2cee85d..6a7b49c96f6 100644 --- a/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java +++ b/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java @@ -105,7 +105,7 @@ void enableOptionalCodecs(BluetoothDevice device, BluetoothCodecConfig currentCo // Set the mandatory codec's priority to default, and remove the rest for (int i = 0; i < codecConfigArray.length; i++) { BluetoothCodecConfig codecConfig = codecConfigArray[i]; - if (!codecConfig.isMandatoryCodec()) { + if (codecConfig != null && !codecConfig.isMandatoryCodec()) { codecConfigArray[i] = null; } } @@ -126,7 +126,7 @@ void disableOptionalCodecs(BluetoothDevice device, BluetoothCodecConfig currentC // Set the mandatory codec's priority to highest, and remove the rest for (int i = 0; i < codecConfigArray.length; i++) { BluetoothCodecConfig codecConfig = codecConfigArray[i]; - if (codecConfig.isMandatoryCodec()) { + if (codecConfig != null && codecConfig.isMandatoryCodec()) { codecConfig.setCodecPriority(BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST); } else { codecConfigArray[i] = null; From 17bc80ed63c348765ea12dfa6511822adafc9f2e Mon Sep 17 00:00:00 2001 From: sravan voleti Date: Thu, 28 Feb 2019 14:53:28 +0530 Subject: [PATCH 08/22] Bluetooth: Remove Duplicate permission Remove READ_CONTACTS permission from android manifest to avoid duplicate permission warning after load system image. Test: Rebooted DUT after flash latest BT APK Bug: 126786932 Change-Id: I3ae22d1e97aa717c5fae33e007afa8440a4e3755 Signed-off-by: Mrinal Ghosh --- AndroidManifest.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 8ce4707dc4e..70e13da1dbf 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -58,7 +58,6 @@ - From 8c6b0fc50bc47568c0b2a02dd2091b6d50c8e611 Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Fri, 10 Jan 2020 22:17:08 +0000 Subject: [PATCH 09/22] Remove intent filter without any action Test: Build and observe that the following warning no longer appears in logs: W PackageParser: No actions in intent filter at /system/app/Bluetooth/Bluetooth.apk Binary XML file line #263 Change-Id: I0074a6a18433e7c2f18ad8011084011372abcdfd Signed-off-by: Mrinal Ghosh --- AndroidManifest.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 70e13da1dbf..b524f7b5428 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -226,9 +226,6 @@ android:excludeFromRecents="true" android:theme="@android:style/Theme.Material.Light.Dialog.Alert" android:enabled="@bool/profile_supported_pbap"> - - - Date: Fri, 18 Oct 2019 10:11:39 +0200 Subject: [PATCH 10/22] translate="false" -> translatable="false" Fixed a typo related to String translation Bug: 142888682 Test: Manual Change-Id: I495af9cd2ad6a1e99130af4af1040654478998b4 --- res/values/strings.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 0204f983064..5b2ad949d2a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -228,13 +228,13 @@ Clear - bluetooth_content_share + bluetooth_content_share - + - + Now Playing From 8987b957ccb8d432360223aa7b0eb8688f68801f Mon Sep 17 00:00:00 2001 From: Yinchu Chen Date: Fri, 3 Apr 2020 17:19:11 +0800 Subject: [PATCH 11/22] Bluetooth string: removed id="sender" in bt_sm_2_1_ As there is no value assignment for string id="sender" in string bt_sm_2_1, %1$s will show as garbled char for the user while the capacity of the device is full bug: b/153128298 Signed-off-by: Yinchu Chen Change-Id: Iec7da3fa32b2133263d18bbe3a2f187aa7be99f0 --- res/values/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 5b2ad949d2a..b7dcaf2a99c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -178,9 +178,9 @@ Stopped sending file to \u0022%1$s\u0022 - There isn\'t enough space in USB storage to save the file from \u0022%1$s\u0022 + There isn\'t enough space in USB storage to save the file. - There isn\'t enough space on the SD card to save the file from \u0022%1$s\u0022 + There isn\'t enough space on the SD card to save the file. Space needed: %1$s Too many requests are being processed. Try again later. From d1c3deb2f8327bcf7980ff04bd72f31f0585ccda Mon Sep 17 00:00:00 2001 From: Subramanian Srinivasan Date: Mon, 15 Jan 2018 17:42:09 -0800 Subject: [PATCH 12/22] Add BLE Scan Phy parameter to scan API Add BLE Scan Phy parameter to set scan parameters API. CRs-Fixed: 2237643 Change-Id: I4c6e77cb1dde07896d967957f38dbabb1e5c23b6 --- jni/com_android_bluetooth_gatt.cpp | 21 ++- .../android/bluetooth/gatt/ScanManager.java | 132 ++++++++++++++---- 2 files changed, 124 insertions(+), 29 deletions(-) diff --git a/jni/com_android_bluetooth_gatt.cpp b/jni/com_android_bluetooth_gatt.cpp index 452151547fd..6e16cc113bc 100644 --- a/jni/com_android_bluetooth_gatt.cpp +++ b/jni/com_android_bluetooth_gatt.cpp @@ -1166,11 +1166,24 @@ void set_scan_params_cmpl_cb(int client_if, uint8_t status) { } static void gattSetScanParametersNative(JNIEnv* env, jobject object, - jint client_if, jint scan_interval_unit, - jint scan_window_unit) { + jint client_if, jint scan_phy, + jintArray scan_interval_unit, + jintArray scan_window_unit) { + std::vector scan_interval = {0,0}; + std::vector scan_window = {0,0}; if (!sGattIf) return; + + int scan_int_cnt = env->GetArrayLength(scan_interval_unit); + if(scan_int_cnt > 0) { + env->GetIntArrayRegion(scan_interval_unit, 0, scan_int_cnt, (jint *)&scan_interval[0]); + } + + int scan_window_cnt = env->GetArrayLength(scan_window_unit); + if(scan_window_cnt > 0) { + env->GetIntArrayRegion(scan_window_unit, 0, scan_window_cnt, (jint *)&scan_window[0]); + } sGattIf->scanner->SetScanParameters( - scan_interval_unit, scan_window_unit, + scan_phy, scan_interval, scan_window, base::Bind(&set_scan_params_cmpl_cb, client_if)); } @@ -2129,7 +2142,7 @@ static JNINativeMethod sScanMethods[] = { (void*)gattClientScanFilterClearNative}, {"gattClientScanFilterEnableNative", "(IZ)V", (void*)gattClientScanFilterEnableNative}, - {"gattSetScanParametersNative", "(III)V", + {"gattSetScanParametersNative", "(II[I[I)V", (void*)gattSetScanParametersNative}, }; diff --git a/src/com/android/bluetooth/gatt/ScanManager.java b/src/com/android/bluetooth/gatt/ScanManager.java index 073697821c2..5adb8945ec2 100644 --- a/src/com/android/bluetooth/gatt/ScanManager.java +++ b/src/com/android/bluetooth/gatt/ScanManager.java @@ -20,6 +20,7 @@ import android.app.AlarmManager; import android.app.PendingIntent; import android.bluetooth.BluetoothAdapter; +import android.bluetooth.BluetoothDevice; import android.bluetooth.le.ScanCallback; import android.bluetooth.le.ScanFilter; import android.bluetooth.le.ScanSettings; @@ -83,7 +84,8 @@ public class ScanManager { // Timeout for each controller operation. private static final int OPERATION_TIME_OUT_MILLIS = 500; - private int mLastConfiguredScanSetting = Integer.MIN_VALUE; + private int mLastConfiguredScanSettingLE1M = Integer.MIN_VALUE; + private int mLastConfiguredScanSettingLECoded = Integer.MIN_VALUE; // Scan parameters for batch scan. private BatchScanParams mBatchScanParms; @@ -117,6 +119,18 @@ private class UidImportance { } } + private class PhyInfo { + public int scanPhy; + public int scanModeLE1M; + public int scanModeLECoded; + + PhyInfo(int scanPhy, int scanModeLE1M, int scanModeLECoded) { + this.scanPhy = scanPhy; + this.scanModeLE1M = scanModeLE1M; + this.scanModeLECoded = scanModeLECoded; + } + }; + ScanManager(GattService service) { mRegularScanClients = Collections.newSetFromMap(new ConcurrentHashMap()); @@ -576,40 +590,85 @@ void configureRegularScanParams() { if (DBG) { Log.d(TAG, "configureRegularScanParams() - queue=" + mRegularScanClients.size()); } - int curScanSetting = Integer.MIN_VALUE; + int curScanSettingLE1M = Integer.MIN_VALUE; + int curScanSettingLECoded = Integer.MIN_VALUE; + int scanPhy = BluetoothDevice.PHY_LE_1M; ScanClient client = getAggressiveClient(mRegularScanClients); + PhyInfo phyInfoResult = getPhyInfo(mRegularScanClients); + boolean scanModeChanged = false; + int scanWindowLE1M = Integer.MIN_VALUE; + int scanIntervalLE1M = Integer.MIN_VALUE; + int scanWindowLECoded = Integer.MIN_VALUE; + int scanIntervalLECoded = Integer.MIN_VALUE; + int[] scanInterval = new int[2]; + int[] scanWindow = new int[2]; + int phyCnt = 0; + + if (client != null) { - curScanSetting = client.settings.getScanMode(); + curScanSettingLE1M = phyInfoResult.scanModeLE1M; + curScanSettingLECoded = phyInfoResult.scanModeLECoded; + scanPhy = phyInfoResult.scanPhy; } if (DBG) { - Log.d(TAG, "configureRegularScanParams() - ScanSetting Scan mode=" + curScanSetting - + " mLastConfiguredScanSetting=" + mLastConfiguredScanSetting); + Log.d(TAG, "configureRegularScanParams() - ScanSetting LE 1M Scan mode=" + curScanSettingLE1M + + "ScanSetting LE Coded Scan mode=" + curScanSettingLECoded + + " mLastConfiguredScanSettingLE1M=" + mLastConfiguredScanSettingLE1M + + " mLastConfiguredScanSettingLECoded=" + mLastConfiguredScanSettingLECoded + + "scanPhy=" + scanPhy); + } + + if ((curScanSettingLE1M != Integer.MIN_VALUE + && curScanSettingLE1M != ScanSettings.SCAN_MODE_OPPORTUNISTIC)) { + if (curScanSettingLE1M != mLastConfiguredScanSettingLE1M) { + scanModeChanged = true; + ScanSettings settings = new ScanSettings.Builder().setScanMode(curScanSettingLE1M).build(); + scanWindowLE1M = getScanWindowMillis(settings); + scanIntervalLE1M = getScanIntervalMillis(settings); + // convert scanWindow and scanInterval from ms to LE scan units(0.625ms) + scanWindow[phyCnt] = Utils.millsToUnit(scanWindowLE1M); + scanInterval[phyCnt] = Utils.millsToUnit(scanIntervalLE1M); + phyCnt++; + } } - - if (curScanSetting != Integer.MIN_VALUE - && curScanSetting != ScanSettings.SCAN_MODE_OPPORTUNISTIC) { - if (curScanSetting != mLastConfiguredScanSetting) { - int scanWindow = getScanWindowMillis(client.settings); - int scanInterval = getScanIntervalMillis(client.settings); + else { + mLastConfiguredScanSettingLE1M = curScanSettingLE1M; + if (DBG) { + Log.d(TAG, "configureRegularScanParams() - queue emtpy, scan stopped"); + } + } + if((curScanSettingLECoded != Integer.MIN_VALUE + && curScanSettingLECoded != ScanSettings.SCAN_MODE_OPPORTUNISTIC)) { + if (curScanSettingLECoded != mLastConfiguredScanSettingLECoded) { + scanModeChanged = true; + ScanSettings settings = new ScanSettings.Builder().setScanMode(curScanSettingLECoded).build(); + scanWindowLECoded = getScanWindowMillis(settings); + scanIntervalLECoded = getScanIntervalMillis(settings); // convert scanWindow and scanInterval from ms to LE scan units(0.625ms) - scanWindow = Utils.millsToUnit(scanWindow); - scanInterval = Utils.millsToUnit(scanInterval); - gattClientScanNative(false); - if (DBG) { - Log.d(TAG, "configureRegularScanParams - scanInterval = " + scanInterval - + "configureRegularScanParams - scanWindow = " + scanWindow); - } - gattSetScanParametersNative(client.scannerId, scanInterval, scanWindow); - gattClientScanNative(true); - mLastConfiguredScanSetting = curScanSetting; + scanWindow[phyCnt] = Utils.millsToUnit(scanWindowLECoded); + scanInterval[phyCnt] = Utils.millsToUnit(scanIntervalLECoded); } - } else { - mLastConfiguredScanSetting = curScanSetting; + } + else { + mLastConfiguredScanSettingLECoded = curScanSettingLECoded; if (DBG) { Log.d(TAG, "configureRegularScanParams() - queue emtpy, scan stopped"); } } + if(scanModeChanged) { + gattClientScanNative(false); + if (DBG) { + Log.d(TAG, "configureRegularScanParams - scanInterval LE 1M = " + scanIntervalLE1M + + "configureRegularScanParams - scanWindow LE 1M= " + scanWindowLE1M + + "configureRegularScanParams - scanWindow LE Coded= " + scanWindowLECoded + + "configureRegularScanParams - scanWindow LE Coded= " + scanWindowLECoded); + } + gattSetScanParametersNative(client.scannerId, scanPhy, scanInterval, scanWindow); + gattClientScanNative(true); + mLastConfiguredScanSettingLE1M = curScanSettingLE1M; + mLastConfiguredScanSettingLECoded = curScanSettingLECoded; + } } ScanClient getAggressiveClient(Set cList) { @@ -626,6 +685,29 @@ ScanClient getAggressiveClient(Set cList) { return result; } + PhyInfo getPhyInfo(Set cList) { + PhyInfo result = null; + int curScanSettingLE1M = Integer.MIN_VALUE; + int curScanSettingLECoded = Integer.MIN_VALUE; + int curScanPhy = BluetoothDevice.PHY_LE_1M; + int aggregateScanPhy = BluetoothDevice.PHY_LE_1M; + for (ScanClient client : cList) { + // Get the most aggresive scan mode for each PHY + curScanPhy = client.settings.getPhy(); + if (((curScanPhy & BluetoothDevice.PHY_LE_1M)== BluetoothDevice.PHY_LE_1M) && + (client.settings.getScanMode() > curScanSettingLE1M)) { + curScanSettingLE1M = client.settings.getScanMode(); + } + if (((curScanPhy & BluetoothDevice.PHY_LE_CODED)== BluetoothDevice.PHY_LE_CODED) && + (client.settings.getScanMode() > curScanSettingLECoded)) { + curScanSettingLECoded = client.settings.getScanMode(); + } + aggregateScanPhy |= client.settings.getPhy(); + } + result = new PhyInfo(aggregateScanPhy, curScanSettingLE1M, curScanSettingLECoded); + return result; + } + void startRegularScan(ScanClient client) { if (isFilteringSupported() && mFilterIndexStack.isEmpty() && mClientFilterIndexMap.isEmpty()) { @@ -1266,8 +1348,8 @@ private boolean manageAllocationOfTrackingAdvertisement(int numOfTrackableAdvert private native void gattClientScanNative(boolean start); - private native void gattSetScanParametersNative(int clientIf, int scanInterval, - int scanWindow); + private native void gattSetScanParametersNative(int clientIf, int scan_phy, int[] scanInterval, + int[] scanWindow); /************************** Filter related native methods ********************************/ private native void gattClientScanFilterAddNative(int clientId, From f657eabe7cfdb26acd2e09fb26e5e4c332650a7c Mon Sep 17 00:00:00 2001 From: Srinu Jella Date: Wed, 24 Apr 2019 16:22:51 +0530 Subject: [PATCH 13/22] Bluetooth: Enable Hybrid Audio from App - Use new intent for active device managememt. - Call the new API to update MM supported offload codecs to stack. CRs-Fixed: 2441055 Change-Id: I19e256ae981516e9054b6e6eed8372ae2929b007 --- jni/com_android_bluetooth_a2dp.cpp | 9 ++++++--- src/com/android/bluetooth/a2dp/A2dpNativeInterface.java | 8 +++++--- src/com/android/bluetooth/a2dp/A2dpService.java | 6 +++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/jni/com_android_bluetooth_a2dp.cpp b/jni/com_android_bluetooth_a2dp.cpp index af125bda736..36fa460c4ba 100644 --- a/jni/com_android_bluetooth_a2dp.cpp +++ b/jni/com_android_bluetooth_a2dp.cpp @@ -260,7 +260,8 @@ static std::vector prepareCodecPreferences( static void initNative(JNIEnv* env, jobject object, jint maxConnectedAudioDevices, - jobjectArray codecConfigArray) { + jobjectArray codecConfigArray, + jobjectArray codecConfigOffload) { std::unique_lock interface_lock(interface_mutex); std::unique_lock callbacks_lock(callbacks_mutex); @@ -306,8 +307,10 @@ static void initNative(JNIEnv* env, jobject object, std::vector codec_priorities = prepareCodecPreferences(env, object, codecConfigArray); + std::vector offload_codec_supported = + prepareCodecPreferences(env, object, codecConfigOffload); bt_status_t status = sBluetoothA2dpInterface->init( - &sBluetoothA2dpCallbacks, maxConnectedAudioDevices, codec_priorities); + &sBluetoothA2dpCallbacks, maxConnectedAudioDevices, codec_priorities, offload_codec_supported); if (status != BT_STATUS_SUCCESS) { ALOGE("%s: Failed to initialize Bluetooth A2DP, status: %d", __func__, status); @@ -475,7 +478,7 @@ static jboolean setCodecConfigPreferenceNative(JNIEnv* env, jobject object, static JNINativeMethod sMethods[] = { {"classInitNative", "()V", (void*)classInitNative}, - {"initNative", "(I[Landroid/bluetooth/BluetoothCodecConfig;)V", + {"initNative", "(I[Landroid/bluetooth/BluetoothCodecConfig;[Landroid/bluetooth/BluetoothCodecConfig;)V", (void*)initNative}, {"cleanupNative", "()V", (void*)cleanupNative}, {"connectA2dpNative", "([B)Z", (void*)connectA2dpNative}, diff --git a/src/com/android/bluetooth/a2dp/A2dpNativeInterface.java b/src/com/android/bluetooth/a2dp/A2dpNativeInterface.java index cbdc28a6061..fc08032bbd8 100644 --- a/src/com/android/bluetooth/a2dp/A2dpNativeInterface.java +++ b/src/com/android/bluetooth/a2dp/A2dpNativeInterface.java @@ -75,8 +75,9 @@ public static A2dpNativeInterface getInstance() { * @param codecConfigPriorities an array with the codec configuration * priorities to configure. */ - public void init(int maxConnectedAudioDevices, BluetoothCodecConfig[] codecConfigPriorities) { - initNative(maxConnectedAudioDevices, codecConfigPriorities); + public void init(int maxConnectedAudioDevices, BluetoothCodecConfig[] codecConfigPriorities, + BluetoothCodecConfig[] codecConfigOffload) { + initNative(maxConnectedAudioDevices, codecConfigPriorities, codecConfigOffload); } /** @@ -205,7 +206,8 @@ private void onCodecConfigChanged(byte[] address, // Native methods that call into the JNI interface private static native void classInitNative(); private native void initNative(int maxConnectedAudioDevices, - BluetoothCodecConfig[] codecConfigPriorities); + BluetoothCodecConfig[] codecConfigPriorities, + BluetoothCodecConfig[] codecConfigOffload); private native void cleanupNative(); private native boolean connectA2dpNative(byte[] address); private native boolean disconnectA2dpNative(byte[] address); diff --git a/src/com/android/bluetooth/a2dp/A2dpService.java b/src/com/android/bluetooth/a2dp/A2dpService.java index cebf7676be1..f9d0501c240 100644 --- a/src/com/android/bluetooth/a2dp/A2dpService.java +++ b/src/com/android/bluetooth/a2dp/A2dpService.java @@ -122,8 +122,12 @@ protected boolean start() { mA2dpCodecConfig = new A2dpCodecConfig(this, mA2dpNativeInterface); // Step 5: Initialize native interface + List codecConfigOffload = mAudioManager.getHwOffloadEncodingFormatsSupportedForA2DP(); + BluetoothCodecConfig[] offloadCodecConfig = new BluetoothCodecConfig[codecConfigOffload.size()]; + offloadCodecConfig = codecConfigOffload.toArray(offloadCodecConfig); mA2dpNativeInterface.init(mMaxConnectedAudioDevices, - mA2dpCodecConfig.codecConfigPriorities()); + mA2dpCodecConfig.codecConfigPriorities(), + offloadCodecConfig); // Step 6: Check if A2DP is in offload mode mA2dpOffloadEnabled = mAdapterService.isA2dpOffloadEnabled(); From 17e5133b574fa5c3a3acd0d5d91a19ddbd04a6b5 Mon Sep 17 00:00:00 2001 From: M Safoorah Banu Date: Tue, 16 Oct 2018 10:32:46 +0530 Subject: [PATCH 14/22] BT: API to update quiet mode status in Adapter service [1/3] - In BLE on use case, quiet mode status is not updated to Adapter service which results in not initiating auto connection of hfp & a2dp though quiet mode is disabled for next turn On. - Added new API to update quiet mode status in Adapter service. CRs-Fixed: 2337538 Change-Id: Ifb848e3cc124dd937db09e6d3fbc0996668390ce --- .../bluetooth/btservice/AdapterService.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java index a65bcfdf97f..28a28864da7 100644 --- a/src/com/android/bluetooth/btservice/AdapterService.java +++ b/src/com/android/bluetooth/btservice/AdapterService.java @@ -1726,6 +1726,16 @@ public void onLeServiceUp() { service.onLeServiceUp(); } + @Override + public void updateQuietModeStatus(boolean quietMode) { + AdapterService service = getService(); + if (service == null) { + return; + } + service.updateQuietModeStatus(quietMode); + } + + @Override public void onBrEdrDown() { AdapterService service = getService(); @@ -2548,6 +2558,12 @@ public int getTotalNumOfTrackableAdvertisements() { return mAdapterProperties.getTotalNumOfTrackableAdvertisements(); } + void updateQuietModeStatus(boolean quietMode) { + debugLog("updateQuietModeStatus()-updateQuietModeStatus called with quiet mode status:" + + quietMode); + mQuietmode = quietMode; + } + void onLeServiceUp() { mAdapterStateMachine.sendMessage(AdapterState.USER_TURN_ON); } From 2ab562ab2d8e2afb2d76cf022d86cffef1d2163c Mon Sep 17 00:00:00 2001 From: Venkata Jagadeesh Garaga Date: Thu, 27 Jun 2019 11:24:21 +0530 Subject: [PATCH 15/22] GAP: Reset bondingInitiatedLocally flag(2/3) When Pairing initiated from DUT, bondingIinitiatedLocally flag sets from adapterservice. If user disable profile options from UI and tries to connect from remote,DUT rejects the incoming connection, when dut rejects connection some remotes may initiates pairing agiagn. Profile options should be in disable state after incoming pairing successful as user disabled profile options, but profile options getting enabled as bondingInitiatedLocally not reset. Hence Reset bondingInitiatedLocally flag after connection Change-Id: I1c1fd8681f25a9e957b5c91be51b587011701956 CRs-Fixed: 2457374 --- .../bluetooth/btservice/AdapterService.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java index 28a28864da7..51a9f829403 100644 --- a/src/com/android/bluetooth/btservice/AdapterService.java +++ b/src/com/android/bluetooth/btservice/AdapterService.java @@ -1215,6 +1215,17 @@ public boolean isBondingInitiatedLocally(BluetoothDevice device) { return service.isBondingInitiatedLocally(device); } + @Override + public void setBondingInitiatedLocally(BluetoothDevice device, boolean localInitiated) { + // don't check caller, may be called from system UI + AdapterService service = getService(); + if (service == null) { + return; + } + service.setBondingInitiatedLocally(device,localInitiated); + return; + } + @Override public long getSupportedProfiles() { AdapterService service = getService(); @@ -2136,6 +2147,17 @@ boolean isBondingInitiatedLocally(BluetoothDevice device) { return deviceProp.isBondingInitiatedLocally(); } + void setBondingInitiatedLocally(BluetoothDevice device, boolean localInitiated) { + enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); + DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device); + if (deviceProp == null) { + return; + } + Log.w(TAG," localInitiated " + localInitiated); + deviceProp.setBondingInitiatedLocally(localInitiated); + return; + } + long getSupportedProfiles() { return Config.getSupportedProfilesBitMask(); } From 081c0e330bc000f19dd19b7390bebcd86d486244 Mon Sep 17 00:00:00 2001 From: dianlujitao Date: Thu, 28 May 2020 22:27:32 +0800 Subject: [PATCH 16/22] Stub TWS related APIs Change-Id: I653611fd906e7ab6d1fb7a6dbda57bf8e47d6976 --- src/com/android/bluetooth/btservice/AdapterService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java index 51a9f829403..f4c1dc7ede3 100644 --- a/src/com/android/bluetooth/btservice/AdapterService.java +++ b/src/com/android/bluetooth/btservice/AdapterService.java @@ -1530,6 +1530,14 @@ public boolean sdpSearch(BluetoothDevice device, ParcelUuid uuid) { return service.sdpSearch(device, uuid); } + public boolean isTwsPlusDevice(BluetoothDevice device) { + return false; + } + + public String getTwsPlusPeerAddress(BluetoothDevice device) { + return null; + } + @Override public int getBatteryLevel(BluetoothDevice device) { if (!Utils.checkCaller()) { From a7990c102203b8c22618f50e7b3e1e54232e423d Mon Sep 17 00:00:00 2001 From: ValdikSS Date: Mon, 10 Sep 2018 02:02:50 +0300 Subject: [PATCH 17/22] SBC Dual Channel (SBC HD Audio) support "HD Audio" checkbox is not checked for SBC by default. Change-Id: Id45c48aeaa2eb86f3dffa0cc825d1e09f1c00187 Signed-off-by: spezi77 --- src/com/android/bluetooth/a2dp/A2dpCodecConfig.java | 8 ++++++++ src/com/android/bluetooth/a2dp/A2dpService.java | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java b/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java index adc4b8bf2a9..df885b3ec76 100644 --- a/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java +++ b/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java @@ -109,6 +109,14 @@ void enableOptionalCodecs(BluetoothDevice device, BluetoothCodecConfig currentCo BluetoothCodecConfig codecConfig = codecConfigArray[i]; if (codecConfig != null && !codecConfig.isMandatoryCodec()) { codecConfigArray[i] = null; + } else { + // Rebuild SBC selectable codec with Dual Channel (SBC HD audio) + codecConfigArray[i] = new BluetoothCodecConfig( + BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, mA2dpSourceCodecPrioritySbc, + BluetoothCodecConfig.SAMPLE_RATE_NONE, + BluetoothCodecConfig.BITS_PER_SAMPLE_NONE, + BluetoothCodecConfig.CHANNEL_MODE_DUAL_CHANNEL, 0 /* codecSpecific1 */, + 0 /* codecSpecific2 */, 0 /* codecSpecific3 */, 0 /* codecSpecific4 */); } } diff --git a/src/com/android/bluetooth/a2dp/A2dpService.java b/src/com/android/bluetooth/a2dp/A2dpService.java index f9d0501c240..14df2c7985a 100644 --- a/src/com/android/bluetooth/a2dp/A2dpService.java +++ b/src/com/android/bluetooth/a2dp/A2dpService.java @@ -1039,7 +1039,13 @@ public void updateOptionalCodecsSupport(BluetoothDevice device) { BluetoothCodecStatus codecStatus = sm.getCodecStatus(); if (codecStatus != null) { for (BluetoothCodecConfig config : codecStatus.getCodecsSelectableCapabilities()) { - if (config.isMandatoryCodec()) { + boolean isMandatoryCodecWithDualChannel = (config.isMandatoryCodec() + && (config.getChannelMode() & config.CHANNEL_MODE_DUAL_CHANNEL) + == config.CHANNEL_MODE_DUAL_CHANNEL); + if (isMandatoryCodecWithDualChannel) { + hasMandatoryCodec = true; + supportsOptional = true; + } else if (config.isMandatoryCodec()) { hasMandatoryCodec = true; } else { supportsOptional = true; From f6a500773ae6bbec8c3f118bbad6a7e0270d34aa Mon Sep 17 00:00:00 2001 From: ValdikSS Date: Mon, 17 Sep 2018 19:04:27 +0300 Subject: [PATCH 18/22] Assume optional codecs are supported if were supported previously This fix is required to properly follow codec reconfiguration for SBC HD (SBC Dual Channel) in case of incoming Bluetooth connection. Change-Id: Idb8fce75b4f628ae865fc1d3a787e34b6a29e31e Signed-off-by: spezi77 --- src/com/android/bluetooth/a2dp/A2dpService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/android/bluetooth/a2dp/A2dpService.java b/src/com/android/bluetooth/a2dp/A2dpService.java index 14df2c7985a..e18656a21aa 100644 --- a/src/com/android/bluetooth/a2dp/A2dpService.java +++ b/src/com/android/bluetooth/a2dp/A2dpService.java @@ -1062,11 +1062,11 @@ public void updateOptionalCodecsSupport(BluetoothDevice device) { } if (previousSupport == BluetoothA2dp.OPTIONAL_CODECS_SUPPORT_UNKNOWN - || supportsOptional != (previousSupport - == BluetoothA2dp.OPTIONAL_CODECS_SUPPORTED)) { + || previousSupport == BluetoothA2dp.OPTIONAL_CODECS_NOT_SUPPORTED) { setSupportsOptionalCodecs(device, supportsOptional); } - if (supportsOptional) { + if (supportsOptional + || previousSupport == BluetoothA2dp.OPTIONAL_CODECS_SUPPORTED) { int enabled = getOptionalCodecsEnabled(device); switch (enabled) { case BluetoothA2dp.OPTIONAL_CODECS_PREF_UNKNOWN: From e7b3f08ffffd530f8e26e94455a0351825b1c863 Mon Sep 17 00:00:00 2001 From: Hikari-no-Tenshi Date: Fri, 3 Jul 2020 17:57:23 +0300 Subject: [PATCH 19/22] A2DP codec priority [2/3] @neobuddy89: Simplify and change sequence. Signed-off-by: Pranav Vashi Change-Id: I36f424a9579b8a15cee58f47f31edc5bc99c73ee --- .../bluetooth/a2dp/A2dpCodecConfig.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java b/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java index df885b3ec76..24caf9e30bb 100644 --- a/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java +++ b/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java @@ -22,6 +22,7 @@ import android.content.Context; import android.content.res.Resources; import android.content.res.Resources.NotFoundException; +import android.provider.Settings; import android.util.Log; import com.android.bluetooth.R; @@ -218,6 +219,31 @@ private BluetoothCodecConfig[] assignCodecConfigPriorities() { mA2dpSourceCodecPriorityLdac = value; } + // Set highest codec priority in the end, so that it can override xml values + int codec_priority = Settings.System.getInt(mContext.getContentResolver(), + Settings.System.A2DP_SOURCE_CODEC_PRIORITY, 0); + + switch (codec_priority) { + case 0: + default: + break; + case 1: + mA2dpSourceCodecPrioritySbc = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; + break; + case 2: + mA2dpSourceCodecPriorityAac = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; + break; + case 3: + mA2dpSourceCodecPriorityAptx = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; + break; + case 4: + mA2dpSourceCodecPriorityAptxHd = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; + break; + case 5: + mA2dpSourceCodecPriorityLdac = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST; + break; + } + BluetoothCodecConfig codecConfig; BluetoothCodecConfig[] codecConfigArray = new BluetoothCodecConfig[BluetoothCodecConfig.SOURCE_CODEC_TYPE_MAX]; From c64274d6fe21aa4c242689d7fd1d72011b42f0dc Mon Sep 17 00:00:00 2001 From: Pranav Vashi Date: Wed, 8 Jul 2020 03:23:05 +0530 Subject: [PATCH 20/22] Disable Dual channel for SBC by default Signed-off-by: Pranav Vashi Change-Id: I82ca0aad54bb5a28dadcd845c8fcf87663fa3570 --- src/com/android/bluetooth/a2dp/A2dpCodecConfig.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java b/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java index 24caf9e30bb..7dd343a817e 100644 --- a/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java +++ b/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java @@ -110,14 +110,6 @@ void enableOptionalCodecs(BluetoothDevice device, BluetoothCodecConfig currentCo BluetoothCodecConfig codecConfig = codecConfigArray[i]; if (codecConfig != null && !codecConfig.isMandatoryCodec()) { codecConfigArray[i] = null; - } else { - // Rebuild SBC selectable codec with Dual Channel (SBC HD audio) - codecConfigArray[i] = new BluetoothCodecConfig( - BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, mA2dpSourceCodecPrioritySbc, - BluetoothCodecConfig.SAMPLE_RATE_NONE, - BluetoothCodecConfig.BITS_PER_SAMPLE_NONE, - BluetoothCodecConfig.CHANNEL_MODE_DUAL_CHANNEL, 0 /* codecSpecific1 */, - 0 /* codecSpecific2 */, 0 /* codecSpecific3 */, 0 /* codecSpecific4 */); } } From e8429c51f4acf5fe5df6707a8c8f2ae9d3892836 Mon Sep 17 00:00:00 2001 From: Pranav Vashi Date: Wed, 8 Jul 2020 03:33:55 +0530 Subject: [PATCH 21/22] Add switch to select SBC HD by default [2/3] Signed-off-by: Pranav Vashi Change-Id: I3307506e332350894dbe6022882a9510293f1a4d --- src/com/android/bluetooth/a2dp/A2dpCodecConfig.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java b/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java index 7dd343a817e..5db50f3845a 100644 --- a/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java +++ b/src/com/android/bluetooth/a2dp/A2dpCodecConfig.java @@ -105,11 +105,22 @@ void enableOptionalCodecs(BluetoothDevice device, BluetoothCodecConfig currentCo return; } + boolean sbc_priority = Settings.System.getInt(mContext.getContentResolver(), + Settings.System.SBC_HD_PRIORITY, 0) != 0; + // Set the mandatory codec's priority to default, and remove the rest for (int i = 0; i < codecConfigArray.length; i++) { BluetoothCodecConfig codecConfig = codecConfigArray[i]; if (codecConfig != null && !codecConfig.isMandatoryCodec()) { codecConfigArray[i] = null; + } else if (sbc_priority) { + // Rebuild SBC selectable codec with Dual Channel (SBC HD audio) + codecConfigArray[i] = new BluetoothCodecConfig( + BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, mA2dpSourceCodecPrioritySbc, + BluetoothCodecConfig.SAMPLE_RATE_NONE, + BluetoothCodecConfig.BITS_PER_SAMPLE_NONE, + BluetoothCodecConfig.CHANNEL_MODE_DUAL_CHANNEL, 0 /* codecSpecific1 */, + 0 /* codecSpecific2 */, 0 /* codecSpecific3 */, 0 /* codecSpecific4 */); } } From 1b7f60306618a7cb298ca7ac4edcdac6d354a54f Mon Sep 17 00:00:00 2001 From: DennySPb Date: Wed, 3 Jun 2020 17:32:07 +0300 Subject: [PATCH 22/22] Stub two more QTI functions Change-Id: Idd3f287630afb68fdb8a58efe7a4fca9ce2e4da6 --- src/com/android/bluetooth/btservice/AdapterService.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java index f4c1dc7ede3..418f79f0206 100644 --- a/src/com/android/bluetooth/btservice/AdapterService.java +++ b/src/com/android/bluetooth/btservice/AdapterService.java @@ -1764,6 +1764,15 @@ public void onBrEdrDown() { service.onBrEdrDown(); } + public int setSocketOpt(int type, int channel, int optionName, byte [] optionVal, + int optionLen) { + return -1; + } + + public int getSocketOpt(int type, int channel, int optionName, byte [] optionVal) { + return -1; + } + @Override public void dump(FileDescriptor fd, String[] args) { PrintWriter writer = new PrintWriter(new FileOutputStream(fd));