blob: cc2fe65dcb7e4ebd3b3361875dcf73409cdc32f7 [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
Arthur Ishigurof2b6f012017-11-28 15:21:38 -080018import android.annotation.SystemApi;
19
20import java.util.concurrent.Executor;
21
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070022/**
23 * A class for {@link android.hardware.location.ContextHubClient ContextHubClient} to
24 * receive messages and life-cycle events from nanoapps in the Context Hub at which the client is
25 * attached to.
26 *
Arthur Ishigurof2b6f012017-11-28 15:21:38 -080027 * This callback is registered through the {@link
28 * android.hardware.location.ContextHubManager#createClient(
29 * ContextHubInfo, ContextHubClientCallback, Executor) creation} of
30 * {@link android.hardware.location.ContextHubClient ContextHubClient}. Callbacks are invoked in
31 * the following ways:
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070032 * 1) Messages from nanoapps delivered through onMessageFromNanoApp may either be broadcasted
33 * or targeted to a specific client.
34 * 2) Nanoapp or Context Hub events (the remaining callbacks) are broadcasted to all clients, and
35 * the client can choose to ignore the event by filtering through the parameters.
36 *
37 * @hide
38 */
Arthur Ishigurof2b6f012017-11-28 15:21:38 -080039@SystemApi
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070040public class ContextHubClientCallback {
41 /**
42 * Callback invoked when receiving a message from a nanoapp.
43 *
44 * The message contents of this callback may either be broadcasted or targeted to the
45 * client receiving the invocation.
46 *
Arthur Ishiguro78493a12018-01-02 10:44:21 -080047 * @param client the client that is associated with this callback
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070048 * @param message the message sent by the nanoapp
49 */
Arthur Ishiguro78493a12018-01-02 10:44:21 -080050 public void onMessageFromNanoApp(ContextHubClient client, NanoAppMessage message) {}
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070051
52 /**
53 * Callback invoked when the attached Context Hub has reset.
Arthur Ishiguro78493a12018-01-02 10:44:21 -080054 *
55 * @param client the client that is associated with this callback
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070056 */
Arthur Ishiguro78493a12018-01-02 10:44:21 -080057 public void onHubReset(ContextHubClient client) {}
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070058
59 /**
60 * Callback invoked when a nanoapp aborts at the attached Context Hub.
61 *
Arthur Ishiguro78493a12018-01-02 10:44:21 -080062 * @param client the client that is associated with this callback
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070063 * @param nanoAppId the ID of the nanoapp that had aborted
64 * @param abortCode the reason for nanoapp's abort, specific to each nanoapp
65 */
Arthur Ishiguro78493a12018-01-02 10:44:21 -080066 public void onNanoAppAborted(ContextHubClient client, long nanoAppId, int abortCode) {}
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070067
68 /**
69 * Callback invoked when a nanoapp is loaded at the attached Context Hub.
70 *
Arthur Ishiguro78493a12018-01-02 10:44:21 -080071 * @param client the client that is associated with this callback
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070072 * @param nanoAppId the ID of the nanoapp that had been loaded
73 */
Arthur Ishiguro78493a12018-01-02 10:44:21 -080074 public void onNanoAppLoaded(ContextHubClient client, long nanoAppId) {}
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070075
76 /**
77 * Callback invoked when a nanoapp is unloaded from the attached Context Hub.
78 *
Arthur Ishiguro78493a12018-01-02 10:44:21 -080079 * @param client the client that is associated with this callback
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070080 * @param nanoAppId the ID of the nanoapp that had been unloaded
81 */
Arthur Ishiguro78493a12018-01-02 10:44:21 -080082 public void onNanoAppUnloaded(ContextHubClient client, long nanoAppId) {}
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070083
84 /**
85 * Callback invoked when a nanoapp is enabled at the attached Context Hub.
86 *
Arthur Ishiguro78493a12018-01-02 10:44:21 -080087 * @param client the client that is associated with this callback
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070088 * @param nanoAppId the ID of the nanoapp that had been enabled
89 */
Arthur Ishiguro78493a12018-01-02 10:44:21 -080090 public void onNanoAppEnabled(ContextHubClient client, long nanoAppId) {}
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070091
92 /**
93 * Callback invoked when a nanoapp is disabled at the attached Context Hub.
94 *
Arthur Ishiguro78493a12018-01-02 10:44:21 -080095 * @param client the client that is associated with this callback
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070096 * @param nanoAppId the ID of the nanoapp that had been disabled
97 */
Arthur Ishiguro78493a12018-01-02 10:44:21 -080098 public void onNanoAppDisabled(ContextHubClient client, long nanoAppId) {}
Arthur Ishigurob9ae7bd2017-10-09 12:47:52 -070099}