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 18 import android.annotation.SystemApi; 19 20 import java.util.concurrent.Executor; 21 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 * 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: 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 */ 39 @SystemApi 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 * 47 * @param client the client that is associated with this callback 48 * @param message the message sent by the nanoapp 49 */ onMessageFromNanoApp(ContextHubClient client, NanoAppMessage message)50 public void onMessageFromNanoApp(ContextHubClient client, NanoAppMessage message) {} 51 52 /** 53 * Callback invoked when the attached Context Hub has reset. 54 * 55 * @param client the client that is associated with this callback 56 */ onHubReset(ContextHubClient client)57 public void onHubReset(ContextHubClient client) {} 58 59 /** 60 * Callback invoked when a nanoapp aborts at the attached Context Hub. 61 * 62 * @param client the client that is associated with this callback 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 */ onNanoAppAborted(ContextHubClient client, long nanoAppId, int abortCode)66 public void onNanoAppAborted(ContextHubClient client, long nanoAppId, int abortCode) {} 67 68 /** 69 * Callback invoked when a nanoapp is loaded at the attached Context Hub. 70 * 71 * @param client the client that is associated with this callback 72 * @param nanoAppId the ID of the nanoapp that had been loaded 73 */ onNanoAppLoaded(ContextHubClient client, long nanoAppId)74 public void onNanoAppLoaded(ContextHubClient client, long nanoAppId) {} 75 76 /** 77 * Callback invoked when a nanoapp is unloaded from the attached Context Hub. 78 * 79 * @param client the client that is associated with this callback 80 * @param nanoAppId the ID of the nanoapp that had been unloaded 81 */ onNanoAppUnloaded(ContextHubClient client, long nanoAppId)82 public void onNanoAppUnloaded(ContextHubClient client, long nanoAppId) {} 83 84 /** 85 * Callback invoked when a nanoapp is enabled at the attached Context Hub. 86 * 87 * @param client the client that is associated with this callback 88 * @param nanoAppId the ID of the nanoapp that had been enabled 89 */ onNanoAppEnabled(ContextHubClient client, long nanoAppId)90 public void onNanoAppEnabled(ContextHubClient client, long nanoAppId) {} 91 92 /** 93 * Callback invoked when a nanoapp is disabled at the attached Context Hub. 94 * 95 * @param client the client that is associated with this callback 96 * @param nanoAppId the ID of the nanoapp that had been disabled 97 */ onNanoAppDisabled(ContextHubClient client, long nanoAppId)98 public void onNanoAppDisabled(ContextHubClient client, long nanoAppId) {} 99 } 100