diff --git a/universal7885-common/usb/typeb/Android.bp b/universal7885-common/usb/typeb/Android.bp old mode 100644 new mode 100755 index e13bab8..4bdba1f --- a/universal7885-common/usb/typeb/Android.bp +++ b/universal7885-common/usb/typeb/Android.bp @@ -1,5 +1,5 @@ // -// Copyright (C) 2017 The LineageOS Project +// Copyright (C) 2017-2018,2020 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. @@ -12,15 +12,16 @@ // 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.a10", relative_install_path: "hw", init_rc: ["android.hardware.usb@1.0-service.a10.rc"], srcs: ["service.cpp", "Usb.cpp"], shared_libs: [ + "libbase", "libcutils", "libhidlbase", - "liblog", "libutils", "libhardware", "android.hardware.usb@1.0", diff --git a/universal7885-common/usb/typeb/Usb.cpp b/universal7885-common/usb/typeb/Usb.cpp old mode 100644 new mode 100755 index c4141b8..f42452f --- a/universal7885-common/usb/typeb/Usb.cpp +++ b/universal7885-common/usb/typeb/Usb.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The LineageOS Project + * 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. @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -29,50 +30,48 @@ namespace usb { namespace V1_0 { namespace implementation { -Return Usb::switchRole(const hidl_string &portName, - const PortRole &newRole) { - (void)portName; - (void)newRole; - ALOGE("%s: Not supported", __func__); - return Void(); +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); + hidl_vec currentPortStatus; + currentPortStatus.resize(1); - /* this device is not type C and can only be a sink */ - 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; + 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()) - ALOGE("queryPortStatus error %s", ret.description().c_str()); - } else { - ALOGI("Notifying userspace skipped. Callback is NULL"); - } - pthread_mutex_unlock(&mLock); + 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 Void(); } Return Usb::setCallback(const sp &callback) { - pthread_mutex_lock(&mLock); + pthread_mutex_lock(&mLock); - mCallback = callback; - ALOGI("registering callback"); + mCallback = callback; + LOG(INFO) << "registering callback"; - pthread_mutex_unlock(&mLock); - return Void(); + pthread_mutex_unlock(&mLock); + return Void(); } } // namespace implementation diff --git a/universal7885-common/usb/typeb/Usb.h b/universal7885-common/usb/typeb/Usb.h old mode 100644 new mode 100755 index c491fab..5517f80 --- a/universal7885-common/usb/typeb/Usb.h +++ b/universal7885-common/usb/typeb/Usb.h @@ -1,3 +1,19 @@ +/* + * 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 @@ -10,7 +26,7 @@ #undef LOG_TAG #endif -#define LOG_TAG "android.hardware.usb@1.0-service.a10" +#define LOG_TAG "android.hardware.usb@1.0-service-a10" #define UEVENT_MSG_LEN 2048 namespace android { @@ -38,9 +54,6 @@ struct Usb : public IUsb { sp mCallback; pthread_mutex_t mLock = PTHREAD_MUTEX_INITIALIZER; - - private: - pthread_t mPoll; }; } // namespace implementation diff --git a/universal7885-common/usb/typeb/android.hardware.usb@1.0-service.a10.rc b/universal7885-common/usb/typeb/android.hardware.usb@1.0-service.a10.rc old mode 100644 new mode 100755 index 31507af..8bc1af8 --- a/universal7885-common/usb/typeb/android.hardware.usb@1.0-service.a10.rc +++ b/universal7885-common/usb/typeb/android.hardware.usb@1.0-service.a10.rc @@ -1,4 +1,5 @@ -service usb-hal-1-0 /vendor/bin/hw/android.hardware.usb@1.0-service.a10 +service vendor.usb-hal-1-0 /vendor/bin/hw/android.hardware.usb@1.0-service.a10 + interface android.hardware.usb@1.0::IUsb default class hal user system group system diff --git a/universal7885-common/usb/typeb/service.cpp b/universal7885-common/usb/typeb/service.cpp old mode 100644 new mode 100755 index 4128097..8193012 --- a/universal7885-common/usb/typeb/service.cpp +++ b/universal7885-common/usb/typeb/service.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The LineageOS jProject + * 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. @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include "Usb.h" @@ -27,23 +28,20 @@ using android::hardware::joinRpcThreadpool; using android::hardware::usb::V1_0::IUsb; using android::hardware::usb::V1_0::implementation::Usb; -using android::status_t; -using android::OK; - int main() { android::sp service = new Usb(); configureRpcThreadpool(1, true /*callerWillJoin*/); - status_t status = service->registerAsService(); + android::status_t status = service->registerAsService(); - if (status != OK) { - ALOGE("Cannot register USB HAL service"); + if (status != android::OK) { + LOG(ERROR) << "Cannot register USB HAL service"; return 1; } - ALOGI("USB HAL Ready."); + LOG(INFO) << "USB HAL Ready."; joinRpcThreadpool(); - // Under noraml cases, execution will not reach this line. - ALOGI("USB HAL failed to join thread pool."); + // Under normal cases, execution will not reach this line. + LOG(ERROR) << "USB HAL failed to join thread pool."; return 1; }