From b9f46f30e9002430cd26e81c3f5ec0395d9b56dc Mon Sep 17 00:00:00 2001 From: Sumit Deshmukh Date: Thu, 22 Oct 2020 15:41:02 +0530 Subject: [PATCH] DeviceGroup: Frameworks changes (for dual mode devices). This change contains implementation of overloaded API's to get device details based on public address. Note: API's are hidden and should be used only from settingslibs LocalBluetoothProfile. CRs-Fixed: 2826578 Change-Id: I9b1f08f4bd5eee8fd66fc032745d3ec5b56e7c2f --- .../bluetooth/BluetoothDeviceGroup.java | 46 +++++++++++++++++-- .../bluetooth/DeviceGroupClientProfile.java | 6 +-- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/core/java/android/bluetooth/BluetoothDeviceGroup.java b/core/java/android/bluetooth/BluetoothDeviceGroup.java index a171e00df1006..0a0fea5b7f2aa 100644 --- a/core/java/android/bluetooth/BluetoothDeviceGroup.java +++ b/core/java/android/bluetooth/BluetoothDeviceGroup.java @@ -532,6 +532,17 @@ public boolean stopGroupDiscovery(int groupId) { * @return List of DeviceGroup that are already discovered. */ public List getDiscoveredGroups() { + return getDiscoveredGroups(false); + } + + /** + * Fetches already discovered device groups. + * + * @param mPublicAddr All discovered device groups with public address of devices. + * @return List of Device Groups that are already discovered. + * @hide + */ + public List getDiscoveredGroups(boolean mPublicAddr) { if (DBG) log("getDiscoveredGroups()"); if (!mAppRegistered) { @@ -547,7 +558,7 @@ public List getDiscoveredGroups() { } try { - List groups = service.getDiscoveredGroups(); + List groups = service.getDiscoveredGroups(mPublicAddr); return groups; } catch (RemoteException e) { Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); @@ -563,6 +574,19 @@ public List getDiscoveredGroups() { * @return Required DeviceGroup. */ public DeviceGroup getGroup(int groupId) { + return getGroup(groupId, false); + } + + /** + * Fetch details of a already discovered Group identified by groupId. + * + * @param groupId Identifier of the device group for which group + * details are required. + * @param mPublicAddr DeviceGroup with Public Address of the group devices. + * @return Required DeviceGroup. + * @hide + */ + public DeviceGroup getGroup(int groupId, boolean mPublicAddr) { if (DBG) log("getGroup() : groupId = " + groupId); if (!mAppRegistered) { @@ -578,7 +602,7 @@ public DeviceGroup getGroup(int groupId) { } try { - DeviceGroup group = service.getDeviceGroup(groupId); + DeviceGroup group = service.getDeviceGroup(groupId, mPublicAddr); return group; } catch (RemoteException e) { Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); @@ -596,6 +620,22 @@ public DeviceGroup getGroup(int groupId) { * @return Group identifier of the required device. */ public int getRemoteDeviceGroupId (BluetoothDevice device, ParcelUuid uuid) { + return getRemoteDeviceGroupId(device, uuid, false); + } + + /** + * Get Group Identifier of the remote device to which it belongs. + * + * @param device BluetoothDevice instance of the remote device. + * @param uuid ParcelUuid of the primary service in which this + * Group Service is included. + * @param mPublicAddr Suggests that group identifier is required for passed + * public address of the remote device. + * @return Group identifier of the required group for the device + * @hide + */ + public int getRemoteDeviceGroupId (BluetoothDevice device, ParcelUuid uuid, + boolean mPublicAddr) { if (DBG) log("getRemoteDeviceGroupId() : device = " + device); if (!mAppRegistered) { @@ -612,7 +652,7 @@ public int getRemoteDeviceGroupId (BluetoothDevice device, ParcelUuid uuid) { } try { - return service.getRemoteDeviceGroupId(device, uuid); + return service.getRemoteDeviceGroupId(device, uuid, mPublicAddr); } catch (RemoteException e) { Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); } diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/DeviceGroupClientProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/DeviceGroupClientProfile.java index a98cb3c9ea873..5a3f33a7c4339 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/DeviceGroupClientProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/DeviceGroupClientProfile.java @@ -251,7 +251,7 @@ public DeviceGroup getGroup (int groupId) { return null; } - return mService.getGroup(groupId); + return mService.getGroup(groupId, true); } public List getDiscoveredGroups () { @@ -263,7 +263,7 @@ public List getDiscoveredGroups () { return null; } - return mService.getDiscoveredGroups(); + return mService.getDiscoveredGroups(true); } public boolean isGroupDiscoveryInProgress (int groupId) { @@ -286,7 +286,7 @@ public int getRemoteDeviceGroupId (BluetoothDevice device) { return BluetoothDeviceGroup.INVALID_GROUP_ID; } - return mService.getRemoteDeviceGroupId(device, null); + return mService.getRemoteDeviceGroupId(device, null, true); } public boolean isProfileReady() {