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.contexthub.HubEndpointInfo; 22 import android.hardware.contexthub.IContextHubEndpoint; 23 import android.hardware.contexthub.IContextHubEndpointCallback; 24 import android.hardware.contexthub.IContextHubEndpointDiscoveryCallback; 25 import android.hardware.location.ContextHubInfo; 26 import android.hardware.location.ContextHubMessage; 27 import android.hardware.location.HubInfo; 28 import android.hardware.location.IContextHubCallback; 29 import android.hardware.location.IContextHubClient; 30 import android.hardware.location.IContextHubClientCallback; 31 import android.hardware.location.IContextHubTransactionCallback; 32 import android.hardware.location.NanoApp; 33 import android.hardware.location.NanoAppBinary; 34 import android.hardware.location.NanoAppFilter; 35 import android.hardware.location.NanoAppInstanceInfo; 36 37 /** 38 * @hide 39 */ 40 interface IContextHubService { 41 42 // Registers a callback to receive messages 43 @EnforcePermission("ACCESS_CONTEXT_HUB") registerCallback(in IContextHubCallback callback)44 int registerCallback(in IContextHubCallback callback); 45 46 // Gets a list of available context hub handles 47 @EnforcePermission("ACCESS_CONTEXT_HUB") getContextHubHandles()48 int[] getContextHubHandles(); 49 50 // Gets the properties of a hub 51 @EnforcePermission("ACCESS_CONTEXT_HUB") getContextHubInfo(int contextHubHandle)52 ContextHubInfo getContextHubInfo(int contextHubHandle); 53 54 // Loads a nanoapp at the specified hub (old API) 55 @EnforcePermission("ACCESS_CONTEXT_HUB") loadNanoApp(int contextHubHandle, in NanoApp nanoApp)56 int loadNanoApp(int contextHubHandle, in NanoApp nanoApp); 57 58 // Unloads a nanoapp given its instance ID (old API) 59 @EnforcePermission("ACCESS_CONTEXT_HUB") unloadNanoApp(int nanoAppHandle)60 int unloadNanoApp(int nanoAppHandle); 61 62 // Gets the NanoAppInstanceInfo of a nanoapp give its instance ID 63 @EnforcePermission("ACCESS_CONTEXT_HUB") getNanoAppInstanceInfo(int nanoAppHandle)64 NanoAppInstanceInfo getNanoAppInstanceInfo(int nanoAppHandle); 65 66 // Finds all nanoApp instances matching some filter 67 @EnforcePermission("ACCESS_CONTEXT_HUB") findNanoAppOnHub(int contextHubHandle, in NanoAppFilter filter)68 int[] findNanoAppOnHub(int contextHubHandle, in NanoAppFilter filter); 69 70 // Sends a message to a nanoApp 71 @EnforcePermission("ACCESS_CONTEXT_HUB") sendMessage(int contextHubHandle, int nanoAppHandle, in ContextHubMessage msg)72 int sendMessage(int contextHubHandle, int nanoAppHandle, in ContextHubMessage msg); 73 74 // Creates a client to send and receive messages 75 @EnforcePermission("ACCESS_CONTEXT_HUB") createClient( int contextHubId, in IContextHubClientCallback client, in String attributionTag, in String packageName)76 IContextHubClient createClient( 77 int contextHubId, in IContextHubClientCallback client, in String attributionTag, 78 in String packageName); 79 80 // Creates a PendingIntent-based client to send and receive messages 81 @EnforcePermission("ACCESS_CONTEXT_HUB") createPendingIntentClient( int contextHubId, in PendingIntent pendingIntent, long nanoAppId, in String attributionTag)82 IContextHubClient createPendingIntentClient( 83 int contextHubId, in PendingIntent pendingIntent, long nanoAppId, 84 in String attributionTag); 85 86 // Returns a list of ContextHub objects of available hubs 87 @EnforcePermission("ACCESS_CONTEXT_HUB") getContextHubs()88 List<ContextHubInfo> getContextHubs(); 89 90 // Returns a list of HubInfo objects of available hubs (including ContextHub and VendorHub) 91 @EnforcePermission("ACCESS_CONTEXT_HUB") getHubs()92 List<HubInfo> getHubs(); 93 94 // Loads a nanoapp at the specified hub (new API) 95 @EnforcePermission("ACCESS_CONTEXT_HUB") loadNanoAppOnHub( int contextHubId, in IContextHubTransactionCallback transactionCallback, in NanoAppBinary nanoAppBinary)96 void loadNanoAppOnHub( 97 int contextHubId, in IContextHubTransactionCallback transactionCallback, 98 in NanoAppBinary nanoAppBinary); 99 100 // Unloads a nanoapp on a specified context hub (new API) 101 @EnforcePermission("ACCESS_CONTEXT_HUB") unloadNanoAppFromHub( int contextHubId, in IContextHubTransactionCallback transactionCallback, long nanoAppId)102 void unloadNanoAppFromHub( 103 int contextHubId, in IContextHubTransactionCallback transactionCallback, 104 long nanoAppId); 105 106 // Enables a nanoapp at the specified hub 107 @EnforcePermission("ACCESS_CONTEXT_HUB") enableNanoApp( int contextHubId, in IContextHubTransactionCallback transactionCallback, long nanoAppId)108 void enableNanoApp( 109 int contextHubId, in IContextHubTransactionCallback transactionCallback, 110 long nanoAppId); 111 112 // Disables a nanoapp at the specified hub 113 @EnforcePermission("ACCESS_CONTEXT_HUB") disableNanoApp( int contextHubId, in IContextHubTransactionCallback transactionCallback, long nanoAppId)114 void disableNanoApp( 115 int contextHubId, in IContextHubTransactionCallback transactionCallback, 116 long nanoAppId); 117 118 // Queries for a list of nanoapps 119 @EnforcePermission("ACCESS_CONTEXT_HUB") queryNanoApps(int contextHubId, in IContextHubTransactionCallback transactionCallback)120 void queryNanoApps(int contextHubId, in IContextHubTransactionCallback transactionCallback); 121 122 // Queries for a list of preloaded nanoapps 123 @EnforcePermission("ACCESS_CONTEXT_HUB") getPreloadedNanoAppIds(in ContextHubInfo hubInfo)124 long[] getPreloadedNanoAppIds(in ContextHubInfo hubInfo); 125 126 // Enables or disables test mode 127 @EnforcePermission("ACCESS_CONTEXT_HUB") setTestMode(in boolean enable)128 boolean setTestMode(in boolean enable); 129 130 // Finds all endpoints that has a specific ID 131 @EnforcePermission("ACCESS_CONTEXT_HUB") findEndpoints(long endpointId)132 List<HubEndpointInfo> findEndpoints(long endpointId); 133 134 // Finds all endpoints that has a specific service 135 @EnforcePermission("ACCESS_CONTEXT_HUB") findEndpointsWithService(String service)136 List<HubEndpointInfo> findEndpointsWithService(String service); 137 138 // Register an endpoint with the context hub 139 @EnforcePermission("ACCESS_CONTEXT_HUB") registerEndpoint(in HubEndpointInfo pendingEndpointInfo, in IContextHubEndpointCallback callback, String packageName, String attributionTag)140 IContextHubEndpoint registerEndpoint(in HubEndpointInfo pendingEndpointInfo, in IContextHubEndpointCallback callback, String packageName, String attributionTag); 141 142 // Register an endpoint discovery callback (id) 143 @EnforcePermission("ACCESS_CONTEXT_HUB") registerEndpointDiscoveryCallbackId(long endpointId, in IContextHubEndpointDiscoveryCallback callback)144 void registerEndpointDiscoveryCallbackId(long endpointId, in IContextHubEndpointDiscoveryCallback callback); 145 146 // Register an endpoint discovery callback (descriptor) 147 @EnforcePermission("ACCESS_CONTEXT_HUB") registerEndpointDiscoveryCallbackDescriptor(String serviceDescriptor, in IContextHubEndpointDiscoveryCallback callback)148 void registerEndpointDiscoveryCallbackDescriptor(String serviceDescriptor, in IContextHubEndpointDiscoveryCallback callback); 149 150 // Unregister an endpoint with the context hub 151 @EnforcePermission("ACCESS_CONTEXT_HUB") unregisterEndpointDiscoveryCallback(in IContextHubEndpointDiscoveryCallback callback)152 void unregisterEndpointDiscoveryCallback(in IContextHubEndpointDiscoveryCallback callback); 153 154 // Called when a discovery callback is finished executing 155 @EnforcePermission("ACCESS_CONTEXT_HUB") onDiscoveryCallbackFinished()156 oneway void onDiscoveryCallbackFinished(); 157 } 158