From 3976e2254beda9ef25105bfe58aecf0057659be0 Mon Sep 17 00:00:00 2001 From: GiaSen Date: Sun, 8 Nov 2020 11:29:24 +0100 Subject: [PATCH] kunlun2: Nuke USB custom Hal --- device.mk | 4 - usb/Android.mk | 32 -------- usb/Usb.cpp | 81 ------------------- usb/Usb.h | 65 --------------- ...hardware.usb@1.0-service.lenovo_kunlun2.rc | 5 -- usb/service.cpp | 47 ----------- 6 files changed, 234 deletions(-) delete mode 100644 usb/Android.mk delete mode 100644 usb/Usb.cpp delete mode 100644 usb/Usb.h delete mode 100644 usb/android.hardware.usb@1.0-service.lenovo_kunlun2.rc delete mode 100644 usb/service.cpp diff --git a/device.mk b/device.mk index 8850b26..7980697 100644 --- a/device.mk +++ b/device.mk @@ -144,10 +144,6 @@ PRODUCT_PACKAGES += \ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/configs/thermal-engine.conf:$(TARGET_COPY_OUT_PRODUCT)/vendor_overlay/$(PRODUCT_TARGET_VNDK_VERSION)/etc/thermal-engine.conf -# USB -PRODUCT_PACKAGES += \ - android.hardware.usb@1.0-service.lenovo_kunlun2 - # WiFi PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/wifi/WCNSS_qcom_cfg.ini:$(TARGET_COPY_OUT_PRODUCT)/vendor_overlay/$(PRODUCT_TARGET_VNDK_VERSION)/etc/wifi/WCNSS_qcom_cfg.ini diff --git a/usb/Android.mk b/usb/Android.mk deleted file mode 100644 index 23d6293..0000000 --- a/usb/Android.mk +++ /dev/null @@ -1,32 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := android.hardware.usb@1.0-service.lenovo_kunlun2 -LOCAL_MODULE_TAGS := optional - -LOCAL_MODULE_PATH := $(TARGET_OUT_PRODUCT)/vendor_overlay/$(PRODUCT_TARGET_VNDK_VERSION)/bin -LOCAL_MODULE_RELATIVE_PATH := hw -LOCAL_MODULE_STEM := android.hardware.usb@1.0-service - -LOCAL_REQUIRED_MODULES := android.hardware.usb@1.0-service.lenovo_kunlun2.rc - -LOCAL_SRC_FILES := service.cpp Usb.cpp - -LOCAL_SHARED_LIBRARIES := \ - libbase \ - libcutils \ - libhidlbase \ - libutils \ - libhardware \ - android.hardware.usb@1.0 - -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) -LOCAL_MODULE := android.hardware.usb@1.0-service.lenovo_kunlun2.rc -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_CLASS := ETC -LOCAL_MODULE_PATH := $(TARGET_OUT_PRODUCT)/vendor_overlay/$(PRODUCT_TARGET_VNDK_VERSION)/etc/init -LOCAL_MODULE_STEM := android.hardware.usb@1.0-service.rc -LOCAL_SRC_FILES := android.hardware.usb@1.0-service.lenovo_kunlun2.rc -include $(BUILD_PREBUILT) diff --git a/usb/Usb.cpp b/usb/Usb.cpp deleted file mode 100644 index f42452f..0000000 --- a/usb/Usb.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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/Usb.h b/usb/Usb.h deleted file mode 100644 index 1f7abd6..0000000 --- a/usb/Usb.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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/android.hardware.usb@1.0-service.lenovo_kunlun2.rc b/usb/android.hardware.usb@1.0-service.lenovo_kunlun2.rc deleted file mode 100644 index 7d40898..0000000 --- a/usb/android.hardware.usb@1.0-service.lenovo_kunlun2.rc +++ /dev/null @@ -1,5 +0,0 @@ -service vendor.usb-hal-1-0 /vendor/bin/hw/android.hardware.usb@1.0-service - override - class hal - user system - group system diff --git a/usb/service.cpp b/usb/service.cpp deleted file mode 100644 index 8193012..0000000 --- a/usb/service.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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; -}