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

Commit a37ddac8 authored by Sumit Bajpai's avatar Sumit Bajpai Committed by Arne Coucheron
Browse files

BT: Fix memory leak when BT on & off done many times

Solves a memory leak in BatteryStatsService when Bluetooth
is turn on/off. Solution adds missing close of proxy then
Bluetooth is turned off.

Change-Id: I65f9db298459c7c15f6a10c752992f1d38469445
CRs-Fixed: 476145
parent 4ff298ac
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -330,6 +330,13 @@ public final class BatteryStatsService extends IBatteryStats.Stub {
        synchronized (mStats) {
            mBluetoothPendingStats = false;
            mStats.noteBluetoothOffLocked();
            mStats.setBtHeadset(null);
        }

        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
        if (adapter != null && mBluetoothHeadset != null) {
            adapter.closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset);
            mBluetoothHeadset = null;
        }
    }