Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fff2fda0 authored by Suchi Amalapurapu's avatar Suchi Amalapurapu
Browse files

Fix memory leaks in system_server

unlink DeathRecipients in a whole bunch of places to avoid memory leaks
parent c56096fe
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -3981,7 +3981,10 @@ public final class ActivityThread {
            ProviderRecord pr = mProviderMap.get(name);
            if (pr.mProvider.asBinder() == provider.asBinder()) {
                Log.i(TAG, "Removing dead content provider: " + name);
                mProviderMap.remove(name);
                ProviderRecord removed = mProviderMap.remove(name);
                if (removed != null) {
                    removed.mProvider.asBinder().unlinkToDeath(removed, 0);
                }
            }
        }
    }
@@ -3990,7 +3993,10 @@ public final class ActivityThread {
        ProviderRecord pr = mProviderMap.get(name);
        if (pr.mProvider.asBinder() == provider.asBinder()) {
            Log.i(TAG, "Removing dead content provider: " + name);
            mProviderMap.remove(name);
            ProviderRecord removed = mProviderMap.remove(name);
            if (removed != null) {
                removed.mProvider.asBinder().unlinkToDeath(removed, 0);
            }
        }
    }

+3 −0
Original line number Diff line number Diff line
@@ -617,6 +617,9 @@ public class GpsLocationProvider extends ILocationProvider.Stub {
            synchronized(mListeners) {
                mListeners.remove(this);
            }
            if (mListener != null) {
                mListener.asBinder().unlinkToDeath(this, 0);
            }
        }
    }

+7 −0
Original line number Diff line number Diff line
@@ -53,6 +53,12 @@ public class LocationProviderProxy implements IBinder.DeathRecipient {
        }
    }

    public void unlinkProvider() {
        if (mProvider != null) {
            mProvider.asBinder().unlinkToDeath(this, 0);
        }
    }

    public String getName() {
        return mName;
    }
@@ -255,5 +261,6 @@ public class LocationProviderProxy implements IBinder.DeathRecipient {
    public void binderDied() {
        Log.w(TAG, "Location Provider " + mName + " died");
        mDead = true;
        mProvider.asBinder().unlinkToDeath(this, 0);
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -507,6 +507,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run

    private void removeProvider(LocationProviderProxy provider) {
        mProviders.remove(provider);
        provider.unlinkProvider();
        mProvidersByName.remove(provider.getName());
    }

+4 −1
Original line number Diff line number Diff line
@@ -709,7 +709,10 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage
                    p.awakeOnSet = true;
                }
            } else {
                mPokeLocks.remove(token);
                PokeLock rLock = mPokeLocks.remove(token);
                if (rLock != null) {
                    token.unlinkToDeath(rLock, 0);
                }
            }

            int oldPokey = mPokey;
Loading