mirror of
https://github.com/Evolution-X-Devices/device_google_gs201
synced 2026-01-27 14:29:33 +00:00
usb: Add retry on role switch
Bug: 341996696 Change-Id: I8caa65288af1588d24fea4aa6c5768d45d69bbd5 Signed-off-by: Kyle Tso <kyletso@google.com> (cherry picked from commit ef5856a4474002cc35a51377adffddd4cb239796)
This commit is contained in:
@@ -602,6 +602,10 @@ ScopedAStatus Usb::switchRole(const string& in_portName, const PortRole& in_role
|
||||
fp = fopen(filename.c_str(), "w");
|
||||
if (fp != NULL) {
|
||||
int ret = fputs(convertRoletoString(in_role).c_str(), fp);
|
||||
if (ret == EAGAIN) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(700));
|
||||
ret = fputs(convertRoletoString(in_role).c_str(), fp);
|
||||
}
|
||||
fclose(fp);
|
||||
if ((ret != EOF) && ReadFileToString(filename, &written)) {
|
||||
written = Trim(written);
|
||||
|
||||
Reference in New Issue
Block a user