11d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi/*
21d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * Copyright (C) 2016 The Android Open Source Project
31d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi *
41d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * Licensed under the Apache License, Version 2.0 (the "License");
51d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * you may not use this file except in compliance with the License.
61d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * You may obtain a copy of the License at
71d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi *
81d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi *      http://www.apache.org/licenses/LICENSE-2.0
91d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi *
101d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * Unless required by applicable law or agreed to in writing, software
111d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * distributed under the License is distributed on an "AS IS" BASIS,
121d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * See the License for the specific language governing permissions and
141d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi * limitations under the License.
151d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi */
161d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
171d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshipackage android.hardware.location;
181d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
191d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi// Declare any non-default types here with import statements
201d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshiimport android.hardware.location.ContextHubInfo;
214e39aa1e1956ef0b363f38630865acd3ef65761fArthur Ishiguroimport android.hardware.location.ContextHubMessage;
221d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshiimport android.hardware.location.NanoApp;
23e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguroimport android.hardware.location.NanoAppBinary;
241d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshiimport android.hardware.location.NanoAppFilter;
254e39aa1e1956ef0b363f38630865acd3ef65761fArthur Ishiguroimport android.hardware.location.NanoAppInstanceInfo;
261d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshiimport android.hardware.location.IContextHubCallback;
274e39aa1e1956ef0b363f38630865acd3ef65761fArthur Ishiguroimport android.hardware.location.IContextHubClient;
284e39aa1e1956ef0b363f38630865acd3ef65761fArthur Ishiguroimport android.hardware.location.IContextHubClientCallback;
29e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguroimport android.hardware.location.IContextHubTransactionCallback;
301d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
319ff7d2235427b211344fa58b608424805a21aa24Peng Xu/**
329ff7d2235427b211344fa58b608424805a21aa24Peng Xu * @hide
339ff7d2235427b211344fa58b608424805a21aa24Peng Xu */
341d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshiinterface IContextHubService {
351d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
36e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro    // Registers a callback to receive messages
379ff7d2235427b211344fa58b608424805a21aa24Peng Xu    int registerCallback(in IContextHubCallback callback);
381d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
391d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    // Gets a list of available context hub handles
401d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    int[] getContextHubHandles();
411d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
42e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro    // Gets the properties of a hub
431d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi    ContextHubInfo getContextHubInfo(int contextHubHandle);
441d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
45e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro    // Loads a nanoapp at the specified hub (old API)
46ab7113d48507a6777c81f14b1134387382947026Arthur Ishiguro    int loadNanoApp(int contextHubHandle, in NanoApp nanoApp);
471d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
48e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro    // Unloads a nanoapp given its instance ID (old API)
49ab7113d48507a6777c81f14b1134387382947026Arthur Ishiguro    int unloadNanoApp(int nanoAppHandle);
501d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
51e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro    // Gets the NanoAppInstanceInfo of a nanoapp give its instance ID
52ab7113d48507a6777c81f14b1134387382947026Arthur Ishiguro    NanoAppInstanceInfo getNanoAppInstanceInfo(int nanoAppHandle);
531d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
54e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro    // Finds all nanoApp instances matching some filter
55ab7113d48507a6777c81f14b1134387382947026Arthur Ishiguro    int[] findNanoAppOnHub(int contextHubHandle, in NanoAppFilter filter);
561d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi
57e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro    // Sends a message to a nanoApp
58ab7113d48507a6777c81f14b1134387382947026Arthur Ishiguro    int sendMessage(int contextHubHandle, int nanoAppHandle, in ContextHubMessage msg);
594e39aa1e1956ef0b363f38630865acd3ef65761fArthur Ishiguro
604e39aa1e1956ef0b363f38630865acd3ef65761fArthur Ishiguro    // Creates a client to send and receive messages
614e39aa1e1956ef0b363f38630865acd3ef65761fArthur Ishiguro    IContextHubClient createClient(in IContextHubClientCallback client, int contextHubId);
62e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro
63fdbbd468dc12f2390f8065fa0a16dd4bdb4bfae4Arthur Ishiguro    // Returns a list of ContextHub objects of available hubs
64fdbbd468dc12f2390f8065fa0a16dd4bdb4bfae4Arthur Ishiguro    List<ContextHubInfo> getContextHubs();
65fdbbd468dc12f2390f8065fa0a16dd4bdb4bfae4Arthur Ishiguro
66e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro    // Loads a nanoapp at the specified hub (new API)
67e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro    void loadNanoAppOnHub(
68e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro            int contextHubId, in IContextHubTransactionCallback transactionCallback,
69e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro            in NanoAppBinary nanoAppBinary);
70e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro
71e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro    // Unloads a nanoapp on a specified context hub (new API)
72e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro    void unloadNanoAppFromHub(
73e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro            int contextHubId, in IContextHubTransactionCallback transactionCallback,
74e1ade4368f8b3739e93bc3f6aefabda8b2b4424cArthur Ishiguro            long nanoAppId);
754493e1498455147a4aefc3c0a8534e43d64177c3Arthur Ishiguro
760ed545c7e580c3dab63bf2771d9c67d57c9d2600Arthur Ishiguro    // Enables a nanoapp at the specified hub
770ed545c7e580c3dab63bf2771d9c67d57c9d2600Arthur Ishiguro    void enableNanoApp(
780ed545c7e580c3dab63bf2771d9c67d57c9d2600Arthur Ishiguro            int contextHubId, in IContextHubTransactionCallback transactionCallback,
790ed545c7e580c3dab63bf2771d9c67d57c9d2600Arthur Ishiguro            long nanoAppId);
800ed545c7e580c3dab63bf2771d9c67d57c9d2600Arthur Ishiguro
8154e1a89cd8ac316c16e4d932811875aeb2fa93afArthur Ishiguro    // Disables a nanoapp at the specified hub
8254e1a89cd8ac316c16e4d932811875aeb2fa93afArthur Ishiguro    void disableNanoApp(
8354e1a89cd8ac316c16e4d932811875aeb2fa93afArthur Ishiguro            int contextHubId, in IContextHubTransactionCallback transactionCallback,
8454e1a89cd8ac316c16e4d932811875aeb2fa93afArthur Ishiguro            long nanoAppId);
8554e1a89cd8ac316c16e4d932811875aeb2fa93afArthur Ishiguro
864493e1498455147a4aefc3c0a8534e43d64177c3Arthur Ishiguro    // Queries for a list of nanoapps
874493e1498455147a4aefc3c0a8534e43d64177c3Arthur Ishiguro    void queryNanoApps(int contextHubId, in IContextHubTransactionCallback transactionCallback);
881d1ac5409597ef668e52c6f27293eaf9af575e33Ashutosh Joshi}
89