diff --git a/Android.bp b/Android.bp index 7aef46b..3b926c1 100644 --- a/Android.bp +++ b/Android.bp @@ -1,3 +1,4 @@ -subdirs = [ - "*" -] +hidl_package_root { + name: "vendor.lineage", + path: "hardware/pixys/interfaces", +} diff --git a/biometrics/Android.bp b/biometrics/Android.bp deleted file mode 100644 index 696ef6b..0000000 --- a/biometrics/Android.bp +++ /dev/null @@ -1,4 +0,0 @@ -// This is an autogenerated file, do not edit. -subdirs = [ - "fingerprint/2.0", -] diff --git a/camera/Android.bp b/camera/Android.bp deleted file mode 100644 index 2778448..0000000 --- a/camera/Android.bp +++ /dev/null @@ -1,5 +0,0 @@ -// This is an autogenerated file, do not edit. -subdirs = [ - "device/1.0-legacy", - "provider/2.4-legacy", -] diff --git a/nfc/Android.bp b/nfc/Android.bp deleted file mode 100644 index 1751493..0000000 --- a/nfc/Android.bp +++ /dev/null @@ -1,4 +0,0 @@ -// This is an autogenerated file, do not edit. -subdirs = [ - "1.0-bcm", -] diff --git a/power/1.0/Android.bp b/power/1.0/Android.bp index 8724fe5..e46c610 100644 --- a/power/1.0/Android.bp +++ b/power/1.0/Android.bp @@ -1,89 +1,18 @@ -// This file is autogenerated by hidl-gen. Do not edit manually. +// This file is autogenerated by hidl-gen -Landroidbp. -filegroup { - name: "vendor.lineage.power@1.0_hal", +hidl_interface { + name: "vendor.lineage.power@1.0", + root: "vendor.lineage", srcs: [ "types.hal", "ILineagePower.hal", ], -} - -genrule { - name: "vendor.lineage.power@1.0_genc++", - tools: ["hidl-gen"], - cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hidl:system/libhidl/transport -rvendor.lineage:hardware/pixys/interfaces vendor.lineage.power@1.0", - srcs: [ - ":vendor.lineage.power@1.0_hal", - ], - out: [ - "vendor/lineage/power/1.0/types.cpp", - "vendor/lineage/power/1.0/LineagePowerAll.cpp", - ], -} - -genrule { - name: "vendor.lineage.power@1.0_genc++_headers", - tools: ["hidl-gen"], - cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hidl:system/libhidl/transport -rvendor.lineage:hardware/pixys/interfaces vendor.lineage.power@1.0", - srcs: [ - ":vendor.lineage.power@1.0_hal", - ], - out: [ - "vendor/lineage/power/1.0/types.h", - "vendor/lineage/power/1.0/hwtypes.h", - "vendor/lineage/power/1.0/ILineagePower.h", - "vendor/lineage/power/1.0/IHwLineagePower.h", - "vendor/lineage/power/1.0/BnHwLineagePower.h", - "vendor/lineage/power/1.0/BpHwLineagePower.h", - "vendor/lineage/power/1.0/BsLineagePower.h", - ], -} - -cc_library { - name: "vendor.lineage.power@1.0", - defaults: ["hidl-module-defaults"], - generated_sources: ["vendor.lineage.power@1.0_genc++"], - generated_headers: ["vendor.lineage.power@1.0_genc++_headers"], - export_generated_headers: ["vendor.lineage.power@1.0_genc++_headers"], - vendor_available: true, - vndk: { - enabled: true, - }, - shared_libs: [ - "libhidlbase", - "libhidltransport", - "libhwbinder", - "liblog", - "libutils", - "libcutils", - ], - export_shared_lib_headers: [ - "libhidlbase", - "libhidltransport", - "libhwbinder", - "libutils", - ], -} - -cc_library { - name: "vendor.lineage.power@1.0_vendor", - defaults: ["hidl-module-defaults"], - generated_sources: ["vendor.lineage.power@1.0_genc++"], - generated_headers: ["vendor.lineage.power@1.0_genc++_headers"], - export_generated_headers: ["vendor.lineage.power@1.0_genc++_headers"], - vendor: true, - shared_libs: [ - "libhidlbase", - "libhidltransport", - "libhwbinder", - "liblog", - "libutils", - "libcutils", + interfaces: [ + "android.hidl.base@1.0", ], - export_shared_lib_headers: [ - "libhidlbase", - "libhidltransport", - "libhwbinder", - "libutils", + types: [ + "LineageFeature", + "LineagePowerHint", ], + gen_java: true, } diff --git a/power/1.0/Android.mk b/power/1.0/Android.mk deleted file mode 100644 index 483ed1a..0000000 --- a/power/1.0/Android.mk +++ /dev/null @@ -1,156 +0,0 @@ -# This file is autogenerated by hidl-gen. Do not edit manually. - -LOCAL_PATH := $(call my-dir) - -################################################################################ - -include $(CLEAR_VARS) -LOCAL_MODULE := vendor.lineage.power-V1.0-java -LOCAL_MODULE_CLASS := JAVA_LIBRARIES - -intermediates := $(call local-generated-sources-dir, COMMON) - -HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX) - -LOCAL_JAVA_LIBRARIES := \ - android.hidl.base-V1.0-java \ - - -# -# Build types.hal (LineageFeature) -# -GEN := $(intermediates)/vendor/lineage/power/V1_0/LineageFeature.java -$(GEN): $(HIDL) -$(GEN): PRIVATE_HIDL := $(HIDL) -$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal -$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) -$(GEN): PRIVATE_CUSTOM_TOOL = \ - $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ - -Ljava \ - -randroid.hidl:system/libhidl/transport \ - -rvendor.lineage:hardware/pixys/interfaces \ - vendor.lineage.power@1.0::types.LineageFeature - -$(GEN): $(LOCAL_PATH)/types.hal - $(transform-generated-source) -LOCAL_GENERATED_SOURCES += $(GEN) - -# -# Build types.hal (LineagePowerHint) -# -GEN := $(intermediates)/vendor/lineage/power/V1_0/LineagePowerHint.java -$(GEN): $(HIDL) -$(GEN): PRIVATE_HIDL := $(HIDL) -$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal -$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) -$(GEN): PRIVATE_CUSTOM_TOOL = \ - $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ - -Ljava \ - -randroid.hidl:system/libhidl/transport \ - -rvendor.lineage:hardware/pixys/interfaces \ - vendor.lineage.power@1.0::types.LineagePowerHint - -$(GEN): $(LOCAL_PATH)/types.hal - $(transform-generated-source) -LOCAL_GENERATED_SOURCES += $(GEN) - -# -# Build ILineagePower.hal -# -GEN := $(intermediates)/vendor/lineage/power/V1_0/ILineagePower.java -$(GEN): $(HIDL) -$(GEN): PRIVATE_HIDL := $(HIDL) -$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/ILineagePower.hal -$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal -$(GEN): $(LOCAL_PATH)/types.hal -$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) -$(GEN): PRIVATE_CUSTOM_TOOL = \ - $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ - -Ljava \ - -randroid.hidl:system/libhidl/transport \ - -rvendor.lineage:hardware/pixys/interfaces \ - vendor.lineage.power@1.0::ILineagePower - -$(GEN): $(LOCAL_PATH)/ILineagePower.hal - $(transform-generated-source) -LOCAL_GENERATED_SOURCES += $(GEN) -include $(BUILD_JAVA_LIBRARY) - - -################################################################################ - -include $(CLEAR_VARS) -LOCAL_MODULE := vendor.lineage.power-V1.0-java-static -LOCAL_MODULE_CLASS := JAVA_LIBRARIES - -intermediates := $(call local-generated-sources-dir, COMMON) - -HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX) - -LOCAL_STATIC_JAVA_LIBRARIES := \ - android.hidl.base-V1.0-java-static \ - - -# -# Build types.hal (LineageFeature) -# -GEN := $(intermediates)/vendor/lineage/power/V1_0/LineageFeature.java -$(GEN): $(HIDL) -$(GEN): PRIVATE_HIDL := $(HIDL) -$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal -$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) -$(GEN): PRIVATE_CUSTOM_TOOL = \ - $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ - -Ljava \ - -randroid.hidl:system/libhidl/transport \ - -rvendor.lineage:hardware/pixys/interfaces \ - vendor.lineage.power@1.0::types.LineageFeature - -$(GEN): $(LOCAL_PATH)/types.hal - $(transform-generated-source) -LOCAL_GENERATED_SOURCES += $(GEN) - -# -# Build types.hal (LineagePowerHint) -# -GEN := $(intermediates)/vendor/lineage/power/V1_0/LineagePowerHint.java -$(GEN): $(HIDL) -$(GEN): PRIVATE_HIDL := $(HIDL) -$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal -$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) -$(GEN): PRIVATE_CUSTOM_TOOL = \ - $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ - -Ljava \ - -randroid.hidl:system/libhidl/transport \ - -rvendor.lineage:hardware/pixys/interfaces \ - vendor.lineage.power@1.0::types.LineagePowerHint - -$(GEN): $(LOCAL_PATH)/types.hal - $(transform-generated-source) -LOCAL_GENERATED_SOURCES += $(GEN) - -# -# Build ILineagePower.hal -# -GEN := $(intermediates)/vendor/lineage/power/V1_0/ILineagePower.java -$(GEN): $(HIDL) -$(GEN): PRIVATE_HIDL := $(HIDL) -$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/ILineagePower.hal -$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal -$(GEN): $(LOCAL_PATH)/types.hal -$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) -$(GEN): PRIVATE_CUSTOM_TOOL = \ - $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ - -Ljava \ - -randroid.hidl:system/libhidl/transport \ - -rvendor.lineage:hardware/pixys/interfaces \ - vendor.lineage.power@1.0::ILineagePower - -$(GEN): $(LOCAL_PATH)/ILineagePower.hal - $(transform-generated-source) -LOCAL_GENERATED_SOURCES += $(GEN) -include $(BUILD_STATIC_JAVA_LIBRARY) - - - -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/power/Android.bp b/power/Android.bp deleted file mode 100644 index bbb3e4b..0000000 --- a/power/Android.bp +++ /dev/null @@ -1,4 +0,0 @@ -// This is an autogenerated file, do not edit. -subdirs = [ - "1.0", -] diff --git a/usb/1.0-basic/Android.bp b/usb/1.0-basic/Android.bp new file mode 100644 index 0000000..4f390d0 --- /dev/null +++ b/usb/1.0-basic/Android.bp @@ -0,0 +1,32 @@ +// +// Copyright (C) 2017-2018 The LineageOS 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. + +cc_binary { + name: "android.hardware.usb@1.0-service.basic", + relative_install_path: "hw", + init_rc: ["android.hardware.usb@1.0-service.basic.rc"], + srcs: ["service.cpp", "Usb.cpp"], + shared_libs: [ + "libbase", + "libcutils", + "libhidlbase", + "libhidltransport", + "libhwbinder", + "libutils", + "libhardware", + "android.hardware.usb@1.0", + ], + proprietary: true, +} diff --git a/usb/1.0-basic/Usb.cpp b/usb/1.0-basic/Usb.cpp new file mode 100644 index 0000000..f42452f --- /dev/null +++ b/usb/1.0-basic/Usb.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2017-2018 The LineageOS 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 +#include +#include +#include + +#include +#include +#include + +#include "Usb.h" + +namespace android { +namespace hardware { +namespace usb { +namespace V1_0 { +namespace implementation { + +Return Usb::switchRole(const hidl_string &portName __unused, + const PortRole &newRole __unused) { + LOG(ERROR) << __func__ << ": Not supported"; + return Void(); +} + +Return Usb::queryPortStatus() { + hidl_vec currentPortStatus; + currentPortStatus.resize(1); + + currentPortStatus[0].portName = "otg_default"; + currentPortStatus[0].currentDataRole = PortDataRole::DEVICE; + currentPortStatus[0].currentPowerRole = PortPowerRole::SINK; + currentPortStatus[0].currentMode = PortMode::UFP; + currentPortStatus[0].canChangeMode = false; + currentPortStatus[0].canChangeDataRole = false; + currentPortStatus[0].canChangePowerRole = false; + currentPortStatus[0].supportedModes = PortMode::UFP; + + pthread_mutex_lock(&mLock); + if (mCallback != NULL) { + Return ret = + mCallback->notifyPortStatusChange(currentPortStatus, Status::SUCCESS); + if (!ret.isOk()) { + LOG(ERROR) << "queryPortStatus error " << ret.description(); + } + } else { + LOG(INFO) << "Notifying userspace skipped. Callback is NULL"; + } + pthread_mutex_unlock(&mLock); + + return Void(); +} + +Return Usb::setCallback(const sp &callback) { + pthread_mutex_lock(&mLock); + + mCallback = callback; + LOG(INFO) << "registering callback"; + + pthread_mutex_unlock(&mLock); + return Void(); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace usb +} // namespace hardware +} // namespace android diff --git a/usb/1.0-basic/Usb.h b/usb/1.0-basic/Usb.h new file mode 100644 index 0000000..1f7abd6 --- /dev/null +++ b/usb/1.0-basic/Usb.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2017-2018 The LineageOS 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_USB_V1_0_USB_H +#define ANDROID_HARDWARE_USB_V1_0_USB_H + +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "android.hardware.usb@1.0-service-basic" +#define UEVENT_MSG_LEN 2048 + +namespace android { +namespace hardware { +namespace usb { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::usb::V1_0::IUsb; +using ::android::hardware::usb::V1_0::IUsbCallback; +using ::android::hardware::usb::V1_0::PortRole; +using ::android::hidl::base::V1_0::IBase; +using ::android::hardware::hidl_array; +using ::android::hardware::hidl_memory; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +struct Usb : public IUsb { + Return switchRole(const hidl_string& portName, const PortRole& role) override; + Return setCallback(const sp& callback) override; + Return queryPortStatus() override; + + sp mCallback; + pthread_mutex_t mLock = PTHREAD_MUTEX_INITIALIZER; +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace usb +} // namespace hardware +} // namespace android + +#endif // ANDROID_HARDWARE_USB_V1_0_USB_H diff --git a/usb/1.0-basic/android.hardware.usb@1.0-service.basic.rc b/usb/1.0-basic/android.hardware.usb@1.0-service.basic.rc new file mode 100644 index 0000000..0665b02 --- /dev/null +++ b/usb/1.0-basic/android.hardware.usb@1.0-service.basic.rc @@ -0,0 +1,4 @@ +service usb-hal-1-0 /vendor/bin/hw/android.hardware.usb@1.0-service.basic + class hal + user system + group system diff --git a/usb/1.0-basic/service.cpp b/usb/1.0-basic/service.cpp new file mode 100644 index 0000000..8193012 --- /dev/null +++ b/usb/1.0-basic/service.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2017-2018 The LineageOS 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 +#include +#include "Usb.h" + +using android::sp; + +// libhwbinder: +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; + +// Generated HIDL files +using android::hardware::usb::V1_0::IUsb; +using android::hardware::usb::V1_0::implementation::Usb; + +int main() { + android::sp service = new Usb(); + + configureRpcThreadpool(1, true /*callerWillJoin*/); + android::status_t status = service->registerAsService(); + + if (status != android::OK) { + LOG(ERROR) << "Cannot register USB HAL service"; + return 1; + } + + LOG(INFO) << "USB HAL Ready."; + joinRpcThreadpool(); + // Under normal cases, execution will not reach this line. + LOG(ERROR) << "USB HAL failed to join thread pool."; + return 1; +}