Skip to content

Commit

Permalink
DeviceGroup: Frameworks changes (for dual mode devices).
Browse files Browse the repository at this point in the history
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
Sumit Deshmukh authored and anruichan committed Jan 21, 2022
1 parent 294a866 commit b9f46f3
Showing 2 changed files with 46 additions and 6 deletions.
46 changes: 43 additions & 3 deletions core/java/android/bluetooth/BluetoothDeviceGroup.java
Original file line number Diff line number Diff line change
@@ -532,6 +532,17 @@ public boolean stopGroupDiscovery(int groupId) {
* @return List of DeviceGroup that are already discovered.
*/
public List<DeviceGroup> 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<DeviceGroup> getDiscoveredGroups(boolean mPublicAddr) {
if (DBG) log("getDiscoveredGroups()");

if (!mAppRegistered) {
@@ -547,7 +558,7 @@ public List<DeviceGroup> getDiscoveredGroups() {
}

try {
List<DeviceGroup> groups = service.getDiscoveredGroups();
List<DeviceGroup> groups = service.getDiscoveredGroups(mPublicAddr);
return groups;
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
@@ -563,6 +574,19 @@ public List<DeviceGroup> 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()));
}
Original file line number Diff line number Diff line change
@@ -251,7 +251,7 @@ public DeviceGroup getGroup (int groupId) {
return null;
}

return mService.getGroup(groupId);
return mService.getGroup(groupId, true);
}

public List<DeviceGroup> getDiscoveredGroups () {
@@ -263,7 +263,7 @@ public List<DeviceGroup> 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() {

0 comments on commit b9f46f3

Please sign in to comment.