Fix a memory leak in ConnectivityManager.

Remove callbacks from the internal storage when they are being unregistered.

Change-Id: Ia42ed7aefaebd8caf3eada8e42b6cb7a940d7647
This commit is contained in:
Pierre Imai
2016-02-19 16:26:01 +09:00
parent 18c98fed4d
commit 66d9bd8806

View File

@@ -2734,7 +2734,7 @@ public class ConnectivityManager {
private void incCallbackHandlerRefCount() {
synchronized(sCallbackRefCount) {
if (sCallbackRefCount.incrementAndGet() == 1) {
// TODO - switch this over to a ManagerThread or expire it when done
// TODO: switch this to ConnectivityThread
HandlerThread callbackThread = new HandlerThread("ConnectivityManager");
callbackThread.start();
sCallbackHandler = new CallbackHandler(callbackThread.getLooper(),
@@ -3093,6 +3093,10 @@ public class ConnectivityManager {
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
synchronized (sNetworkCallback) {
sNetworkCallback.remove(networkCallback.networkRequest);
}
}
/**