Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package android.hardware.location; |
| 17 | |
Arthur Ishiguro | f2b6f01 | 2017-11-28 15:21:38 -0800 | [diff] [blame^] | 18 | import android.annotation.SystemApi; |
| 19 | |
| 20 | import java.util.concurrent.Executor; |
| 21 | |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 22 | /** |
| 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 Ishiguro | f2b6f01 | 2017-11-28 15:21:38 -0800 | [diff] [blame^] | 27 | * 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 Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 32 | * 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 Ishiguro | f2b6f01 | 2017-11-28 15:21:38 -0800 | [diff] [blame^] | 39 | @SystemApi |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 40 | public 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 Ishiguro | 78493a1 | 2018-01-02 10:44:21 -0800 | [diff] [blame] | 47 | * @param client the client that is associated with this callback |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 48 | * @param message the message sent by the nanoapp |
| 49 | */ |
Arthur Ishiguro | 78493a1 | 2018-01-02 10:44:21 -0800 | [diff] [blame] | 50 | public void onMessageFromNanoApp(ContextHubClient client, NanoAppMessage message) {} |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * Callback invoked when the attached Context Hub has reset. |
Arthur Ishiguro | 78493a1 | 2018-01-02 10:44:21 -0800 | [diff] [blame] | 54 | * |
| 55 | * @param client the client that is associated with this callback |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 56 | */ |
Arthur Ishiguro | 78493a1 | 2018-01-02 10:44:21 -0800 | [diff] [blame] | 57 | public void onHubReset(ContextHubClient client) {} |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 58 | |
| 59 | /** |
| 60 | * Callback invoked when a nanoapp aborts at the attached Context Hub. |
| 61 | * |
Arthur Ishiguro | 78493a1 | 2018-01-02 10:44:21 -0800 | [diff] [blame] | 62 | * @param client the client that is associated with this callback |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 63 | * @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 Ishiguro | 78493a1 | 2018-01-02 10:44:21 -0800 | [diff] [blame] | 66 | public void onNanoAppAborted(ContextHubClient client, long nanoAppId, int abortCode) {} |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 67 | |
| 68 | /** |
| 69 | * Callback invoked when a nanoapp is loaded at the attached Context Hub. |
| 70 | * |
Arthur Ishiguro | 78493a1 | 2018-01-02 10:44:21 -0800 | [diff] [blame] | 71 | * @param client the client that is associated with this callback |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 72 | * @param nanoAppId the ID of the nanoapp that had been loaded |
| 73 | */ |
Arthur Ishiguro | 78493a1 | 2018-01-02 10:44:21 -0800 | [diff] [blame] | 74 | public void onNanoAppLoaded(ContextHubClient client, long nanoAppId) {} |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 75 | |
| 76 | /** |
| 77 | * Callback invoked when a nanoapp is unloaded from the attached Context Hub. |
| 78 | * |
Arthur Ishiguro | 78493a1 | 2018-01-02 10:44:21 -0800 | [diff] [blame] | 79 | * @param client the client that is associated with this callback |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 80 | * @param nanoAppId the ID of the nanoapp that had been unloaded |
| 81 | */ |
Arthur Ishiguro | 78493a1 | 2018-01-02 10:44:21 -0800 | [diff] [blame] | 82 | public void onNanoAppUnloaded(ContextHubClient client, long nanoAppId) {} |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 83 | |
| 84 | /** |
| 85 | * Callback invoked when a nanoapp is enabled at the attached Context Hub. |
| 86 | * |
Arthur Ishiguro | 78493a1 | 2018-01-02 10:44:21 -0800 | [diff] [blame] | 87 | * @param client the client that is associated with this callback |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 88 | * @param nanoAppId the ID of the nanoapp that had been enabled |
| 89 | */ |
Arthur Ishiguro | 78493a1 | 2018-01-02 10:44:21 -0800 | [diff] [blame] | 90 | public void onNanoAppEnabled(ContextHubClient client, long nanoAppId) {} |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 91 | |
| 92 | /** |
| 93 | * Callback invoked when a nanoapp is disabled at the attached Context Hub. |
| 94 | * |
Arthur Ishiguro | 78493a1 | 2018-01-02 10:44:21 -0800 | [diff] [blame] | 95 | * @param client the client that is associated with this callback |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 96 | * @param nanoAppId the ID of the nanoapp that had been disabled |
| 97 | */ |
Arthur Ishiguro | 78493a1 | 2018-01-02 10:44:21 -0800 | [diff] [blame] | 98 | public void onNanoAppDisabled(ContextHubClient client, long nanoAppId) {} |
Arthur Ishiguro | b9ae7bd | 2017-10-09 12:47:52 -0700 | [diff] [blame] | 99 | } |