summaryrefslogtreecommitdiff
path: root/usb
diff options
context:
space:
mode:
authorJimmy Hu <hhhuuu@google.com>2022-05-24 09:33:42 +0000
committerAlbert Wang <albertccwang@google.com>2022-05-26 02:42:33 +0000
commit3b1583d7a5711b90e6f867b7b61b9fe5f5f7d6c8 (patch)
treeaa9dcefbbd945d4d6e41384d6499f7033cb5f5b0 /usb
parent677871f4ddad91ad5f09a3bbd99dd0e126bf9346 (diff)
downloadgs201-3b1583d7a5711b90e6f867b7b61b9fe5f5f7d6c8.tar.gz
Write the pullup value only if new value applied
Bug: 226018845 Test: build, boot Signed-off-by: Jimmy Hu <hhhuuu@google.com> Change-Id: I636dc18dca123f88dbf10c4a17caa9a75cbb12f7
Diffstat (limited to 'usb')
-rw-r--r--usb/usb/Usb.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/usb/usb/Usb.cpp b/usb/usb/Usb.cpp
index 31dd1b7..82f6e18 100644
--- a/usb/usb/Usb.cpp
+++ b/usb/usb/Usb.cpp
@@ -83,23 +83,39 @@ ScopedAStatus Usb::enableUsbData(const string& in_portName, bool in_enable,
int64_t in_transactionId) {
bool result = true;
std::vector<PortStatus> currentPortStatus;
+ string pullup;
ALOGI("Userspace turn %s USB data signaling. opID:%ld", in_enable ? "on" : "off",
in_transactionId);
if (in_enable) {
if (!mUsbDataEnabled) {
- if (!WriteStringToFile("1", USB_DATA_PATH)) {
- ALOGE("Not able to turn on usb connection notification");
- result = false;
+ if (ReadFileToString(PULLUP_PATH, &pullup)) {
+ pullup = Trim(pullup);
+ if (pullup != kGadgetName) {
+ if (!WriteStringToFile(kGadgetName, PULLUP_PATH)) {
+ ALOGE("Gadget cannot be pulled up");
+ result = false;
+ }
+ }
}
- if (!WriteStringToFile(kGadgetName, PULLUP_PATH)) {
- ALOGE("Gadget cannot be pulled up");
+ if (!WriteStringToFile("1", USB_DATA_PATH)) {
+ ALOGE("Not able to turn on usb connection notification");
result = false;
}
}
} else {
+ if (ReadFileToString(PULLUP_PATH, &pullup)) {
+ pullup = Trim(pullup);
+ if (pullup == kGadgetName) {
+ if (!WriteStringToFile("none", PULLUP_PATH)) {
+ ALOGE("Gadget cannot be pulled down");
+ result = false;
+ }
+ }
+ }
+
if (!WriteStringToFile("1", ID_PATH)) {
ALOGE("Not able to turn off host mode");
result = false;
@@ -114,11 +130,6 @@ ScopedAStatus Usb::enableUsbData(const string& in_portName, bool in_enable,
ALOGE("Not able to turn on usb connection notification");
result = false;
}
-
- if (!WriteStringToFile("none", PULLUP_PATH)) {
- ALOGE("Gadget cannot be pulled down");
- result = false;
- }
}
if (result) {