Write the pullup value only if new value applied am: 11f2c88795
Original change: https://googleplex-android-review.googlesource.com/c/device/google/gs101/+/18555372 Change-Id: Ide4fb5595688e0cb76522fe45256e51fb55f0878 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
0c364d873c
1 changed files with 21 additions and 10 deletions
|
@ -83,23 +83,39 @@ ScopedAStatus Usb::enableUsbData(const string& in_portName, bool in_enable,
|
||||||
int64_t in_transactionId) {
|
int64_t in_transactionId) {
|
||||||
bool result = true;
|
bool result = true;
|
||||||
std::vector<PortStatus> currentPortStatus;
|
std::vector<PortStatus> currentPortStatus;
|
||||||
|
string pullup;
|
||||||
|
|
||||||
ALOGI("Userspace turn %s USB data signaling. opID:%ld", in_enable ? "on" : "off",
|
ALOGI("Userspace turn %s USB data signaling. opID:%ld", in_enable ? "on" : "off",
|
||||||
in_transactionId);
|
in_transactionId);
|
||||||
|
|
||||||
if (in_enable) {
|
if (in_enable) {
|
||||||
if (!mUsbDataEnabled) {
|
if (!mUsbDataEnabled) {
|
||||||
if (!WriteStringToFile("1", USB_DATA_PATH)) {
|
if (ReadFileToString(PULLUP_PATH, &pullup)) {
|
||||||
ALOGE("Not able to turn on usb connection notification");
|
pullup = Trim(pullup);
|
||||||
result = false;
|
if (pullup != kGadgetName) {
|
||||||
}
|
|
||||||
|
|
||||||
if (!WriteStringToFile(kGadgetName, PULLUP_PATH)) {
|
if (!WriteStringToFile(kGadgetName, PULLUP_PATH)) {
|
||||||
ALOGE("Gadget cannot be pulled up");
|
ALOGE("Gadget cannot be pulled up");
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!WriteStringToFile("1", USB_DATA_PATH)) {
|
||||||
|
ALOGE("Not able to turn on usb connection notification");
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} 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)) {
|
if (!WriteStringToFile("1", ID_PATH)) {
|
||||||
ALOGE("Not able to turn off host mode");
|
ALOGE("Not able to turn off host mode");
|
||||||
result = false;
|
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");
|
ALOGE("Not able to turn on usb connection notification");
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WriteStringToFile("none", PULLUP_PATH)) {
|
|
||||||
ALOGE("Gadget cannot be pulled down");
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue