Merge "Fix memory leak of Dnd tile" am: 6057a8360a

am: 465397e28e

Change-Id: I66d6f38d6f53251c0bc58d9ea49b4458d8b000f9
This commit is contained in:
Yuta Yamada
2016-10-13 14:30:09 +00:00
committed by android-build-merger
2 changed files with 16 additions and 1 deletions

View File

@@ -65,7 +65,10 @@ public class TileQueryHelper {
for (int i = 0; i < possibleTiles.length; i++) { for (int i = 0; i < possibleTiles.length; i++) {
final String spec = possibleTiles[i]; final String spec = possibleTiles[i];
final QSTile<?> tile = host.createTile(spec); final QSTile<?> tile = host.createTile(spec);
if (tile == null || !tile.isAvailable()) { if (tile == null) {
continue;
} else if (!tile.isAvailable()) {
tile.destroy();
continue; continue;
} }
tile.setListening(this, true); tile.setListening(this, true);
@@ -79,6 +82,7 @@ public class TileQueryHelper {
tile.getState().copyTo(state); tile.getState().copyTo(state);
// Ignore the current state and get the generic label instead. // Ignore the current state and get the generic label instead.
state.label = tile.getTileLabel(); state.label = tile.getTileLabel();
tile.destroy();
mainHandler.post(new Runnable() { mainHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@@ -68,12 +68,23 @@ public class DndTile extends QSTile<QSTile.BooleanState> {
private boolean mListening; private boolean mListening;
private boolean mShowingDetail; private boolean mShowingDetail;
private boolean mReceiverRegistered;
public DndTile(Host host) { public DndTile(Host host) {
super(host); super(host);
mController = host.getZenModeController(); mController = host.getZenModeController();
mDetailAdapter = new DndDetailAdapter(); mDetailAdapter = new DndDetailAdapter();
mContext.registerReceiver(mReceiver, new IntentFilter(ACTION_SET_VISIBLE)); 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) { public static void setVisible(Context context, boolean visible) {