diff options
| author | 2018-10-16 11:45:28 -0700 | |
|---|---|---|
| committer | 2018-11-02 11:29:23 -0700 | |
| commit | 6cc24a5df3e17279b366919c8712de61d92d3780 (patch) | |
| tree | 684f2d1e44ceb51ec84030088fa28eeecdf8a502 | |
| parent | d3464c7c938f3facb3dc26f449249b93774d35da (diff) | |
Implements PendingIntent based createClient API
Bug: 117612105
Test: Compile and flash, verify API user can regenerate a
ContextHubClient
Change-Id: I9f2d4e1b4389e32b0828d494d74151ec56fa9d57
| -rw-r--r-- | core/java/android/hardware/location/ContextHubManager.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/core/java/android/hardware/location/ContextHubManager.java b/core/java/android/hardware/location/ContextHubManager.java index 18e1b9fecb93..9acefa567ed6 100644 --- a/core/java/android/hardware/location/ContextHubManager.java +++ b/core/java/android/hardware/location/ContextHubManager.java @@ -818,8 +818,24 @@ public final class ContextHubManager { @NonNull PendingIntent pendingIntent, @NonNull ContextHubInfo hubInfo, @NonNull ContextHubClientCallback callback, @NonNull @CallbackExecutor Executor executor) { - // TODO: Implement this - throw new UnsupportedOperationException("Not implemented yet"); + Preconditions.checkNotNull(pendingIntent, "PendingIntent cannot be null"); + Preconditions.checkNotNull(callback, "Callback cannot be null"); + Preconditions.checkNotNull(hubInfo, "ContextHubInfo cannot be null"); + Preconditions.checkNotNull(executor, "Executor cannot be null"); + + ContextHubClient client = new ContextHubClient(hubInfo); + IContextHubClientCallback clientInterface = createClientCallback( + client, callback, executor); + + IContextHubClient clientProxy; + try { + clientProxy = mService.bindClient(pendingIntent, clientInterface, hubInfo.getId()); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + + client.setClientProxy(clientProxy); + return client; } /** |