mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-24 04:45:32 -04:00
universal7885: format code using clang-format-15
This commit is contained in:
parent
bfcbd0d355
commit
cb072badd5
55 changed files with 3946 additions and 3783 deletions
|
|
@ -30,51 +30,52 @@ namespace usb {
|
|||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
Return<void> Usb::switchRole(const hidl_string& portName __unused,
|
||||
const PortRole& newRole __unused) {
|
||||
LOG(ERROR) << __func__ << ": Not supported";
|
||||
return Void();
|
||||
Return<void> Usb::switchRole(const hidl_string &portName __unused,
|
||||
const PortRole &newRole __unused) {
|
||||
LOG(ERROR) << __func__ << ": Not supported";
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Usb::queryPortStatus() {
|
||||
hidl_vec<PortStatus> currentPortStatus;
|
||||
currentPortStatus.resize(1);
|
||||
hidl_vec<PortStatus> 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;
|
||||
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<void> 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_lock(&mLock);
|
||||
if (mCallback != NULL) {
|
||||
Return<void> ret =
|
||||
mCallback->notifyPortStatusChange(currentPortStatus, Status::SUCCESS);
|
||||
if (!ret.isOk()) {
|
||||
LOG(ERROR) << "queryPortStatus error " << ret.description();
|
||||
}
|
||||
pthread_mutex_unlock(&mLock);
|
||||
} else {
|
||||
LOG(INFO) << "Notifying userspace skipped. Callback is NULL";
|
||||
}
|
||||
pthread_mutex_unlock(&mLock);
|
||||
|
||||
return Void();
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Usb::setCallback(const sp<IUsbCallback>& callback) {
|
||||
pthread_mutex_lock(&mLock);
|
||||
Return<void> Usb::setCallback(const sp<IUsbCallback> &callback) {
|
||||
pthread_mutex_lock(&mLock);
|
||||
|
||||
mCallback = callback;
|
||||
LOG(INFO) << "registering callback";
|
||||
mCallback = callback;
|
||||
LOG(INFO) << "registering callback";
|
||||
|
||||
pthread_mutex_unlock(&mLock);
|
||||
return Void();
|
||||
pthread_mutex_unlock(&mLock);
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace usb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace usb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
|
|
|||
|
|
@ -48,18 +48,19 @@ using ::android::hardware::usb::V1_0::PortRole;
|
|||
using ::android::hidl::base::V1_0::IBase;
|
||||
|
||||
struct Usb : public IUsb {
|
||||
Return<void> switchRole(const hidl_string& portName, const PortRole& role) override;
|
||||
Return<void> setCallback(const sp<IUsbCallback>& callback) override;
|
||||
Return<void> queryPortStatus() override;
|
||||
Return<void> switchRole(const hidl_string &portName,
|
||||
const PortRole &role) override;
|
||||
Return<void> setCallback(const sp<IUsbCallback> &callback) override;
|
||||
Return<void> queryPortStatus() override;
|
||||
|
||||
sp<IUsbCallback> mCallback;
|
||||
pthread_mutex_t mLock = PTHREAD_MUTEX_INITIALIZER;
|
||||
sp<IUsbCallback> mCallback;
|
||||
pthread_mutex_t mLock = PTHREAD_MUTEX_INITIALIZER;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace usb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace usb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_USB_V1_0_USB_H
|
||||
#endif // ANDROID_HARDWARE_USB_V1_0_USB_H
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "Usb.h"
|
||||
#include <android-base/logging.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include "Usb.h"
|
||||
|
||||
using android::sp;
|
||||
|
||||
|
|
@ -29,19 +29,19 @@ using android::hardware::usb::V1_0::IUsb;
|
|||
using android::hardware::usb::V1_0::implementation::Usb;
|
||||
|
||||
int main() {
|
||||
android::sp<IUsb> service = new Usb();
|
||||
android::sp<IUsb> service = new Usb();
|
||||
|
||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||
android::status_t status = service->registerAsService();
|
||||
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.";
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -17,9 +17,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android/hardware/usb/1.3/IUsb.h>
|
||||
#include <android/hardware/usb/1.2/types.h>
|
||||
#include <android/hardware/usb/1.2/IUsbCallback.h>
|
||||
#include <android/hardware/usb/1.2/types.h>
|
||||
#include <android/hardware/usb/1.3/IUsb.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
|
|
@ -36,67 +36,64 @@ namespace usb {
|
|||
namespace V1_3 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::base::WriteStringToFile;
|
||||
using ::android::sp;
|
||||
using ::android::base::ReadFileToString;
|
||||
using ::android::base::WriteStringToFile;
|
||||
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::hardware::usb::V1_0::PortRole;
|
||||
using ::android::hardware::usb::V1_0::PortRoleType;
|
||||
using ::android::hardware::usb::V1_0::PortDataRole;
|
||||
using ::android::hardware::usb::V1_0::PortPowerRole;
|
||||
using ::android::hardware::usb::V1_0::PortRole;
|
||||
using ::android::hardware::usb::V1_0::PortRoleType;
|
||||
using ::android::hardware::usb::V1_0::Status;
|
||||
using ::android::hardware::usb::V1_3::IUsb;
|
||||
using ::android::hardware::usb::V1_2::IUsbCallback;
|
||||
using ::android::hardware::usb::V1_2::PortStatus;
|
||||
using ::android::hardware::usb::V1_1::PortMode_1_1;
|
||||
using ::android::hardware::usb::V1_1::PortStatus_1_1;
|
||||
using ::android::hardware::usb::V1_2::IUsbCallback;
|
||||
using ::android::hardware::usb::V1_2::PortStatus;
|
||||
using ::android::hardware::usb::V1_3::IUsb;
|
||||
using ::android::hidl::base::V1_0::DebugInfo;
|
||||
using ::android::hidl::base::V1_0::IBase;
|
||||
using ::android::sp;
|
||||
|
||||
enum class HALVersion{
|
||||
V1_0,
|
||||
V1_1,
|
||||
V1_2,
|
||||
V1_3
|
||||
};
|
||||
enum class HALVersion { V1_0, V1_1, V1_2, V1_3 };
|
||||
|
||||
#define USB_DATA_PATH "/sys/devices/virtual/usb_notify/usb_control/usb_data_enabled"
|
||||
#define USB_DATA_PATH \
|
||||
"/sys/devices/virtual/usb_notify/usb_control/usb_data_enabled"
|
||||
|
||||
struct Usb : public IUsb {
|
||||
Usb();
|
||||
Usb();
|
||||
|
||||
Return<void> switchRole(const hidl_string &portName, const PortRole &role) override;
|
||||
Return<void> setCallback(const sp<V1_0::IUsbCallback>& callback) override;
|
||||
Return<void> queryPortStatus() override;
|
||||
Return<void> enableContaminantPresenceDetection(const hidl_string &portName, bool enable);
|
||||
Return<void> enableContaminantPresenceProtection(const hidl_string &portName, bool enable);
|
||||
Return<bool> enableUsbDataSignal(bool enable) override;
|
||||
Return<void> switchRole(const hidl_string &portName,
|
||||
const PortRole &role) override;
|
||||
Return<void> setCallback(const sp<V1_0::IUsbCallback> &callback) override;
|
||||
Return<void> queryPortStatus() override;
|
||||
Return<void> enableContaminantPresenceDetection(const hidl_string &portName,
|
||||
bool enable);
|
||||
Return<void> enableContaminantPresenceProtection(const hidl_string &portName,
|
||||
bool enable);
|
||||
Return<bool> enableUsbDataSignal(bool enable) override;
|
||||
|
||||
sp<V1_0::IUsbCallback> mCallback_1_0;
|
||||
// Protects mCallback variable
|
||||
pthread_mutex_t mLock;
|
||||
// Protects roleSwitch operation
|
||||
pthread_mutex_t mRoleSwitchLock;
|
||||
// Threads waiting for the partner to come back wait here
|
||||
pthread_cond_t mPartnerCV;
|
||||
// lock protecting mPartnerCV
|
||||
pthread_mutex_t mPartnerLock;
|
||||
// Variable to signal partner coming back online after type switch
|
||||
bool mPartnerUp;
|
||||
sp<V1_0::IUsbCallback> mCallback_1_0;
|
||||
// Protects mCallback variable
|
||||
pthread_mutex_t mLock;
|
||||
// Protects roleSwitch operation
|
||||
pthread_mutex_t mRoleSwitchLock;
|
||||
// Threads waiting for the partner to come back wait here
|
||||
pthread_cond_t mPartnerCV;
|
||||
// lock protecting mPartnerCV
|
||||
pthread_mutex_t mPartnerLock;
|
||||
// Variable to signal partner coming back online after type switch
|
||||
bool mPartnerUp;
|
||||
|
||||
private:
|
||||
pthread_t mPoll;
|
||||
private:
|
||||
pthread_t mPoll;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_3
|
||||
} // namespace usb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace implementation
|
||||
} // namespace V1_3
|
||||
} // namespace usb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
#define LOG_TAG "android.hardware.usb@1.3-service.samsung"
|
||||
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include "Usb.h"
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
|
||||
using android::sp;
|
||||
|
||||
|
|
@ -34,19 +34,19 @@ using android::OK;
|
|||
using android::status_t;
|
||||
|
||||
int main() {
|
||||
android::sp<IUsb> service = new Usb();
|
||||
android::sp<IUsb> service = new Usb();
|
||||
|
||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||
status_t status = service->registerAsService();
|
||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||
status_t status = service->registerAsService();
|
||||
|
||||
if (status != OK) {
|
||||
ALOGE("Cannot register USB HAL service");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ALOGI("USB HAL Ready.");
|
||||
joinRpcThreadpool();
|
||||
// Under noraml cases, execution will not reach this line.
|
||||
ALOGI("USB HAL failed to join thread pool.");
|
||||
if (status != OK) {
|
||||
ALOGE("Cannot register USB HAL service");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ALOGI("USB HAL Ready.");
|
||||
joinRpcThreadpool();
|
||||
// Under noraml cases, execution will not reach this line.
|
||||
ALOGI("USB HAL failed to join thread pool.");
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue