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:
parent
a7d868694f
commit
a22b308d42
1 changed files with 4 additions and 0 deletions
|
@ -672,6 +672,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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue