From d01fa6e6869f32d42c573ef0fe8c5a78d4153440 Mon Sep 17 00:00:00 2001 From: Pulkit Bhuwalka Date: Wed, 20 Sep 2017 15:10:45 -0700 Subject: [PATCH 1/2] Get Bluetooth Class of Device Adds API to fetch Bluetooth CoD value of the stack. The API is hidden to only be used by System code. Bug: 36015415 Test: Verified fetching of COD from test app on flashed device, after modification and after after reboot. Change-Id: Ie35ecf141704c2aac46678da7cabdc7203a088f2 --- .../android/bluetooth/BluetoothAdapter.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index 01af9fe31d27a..3d9651db6833d 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -1133,6 +1133,28 @@ public final class BluetoothAdapter { return false; } + /** + * Returns the {@link BluetoothClass} Bluetooth Class of Device (CoD) of the local Bluetooth + * adapter. + * + * @return {@link BluetoothClass} Bluetooth CoD of local Bluetooth device. + * + * @hide + */ + @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN) + public BluetoothClass getBluetoothClass() { + if (getState() != STATE_ON) return null; + try { + mServiceLock.readLock().lock(); + if (mService != null) return mService.getBluetoothClass(); + } catch (RemoteException e) { + Log.e(TAG, "", e); + } finally { + mServiceLock.readLock().unlock(); + } + return null; + } + /** * Sets the {@link BluetoothClass} Bluetooth Class of Device (CoD) of the local Bluetooth * adapter. From dab081ca5648c95b6d42cd35a7792e45188810be Mon Sep 17 00:00:00 2001 From: Pulkit Bhuwalka Date: Mon, 25 Sep 2017 19:19:46 -0700 Subject: [PATCH 2/2] Add missing intents to protected broadcasts Intents broadcasted by the Bluetooth stack need to be added to protected broadcasts else they complain with errors in the log since Bluetooth is considered a system process. A few of these intents, especially AVRCP intents were missing in the list. Bug: None Test: Verified errors don't show up after introducing the intents while playing on a sink device. Change-Id: Ie283c50243d9a1bac3fd937f58bc1ddc20867d2f --- core/res/AndroidManifest.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index fc61a1532f4c8..aa4a6b99a25cc 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -181,10 +181,18 @@ android:name="android.bluetooth.a2dp-sink.profile.action.PLAYING_STATE_CHANGED" /> + + + +