summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yuta Yamada <yuta.x.yamada@sonymobile.com> 2016-10-14 14:29:58 +0000
committer android-build-merger <android-build-merger@google.com> 2016-10-14 14:29:58 +0000
commitdd1bd9875f7b9834bceb133f2a820dadd139f720 (patch)
treee54c9f3a05b1bcb87d1fe029b63309697ab64e10
parentf69a47fcdcfa5fe062b160cecdc743acc39c59cf (diff)
parentbe3b53beca6ff70b66919614f2f3d1b2a5270359 (diff)
Merge "Fix memory leak of Dnd tile" am: 6057a8360a am: 465397e28e
am: be3b53beca Change-Id: I12dae89a0b577379e7a868182b535f5dcda09d36
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/customize/TileQueryHelper.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java11
2 files changed, 16 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/TileQueryHelper.java b/packages/SystemUI/src/com/android/systemui/qs/customize/TileQueryHelper.java
index 40ef6eb999db..1ba7135d3b80 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/customize/TileQueryHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/customize/TileQueryHelper.java
@@ -64,7 +64,10 @@ public class TileQueryHelper {
for (int i = 0; i < possibleTiles.length; i++) {
final String spec = possibleTiles[i];
final QSTile<?> tile = host.createTile(spec);
- if (tile == null || !tile.isAvailable()) {
+ if (tile == null) {
+ continue;
+ } else if (!tile.isAvailable()) {
+ tile.destroy();
continue;
}
tile.setListening(this, true);
@@ -78,6 +81,7 @@ public class TileQueryHelper {
tile.getState().copyTo(state);
// Ignore the current state and get the generic label instead.
state.label = tile.getTileLabel();
+ tile.destroy();
mainHandler.post(new Runnable() {
@Override
public void run() {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
index 91821bad988a..8fcda59011e9 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
@@ -68,12 +68,23 @@ public class DndTile extends QSTile<QSTile.BooleanState> {
private boolean mListening;
private boolean mShowingDetail;
+ private boolean mReceiverRegistered;
public DndTile(Host host) {
super(host);
mController = host.getZenModeController();
mDetailAdapter = new DndDetailAdapter();
mContext.registerReceiver(mReceiver, new IntentFilter(ACTION_SET_VISIBLE));
+ mReceiverRegistered = true;
+ }
+
+ @Override
+ protected void handleDestroy() {
+ super.handleDestroy();
+ if (mReceiverRegistered) {
+ mContext.unregisterReceiver(mReceiver);
+ mReceiverRegistered = false;
+ }
}
public static void setVisible(Context context, boolean visible) {