blob: b7e353a4860c343278fdf02b0508145aff48e701 [file] [log] [blame]
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -07001/*
2 * Copyright 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package android.hardware.location;
17
18import android.annotation.RequiresPermission;
19import android.os.Handler;
20
21import java.io.Closeable;
22
23/**
24 * A class describing a client of the Context Hub Service.
25 *
26 * Clients can send messages to nanoapps at a Context Hub through this object.
27 *
28 * @hide
29 */
30public class ContextHubClient implements Closeable {
31 /*
32 * The ContextHubClient interface associated with this client.
33 */
34 // TODO: Implement this interface and associate with ContextHubClient object
35 // private final IContextHubClient mClientInterface;
36
37 /*
38 * The listening callback associated with this client.
39 */
40 private ContextHubClientCallback mCallback;
41
42 /*
43 * The Context Hub that this client is attached to.
44 */
45 private ContextHubInfo mAttachedHub;
46
47 /*
48 * The handler to invoke mCallback.
49 */
50 private Handler mCallbackHandler;
51
52 ContextHubClient(ContextHubClientCallback callback, Handler handler, ContextHubInfo hubInfo) {
53 mCallback = callback;
54 mCallbackHandler = handler;
55 mAttachedHub = hubInfo;
56 }
57
58 /**
59 * Returns the hub that this client is attached to.
60 *
61 * @return the ContextHubInfo of the attached hub
62 */
63 public ContextHubInfo getAttachedHub() {
64 return mAttachedHub;
65 }
66
67 /**
68 * Closes the connection for this client and the Context Hub Service.
69 *
70 * When this function is invoked, the messaging associated with this client is invalidated.
71 * All futures messages targeted for this client are dropped at the service.
72 */
73 public void close() {
74 throw new UnsupportedOperationException("TODO: Implement this");
75 }
76
77 /**
78 * Sends a message to a nanoapp through the Context Hub Service.
79 *
80 * This function returns TRANSACTION_SUCCESS if the message has reached the HAL, but
81 * does not guarantee delivery of the message to the target nanoapp.
82 *
83 * @param message the message object to send
84 *
85 * @return the result of sending the message defined as in ContextHubTransaction.Result
86 *
87 * @see NanoAppMessage
88 * @see ContextHubTransaction.Result
89 */
90 @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
91 @ContextHubTransaction.Result
92 public int sendMessageToNanoApp(NanoAppMessage message) {
93 throw new UnsupportedOperationException("TODO: Implement this");
94 }
95}