• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.car.hardware.property;
18 
19 import android.car.hardware.CarPropertyConfig;
20 import android.car.hardware.CarPropertyValue;
21 import android.car.hardware.property.ICarPropertyEventListener;
22 
23 import com.android.car.internal.property.AsyncPropertyServiceRequest;
24 import com.android.car.internal.property.AsyncPropertyServiceRequestList;
25 import com.android.car.internal.property.CarPropertyConfigList;
26 import com.android.car.internal.property.CarSubscription;
27 import com.android.car.internal.property.GetPropertyConfigListResult;
28 import com.android.car.internal.property.IAsyncPropertyResultCallback;
29 import com.android.car.internal.property.ISupportedValuesChangeCallback;
30 import com.android.car.internal.property.MinMaxSupportedPropertyValue;
31 import com.android.car.internal.property.PropIdAreaId;
32 import com.android.car.internal.property.RawPropertyValue;
33 
34 /**
35  * @hide
36  */
37 interface ICarProperty {
38 
registerListener(in List<CarSubscription> carSubscription, in ICarPropertyEventListener callback)39     void registerListener(in List<CarSubscription> carSubscription,
40                 in ICarPropertyEventListener callback);
41 
unregisterListener(int propId, in ICarPropertyEventListener callback)42     void unregisterListener(int propId, in ICarPropertyEventListener callback);
43 
getPropertyList()44     CarPropertyConfigList getPropertyList();
45 
getProperty(int prop, int zone)46     CarPropertyValue getProperty(int prop, int zone);
47 
setProperty(in CarPropertyValue prop, in ICarPropertyEventListener callback)48     void setProperty(in CarPropertyValue prop, in ICarPropertyEventListener callback);
49 
getReadPermission(int propId)50     String getReadPermission(int propId);
51 
getWritePermission(int propId)52     String getWritePermission(int propId);
53 
getPropertyConfigList(in int[] propIds)54     GetPropertyConfigListResult getPropertyConfigList(in int[] propIds);
55 
56     /**
57      * Gets CarPropertyValues asynchronously.
58      */
getPropertiesAsync(in AsyncPropertyServiceRequestList asyncPropertyServiceRequests, in IAsyncPropertyResultCallback asyncPropertyResultCallback, long timeoutInMs)59     void getPropertiesAsync(in AsyncPropertyServiceRequestList asyncPropertyServiceRequests,
60                 in IAsyncPropertyResultCallback asyncPropertyResultCallback,
61                 long timeoutInMs);
62 
63     /**
64      * Cancel on-going async requests.
65      *
66      * @param serviceRequestIds A list of async get/set property request IDs.
67      */
cancelRequests(in int[] serviceRequestIds)68     void cancelRequests(in int[] serviceRequestIds);
69 
70     /**
71      * Sets CarPropertyValues asynchronously.
72      */
setPropertiesAsync(in AsyncPropertyServiceRequestList asyncPropertyServiceRequests, in IAsyncPropertyResultCallback asyncPropertyResultCallback, long timeoutInMs)73     void setPropertiesAsync(in AsyncPropertyServiceRequestList asyncPropertyServiceRequests,
74                 in IAsyncPropertyResultCallback asyncPropertyResultCallback,
75                 long timeoutInMs);
76 
77     /**
78      * Returns the property IDs that are supported but the caller does not have read permission for.
79      */
getSupportedNoReadPermPropIds(in int[] propIds)80     int[] getSupportedNoReadPermPropIds(in int[] propIds);
81 
82     /**
83      * Returns whether the property is supported and the caller only has write permission, but
84      * no read permission for the property.
85      */
isSupportedAndHasWritePermissionOnly(int propId)86     boolean isSupportedAndHasWritePermissionOnly(int propId);
87 
88     /**
89      * Gets the current values for [propId, areaId]s and deliver them to the client as
90      * initial value events.
91      */
getAndDispatchInitialValue(in List<PropIdAreaId> propIdAreaIds, in ICarPropertyEventListener callback)92     void getAndDispatchInitialValue(in List<PropIdAreaId> propIdAreaIds,
93             in ICarPropertyEventListener callback);
94 
95     /**
96      * Gets the currently min/max supported value.
97      *
98      * @return The currently supported min/max value.
99      * @throws IllegalArgumentException if [propertyId, areaId] is not supported.
100      * @throws SecurityException if the caller does not have read and does not have write access
101      *      for the property.
102      * @throws ServiceSpecificException If VHAL returns error.
103      */
getMinMaxSupportedValue(int propertyId, int areaId)104     MinMaxSupportedPropertyValue getMinMaxSupportedValue(int propertyId, int areaId);
105 
106     /**
107      * Gets the currently supported values list.
108      *
109      * <p>The returned supported value list is in sorted ascending order if the property is of
110      * type int32, int64 or float.
111      *
112      * @return The currently supported values list.
113      * @throws IllegalArgumentException if [propertyId, areaId] is not supported.
114      * @throws SecurityException if the caller does not have read and does not have write access
115      *      for the property.
116      * @throws ServiceSpecificException If VHAL returns error.
117      */
getSupportedValuesList(int propertyId, int areaId)118     @nullable List<RawPropertyValue> getSupportedValuesList(int propertyId, int areaId);
119 
120     /**
121      * Registers the callback to be called when the min/max supported value or supported values
122      * list change.
123      *
124      * @throws IllegalArgumentException if one of the [propertyId, areaId]s are not supported.
125      * @throws SecurityException if the caller does not have read and does not have write access
126      *      for any of the requested property.
127      * @throws ServiceSpecificException If VHAL returns error.
128      */
registerSupportedValuesChangeCallback(in List<PropIdAreaId> propIdAreaIds, in ISupportedValuesChangeCallback callback)129     void registerSupportedValuesChangeCallback(in List<PropIdAreaId> propIdAreaIds,
130                 in ISupportedValuesChangeCallback callback);
131 
132     /**
133      * Unregisters the callback previously registered with registerSupportedValuesChangeCallback.
134      *
135      * Do nothing if the [propertyId, areaId]s were not previously registered.
136      */
unregisterSupportedValuesChangeCallback(in List<PropIdAreaId> propIdAreaIds, in ISupportedValuesChangeCallback callback)137     void unregisterSupportedValuesChangeCallback(in List<PropIdAreaId> propIdAreaIds,
138             in ISupportedValuesChangeCallback callback);
139 
140     /**
141      * Registers a listener to get all car property changes from the VHAL.
142      *
143      * @throws IllegalStateException If the build is not userdebug or eng.
144      * @throws IllegalStateException If there is a recording already in progress this includes one
145      *                               started by this process and started by other processes, only
146      *                               one system-wide recording is allowed at a single time.
147      * @throws IllegalStateException If fake vehicle injection mode is enabled.
148      * @throws SecurityException If missing permission.
149      *
150      * @return A list of {@link CarPropertyConfig} that are being recorded.
151      */
registerRecordingListener(in ICarPropertyEventListener callback)152     CarPropertyConfigList registerRecordingListener(in ICarPropertyEventListener callback);
153 
154     /**
155      * Returns whether an ICarPropertyEventListener is registed through registerRecordingListener.
156      *
157      * @throws IllegalStateException If the build is not userdebug or eng.
158      * @throws SecurityException If the caller is missing required permissions.
159      *
160      * @return true if a recording is in progress, false otherwise.
161      */
isRecordingVehicleProperties()162     boolean isRecordingVehicleProperties();
163 
164     /**
165      * Stops the recording based on the event listener that was given.
166      *
167      * @throws IllegalStateException If the build is not userdebug or eng.
168      * @throws IllegalStateException If the recording that was started was not started by this
169      *                               process.
170      * @throws SecurityException If the caller is missing required permissions.
171      */
stopRecordingVehicleProperties(in ICarPropertyEventListener callback)172     void stopRecordingVehicleProperties(in ICarPropertyEventListener callback);
173 
174     /**
175      * Enables injection mode with properties to allow from the real hardware.
176      *
177      * @throws IllegalStateException If the build is not userdebug or eng.
178      * @throws IllegalStateException If recording vehicle property state is enabled.
179      * @throws SecurityException If missing permission.
180      *
181      * @return The timestamp in nanos when the injection mode has started.
182      */
enableInjectionMode(in int[] propertyIdsFromRealHardware)183     long enableInjectionMode(in int[] propertyIdsFromRealHardware);
184 
185     /**
186      * Disables injection mode.
187      *
188      * @throws IllegalStateException if the build is not userdebug or eng.
189      * @throws SecurityException If missing permission.
190      */
disableInjectionMode()191     void disableInjectionMode();
192 
193     /**
194      * Returns whether fake vehciel property injection mode is enabled.
195      *
196      * @throws IllegalStateException if the build is not userdebug or eng.
197      * @throws SecurityException If missing permission.
198      *
199      * @return True if propertyInjectionMode is enabled False otherwise.
200      */
isVehiclePropertyInjectionModeEnabled()201     boolean isVehiclePropertyInjectionModeEnabled();
202 
203     /**
204      * Returns the latest CarPropertyValue that has been injected for the given propertyId
205      *
206      * This method returns null if no previous vehicle property injection has occurred for the
207      * specified propertyId.
208      *
209      * @throws IllegalStateException if the build is not userdebug or eng.
210      * @throws IllegalStateException if fakeVehiclePropertyInjection mode is not enabled.
211      * @throws SecurityException If missing permission.
212      *
213      * @return The latest CarPropertyValue that has been injected for the given PropertyId.
214      */
getLastInjectedVehicleProperty(in int propertyId)215     CarPropertyValue getLastInjectedVehicleProperty(in int propertyId);
216 
217     /**
218      * Injects fake VHAL data into car service. An empty list will be treated as a no-op.
219      *
220      * @throws IllegalStateException if the build is not userdebug or eng.
221      * @throws IllegalStateException if FakeVehiclePropertyInjectionMode is not enabled.
222      * @throws SecurityException If missing permission.
223      */
injectVehicleProperties(in List<CarPropertyValue> carPropertyValues)224     void injectVehicleProperties(in List<CarPropertyValue> carPropertyValues);
225 }
226