blob: f8ba29755a342752d4bfdfb87732b0fac8ca6462 [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 */
16
17#define LOG_TAG "VehicleNetwork"
18
19#include <memory>
Keun-young Park71b2f5c2016-03-10 18:44:40 -080020#include <string.h>
keunyounge18e25d2015-08-28 15:57:19 -070021
22#include <binder/IPCThreadState.h>
Keun-young Parkba485482016-03-24 13:24:31 -070023#include <binder/Status.h>
keunyounge18e25d2015-08-28 15:57:19 -070024
25#include <utils/Log.h>
26
27#include <IVehicleNetwork.h>
28#include <VehicleNetworkProto.pb.h>
29
keunyoung15882e52015-09-16 16:57:58 -070030#include "BinderUtil.h"
keunyounge18e25d2015-08-28 15:57:19 -070031#include "VehicleNetworkProtoUtil.h"
32
33namespace android {
34
35enum {
36 LIST_PROPERTIES = IBinder::FIRST_CALL_TRANSACTION,
37 SET_PROPERTY,
38 GET_PROPERTY,
39 SUBSCRIBE,
40 UNSUBSCRIBE,
keunyoung1ab8e182015-09-24 09:25:22 -070041 INJECT_EVENT,
42 START_MOCKING,
43 STOP_MOCKING,
Keun-young Park28dd4702015-11-19 18:06:04 -080044 INJECT_HAL_ERROR,
45 START_ERROR_LISTENING,
46 STOP_ERROR_LISTENING,
47 START_HAL_RESTART_MONITORING,
48 STOP_HAL_RESTART_MONITORING
keunyounge18e25d2015-08-28 15:57:19 -070049};
50
51// ----------------------------------------------------------------------------
52
keunyoung15882e52015-09-16 16:57:58 -070053const char IVehicleNetwork::SERVICE_NAME[] = "com.android.car.vehiclenetwork.IVehicleNetwork";
keunyounge18e25d2015-08-28 15:57:19 -070054
55// ----------------------------------------------------------------------------
56
57class BpVehicleNetwork : public BpInterface<IVehicleNetwork> {
58public:
59 BpVehicleNetwork(const sp<IBinder> & impl)
60 : BpInterface<IVehicleNetwork>(impl) {
61 }
62
63 virtual sp<VehiclePropertiesHolder> listProperties(int32_t property) {
64 sp<VehiclePropertiesHolder> holder;
65 Parcel data, reply;
66 data.writeInterfaceToken(IVehicleNetwork::getInterfaceDescriptor());
67 data.writeInt32(property);
68 status_t status = remote()->transact(LIST_PROPERTIES, data, &reply);
69 if (status == NO_ERROR) {
keunyoung15882e52015-09-16 16:57:58 -070070 reply.readExceptionCode(); // for compatibility with java
keunyounge18e25d2015-08-28 15:57:19 -070071 if (reply.readInt32() == 0) { // no result
72 return holder;
73 }
74 ReadableBlobHolder blob(new Parcel::ReadableBlob());
75 if (blob.blob == NULL) {
76 ALOGE("listProperties, no memory");
77 return holder;
78 }
79 int32_t size = reply.readInt32();
Keun-young Park20539ba2016-10-10 17:57:34 -070080 if (size < 0) {
81 ALOGE("listProperties, bad blob size %d", size);
82 return holder;
83 }
keunyounge18e25d2015-08-28 15:57:19 -070084 status = reply.readBlob(size, blob.blob);
85 if (status != NO_ERROR) {
86 ALOGE("listProperties, cannot read blob %d", status);
87 return holder;
88 }
89 //TODO make this more memory efficient
90 std::unique_ptr<VehiclePropConfigs> configs(new VehiclePropConfigs());
91 if (configs.get() == NULL) {
92 return holder;
93 }
94 if(!configs->ParseFromArray(blob.blob->data(), size)) {
95 ALOGE("listProperties, cannot parse reply");
96 return holder;
97 }
keunyoungd32f4e62015-09-21 11:33:06 -070098 holder = new VehiclePropertiesHolder();
99 ASSERT_OR_HANDLE_NO_MEMORY(holder.get(), return);
100 status = VehicleNetworkProtoUtil::fromVehiclePropConfigs(*configs.get(),
101 holder->getList());
keunyounge18e25d2015-08-28 15:57:19 -0700102 if (status != NO_ERROR) {
103 ALOGE("listProperties, cannot convert VehiclePropConfigs %d", status);
104 return holder;
105 }
keunyoungd32f4e62015-09-21 11:33:06 -0700106
keunyounge18e25d2015-08-28 15:57:19 -0700107 }
108 return holder;
109 }
110
111 virtual status_t setProperty(const vehicle_prop_value_t& value) {
112 Parcel data, reply;
113 data.writeInterfaceToken(IVehicleNetwork::getInterfaceDescriptor());
keunyoung7d74e6d2015-10-14 15:43:10 -0700114 status_t status = VehiclePropValueBinderUtil::writeToParcel(data, value);
115 if (status != NO_ERROR) {
116 return status;
117 }
118 status = remote()->transact(SET_PROPERTY, data, &reply);
Keun-young Parke78bf532016-04-25 18:59:22 -0700119 if (status == NO_ERROR) {
120 int32_t exceptionCode = reply.readExceptionCode();
121 if (exceptionCode != NO_ERROR) {
122 if (exceptionCode == binder::Status::EX_SERVICE_SPECIFIC) {
123 return -EAGAIN;
124 } else if (exceptionCode == binder::Status::EX_ILLEGAL_STATE) {
125 return -ESHUTDOWN;
126 }
127 return exceptionCode;
128 }
129 }
keunyounge18e25d2015-08-28 15:57:19 -0700130 return status;
131 }
132
133 virtual status_t getProperty(vehicle_prop_value_t* value) {
134 Parcel data, reply;
keunyoung7d74e6d2015-10-14 15:43:10 -0700135 if (value == NULL) {
136 return BAD_VALUE;
137 }
keunyounge18e25d2015-08-28 15:57:19 -0700138 data.writeInterfaceToken(IVehicleNetwork::getInterfaceDescriptor());
keunyoung7d74e6d2015-10-14 15:43:10 -0700139 status_t status = VehiclePropValueBinderUtil::writeToParcel(data, *value);
140 if (status != NO_ERROR) {
141 ALOGE("getProperty, cannot write");
142 return status;
143 }
144 status = remote()->transact(GET_PROPERTY, data, &reply);
keunyounge18e25d2015-08-28 15:57:19 -0700145 if (status == NO_ERROR) {
Keun-young Parkba485482016-03-24 13:24:31 -0700146 int32_t exceptionCode = reply.readExceptionCode();
147 if (exceptionCode != NO_ERROR) {
148 if (exceptionCode == binder::Status::EX_SERVICE_SPECIFIC) {
149 return -EAGAIN;
Steve Paikb224b852016-07-08 16:11:43 -0700150 } else if (exceptionCode == binder::Status::EX_ILLEGAL_STATE) {
151 return -ESHUTDOWN;
Keun-young Parkba485482016-03-24 13:24:31 -0700152 }
153 return exceptionCode;
154 }
keunyoung7d74e6d2015-10-14 15:43:10 -0700155 status = VehiclePropValueBinderUtil::readFromParcel(reply, value);
keunyounge18e25d2015-08-28 15:57:19 -0700156 }
157 return status;
158 }
159
160 virtual status_t subscribe(const sp<IVehicleNetworkListener> &listener, int32_t property,
Pavel Maltsevb0324b42016-09-27 21:00:41 -0700161 float sampleRate, int32_t zones, int32_t flags) {
keunyounge18e25d2015-08-28 15:57:19 -0700162 Parcel data, reply;
163 data.writeInterfaceToken(IVehicleNetwork::getInterfaceDescriptor());
164 data.writeStrongBinder(IInterface::asBinder(listener));
165 data.writeInt32(property);
166 data.writeFloat(sampleRate);
Keun-young Park0727f952015-12-21 14:30:07 -0800167 data.writeInt32(zones);
Pavel Maltsevb0324b42016-09-27 21:00:41 -0700168 data.writeInt32(flags);
keunyounge18e25d2015-08-28 15:57:19 -0700169 status_t status = remote()->transact(SUBSCRIBE, data, &reply);
170 return status;
171 }
172
173 virtual void unsubscribe(const sp<IVehicleNetworkListener> &listener, int32_t property) {
174 Parcel data, reply;
175 data.writeInterfaceToken(IVehicleNetwork::getInterfaceDescriptor());
176 data.writeStrongBinder(IInterface::asBinder(listener));
177 data.writeInt32(property);
178 status_t status = remote()->transact(UNSUBSCRIBE, data, &reply);
179 if (status != NO_ERROR) {
180 ALOGI("unsubscribing property %d failed %d", property, status);
181 }
182 }
keunyoung1ab8e182015-09-24 09:25:22 -0700183
184 virtual status_t injectEvent(const vehicle_prop_value_t& value) {
185 Parcel data, reply;
186 data.writeInterfaceToken(IVehicleNetwork::getInterfaceDescriptor());
187 data.writeInt32(1); // 0 means no value. For compatibility with aidl based code.
188 std::unique_ptr<VehiclePropValue> v(new VehiclePropValue());
189 ASSERT_OR_HANDLE_NO_MEMORY(v.get(), return NO_MEMORY);
190 VehicleNetworkProtoUtil::toVehiclePropValue(value, *v.get());
191 int size = v->ByteSize();
192 WritableBlobHolder blob(new Parcel::WritableBlob());
193 ASSERT_OR_HANDLE_NO_MEMORY(blob.blob, return NO_MEMORY);
194 data.writeInt32(size);
195 data.writeBlob(size, false, blob.blob);
196 v->SerializeToArray(blob.blob->data(), size);
197 status_t status = remote()->transact(INJECT_EVENT, data, &reply);
198 return status;
199 }
200
201 virtual status_t startMocking(const sp<IVehicleNetworkHalMock>& mock) {
202 Parcel data, reply;
203 data.writeInterfaceToken(IVehicleNetwork::getInterfaceDescriptor());
204 data.writeStrongBinder(IInterface::asBinder(mock));
205 status_t status = remote()->transact(START_MOCKING, data, &reply);
206 return status;
207 }
208
209 virtual void stopMocking(const sp<IVehicleNetworkHalMock>& mock) {
210 Parcel data, reply;
211 data.writeInterfaceToken(IVehicleNetwork::getInterfaceDescriptor());
212 data.writeStrongBinder(IInterface::asBinder(mock));
213 status_t status = remote()->transact(STOP_MOCKING, data, &reply);
214 if (status != NO_ERROR) {
215 ALOGI("stop mocking failed %d", status);
216 }
217 }
Keun-young Park28dd4702015-11-19 18:06:04 -0800218
219 status_t injectHalError(int32_t errorCode, int32_t property, int32_t operation) {
220 Parcel data, reply;
221 data.writeInterfaceToken(IVehicleNetwork::getInterfaceDescriptor());
222 data.writeInt32(errorCode);
223 data.writeInt32(property);
224 data.writeInt32(operation);
225 status_t status = remote()->transact(INJECT_HAL_ERROR, data, &reply);
226 return status;
227 }
228
229 virtual status_t startErrorListening(const sp<IVehicleNetworkListener> &listener) {
230 Parcel data, reply;
231 data.writeInterfaceToken(IVehicleNetwork::getInterfaceDescriptor());
232 data.writeStrongBinder(IInterface::asBinder(listener));
233 status_t status = remote()->transact(START_ERROR_LISTENING, data, &reply);
234 return status;
235 }
236
237 virtual void stopErrorListening(const sp<IVehicleNetworkListener> &listener) {
238 Parcel data, reply;
239 data.writeInterfaceToken(IVehicleNetwork::getInterfaceDescriptor());
240 data.writeStrongBinder(IInterface::asBinder(listener));
241 status_t status = remote()->transact(STOP_ERROR_LISTENING, data, &reply);
242 if (status != NO_ERROR) {
243 ALOGI("stopErrorListening %d", status);
244 }
245 }
246
247 virtual status_t startHalRestartMonitoring(const sp<IVehicleNetworkListener> &listener) {
248 Parcel data, reply;
249 data.writeInterfaceToken(IVehicleNetwork::getInterfaceDescriptor());
250 data.writeStrongBinder(IInterface::asBinder(listener));
251 status_t status = remote()->transact(START_HAL_RESTART_MONITORING, data, &reply);
252 return status;
253 }
254
255 virtual void stopHalRestartMonitoring(const sp<IVehicleNetworkListener> &listener) {
256 Parcel data, reply;
257 data.writeInterfaceToken(IVehicleNetwork::getInterfaceDescriptor());
258 data.writeStrongBinder(IInterface::asBinder(listener));
259 status_t status = remote()->transact(STOP_HAL_RESTART_MONITORING, data, &reply);
260 if (status != NO_ERROR) {
261 ALOGI("stopHalRestartMonitoring %d", status);
262 }
263 }
keunyounge18e25d2015-08-28 15:57:19 -0700264};
265
266IMPLEMENT_META_INTERFACE(VehicleNetwork, IVehicleNetwork::SERVICE_NAME);
267
268// ----------------------------------------------------------------------
269
keunyounge18e25d2015-08-28 15:57:19 -0700270status_t BnVehicleNetwork::onTransact(uint32_t code, const Parcel& data, Parcel* reply,
271 uint32_t flags) {
keunyounge18e25d2015-08-28 15:57:19 -0700272 status_t r;
273 switch (code) {
274 case LIST_PROPERTIES: {
275 CHECK_INTERFACE(IVehicleNetwork, data, reply);
Keun-young Park737cdfb2016-02-12 15:11:39 -0800276 if (!isOperationAllowed(0, false)) {
277 return PERMISSION_DENIED;
278 }
keunyounge18e25d2015-08-28 15:57:19 -0700279 int32_t property = data.readInt32();
280 sp<VehiclePropertiesHolder> holder = listProperties(property);
281 if (holder.get() == NULL) { // given property not found
keunyoung15882e52015-09-16 16:57:58 -0700282 BinderUtil::fillObjectResultReply(reply, false /* isValid */);
283 return NO_ERROR;
keunyounge18e25d2015-08-28 15:57:19 -0700284 }
285 std::unique_ptr<VehiclePropConfigs> configs(new VehiclePropConfigs());
286 ASSERT_OR_HANDLE_NO_MEMORY(configs.get(), return NO_MEMORY);
keunyoungd32f4e62015-09-21 11:33:06 -0700287 VehicleNetworkProtoUtil::toVehiclePropConfigs(holder->getList(), *configs.get());
keunyounge18e25d2015-08-28 15:57:19 -0700288 int size = configs->ByteSize();
289 WritableBlobHolder blob(new Parcel::WritableBlob());
290 ASSERT_OR_HANDLE_NO_MEMORY(blob.blob, return NO_MEMORY);
keunyoung15882e52015-09-16 16:57:58 -0700291 BinderUtil::fillObjectResultReply(reply, true);
keunyounge18e25d2015-08-28 15:57:19 -0700292 reply->writeInt32(size);
293 reply->writeBlob(size, false, blob.blob);
294 configs->SerializeToArray(blob.blob->data(), size);
295 return NO_ERROR;
296 } break;
297 case SET_PROPERTY: {
298 CHECK_INTERFACE(IVehicleNetwork, data, reply);
keunyounge18e25d2015-08-28 15:57:19 -0700299 ScopedVehiclePropValue value;
keunyoung7d74e6d2015-10-14 15:43:10 -0700300 r = VehiclePropValueBinderUtil::readFromParcel(data, &value.value,
301 false /* deleteMembers */);
keunyounge18e25d2015-08-28 15:57:19 -0700302 if (r != NO_ERROR) {
keunyounge18e25d2015-08-28 15:57:19 -0700303 return r;
304 }
Keun-young Park737cdfb2016-02-12 15:11:39 -0800305 if (!isOperationAllowed(value.value.prop, true)) {
306 return PERMISSION_DENIED;
307 }
keunyounge18e25d2015-08-28 15:57:19 -0700308 r = setProperty(value.value);
Keun-young Parke78bf532016-04-25 18:59:22 -0700309 if (r == NO_ERROR) {
310 reply->writeNoException();
311 } else if (r == -EAGAIN) {
312 // this should be handled specially to throw ServiceSpecificException in java.
313 reply->writeInt32(binder::Status::EX_SERVICE_SPECIFIC);
314 return NO_ERROR;
315 } else if (r == -ESHUTDOWN) {
316 // this should be handled specially to throw IllegalStateException in java.
317 reply->writeInt32(binder::Status::EX_ILLEGAL_STATE);
318 return NO_ERROR;
319 }
keunyounge18e25d2015-08-28 15:57:19 -0700320 return r;
321 } break;
322 case GET_PROPERTY: {
323 CHECK_INTERFACE(IVehicleNetwork, data, reply);
Keun-young Park71b2f5c2016-03-10 18:44:40 -0800324 vehicle_prop_value_t value;
325 memset(&value, 0, sizeof(value));
326 r = VehiclePropValueBinderUtil::readFromParcel(data, &value,
keunyoung7d74e6d2015-10-14 15:43:10 -0700327 false /* deleteMembers */, true /*canIgnoreNoData*/);
328 if (r != NO_ERROR) {
329 ALOGE("getProperty cannot read %d", r);
330 return r;
331 }
Keun-young Park71b2f5c2016-03-10 18:44:40 -0800332 if (!isOperationAllowed(value.prop, false)) {
Keun-young Park737cdfb2016-02-12 15:11:39 -0800333 return PERMISSION_DENIED;
334 }
Keun-young Park71b2f5c2016-03-10 18:44:40 -0800335 r = getProperty(&value);
keunyounge18e25d2015-08-28 15:57:19 -0700336 if (r == NO_ERROR) {
Steve Paikb224b852016-07-08 16:11:43 -0700337 // If int32 or float value is out of range, throw an exception:
338 switch (value.value_type) {
339 case VEHICLE_VALUE_TYPE_INT32:
340 case VEHICLE_VALUE_TYPE_ZONED_INT32:
341 // TODO: Handle array types as well?
342 if (value.value.int32_value == VEHICLE_INT_OUT_OF_RANGE_OFF) {
343 // this should be handled specially to throw IllegalStateException in java.
344 reply->writeInt32(binder::Status::EX_ILLEGAL_STATE);
345 return NO_ERROR;
346 }
347 break;
348 case VEHICLE_VALUE_TYPE_FLOAT:
349 case VEHICLE_VALUE_TYPE_ZONED_FLOAT:
350 // TODO: Handle array types as well?
351 if (value.value.float_value == VEHICLE_FLOAT_OUT_OF_RANGE_OFF) {
352 // this should be handled specially to throw IllegalStateException in java.
353 reply->writeInt32(binder::Status::EX_ILLEGAL_STATE);
354 return NO_ERROR;
355 }
356 break;
357 }
keunyoung7d74e6d2015-10-14 15:43:10 -0700358 reply->writeNoException();
Keun-young Park71b2f5c2016-03-10 18:44:40 -0800359 r = VehiclePropValueBinderUtil::writeToParcel(*reply, value);
360 releaseMemoryFromGet(&value);
Keun-young Parkba485482016-03-24 13:24:31 -0700361 } else if (r == -EAGAIN) {
362 // this should be handled specially to throw ServiceSpecificException in java.
363 reply->writeInt32(binder::Status::EX_SERVICE_SPECIFIC);
364 return NO_ERROR;
keunyounge18e25d2015-08-28 15:57:19 -0700365 }
366 return r;
367 } break;
368 case SUBSCRIBE: {
369 CHECK_INTERFACE(IVehicleNetwork, data, reply);
370 sp<IVehicleNetworkListener> listener =
371 interface_cast<IVehicleNetworkListener>(data.readStrongBinder());
372 int32_t property = data.readInt32();
Keun-young Park737cdfb2016-02-12 15:11:39 -0800373 if (!isOperationAllowed(property, false)) {
374 return PERMISSION_DENIED;
375 }
keunyounge18e25d2015-08-28 15:57:19 -0700376 float sampleRate = data.readFloat();
Keun-young Park0727f952015-12-21 14:30:07 -0800377 int32_t zones = data.readInt32();
Pavel Maltsevb0324b42016-09-27 21:00:41 -0700378 int32_t flags = data.readInt32();
379 r = subscribe(listener, property, sampleRate, zones, flags);
keunyoung15882e52015-09-16 16:57:58 -0700380 BinderUtil::fillNoResultReply(reply);
keunyounge18e25d2015-08-28 15:57:19 -0700381 return r;
382 } break;
383 case UNSUBSCRIBE: {
384 CHECK_INTERFACE(IVehicleNetwork, data, reply);
385 sp<IVehicleNetworkListener> listener =
386 interface_cast<IVehicleNetworkListener>(data.readStrongBinder());
387 int32_t property = data.readInt32();
Keun-young Park737cdfb2016-02-12 15:11:39 -0800388 if (!isOperationAllowed(property, false)) {
389 return PERMISSION_DENIED;
390 }
keunyounge18e25d2015-08-28 15:57:19 -0700391 unsubscribe(listener, property);
keunyoung15882e52015-09-16 16:57:58 -0700392 BinderUtil::fillNoResultReply(reply);
keunyounge18e25d2015-08-28 15:57:19 -0700393 return NO_ERROR;
394 } break;
keunyoung1ab8e182015-09-24 09:25:22 -0700395 case INJECT_EVENT: {
396 CHECK_INTERFACE(IVehicleNetwork, data, reply);
397 if (data.readInt32() == 0) { // java side allows passing null with this.
398 return BAD_VALUE;
399 }
Keun-young Park737cdfb2016-02-12 15:11:39 -0800400 if (!isOperationAllowed(0, true)) {
401 return PERMISSION_DENIED;
402 }
keunyoung1ab8e182015-09-24 09:25:22 -0700403 ScopedVehiclePropValue value;
404 ReadableBlobHolder blob(new Parcel::ReadableBlob());
405 ASSERT_OR_HANDLE_NO_MEMORY(blob.blob, return NO_MEMORY);
406 int32_t size = data.readInt32();
Keun-young Park20539ba2016-10-10 17:57:34 -0700407 if (size < 0) {
408 ALOGE("injectEvent:service, bad blob size %d", size);
409 return BAD_VALUE;
410 }
keunyoung1ab8e182015-09-24 09:25:22 -0700411 r = data.readBlob(size, blob.blob);
412 if (r != NO_ERROR) {
413 ALOGE("injectEvent:service, cannot read blob");
414 return r;
415 }
416 std::unique_ptr<VehiclePropValue> v(new VehiclePropValue());
417 ASSERT_OR_HANDLE_NO_MEMORY(v.get(), return NO_MEMORY);
418 if (!v->ParseFromArray(blob.blob->data(), size)) {
419 ALOGE("injectEvent:service, cannot parse data");
420 return BAD_VALUE;
421 }
422 r = VehicleNetworkProtoUtil::fromVehiclePropValue(*v.get(), value.value);
423 if (r != NO_ERROR) {
424 ALOGE("injectEvent:service, cannot convert data");
425 return BAD_VALUE;
426 }
427 r = injectEvent(value.value);
428 BinderUtil::fillNoResultReply(reply);
429 return r;
430 } break;
431 case START_MOCKING: {
Keun-young Park737cdfb2016-02-12 15:11:39 -0800432 if (!isOperationAllowed(0, true)) {
433 return PERMISSION_DENIED;
434 }
keunyoung1ab8e182015-09-24 09:25:22 -0700435 CHECK_INTERFACE(IVehicleNetwork, data, reply);
436 sp<IVehicleNetworkHalMock> mock =
437 interface_cast<IVehicleNetworkHalMock>(data.readStrongBinder());
438 r = startMocking(mock);
439 BinderUtil::fillNoResultReply(reply);
440 return r;
441 } break;
442 case STOP_MOCKING: {
Keun-young Park737cdfb2016-02-12 15:11:39 -0800443 if (!isOperationAllowed(0, true)) {
444 return PERMISSION_DENIED;
445 }
keunyoung1ab8e182015-09-24 09:25:22 -0700446 CHECK_INTERFACE(IVehicleNetwork, data, reply);
447 sp<IVehicleNetworkHalMock> mock =
448 interface_cast<IVehicleNetworkHalMock>(data.readStrongBinder());
449 stopMocking(mock);
450 BinderUtil::fillNoResultReply(reply);
451 return NO_ERROR;
452 } break;
Keun-young Park28dd4702015-11-19 18:06:04 -0800453 case INJECT_HAL_ERROR: {
Keun-young Park737cdfb2016-02-12 15:11:39 -0800454 if (!isOperationAllowed(0, true)) {
455 return PERMISSION_DENIED;
456 }
Keun-young Park28dd4702015-11-19 18:06:04 -0800457 CHECK_INTERFACE(IVehicleNetwork, data, reply);
458 int32_t errorCode = data.readInt32();
459 int32_t property = data.readInt32();
460 int32_t operation = data.readInt32();
461 r = injectHalError(errorCode, property, operation);
462 BinderUtil::fillNoResultReply(reply);
463 return r;
464 } break;
465 case START_ERROR_LISTENING: {
Keun-young Park737cdfb2016-02-12 15:11:39 -0800466 if (!isOperationAllowed(0, false)) {
467 return PERMISSION_DENIED;
468 }
Keun-young Park28dd4702015-11-19 18:06:04 -0800469 CHECK_INTERFACE(IVehicleNetwork, data, reply);
470 sp<IVehicleNetworkListener> listener =
471 interface_cast<IVehicleNetworkListener>(data.readStrongBinder());
472 r = startErrorListening(listener);
473 BinderUtil::fillNoResultReply(reply);
474 return r;
475 } break;
476 case STOP_ERROR_LISTENING: {
Keun-young Park737cdfb2016-02-12 15:11:39 -0800477 if (!isOperationAllowed(0, false)) {
478 return PERMISSION_DENIED;
479 }
Keun-young Park28dd4702015-11-19 18:06:04 -0800480 CHECK_INTERFACE(IVehicleNetwork, data, reply);
481 sp<IVehicleNetworkListener> listener =
482 interface_cast<IVehicleNetworkListener>(data.readStrongBinder());
483 stopErrorListening(listener);
484 BinderUtil::fillNoResultReply(reply);
485 return NO_ERROR;
486 } break;
487 case START_HAL_RESTART_MONITORING: {
Keun-young Park737cdfb2016-02-12 15:11:39 -0800488 if (!isOperationAllowed(0, false)) {
489 return PERMISSION_DENIED;
490 }
Keun-young Park28dd4702015-11-19 18:06:04 -0800491 CHECK_INTERFACE(IVehicleNetwork, data, reply);
492 sp<IVehicleNetworkListener> listener =
493 interface_cast<IVehicleNetworkListener>(data.readStrongBinder());
494 r = startHalRestartMonitoring(listener);
495 BinderUtil::fillNoResultReply(reply);
496 return r;
497 } break;
498 case STOP_HAL_RESTART_MONITORING: {
Keun-young Park737cdfb2016-02-12 15:11:39 -0800499 if (!isOperationAllowed(0, false)) {
500 return PERMISSION_DENIED;
501 }
Keun-young Park28dd4702015-11-19 18:06:04 -0800502 CHECK_INTERFACE(IVehicleNetwork, data, reply);
503 sp<IVehicleNetworkListener> listener =
504 interface_cast<IVehicleNetworkListener>(data.readStrongBinder());
505 stopHalRestartMonitoring(listener);
506 BinderUtil::fillNoResultReply(reply);
507 return NO_ERROR;
508 } break;
keunyounge18e25d2015-08-28 15:57:19 -0700509 default:
510 return BBinder::onTransact(code, data, reply, flags);
511 }
512}
513
514}; // namespace android