Fix memory leak of ConnectivityManager
The instance of ConnectivityManager is static, and so its inner class should be static to avoid the memory leak. Otherwise, the inner class will get the reference to the mContext. Bug:248184860 Signed-off-by: zhujiatai <zhujiatai@xiaomi.com> Change-Id: I2c755f04a689f3e9e5f829d9be48765816257366
This commit is contained in:
@@ -4080,7 +4080,7 @@ public class ConnectivityManager {
|
||||
}
|
||||
}
|
||||
|
||||
private class CallbackHandler extends Handler {
|
||||
private static class CallbackHandler extends Handler {
|
||||
private static final String TAG = "ConnectivityManager.CallbackHandler";
|
||||
private static final boolean DBG = false;
|
||||
|
||||
@@ -4095,7 +4095,10 @@ public class ConnectivityManager {
|
||||
@Override
|
||||
public void handleMessage(Message message) {
|
||||
if (message.what == EXPIRE_LEGACY_REQUEST) {
|
||||
expireRequest((NetworkCapabilities) message.obj, message.arg1);
|
||||
// the sInstance can't be null because to send this message a ConnectivityManager
|
||||
// instance must have been created prior to creating the thread on which this
|
||||
// Handler is running.
|
||||
sInstance.expireRequest((NetworkCapabilities) message.obj, message.arg1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user