From 729c211a95fd489d47642f2c5372d3432f120a9b Mon Sep 17 00:00:00 2001 From: Tim Zimmermann Date: Thu, 25 Aug 2022 11:47:40 +0200 Subject: [PATCH] aidl: usb: Support enableUsbData() Change-Id: I369731be320b708e63c92bae08f563607d6a8512 --- aidl/usb/Usb.cpp | 9 ++++++++- aidl/usb/Usb.h | 2 ++ aidl/usb/android.hardware.usb-service.samsung.rc | 11 +++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/aidl/usb/Usb.cpp b/aidl/usb/Usb.cpp index 7e738c47..71d792e0 100644 --- a/aidl/usb/Usb.cpp +++ b/aidl/usb/Usb.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2021 The Android Open Source Project + * Copyright (C) 2022 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. @@ -58,11 +59,17 @@ void queryVersionHelper(android::hardware::usb::Usb *usb, ScopedAStatus Usb::enableUsbData(const string& in_portName, bool in_enable, int64_t in_transactionId) { std::vector currentPortStatus; + bool result = true; pthread_mutex_lock(&mLock); + if (!WriteStringToFile(in_enable ? "1" : "0", USB_DATA_PATH)) { + ALOGE("Not able to turn %s usb connection notification", in_enable ? "on" : "off"); + result = false; + } + if (mCallback != NULL) { ScopedAStatus ret = mCallback->notifyEnableUsbDataStatus( - in_portName, true, in_enable ? Status::SUCCESS : Status::ERROR, in_transactionId); + in_portName, true, result ? Status::SUCCESS : Status::ERROR, in_transactionId); if (!ret.isOk()) ALOGE("notifyEnableUsbDataStatus error %s", ret.getDescription().c_str()); } else { diff --git a/aidl/usb/Usb.h b/aidl/usb/Usb.h index d507af6f..46be609d 100644 --- a/aidl/usb/Usb.h +++ b/aidl/usb/Usb.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2021 The Android Open Source Project + * Copyright (C) 2022 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. @@ -28,6 +29,7 @@ // Having a margin of ~3 secs for the directory and other related bookeeping // structures created and uvent fired. #define PORT_TYPE_TIMEOUT 8 +#define USB_DATA_PATH "/sys/devices/virtual/usb_notify/usb_control/usb_data_enabled" namespace aidl { namespace android { diff --git a/aidl/usb/android.hardware.usb-service.samsung.rc b/aidl/usb/android.hardware.usb-service.samsung.rc index ee5c4c0a..62360c82 100644 --- a/aidl/usb/android.hardware.usb-service.samsung.rc +++ b/aidl/usb/android.hardware.usb-service.samsung.rc @@ -2,3 +2,14 @@ service vendor.usb_default /vendor/bin/hw/android.hardware.usb-service.samsung class hal user system group system + +on post-fs + chown root system /sys/class/typec/port0/power_role + chown root system /sys/class/typec/port0/data_role + chown root system /sys/class/typec/port0/port_type + chown root system /sys/devices/virtual/sec/ccic/water + chown root system /sys/devices/virtual/usb_notify/usb_control/usb_data_enabled + chmod 664 /sys/class/typec/port0/power_role + chmod 664 /sys/class/typec/port0/data_role + chmod 664 /sys/class/typec/port0/port_type + chmod 664 /sys/devices/virtual/usb_notify/usb_control/usb_data_enabled