mirror of
https://github.com/Evolution-X-Devices/device_google_gs201
synced 2026-01-27 18:37:19 +00:00
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
This commit is contained in:
@@ -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 (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("1", USB_DATA_PATH)) {
|
||||
ALOGE("Not able to turn on usb connection notification");
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (!WriteStringToFile(kGadgetName, PULLUP_PATH)) {
|
||||
ALOGE("Gadget cannot be pulled up");
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user