From 92e8b01449d010080c5651959b274364a5dbeb96 Mon Sep 17 00:00:00 2001 From: Lei Ju Date: Wed, 15 Feb 2023 16:31:49 -0800 Subject: Register callback before calling other hal APIs Test: manual test on a device Bug: 269525639 Change-Id: I97944079d78c1723a5422e7ac9b019ce61aaafbd Merged-In: I97944079d78c1723a5422e7ac9b019ce61aaafbd --- .../android/server/location/contexthub/ContextHubService.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubService.java b/services/core/java/com/android/server/location/contexthub/ContextHubService.java index 8f657756eed3..25fd5eaed5a4 100644 --- a/services/core/java/com/android/server/location/contexthub/ContextHubService.java +++ b/services/core/java/com/android/server/location/contexthub/ContextHubService.java @@ -370,11 +370,6 @@ public class ContextHubService extends IContextHubService.Stub { mLastRestartTimestampMap.put(contextHubId, new AtomicLong(SystemClock.elapsedRealtimeNanos())); - IContextHubClient client = mClientManager.registerClient( - contextHubInfo, createDefaultClientCallback(contextHubId), - /* attributionTag= */ null, mTransactionManager, mContext.getPackageName()); - defaultClientMap.put(contextHubId, client); - try { mContextHubWrapper.registerCallback(contextHubId, new ContextHubServiceCallback(contextHubId)); @@ -383,6 +378,11 @@ public class ContextHubService extends IContextHubService.Stub { + contextHubId + ")", e); } + IContextHubClient client = mClientManager.registerClient( + contextHubInfo, createDefaultClientCallback(contextHubId), + /* attributionTag= */ null, mTransactionManager, mContext.getPackageName()); + defaultClientMap.put(contextHubId, client); + // Do a query to initialize the service cache list of nanoapps // TODO(b/194289715): Remove this when old API is deprecated queryNanoAppsInternal(contextHubId); -- cgit v1.2.3-59-g8ed1b