Merge "Only update the current connected set for selfManaged only" into tm-dev am: 5547ff26d0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18235827 Change-Id: I7bbda17fc987f11c95301a33662e654475d298d0 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -292,14 +292,13 @@ public class CompanionDeviceManagerService extends SystemService {
|
|||||||
|
|
||||||
private boolean onCompanionApplicationBindingDiedInternal(
|
private boolean onCompanionApplicationBindingDiedInternal(
|
||||||
@UserIdInt int userId, @NonNull String packageName) {
|
@UserIdInt int userId, @NonNull String packageName) {
|
||||||
// Update the current connected devices sets when binderDied, so that application is able
|
|
||||||
// to call notifyDeviceAppeared after re-launch the application.
|
|
||||||
for (AssociationInfo ai :
|
for (AssociationInfo ai :
|
||||||
mAssociationStore.getAssociationsForPackage(userId, packageName)) {
|
mAssociationStore.getAssociationsForPackage(userId, packageName)) {
|
||||||
int id = ai.getId();
|
final int associationId = ai.getId();
|
||||||
Slog.i(TAG, "Removing association id: " + id + " for package: "
|
if (ai.isSelfManaged()
|
||||||
+ packageName + " due to binderDied.");
|
&& mDevicePresenceMonitor.isDevicePresent(associationId)) {
|
||||||
mDevicePresenceMonitor.removeDeviceFromMonitoring(id);
|
mDevicePresenceMonitor.onSelfManagedDeviceReporterBinderDied(associationId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// TODO(b/218613015): implement.
|
// TODO(b/218613015): implement.
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -149,6 +149,13 @@ public class CompanionDevicePresenceMonitor implements AssociationStore.OnChange
|
|||||||
onDeviceGone(mReportedSelfManagedDevices, associationId, "application-reported");
|
onDeviceGone(mReportedSelfManagedDevices, associationId, "application-reported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks a "self-managed" device as disconnected when binderDied.
|
||||||
|
*/
|
||||||
|
public void onSelfManagedDeviceReporterBinderDied(int associationId) {
|
||||||
|
onDeviceGone(mReportedSelfManagedDevices, associationId, "application-reported");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBluetoothCompanionDeviceConnected(int associationId) {
|
public void onBluetoothCompanionDeviceConnected(int associationId) {
|
||||||
onDevicePresent(mConnectedBtDevices, associationId, /* sourceLoggingTag */ "bt");
|
onDevicePresent(mConnectedBtDevices, associationId, /* sourceLoggingTag */ "bt");
|
||||||
@@ -258,16 +265,6 @@ public class CompanionDevicePresenceMonitor implements AssociationStore.OnChange
|
|||||||
mCallback.onDeviceDisappeared(goneDeviceAssociationId);
|
mCallback.onDeviceDisappeared(goneDeviceAssociationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the current connected devices by associationId.
|
|
||||||
*/
|
|
||||||
public void removeDeviceFromMonitoring(int associationId) {
|
|
||||||
mConnectedBtDevices.remove(associationId);
|
|
||||||
mNearbyBleDevices.remove(associationId);
|
|
||||||
mReportedSelfManagedDevices.remove(associationId);
|
|
||||||
mSimulated.remove(associationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements
|
* Implements
|
||||||
* {@link AssociationStore.OnChangeListener#onAssociationRemoved(AssociationInfo)}
|
* {@link AssociationStore.OnChangeListener#onAssociationRemoved(AssociationInfo)}
|
||||||
@@ -280,7 +277,9 @@ public class CompanionDevicePresenceMonitor implements AssociationStore.OnChange
|
|||||||
Log.d(TAG, " > association=" + association);
|
Log.d(TAG, " > association=" + association);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeDeviceFromMonitoring(id);
|
mConnectedBtDevices.remove(id);
|
||||||
|
mNearbyBleDevices.remove(id);
|
||||||
|
mReportedSelfManagedDevices.remove(id);
|
||||||
|
|
||||||
// Do NOT call mCallback.onDeviceDisappeared()!
|
// Do NOT call mCallback.onDeviceDisappeared()!
|
||||||
// CompanionDeviceManagerService will know that the association is removed, and will do
|
// CompanionDeviceManagerService will know that the association is removed, and will do
|
||||||
|
|||||||
Reference in New Issue
Block a user