Merge "Initial HIDL vehicle HAL"
This commit is contained in:
commit
e30fb98122
13 changed files with 4813 additions and 0 deletions
|
@ -24,6 +24,7 @@ subdirs = [
|
|||
"tests/msgq/1.0",
|
||||
"tests/pointer/1.0",
|
||||
"vibrator/1.0",
|
||||
"vehicle/2.0",
|
||||
"wifi/1.0",
|
||||
"wifi/supplicant/1.0",
|
||||
]
|
||||
|
|
54
vehicle/2.0/Android.bp
Normal file
54
vehicle/2.0/Android.bp
Normal file
|
@ -0,0 +1,54 @@
|
|||
// This file is autogenerated by hidl-gen. Do not edit manually.
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.vehicle@2.0_genc++",
|
||||
tool: "hidl-gen",
|
||||
cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.vehicle@2.0",
|
||||
srcs: [
|
||||
"types.hal",
|
||||
"IVehicle.hal",
|
||||
"IVehicleCallback.hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/vehicle/2.0/types.cpp",
|
||||
"android/hardware/vehicle/2.0/VehicleAll.cpp",
|
||||
"android/hardware/vehicle/2.0/VehicleCallbackAll.cpp",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.vehicle@2.0_genc++_headers",
|
||||
tool: "hidl-gen",
|
||||
cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.vehicle@2.0",
|
||||
srcs: [
|
||||
"types.hal",
|
||||
"IVehicle.hal",
|
||||
"IVehicleCallback.hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/vehicle/2.0/types.h",
|
||||
"android/hardware/vehicle/2.0/IVehicle.h",
|
||||
"android/hardware/vehicle/2.0/IHwVehicle.h",
|
||||
"android/hardware/vehicle/2.0/BnVehicle.h",
|
||||
"android/hardware/vehicle/2.0/BpVehicle.h",
|
||||
"android/hardware/vehicle/2.0/BsVehicle.h",
|
||||
"android/hardware/vehicle/2.0/IVehicleCallback.h",
|
||||
"android/hardware/vehicle/2.0/IHwVehicleCallback.h",
|
||||
"android/hardware/vehicle/2.0/BnVehicleCallback.h",
|
||||
"android/hardware/vehicle/2.0/BpVehicleCallback.h",
|
||||
"android/hardware/vehicle/2.0/BsVehicleCallback.h",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library_shared {
|
||||
name: "android.hardware.vehicle@2.0",
|
||||
generated_sources: ["android.hardware.vehicle@2.0_genc++"],
|
||||
generated_headers: ["android.hardware.vehicle@2.0_genc++_headers"],
|
||||
export_generated_headers: ["android.hardware.vehicle@2.0_genc++_headers"],
|
||||
shared_libs: [
|
||||
"libhidl",
|
||||
"libhwbinder",
|
||||
"libutils",
|
||||
"libcutils",
|
||||
],
|
||||
}
|
1708
vehicle/2.0/Android.mk
Normal file
1708
vehicle/2.0/Android.mk
Normal file
File diff suppressed because it is too large
Load diff
99
vehicle/2.0/IVehicle.hal
Normal file
99
vehicle/2.0/IVehicle.hal
Normal file
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.vehicle@2.0;
|
||||
|
||||
import IVehicleCallback;
|
||||
|
||||
interface IVehicle {
|
||||
/**
|
||||
* Returns a list of all property configurations supported by this vehicle
|
||||
* HAL.
|
||||
*/
|
||||
getAllPropConfigs() generates (vec<VehiclePropConfig> propConfigs);
|
||||
|
||||
/*
|
||||
* Returns a list of property configurations for given properties.
|
||||
*/
|
||||
getPropConfigs(vec<VehicleProperty> props)
|
||||
generates (vec<VehiclePropConfig> propConfigs);
|
||||
|
||||
/**
|
||||
* Get a vehicle property value.
|
||||
*
|
||||
* For VehiclePropertyChangeMode::STATIC properties, this method must always
|
||||
* return the same value always.
|
||||
* For VehiclePropertyChangeMode::ON_CHANGE properties, it must return the
|
||||
* latest available value.
|
||||
*
|
||||
* If there is no data available yet, which can happen during initial stage,
|
||||
* this call must return immediately with an error code of
|
||||
* StatusCode::TRY_AGAIN.
|
||||
*/
|
||||
get(VehicleProperty propId, int32_t areaId)
|
||||
generates (StatusCode status, VehiclePropValue propValue);
|
||||
|
||||
/**
|
||||
* Set a vehicle property value.
|
||||
*
|
||||
* Timestamp of data must be ignored for set operation.
|
||||
*
|
||||
* Setting some properties require having initial state available. If initial
|
||||
* data is not available yet this call must return StatusCode::TRY_AGAIN.
|
||||
* For a property with separate power control this call must return
|
||||
* StatusCode::NOT_AVAILABLE error if property is not powered on.
|
||||
*/
|
||||
set(VehiclePropValue propValue) generates (StatusCode status);
|
||||
|
||||
/**
|
||||
* Subscribes to property events.
|
||||
*
|
||||
* Clients must be able to subscribe to multiple properties at a time
|
||||
* depending on data provided in options argument.
|
||||
*
|
||||
* @param listener This client must be called on aproperiate event.
|
||||
* @param options List of options to subscribe. SubscribeOption contains
|
||||
* information such as propery Id, area Id, sample rate, etc.
|
||||
*/
|
||||
subscribe(IVehicleCallback listener, vec<SubscribeOptions> options)
|
||||
generates (StatusCode status);
|
||||
|
||||
/**
|
||||
* Unsubscribes from property events.
|
||||
*
|
||||
* If this client wasn't subscribed to the given property, this method
|
||||
* must return StatusCode::INVALID_ARGUMENT.
|
||||
*/
|
||||
unsubscribe(VehicleProperty propId) generates (StatusCode status);
|
||||
|
||||
/**
|
||||
* Print out debugging state for the vehicle hal.
|
||||
*
|
||||
* The text must be in ASCII encoding only.
|
||||
*
|
||||
* Performance requirements:
|
||||
*
|
||||
* The HAL must return from this call in less than 10ms. This call must avoid
|
||||
* deadlocks, as it may be called at any point of operation. Any synchronization
|
||||
* primitives used (such as mutex locks or semaphores) must be acquired
|
||||
* with a timeout.
|
||||
*
|
||||
* TODO(pavelm): we cannot use handle here due to Java compatability, it's
|
||||
* better to pass file descriptor and write debug data directly in vehicle HAL
|
||||
* rather than passing back a string.
|
||||
*/
|
||||
debugDump() generates (string s);
|
||||
};
|
56
vehicle/2.0/IVehicleCallback.hal
Normal file
56
vehicle/2.0/IVehicleCallback.hal
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.vehicle@2.0;
|
||||
|
||||
interface IVehicleCallback {
|
||||
|
||||
/*
|
||||
* Event callback happens whenever a variable that the API user has
|
||||
* subscribed to needs to be reported. This may be based purely on
|
||||
* threshold and frequency (a regular subscription, see subscribe call's
|
||||
* arguments) or when the IVehicle#set method was called and the actual
|
||||
* change needs to be reported.
|
||||
*
|
||||
* These callbacks are chunked.
|
||||
*
|
||||
* @param values that has been updated.
|
||||
*/
|
||||
onPropertyEvent(vec<VehiclePropValue> propValues);
|
||||
|
||||
/*
|
||||
* This method gets called if the client was susbscribed to a property using
|
||||
* SubscribeFlags::SET_CALL flag and IVehicle#set(...) method was called.
|
||||
*
|
||||
* These events must be delivered to subscriber immediately without any
|
||||
* batching.
|
||||
*
|
||||
* @param value Value that was set by a client.
|
||||
*/
|
||||
onPropertySet(VehiclePropValue propValue);
|
||||
|
||||
/*
|
||||
* Called by HAL server when error condition has occurred.
|
||||
*
|
||||
* @param errorCode - any value from StatusCode enum.
|
||||
* @parm property - a property where error has happened. If this is
|
||||
* a generic error, this value should be VehicleProperty::INVALID.
|
||||
* @param operation Represent the operation where the error has happened.
|
||||
*/
|
||||
onError(StatusCode errorCode,
|
||||
VehicleProperty propId,
|
||||
VehiclePropertyOperation operation);
|
||||
};
|
48
vehicle/2.0/default/Android.mk
Normal file
48
vehicle/2.0/default/Android.mk
Normal file
|
@ -0,0 +1,48 @@
|
|||
# Copyright (C) 2016 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.vehicle@2.0-impl
|
||||
# TODO(pavelm): add LOCAL_INIT_RC
|
||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
||||
LOCAL_SRC_FILES := \
|
||||
Vehicle.cpp \
|
||||
VehicleCallback.cpp \
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libhidl \
|
||||
libhwbinder \
|
||||
libutils \
|
||||
android.hardware.vehicle@2.0 \
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := android.hardware.vehicle@2.0-service
|
||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
||||
LOCAL_SRC_FILES := \
|
||||
VehicleService.cpp
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
liblog \
|
||||
libbinder \
|
||||
libhidl \
|
||||
libhwbinder \
|
||||
libutils \
|
||||
android.hardware.vehicle@2.0
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
147
vehicle/2.0/default/Vehicle.cpp
Normal file
147
vehicle/2.0/default/Vehicle.cpp
Normal file
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "Vehicle.h"
|
||||
#include "VehicleUtils.h"
|
||||
|
||||
#include <utils/SystemClock.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace vehicle {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
const VehiclePropConfig kVehicleProperties[] = {
|
||||
{
|
||||
.prop = VehicleProperty::INFO_MAKE,
|
||||
.access = VehiclePropertyAccess::READ,
|
||||
.changeMode = VehiclePropertyChangeMode::STATIC,
|
||||
.permissionModel = VehiclePermissionModel::OEM_ONLY,
|
||||
.configString = init_hidl_string("Some=configuration,options=if,you=have,any=?"),
|
||||
},
|
||||
|
||||
{
|
||||
.prop = VehicleProperty::HVAC_FAN_SPEED,
|
||||
.access = VehiclePropertyAccess::READ_WRITE,
|
||||
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
|
||||
.permissionModel = VehiclePermissionModel::NO_RESTRICTION,
|
||||
.supportedAreas = static_cast<int32_t>(
|
||||
VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT),
|
||||
.areaConfigs = init_hidl_vec({
|
||||
VehicleAreaConfig {
|
||||
.areaId = enum_val(VehicleAreaZone::ROW_2_LEFT),
|
||||
.minInt32Value = 1,
|
||||
.maxInt32Value = 7},
|
||||
VehicleAreaConfig {
|
||||
.areaId = enum_val(VehicleAreaZone::ROW_1_RIGHT),
|
||||
.minInt32Value = 1,
|
||||
.maxInt32Value = 5,
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
{
|
||||
.prop = VehicleProperty::INFO_FUEL_CAPACITY,
|
||||
.access = VehiclePropertyAccess::READ,
|
||||
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
|
||||
.permissionModel = VehiclePermissionModel::OEM_ONLY,
|
||||
.areaConfigs = init_hidl_vec({
|
||||
VehicleAreaConfig {
|
||||
.minFloatValue = 0,
|
||||
.maxFloatValue = 1.0
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
const char kInfoMake[] = "Android Super Car";
|
||||
|
||||
|
||||
Return<void> Vehicle::getAllPropConfigs(getAllPropConfigs_cb _hidl_cb) {
|
||||
hidl_vec<VehiclePropConfig> configs;
|
||||
|
||||
configs.setToExternal(const_cast<VehiclePropConfig*>(kVehicleProperties),
|
||||
arraysize(kVehicleProperties));
|
||||
|
||||
_hidl_cb(configs);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Vehicle::getPropConfigs(const hidl_vec<VehicleProperty>& properties,
|
||||
getAllPropConfigs_cb _hidl_cb) {
|
||||
// TODO(pavelm): add default implementation
|
||||
hidl_vec<VehiclePropConfig> configs;
|
||||
_hidl_cb(configs);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Vehicle::get(VehicleProperty propId, int32_t areaId, get_cb _hidl_cb) {
|
||||
VehiclePropValue v {
|
||||
.prop = propId,
|
||||
.areaId = areaId,
|
||||
.timestamp = elapsedRealtimeNano(),
|
||||
};
|
||||
|
||||
StatusCode status = StatusCode::OK;
|
||||
|
||||
if (propId == VehicleProperty::INFO_MAKE) {
|
||||
v.value.stringValue.setToExternal(kInfoMake, strlen(kInfoMake));
|
||||
} else if (propId == VehicleProperty::HVAC_FAN_SPEED) {
|
||||
v.value.int32Values = init_hidl_vec({42});
|
||||
} else {
|
||||
status = StatusCode::INVALID_ARG;
|
||||
}
|
||||
|
||||
_hidl_cb(status, v);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<StatusCode> Vehicle::set(const VehiclePropValue& value) {
|
||||
// TODO(pavelm): add default implementation
|
||||
return StatusCode::OK;
|
||||
}
|
||||
|
||||
Return<StatusCode> Vehicle::subscribe(const sp<IVehicleCallback>& listener,
|
||||
const hidl_vec<SubscribeOptions>& options) {
|
||||
// TODO(pavelm): add default implementation
|
||||
return StatusCode::OK;
|
||||
}
|
||||
|
||||
Return<StatusCode> Vehicle::unsubscribe(VehicleProperty propId) {
|
||||
// TODO(pavelm): add default implementation
|
||||
return StatusCode::OK;
|
||||
}
|
||||
|
||||
Return<void> Vehicle::debugDump(debugDump_cb _hidl_cb) {
|
||||
hidl_string debug;
|
||||
debug = "Put debug data here";
|
||||
|
||||
_hidl_cb(debug);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
IVehicle* HIDL_FETCH_IVehicle(const char* /* name */) {
|
||||
return new Vehicle();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace vehicle
|
||||
} // namespace hardware
|
||||
} // namespace android
|
61
vehicle/2.0/default/Vehicle.h
Normal file
61
vehicle/2.0/default/Vehicle.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef HIDL_GENERATED_android_hardware_vehicle_V2_0_Vehicle_H_
|
||||
#define HIDL_GENERATED_android_hardware_vehicle_V2_0_Vehicle_H_
|
||||
|
||||
#include <android/hardware/vehicle/2.0/IVehicle.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
#include <hidl/MQDescriptor.h>
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace vehicle {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::vehicle::V2_0::IVehicle;
|
||||
using ::android::hardware::vehicle::V2_0::IVehicleCallback;
|
||||
using ::android::hardware::vehicle::V2_0::SubscribeOptions;
|
||||
using ::android::hardware::vehicle::V2_0::VehiclePropConfig;
|
||||
using ::android::hardware::vehicle::V2_0::VehiclePropValue;
|
||||
using ::android::hardware::vehicle::V2_0::VehicleProperty;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::sp;
|
||||
|
||||
struct Vehicle : public IVehicle {
|
||||
// Methods from ::android::hardware::vehicle::V2_0::IVehicle follow.
|
||||
Return<void> getAllPropConfigs(getAllPropConfigs_cb _hidl_cb) override;
|
||||
Return<void> getPropConfigs(const hidl_vec<VehicleProperty>& properties, getPropConfigs_cb _hidl_cb) override;
|
||||
Return<void> get(VehicleProperty propId, int32_t areaId, get_cb _hidl_cb) override;
|
||||
Return<StatusCode> set(const VehiclePropValue& value) override;
|
||||
Return<StatusCode> subscribe(const sp<IVehicleCallback>& listener, const hidl_vec<SubscribeOptions>& options) override;
|
||||
Return<StatusCode> unsubscribe(VehicleProperty propId) override;
|
||||
Return<void> debugDump(debugDump_cb _hidl_cb = nullptr) override;
|
||||
};
|
||||
|
||||
extern "C" IVehicle* HIDL_FETCH_IVehicle(const char* name);
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace vehicle
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // HIDL_GENERATED_android_hardware_vehicle_V2_0_Vehicle_H_
|
53
vehicle/2.0/default/VehicleCallback.cpp
Normal file
53
vehicle/2.0/default/VehicleCallback.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "VehicleCallback.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace vehicle {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
// Methods from ::android::hardware::vehicle::V2_0::IVehicleCallback follow.
|
||||
Return<void> VehicleCallback::onPropertyEvent(const hidl_vec<VehiclePropValue>& value) {
|
||||
// TODO(pavelm): add default implementation
|
||||
return Void();
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::vehicle::V2_0::IVehicleCallback follow.
|
||||
Return<void> VehicleCallback::onPropertySet(const VehiclePropValue& value) {
|
||||
// TODO(pavelm): add default implementation
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> VehicleCallback::onError(StatusCode errorCode,
|
||||
VehicleProperty propId,
|
||||
VehiclePropertyOperation operation) {
|
||||
// TODO(pavelm): add default implementation
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
||||
IVehicleCallback* HIDL_FETCH_IVehicleCallback(const char* /* name */) {
|
||||
return new VehicleCallback();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace vehicle
|
||||
} // namespace hardware
|
||||
} // namespace android
|
56
vehicle/2.0/default/VehicleCallback.h
Normal file
56
vehicle/2.0/default/VehicleCallback.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef HIDL_GENERATED_android_hardware_vehicle_V2_0_VehicleCallback_H_
|
||||
#define HIDL_GENERATED_android_hardware_vehicle_V2_0_VehicleCallback_H_
|
||||
|
||||
#include <android/hardware/vehicle/2.0/IVehicleCallback.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
#include <hidl/MQDescriptor.h>
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace vehicle {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::vehicle::V2_0::IVehicleCallback;
|
||||
using ::android::hardware::vehicle::V2_0::VehiclePropValue;
|
||||
using ::android::hardware::vehicle::V2_0::VehicleProperty;
|
||||
using ::android::hardware::vehicle::V2_0::VehiclePropertyOperation;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::sp;
|
||||
|
||||
struct VehicleCallback : public IVehicleCallback {
|
||||
// Methods from ::android::hardware::vehicle::V2_0::IVehicleCallback follow.
|
||||
Return<void> onPropertyEvent(const hidl_vec<VehiclePropValue>& values) override;
|
||||
Return<void> onPropertySet(const VehiclePropValue& value) override;
|
||||
Return<void> onError(StatusCode errorCode, VehicleProperty propId, VehiclePropertyOperation operation) override;
|
||||
|
||||
};
|
||||
|
||||
extern "C" IVehicleCallback* HIDL_FETCH_IVehicleCallback(const char* name);
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace vehicle
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // HIDL_GENERATED_android_hardware_vehicle_V2_0_VehicleCallback_H_
|
46
vehicle/2.0/default/VehicleService.cpp
Normal file
46
vehicle/2.0/default/VehicleService.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.vehicle@2.0-service"
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <hwbinder/IPCThreadState.h>
|
||||
|
||||
#include <android/hardware/vehicle/2.0/IVehicle.h>
|
||||
|
||||
using namespace android;
|
||||
using namespace android::hardware;
|
||||
using namespace android::hardware::vehicle::V2_0;
|
||||
|
||||
int main(int /* argc */, char* /* argv */ []) {
|
||||
ALOGI("Service is starting");
|
||||
android::sp<IVehicle> service = IVehicle::getService("Vehicle");
|
||||
if (service.get() == NULL) {
|
||||
ALOGE("IVehicle::getService returned NULL, exiting");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ALOGI("Registering as service");
|
||||
// will register the -impl as a binderized service in this process
|
||||
service->registerAsService("Vehicle");
|
||||
|
||||
ALOGI("Ready");
|
||||
ProcessState::self()->setThreadPoolMaxThreadCount(0);
|
||||
ProcessState::self()->startThreadPool();
|
||||
IPCThreadState::self()->joinThreadPool();
|
||||
}
|
90
vehicle/2.0/default/VehicleUtils.h
Normal file
90
vehicle/2.0/default/VehicleUtils.h
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef android_hardware_vehicle_V2_0_VehicleUtils_H_
|
||||
#define android_hardware_vehicle_V2_0_VehicleUtils_H_
|
||||
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <android/hardware/vehicle/2.0/types.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace vehicle {
|
||||
namespace V2_0 {
|
||||
|
||||
hidl_string init_hidl_string(const char *cstr) {
|
||||
hidl_string hidlString;
|
||||
hidlString = cstr;
|
||||
return hidlString;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
hidl_vec<T> init_hidl_vec(std::initializer_list<T> values) {
|
||||
hidl_vec<T> vector;
|
||||
vector.resize(values.size());
|
||||
size_t i = 0;
|
||||
for (auto& c : values) {
|
||||
vector[i++] = c;
|
||||
}
|
||||
return vector;
|
||||
}
|
||||
|
||||
// OR operator for class enums. The return type will be enum's underline type.
|
||||
template <typename ENUM>
|
||||
typename std::underlying_type<ENUM>::type operator |(ENUM v1, ENUM v2) {
|
||||
return static_cast<typename std::underlying_type<ENUM>::type>(v1)
|
||||
| static_cast<typename std::underlying_type<ENUM>::type>(v2);
|
||||
}
|
||||
|
||||
// AND operator for class enums. The return type will be enum's underline type.
|
||||
template <typename ENUM>
|
||||
typename std::underlying_type<ENUM>::type operator &(ENUM v1, ENUM v2) {
|
||||
return static_cast<typename std::underlying_type<ENUM>::type>(v1)
|
||||
| static_cast<typename std::underlying_type<ENUM>::type>(v2);
|
||||
}
|
||||
|
||||
// Returns underlying (integer) value for given enum.
|
||||
template <typename ENUM>
|
||||
typename std::underlying_type<ENUM>::type enum_val(ENUM const value)
|
||||
{
|
||||
return static_cast<typename std::underlying_type<ENUM>::type>(value);
|
||||
}
|
||||
|
||||
VehiclePropertyType getPropType(VehicleProperty prop) {
|
||||
return static_cast<VehiclePropertyType>(
|
||||
static_cast<int32_t>(prop) & static_cast<int32_t>(VehiclePropertyType::MASK));
|
||||
}
|
||||
|
||||
VehiclePropertyGroup getPropGroup(VehicleProperty prop) {
|
||||
return static_cast<VehiclePropertyGroup>(
|
||||
static_cast<int32_t>(prop) & static_cast<int32_t>(VehiclePropertyGroup::MASK));
|
||||
}
|
||||
|
||||
bool checkPropType(VehicleProperty prop, VehiclePropertyType type) {
|
||||
return getPropType(prop) == type;
|
||||
}
|
||||
|
||||
bool isSystemProperty(VehicleProperty prop) {
|
||||
return VehiclePropertyGroup::SYSTEM == getPropGroup(prop);
|
||||
}
|
||||
|
||||
|
||||
} // namespace V2_0
|
||||
} // namespace vehicle
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif android_hardware_vehicle_V2_0_VehicleUtils_H_
|
2394
vehicle/2.0/types.hal
Normal file
2394
vehicle/2.0/types.hal
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue