summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSumit Bajpai <sbajpai@codeaurora.org>2013-04-25 18:57:02 +0530
committerArne Coucheron <arco68@gmail.com>2013-07-24 07:21:20 +0200
commita37ddac8d03e30996b3fbbef5d7adbbe8f9a05d2 (patch)
tree06909af010eaeee9939102e2b5be290eacdde9cf
parent4ff298acd7539011e192b75cd7f09c6b63487811 (diff)
downloadframeworks_base-a37ddac8d03e30996b3fbbef5d7adbbe8f9a05d2.zip
frameworks_base-a37ddac8d03e30996b3fbbef5d7adbbe8f9a05d2.tar.gz
frameworks_base-a37ddac8d03e30996b3fbbef5d7adbbe8f9a05d2.tar.bz2
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
-rw-r--r--services/java/com/android/server/am/BatteryStatsService.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/services/java/com/android/server/am/BatteryStatsService.java b/services/java/com/android/server/am/BatteryStatsService.java
index ab20208..99cb2c8 100644
--- a/services/java/com/android/server/am/BatteryStatsService.java
+++ b/services/java/com/android/server/am/BatteryStatsService.java
@@ -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;
}
}