1 /*
2  * Copyright (C) 2016 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 
17 package android.hardware.location;
18 
19 // Declare any non-default types here with import statements
20 import android.app.PendingIntent;
21 import android.hardware.location.ContextHubInfo;
22 import android.hardware.location.ContextHubMessage;
23 import android.hardware.location.NanoApp;
24 import android.hardware.location.NanoAppBinary;
25 import android.hardware.location.NanoAppFilter;
26 import android.hardware.location.NanoAppInstanceInfo;
27 import android.hardware.location.IContextHubCallback;
28 import android.hardware.location.IContextHubClient;
29 import android.hardware.location.IContextHubClientCallback;
30 import android.hardware.location.IContextHubTransactionCallback;
31 
32 /**
33  * @hide
34  */
35 interface IContextHubService {
36 
37     // Registers a callback to receive messages
38     @EnforcePermission("ACCESS_CONTEXT_HUB")
registerCallback(in IContextHubCallback callback)39     int registerCallback(in IContextHubCallback callback);
40 
41     // Gets a list of available context hub handles
42     @EnforcePermission("ACCESS_CONTEXT_HUB")
getContextHubHandles()43     int[] getContextHubHandles();
44 
45     // Gets the properties of a hub
46     @EnforcePermission("ACCESS_CONTEXT_HUB")
getContextHubInfo(int contextHubHandle)47     ContextHubInfo getContextHubInfo(int contextHubHandle);
48 
49     // Loads a nanoapp at the specified hub (old API)
50     @EnforcePermission("ACCESS_CONTEXT_HUB")
loadNanoApp(int contextHubHandle, in NanoApp nanoApp)51     int loadNanoApp(int contextHubHandle, in NanoApp nanoApp);
52 
53     // Unloads a nanoapp given its instance ID (old API)
54     @EnforcePermission("ACCESS_CONTEXT_HUB")
unloadNanoApp(int nanoAppHandle)55     int unloadNanoApp(int nanoAppHandle);
56 
57     // Gets the NanoAppInstanceInfo of a nanoapp give its instance ID
58     @EnforcePermission("ACCESS_CONTEXT_HUB")
getNanoAppInstanceInfo(int nanoAppHandle)59     NanoAppInstanceInfo getNanoAppInstanceInfo(int nanoAppHandle);
60 
61     // Finds all nanoApp instances matching some filter
62     @EnforcePermission("ACCESS_CONTEXT_HUB")
findNanoAppOnHub(int contextHubHandle, in NanoAppFilter filter)63     int[] findNanoAppOnHub(int contextHubHandle, in NanoAppFilter filter);
64 
65     // Sends a message to a nanoApp
66     @EnforcePermission("ACCESS_CONTEXT_HUB")
sendMessage(int contextHubHandle, int nanoAppHandle, in ContextHubMessage msg)67     int sendMessage(int contextHubHandle, int nanoAppHandle, in ContextHubMessage msg);
68 
69     // Creates a client to send and receive messages
70     @EnforcePermission("ACCESS_CONTEXT_HUB")
createClient( int contextHubId, in IContextHubClientCallback client, in String attributionTag, in String packageName)71     IContextHubClient createClient(
72             int contextHubId, in IContextHubClientCallback client, in String attributionTag,
73             in String packageName);
74 
75     // Creates a PendingIntent-based client to send and receive messages
76     @EnforcePermission("ACCESS_CONTEXT_HUB")
createPendingIntentClient( int contextHubId, in PendingIntent pendingIntent, long nanoAppId, in String attributionTag)77     IContextHubClient createPendingIntentClient(
78             int contextHubId, in PendingIntent pendingIntent, long nanoAppId,
79             in String attributionTag);
80 
81     // Returns a list of ContextHub objects of available hubs
82     @EnforcePermission("ACCESS_CONTEXT_HUB")
getContextHubs()83     List<ContextHubInfo> getContextHubs();
84 
85     // Loads a nanoapp at the specified hub (new API)
86     @EnforcePermission("ACCESS_CONTEXT_HUB")
loadNanoAppOnHub( int contextHubId, in IContextHubTransactionCallback transactionCallback, in NanoAppBinary nanoAppBinary)87     void loadNanoAppOnHub(
88             int contextHubId, in IContextHubTransactionCallback transactionCallback,
89             in NanoAppBinary nanoAppBinary);
90 
91     // Unloads a nanoapp on a specified context hub (new API)
92     @EnforcePermission("ACCESS_CONTEXT_HUB")
unloadNanoAppFromHub( int contextHubId, in IContextHubTransactionCallback transactionCallback, long nanoAppId)93     void unloadNanoAppFromHub(
94             int contextHubId, in IContextHubTransactionCallback transactionCallback,
95             long nanoAppId);
96 
97     // Enables a nanoapp at the specified hub
98     @EnforcePermission("ACCESS_CONTEXT_HUB")
enableNanoApp( int contextHubId, in IContextHubTransactionCallback transactionCallback, long nanoAppId)99     void enableNanoApp(
100             int contextHubId, in IContextHubTransactionCallback transactionCallback,
101             long nanoAppId);
102 
103     // Disables a nanoapp at the specified hub
104     @EnforcePermission("ACCESS_CONTEXT_HUB")
disableNanoApp( int contextHubId, in IContextHubTransactionCallback transactionCallback, long nanoAppId)105     void disableNanoApp(
106             int contextHubId, in IContextHubTransactionCallback transactionCallback,
107             long nanoAppId);
108 
109     // Queries for a list of nanoapps
110     @EnforcePermission("ACCESS_CONTEXT_HUB")
queryNanoApps(int contextHubId, in IContextHubTransactionCallback transactionCallback)111     void queryNanoApps(int contextHubId, in IContextHubTransactionCallback transactionCallback);
112 
113     // Queries for a list of preloaded nanoapps
114     @EnforcePermission("ACCESS_CONTEXT_HUB")
getPreloadedNanoAppIds(in ContextHubInfo hubInfo)115     long[] getPreloadedNanoAppIds(in ContextHubInfo hubInfo);
116 
117     // Enables or disables test mode
118     @EnforcePermission("ACCESS_CONTEXT_HUB")
setTestMode(in boolean enable)119     boolean setTestMode(in boolean enable);
120 }
121