Change TetheringManager#RequestDispatcher as static
If the system GC does not recycle the RequestDispatcher objects in time, they will hold more contexts, which may lead to OutOfMemoryError. So change TetheringManager#RequestDispatcher as static. Bug:369730368 Change-Id: Ia67d8547bd2d239b5f939bd870761f2946afd43b Signed-off-by: dingfeisong <dingfeisong@xiaomi.corp-partner.google.com>
This commit is contained in:
parent
355670c196
commit
8675fc0c5d
1 changed files with 8 additions and 8 deletions
|
|
@ -423,7 +423,7 @@ public class TetheringManager {
|
|||
// Used to dispatch legacy ConnectivityManager methods that expect tethering to be able to
|
||||
// return results and perform operations synchronously.
|
||||
// TODO: remove once there are no callers of these legacy methods.
|
||||
private class RequestDispatcher {
|
||||
private static class RequestDispatcher {
|
||||
private final ConditionVariable mWaiting;
|
||||
public volatile int mRemoteResult;
|
||||
|
||||
|
|
@ -439,8 +439,8 @@ public class TetheringManager {
|
|||
mWaiting = new ConditionVariable();
|
||||
}
|
||||
|
||||
int waitForResult(final RequestHelper request) {
|
||||
getConnector(c -> request.runRequest(c, mListener));
|
||||
int waitForResult(final RequestHelper request, final TetheringManager mgr) {
|
||||
mgr.getConnector(c -> request.runRequest(c, mListener));
|
||||
if (!mWaiting.block(DEFAULT_TIMEOUT_MS)) {
|
||||
throw new IllegalStateException("Callback timeout");
|
||||
}
|
||||
|
|
@ -596,7 +596,7 @@ public class TetheringManager {
|
|||
} catch (RemoteException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
});
|
||||
}, this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -628,7 +628,7 @@ public class TetheringManager {
|
|||
} catch (RemoteException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
});
|
||||
}, this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -656,7 +656,7 @@ public class TetheringManager {
|
|||
} catch (RemoteException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
});
|
||||
}, this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1677,7 +1677,7 @@ public class TetheringManager {
|
|||
} catch (RemoteException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
});
|
||||
}, this);
|
||||
|
||||
return ret == TETHER_ERROR_NO_ERROR;
|
||||
}
|
||||
|
|
@ -1726,6 +1726,6 @@ public class TetheringManager {
|
|||
} catch (RemoteException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
});
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue