blob: 7c49c8ce6ed88c07c2a05f2494943e7251cc806f [file] [log] [blame]
keunyounge18e25d2015-08-28 15:57:19 -07001/*
2 * Copyright (C) 2015 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 */
16package com.android.car.vehiclenetwork;
17
18import android.annotation.Nullable;
19import android.os.Handler;
20import android.os.Looper;
21import android.os.Message;
22import android.os.RemoteException;
23import android.os.ServiceManager;
24import android.util.Log;
25
keunyoungd32f4e62015-09-21 11:33:06 -070026import com.android.car.vehiclenetwork.VehicleNetworkConsts.VehicleValueType;
keunyounge18e25d2015-08-28 15:57:19 -070027import com.android.car.vehiclenetwork.VehicleNetworkProto.VehiclePropConfigs;
28import com.android.car.vehiclenetwork.VehicleNetworkProto.VehiclePropValue;
29import com.android.car.vehiclenetwork.VehicleNetworkProto.VehiclePropValues;
keunyoung1ab8e182015-09-24 09:25:22 -070030import com.android.internal.annotations.GuardedBy;
keunyounge18e25d2015-08-28 15:57:19 -070031
32import java.lang.ref.WeakReference;
33
34/**
35 * System API to access Vehicle network. This is only for system services and applications should
keunyoung15882e52015-09-16 16:57:58 -070036 * not use this. All APIs will fail with security error if normal app tries this.
keunyounge18e25d2015-08-28 15:57:19 -070037 */
38public class VehicleNetwork {
keunyoung1ab8e182015-09-24 09:25:22 -070039 /**
40 * Listener for VNS events.
41 */
keunyounge18e25d2015-08-28 15:57:19 -070042 public interface VehicleNetworkListener {
keunyoung1ab8e182015-09-24 09:25:22 -070043 /**
44 * Notify HAL events. This requires subscribing the property
45 */
keunyounge18e25d2015-08-28 15:57:19 -070046 void onVehicleNetworkEvents(VehiclePropValues values);
47 }
48
keunyoung1ab8e182015-09-24 09:25:22 -070049 public interface VehicleNetworkHalMock {
50 VehiclePropConfigs onListProperties();
51 void onPropertySet(VehiclePropValue value);
keunyoung7d74e6d2015-10-14 15:43:10 -070052 VehiclePropValue onPropertyGet(VehiclePropValue property);
keunyoung1ab8e182015-09-24 09:25:22 -070053 void onPropertySubscribe(int property, int sampleRate);
54 void onPropertyUnsubscribe(int property);
55 }
56
keunyounge18e25d2015-08-28 15:57:19 -070057 private static final String TAG = VehicleNetwork.class.getSimpleName();
58
59 private final IVehicleNetwork mService;
60 private final VehicleNetworkListener mListener;
61 private final IVehicleNetworkListenerImpl mVehicleNetworkListener;
62 private final EventHandler mEventHandler;
63
keunyoung1ab8e182015-09-24 09:25:22 -070064 @GuardedBy("this")
65 private VehicleNetworkHalMock mHalMock;
66 private IVehicleNetworkHalMock mHalMockImpl;
67
keunyoung5c7cb262015-10-19 10:47:45 -070068 /**
69 * Factory method to create VehicleNetwork
70 * @param listener listener for listening events
71 * @param looper Looper to dispatch listener events
72 * @return
73 */
keunyoung15882e52015-09-16 16:57:58 -070074 public static VehicleNetwork createVehicleNetwork(VehicleNetworkListener listener,
75 Looper looper) {
keunyounge18e25d2015-08-28 15:57:19 -070076 IVehicleNetwork service = IVehicleNetwork.Stub.asInterface(ServiceManager.getService(
77 IVehicleNetwork.class.getCanonicalName()));
78 if (service == null) {
keunyoung15882e52015-09-16 16:57:58 -070079 throw new RuntimeException("Vehicle network service not available:" +
80 IVehicleNetwork.class.getCanonicalName());
keunyounge18e25d2015-08-28 15:57:19 -070081 }
82 return new VehicleNetwork(service, listener, looper);
83 }
84
85 private VehicleNetwork(IVehicleNetwork service, VehicleNetworkListener listener,
86 Looper looper) {
87 mService = service;
88 mListener = listener;
89 mEventHandler = new EventHandler(looper);
90 mVehicleNetworkListener = new IVehicleNetworkListenerImpl(this);
91 }
92
keunyoung5c7cb262015-10-19 10:47:45 -070093 /**
94 * List all properties from vehicle HAL
95 * @return all properties
96 */
keunyoung15882e52015-09-16 16:57:58 -070097 public VehiclePropConfigs listProperties() {
98 return listProperties(0 /* all */);
99 }
100
keunyoung5c7cb262015-10-19 10:47:45 -0700101 /**
102 * Return configuration information of single property
103 * @param property vehicle property number defined in {@link VehicleNetworkConsts}. 0 has
104 * has special meaning of list all properties.
105 * @return null if given property does not exist.
106 */
keunyounge18e25d2015-08-28 15:57:19 -0700107 public VehiclePropConfigs listProperties(int property) {
108 try {
109 VehiclePropConfigsParcelable parcelable = mService.listProperties(property);
110 if (parcelable != null) {
111 return parcelable.configs;
112 }
113 } catch (RemoteException e) {
114 handleRemoteException(e);
115 }
116 return null;
117 }
118
keunyoung5c7cb262015-10-19 10:47:45 -0700119 /**
120 * Set property which will lead into writing the value to vehicle HAL.
121 * @param value
122 * @throws IllegalArgumentException If value set has wrong value like wrong valueType,
123 * wrong data, and etc.
124 */
125 public void setProperty(VehiclePropValue value) throws IllegalArgumentException {
keunyounge18e25d2015-08-28 15:57:19 -0700126 VehiclePropValueParcelable parcelable = new VehiclePropValueParcelable(value);
127 try {
keunyoung15882e52015-09-16 16:57:58 -0700128 mService.setProperty(parcelable);
keunyounge18e25d2015-08-28 15:57:19 -0700129 } catch (RemoteException e) {
130 handleRemoteException(e);
131 }
keunyounge18e25d2015-08-28 15:57:19 -0700132 }
133
keunyoung5c7cb262015-10-19 10:47:45 -0700134 /**
135 * Set integer type property
136 * @param property
137 * @param value
138 * @throws IllegalArgumentException For type mismatch (=the property is not int type)
139 */
140 public void setIntProperty(int property, int value) throws IllegalArgumentException {
keunyoung1ab8e182015-09-24 09:25:22 -0700141 VehiclePropValue v = VehiclePropValueUtil.createIntValue(property, value, 0);
keunyoungfe30ba02015-09-17 17:56:35 -0700142 setProperty(v);
143 }
144
keunyoung5c7cb262015-10-19 10:47:45 -0700145 /**
146 * Set int vector type property. Length of passed values should match with vector length.
147 * @param property
148 * @param values
149 * @throws IllegalArgumentException
150 */
151 public void setIntVectorProperty(int property, int[] values) throws IllegalArgumentException {
keunyoung1ab8e182015-09-24 09:25:22 -0700152 VehiclePropValue v = VehiclePropValueUtil.createIntVectorValue(property, values, 0);
153 setProperty(v);
keunyoungd32f4e62015-09-21 11:33:06 -0700154 }
155
keunyoung5c7cb262015-10-19 10:47:45 -0700156 /**
157 * Set long type property.
158 * @param property
159 * @param value
160 * @throws IllegalArgumentException
161 */
162 public void setLongProperty(int property, long value) throws IllegalArgumentException {
keunyoung1ab8e182015-09-24 09:25:22 -0700163 VehiclePropValue v = VehiclePropValueUtil.createLongValue(property, value, 0);
keunyoungfe30ba02015-09-17 17:56:35 -0700164 setProperty(v);
165 }
166
keunyoung5c7cb262015-10-19 10:47:45 -0700167 /**
168 * Set float type property.
169 * @param property
170 * @param value
171 * @throws IllegalArgumentException
172 */
173 public void setFloatProperty(int property, float value) throws IllegalArgumentException {
keunyoung1ab8e182015-09-24 09:25:22 -0700174 VehiclePropValue v = VehiclePropValueUtil.createFloatValue(property, value, 0);
keunyoungfe30ba02015-09-17 17:56:35 -0700175 setProperty(v);
176 }
177
keunyoung5c7cb262015-10-19 10:47:45 -0700178 /**
179 * Set float vector type property. Length of values should match with vector length.
180 * @param property
181 * @param values
182 * @throws IllegalArgumentException
183 */
184 public void setFloatVectorProperty(int property, float[] values)
185 throws IllegalArgumentException {
keunyoung1ab8e182015-09-24 09:25:22 -0700186 VehiclePropValue v = VehiclePropValueUtil.createFloatVectorValue(property, values, 0);
187 setProperty(v);
keunyoungd32f4e62015-09-21 11:33:06 -0700188 }
189
keunyoung5c7cb262015-10-19 10:47:45 -0700190 /**
191 * Get property. This can be used for a property which does not require any other data.
192 * @param property
193 * @return
194 * @throws IllegalArgumentException
195 */
196 public VehiclePropValue getProperty(int property) throws IllegalArgumentException {
keunyoung7d74e6d2015-10-14 15:43:10 -0700197 int valueType = VehicleNetworkConsts.getVehicleValueType(property);
198 VehiclePropValue value = VehiclePropValueUtil.createBuilder(property, valueType, 0).build();
199 return getProperty(value);
200 }
201
keunyoung5c7cb262015-10-19 10:47:45 -0700202 /**
203 * Generic get method for any type of property. Some property may require setting data portion
204 * as get may return different result depending on the data set.
205 * @param value
206 * @return
207 * @throws IllegalArgumentException
208 */
209 public VehiclePropValue getProperty(VehiclePropValue value) throws IllegalArgumentException {
keunyoung7d74e6d2015-10-14 15:43:10 -0700210 VehiclePropValueParcelable parcelable = new VehiclePropValueParcelable(value);
keunyounge18e25d2015-08-28 15:57:19 -0700211 try {
keunyoung7d74e6d2015-10-14 15:43:10 -0700212 VehiclePropValueParcelable resParcelable = mService.getProperty(parcelable);
213 if (resParcelable != null) {
214 return resParcelable.value;
keunyounge18e25d2015-08-28 15:57:19 -0700215 }
216 } catch (RemoteException e) {
217 handleRemoteException(e);
218 }
219 return null;
220 }
221
keunyoung5c7cb262015-10-19 10:47:45 -0700222 /**
223 * get int type property
224 * @param property
225 * @return
226 * @throws IllegalArgumentException
227 */
228 public int getIntProperty(int property) throws IllegalArgumentException {
keunyoungfe30ba02015-09-17 17:56:35 -0700229 VehiclePropValue v = getProperty(property);
230 if (v == null) {
keunyoungd32f4e62015-09-21 11:33:06 -0700231 // if property is invalid, IllegalArgumentException should have been thrown
232 // from getProperty.
keunyoungfe30ba02015-09-17 17:56:35 -0700233 throw new IllegalStateException();
234 }
keunyoungd32f4e62015-09-21 11:33:06 -0700235 if (v.getValueType() != VehicleValueType.VEHICLE_VALUE_TYPE_INT32) {
keunyoungfe30ba02015-09-17 17:56:35 -0700236 throw new IllegalArgumentException();
237 }
keunyoungd32f4e62015-09-21 11:33:06 -0700238 if (v.getInt32ValuesCount() != 1) {
239 throw new IllegalStateException();
240 }
241 return v.getInt32Values(0);
242 }
243
keunyoung5c7cb262015-10-19 10:47:45 -0700244 /**
245 * get int vector type property. Length of values should match vector length.
246 * @param property
247 * @param values
248 * @throws IllegalArgumentException
249 */
250 public void getIntVectorProperty(int property, int[] values) throws IllegalArgumentException {
keunyoungd32f4e62015-09-21 11:33:06 -0700251 VehiclePropValue v = getProperty(property);
252 if (v == null) {
253 // if property is invalid, IllegalArgumentException should have been thrown
254 // from getProperty.
255 throw new IllegalStateException();
256 }
257 switch (v.getValueType()) {
258 case VehicleValueType.VEHICLE_VALUE_TYPE_INT32_VEC2:
259 case VehicleValueType.VEHICLE_VALUE_TYPE_INT32_VEC3:
260 case VehicleValueType.VEHICLE_VALUE_TYPE_INT32_VEC4:
261 if (values.length !=
262 (v.getValueType() - VehicleValueType.VEHICLE_VALUE_TYPE_INT32_VEC2 + 2)) {
263 throw new IllegalArgumentException("wrong array length");
264 }
265 break;
266 default:
267 throw new IllegalArgumentException();
268 }
269 if (v.getInt32ValuesCount() != values.length) {
270 throw new IllegalStateException();
271 }
272 for (int i = 0; i < values.length; i++) {
273 values[i] = v.getInt32Values(i);
274 }
keunyoungfe30ba02015-09-17 17:56:35 -0700275 }
276
keunyoung5c7cb262015-10-19 10:47:45 -0700277 /**
278 * Get float type property.
279 * @param property
280 * @return
281 * @throws IllegalArgumentException
282 */
283 public float getFloatProperty(int property) throws IllegalArgumentException {
keunyoungfe30ba02015-09-17 17:56:35 -0700284 VehiclePropValue v = getProperty(property);
285 if (v == null) {
286 throw new IllegalStateException();
287 }
keunyoungd32f4e62015-09-21 11:33:06 -0700288 if (v.getValueType() != VehicleValueType.VEHICLE_VALUE_TYPE_FLOAT) {
keunyoungfe30ba02015-09-17 17:56:35 -0700289 throw new IllegalArgumentException();
290 }
keunyoungd32f4e62015-09-21 11:33:06 -0700291 if (v.getFloatValuesCount() != 1) {
292 throw new IllegalStateException();
293 }
294 return v.getFloatValues(0);
295 }
296
keunyoung5c7cb262015-10-19 10:47:45 -0700297 /**
298 * Get float vector type property. Length of values should match vector's length.
299 * @param property
300 * @param values
301 * @throws IllegalArgumentException
302 */
303 public void getFloatVectorProperty(int property, float[] values)
304 throws IllegalArgumentException {
keunyoungd32f4e62015-09-21 11:33:06 -0700305 VehiclePropValue v = getProperty(property);
306 if (v == null) {
307 // if property is invalid, IllegalArgumentException should have been thrown
308 // from getProperty.
309 throw new IllegalStateException();
310 }
311 switch (v.getValueType()) {
312 case VehicleValueType.VEHICLE_VALUE_TYPE_FLOAT_VEC2:
313 case VehicleValueType.VEHICLE_VALUE_TYPE_FLOAT_VEC3:
314 case VehicleValueType.VEHICLE_VALUE_TYPE_FLOAT_VEC4:
315 if (values.length !=
316 (v.getValueType() - VehicleValueType.VEHICLE_VALUE_TYPE_FLOAT_VEC2 + 2)) {
317 throw new IllegalArgumentException("wrong array length");
318 }
319 break;
320 default:
321 throw new IllegalArgumentException();
322 }
323 if (v.getFloatValuesCount() != values.length) {
324 throw new IllegalStateException();
325 }
326 for (int i = 0; i < values.length; i++) {
327 values[i] = v.getFloatValues(i);
328 }
keunyoungfe30ba02015-09-17 17:56:35 -0700329 }
330
keunyoung5c7cb262015-10-19 10:47:45 -0700331 /**
332 * Get long type property.
333 * @param property
334 * @return
335 * @throws IllegalArgumentException
336 */
337 public long getLongProperty(int property) throws IllegalArgumentException {
keunyoungfe30ba02015-09-17 17:56:35 -0700338 VehiclePropValue v = getProperty(property);
339 if (v == null) {
340 throw new IllegalStateException();
341 }
keunyoungd32f4e62015-09-21 11:33:06 -0700342 if (v.getValueType() != VehicleValueType.VEHICLE_VALUE_TYPE_INT64) {
keunyoungfe30ba02015-09-17 17:56:35 -0700343 throw new IllegalArgumentException();
344 }
345 return v.getInt64Value();
346 }
347
keunyoung5c7cb262015-10-19 10:47:45 -0700348 /**
349 * Get string type property.
350 * @param property
351 * @return
352 * @throws IllegalArgumentException
353 */
keunyoungfe30ba02015-09-17 17:56:35 -0700354 //TODO check UTF8 to java string conversion
keunyoung5c7cb262015-10-19 10:47:45 -0700355 public String getStringProperty(int property) throws IllegalArgumentException {
keunyoungfe30ba02015-09-17 17:56:35 -0700356 VehiclePropValue v = getProperty(property);
357 if (v == null) {
358 throw new IllegalStateException();
359 }
keunyoungd32f4e62015-09-21 11:33:06 -0700360 if (v.getValueType() != VehicleValueType.VEHICLE_VALUE_TYPE_STRING) {
keunyoungfe30ba02015-09-17 17:56:35 -0700361 throw new IllegalArgumentException();
362 }
363 return v.getStringValue();
364 }
365
keunyoung5c7cb262015-10-19 10:47:45 -0700366 /**
367 * Subscribe given property with given sample rate.
368 * @param property
369 * @param sampleRate
370 * @throws IllegalArgumentException
371 */
372 public void subscribe(int property, float sampleRate) throws IllegalArgumentException {
keunyounge18e25d2015-08-28 15:57:19 -0700373 try {
keunyoung15882e52015-09-16 16:57:58 -0700374 mService.subscribe(mVehicleNetworkListener, property, sampleRate);
keunyounge18e25d2015-08-28 15:57:19 -0700375 } catch (RemoteException e) {
376 handleRemoteException(e);
377 }
keunyounge18e25d2015-08-28 15:57:19 -0700378 }
379
keunyoung5c7cb262015-10-19 10:47:45 -0700380 /**
381 * Stop subscribing the property.
382 * @param property
383 */
keunyounge18e25d2015-08-28 15:57:19 -0700384 public void unsubscribe(int property) {
385 try {
386 mService.unsubscribe(mVehicleNetworkListener, property);
387 } catch (RemoteException e) {
388 handleRemoteException(e);
389 }
390 }
391
keunyoung5c7cb262015-10-19 10:47:45 -0700392 /**
393 * Inject given value to all clients subscribing the property. This is for testing.
394 * @param value
395 */
keunyoung1ab8e182015-09-24 09:25:22 -0700396 public synchronized void injectEvent(VehiclePropValue value) {
397 try {
398 mService.injectEvent(new VehiclePropValueParcelable(value));
399 } catch (RemoteException e) {
400 handleRemoteException(e);
401 }
402 }
403
keunyoung5c7cb262015-10-19 10:47:45 -0700404 /**
405 * Start mocking of vehicle HAL. For testing only.
406 * @param mock
407 */
keunyoung1ab8e182015-09-24 09:25:22 -0700408 public synchronized void startMocking(VehicleNetworkHalMock mock) {
409 mHalMock = mock;
410 mHalMockImpl = new IVehicleNetworkHalMockImpl(this);
411 try {
412 mService.startMocking(mHalMockImpl);
413 } catch (RemoteException e) {
414 handleRemoteException(e);
415 }
416 }
417
keunyoung5c7cb262015-10-19 10:47:45 -0700418 /**
419 * Stop mocking of vehicle HAL. For testing only.
420 */
keunyoung1ab8e182015-09-24 09:25:22 -0700421 public synchronized void stopMocking() {
422 try {
423 mService.stopMocking(mHalMockImpl);
424 } catch (RemoteException e) {
425 handleRemoteException(e);
426 } finally {
427 mHalMock = null;
428 mHalMockImpl = null;
429 }
430 }
431
keunyoung5c7cb262015-10-19 10:47:45 -0700432 /**
433 * Start mocking of vehicle HAL. For testing only.
434 * @param mock
435 */
keunyoung1ab8e182015-09-24 09:25:22 -0700436 public synchronized void startMocking(IVehicleNetworkHalMock mock) {
437 mHalMock = null;
438 mHalMockImpl = mock;
439 try {
440 mService.startMocking(mHalMockImpl);
441 } catch (RemoteException e) {
442 handleRemoteException(e);
443 }
444 }
445
keunyoung5c7cb262015-10-19 10:47:45 -0700446 /**
447 * Stop mocking of vehicle HAL. For testing only.
448 */
keunyoung1ab8e182015-09-24 09:25:22 -0700449 public synchronized void stopMocking(IVehicleNetworkHalMock mock) {
450 if (mock.asBinder() != mHalMockImpl.asBinder()) {
451 return;
452 }
453 try {
454 mService.stopMocking(mHalMockImpl);
455 } catch (RemoteException e) {
456 handleRemoteException(e);
457 } finally {
458 mHalMock = null;
459 mHalMockImpl = null;
460 }
461 }
462
463 private synchronized VehicleNetworkHalMock getHalMock() {
464 return mHalMock;
465 }
466
keunyounge18e25d2015-08-28 15:57:19 -0700467 private void handleRemoteException(RemoteException e) {
468 throw new RuntimeException("Vehicle network service not working ", e);
469 }
470
471 private void handleVehicleNetworkEvents(VehiclePropValues values) {
472 mEventHandler.notifyEvents(values);
473 }
474
475 private void doHandleVehicleNetworkEvents(VehiclePropValues values) {
476 mListener.onVehicleNetworkEvents(values);
477 }
478
479 private class EventHandler extends Handler {
480 private static final int MSG_EVENTS = 0;
481
482 private EventHandler(Looper looper) {
483 super(looper);
484 }
485
486 private void notifyEvents(VehiclePropValues values) {
487 Message msg = obtainMessage(MSG_EVENTS, values);
488 sendMessage(msg);
489 }
490
491 @Override
492 public void handleMessage(Message msg) {
493 switch (msg.what) {
494 case MSG_EVENTS:
495 doHandleVehicleNetworkEvents((VehiclePropValues)msg.obj);
496 break;
497 default:
498 Log.w(TAG, "unown message:" + msg.what, new RuntimeException());
499 break;
500 }
501 }
502 }
503
504 private static class IVehicleNetworkListenerImpl extends IVehicleNetworkListener.Stub {
505 private final WeakReference<VehicleNetwork> mVehicleNetwork;
506
507 private IVehicleNetworkListenerImpl(VehicleNetwork vehicleNewotk) {
508 mVehicleNetwork = new WeakReference<VehicleNetwork>(vehicleNewotk);
509 }
510
511 @Override
512 public void onVehicleNetworkEvents(VehiclePropValuesParcelable values) {
513 VehicleNetwork vehicleNetwork = mVehicleNetwork.get();
514 if (vehicleNetwork != null) {
515 vehicleNetwork.handleVehicleNetworkEvents(values.values);
516 }
517 }
518 }
keunyoung1ab8e182015-09-24 09:25:22 -0700519
520 private static class IVehicleNetworkHalMockImpl extends IVehicleNetworkHalMock.Stub {
521 private final WeakReference<VehicleNetwork> mVehicleNetwork;
522
523 private IVehicleNetworkHalMockImpl(VehicleNetwork vehicleNewotk) {
524 mVehicleNetwork = new WeakReference<VehicleNetwork>(vehicleNewotk);
525 }
526
527 @Override
528 public VehiclePropConfigsParcelable onListProperties() {
529 VehicleNetwork vehicleNetwork = mVehicleNetwork.get();
530 if (vehicleNetwork == null) {
531 return null;
532 }
533 VehiclePropConfigs configs = vehicleNetwork.getHalMock().onListProperties();
534 return new VehiclePropConfigsParcelable(configs);
535 }
536
537 @Override
538 public void onPropertySet(VehiclePropValueParcelable value) {
539 VehicleNetwork vehicleNetwork = mVehicleNetwork.get();
540 if (vehicleNetwork == null) {
541 return;
542 }
543 vehicleNetwork.getHalMock().onPropertySet(value.value);
544 }
545
546 @Override
keunyoung7d74e6d2015-10-14 15:43:10 -0700547 public VehiclePropValueParcelable onPropertyGet(VehiclePropValueParcelable value) {
keunyoung1ab8e182015-09-24 09:25:22 -0700548 VehicleNetwork vehicleNetwork = mVehicleNetwork.get();
549 if (vehicleNetwork == null) {
550 return null;
551 }
keunyoung7d74e6d2015-10-14 15:43:10 -0700552 VehiclePropValue resValue = vehicleNetwork.getHalMock().onPropertyGet(value.value);
553 return new VehiclePropValueParcelable(resValue);
keunyoung1ab8e182015-09-24 09:25:22 -0700554 }
555
556 @Override
557 public void onPropertySubscribe(int property, int sampleRate) {
558 VehicleNetwork vehicleNetwork = mVehicleNetwork.get();
559 if (vehicleNetwork == null) {
560 return;
561 }
562 vehicleNetwork.getHalMock().onPropertySubscribe(property, sampleRate);
563 }
564
565 @Override
566 public void onPropertyUnsubscribe(int property) {
567 VehicleNetwork vehicleNetwork = mVehicleNetwork.get();
568 if (vehicleNetwork == null) {
569 return;
570 }
571 vehicleNetwork.getHalMock().onPropertyUnsubscribe(property);
572 }
573 }
keunyounge18e25d2015-08-28 15:57:19 -0700574}