Send host endpoint connected event on hub restart
Bug: 194287786
Test: Manual test
Change-Id: Idf4cb02647d302544a31c85cd95771cd44735ec9
diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java b/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java
index 0fd7cc1..e40d86a 100644
--- a/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java
+++ b/services/core/java/com/android/server/location/contexthub/ContextHubClientBroker.java
@@ -331,15 +331,7 @@
mAppOpsManager = context.getSystemService(AppOpsManager.class);
startMonitoringOpChanges();
-
- HostEndpointInfo info = new HostEndpointInfo();
- info.hostEndpointId = (char) mHostEndPointId;
- info.packageName = mPackage;
- info.attributionTag = mAttributionTag;
- info.type = (mUid == Process.SYSTEM_UID)
- ? HostEndpointInfo.Type.TYPE_FRAMEWORK
- : HostEndpointInfo.Type.TYPE_APP;
- mContextHubProxy.onHostEndpointConnected(info);
+ sendHostEndpointConnectedEvent();
}
/* package */ ContextHubClientBroker(
@@ -556,6 +548,9 @@
/* package */ void onHubReset() {
invokeCallback(callback -> callback.onHubReset());
sendPendingIntent(() -> createIntent(ContextHubManager.EVENT_HUB_RESET));
+
+ // Re-send the host endpoint connected event as the Context Hub restarted.
+ sendHostEndpointConnectedEvent();
}
/**
@@ -895,6 +890,17 @@
}
}
+ private void sendHostEndpointConnectedEvent() {
+ HostEndpointInfo info = new HostEndpointInfo();
+ info.hostEndpointId = (char) mHostEndPointId;
+ info.packageName = mPackage;
+ info.attributionTag = mAttributionTag;
+ info.type = (mUid == Process.SYSTEM_UID)
+ ? HostEndpointInfo.Type.TYPE_FRAMEWORK
+ : HostEndpointInfo.Type.TYPE_APP;
+ mContextHubProxy.onHostEndpointConnected(info);
+ }
+
/**
* Dump debugging info as ClientBrokerProto
*