From 34f6cbc288bfcd627cd6af4199123f7edc3e02c1 Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Tue, 30 Aug 2016 16:33:48 -0400 Subject: [PATCH] Fix QS CTS failure caused by tile backup The CTS tests weren't receiving the onTileAdded callbacks since the shade was not in the listening state when tiles were added. This is not possible for users (since tiles are added while the UI is listening), but add a flushMessagesAndUnbind call to make sure the tiles always receive onTileAdded. Since now flushMessagesAndUnbind can be called before a real call to setBindService(true), add a clause that will clear out its immediate unbind state. Change-Id: Idd13c432a4af5741813da9a9b1b292a47fd9443b Fixes: 31147742 --- .../android/systemui/qs/external/TileLifecycleManager.java | 6 ++++++ .../android/systemui/qs/external/TileServiceManager.java | 1 + 2 files changed, 7 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java b/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java index 28da69c34e28b..17ce0cb80eef9 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java +++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java @@ -129,6 +129,12 @@ public class TileLifecycleManager extends BroadcastReceiver implements } public void setBindService(boolean bind) { + if (mBound && mUnbindImmediate) { + // If we are already bound and expecting to unbind, this means we should stay bound + // because something else wants to hold the connection open. + mUnbindImmediate = false; + return; + } mBound = bind; if (bind) { if (mBindTryCount == MAX_BIND_RETRIES) { diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java b/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java index 8493cc671d3a1..91a0eb095ff97 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java +++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java @@ -95,6 +95,7 @@ public class TileServiceManager { if (!TileLifecycleManager.isTileAdded(context, component)) { TileLifecycleManager.setTileAdded(context, component, true); mStateManager.onTileAdded(); + mStateManager.flushMessagesAndUnbind(); } }