summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wilson Wu <wilsonwu@google.com> 2020-01-06 07:06:08 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-01-06 07:06:08 +0000
commit1b59b9d1020259d1ebe2c614c0239fc1bad3823e (patch)
tree67ef7740035acf3f4fc56756cfb68509167d2256
parentcdbf667823755388e99f20cab228b2d78be2ada0 (diff)
parent0e72713fdf3e065ec4d1e8ca5c4f14dfcc74ebb6 (diff)
Merge "Use the main thread to update alignment indication"
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java3
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java50
2 files changed, 32 insertions, 21 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
index 5abca6b92a3b..7ad07c266cc3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
@@ -168,7 +168,8 @@ public class KeyguardIndicationController implements StateListener,
mStatusBarStateController = statusBarStateController;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mDockManager = dockManager;
- mDockManager.addAlignmentStateListener(this::handleAlignStateChanged);
+ mDockManager.addAlignmentStateListener(
+ alignState -> mHandler.post(() -> handleAlignStateChanged(alignState)));
// lock icon is not used on all form factors.
if (mLockIcon != null) {
mLockIcon.setOnLongClickListener(this::handleLockLongClick);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java
index 48169ea6c467..0a3bc6def160 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java
@@ -154,12 +154,14 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
@Test
public void onAlignmentStateChanged_showsSlowChargingIndication() {
- createController();
- verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
- mController.setVisible(true);
+ mInstrumentation.runOnMainSync(() -> {
+ createController();
+ verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
+ mController.setVisible(true);
- mAlignmentListener.getValue().onAlignmentStateChanged(
- DockManager.ALIGN_STATE_POOR);
+ mAlignmentListener.getValue().onAlignmentStateChanged(DockManager.ALIGN_STATE_POOR);
+ });
+ mInstrumentation.waitForIdleSync();
assertThat(mTextView.getText()).isEqualTo(
mContext.getResources().getString(R.string.dock_alignment_slow_charging));
@@ -169,11 +171,14 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
@Test
public void onAlignmentStateChanged_showsNotChargingIndication() {
- createController();
- verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
- mController.setVisible(true);
+ mInstrumentation.runOnMainSync(() -> {
+ createController();
+ verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
+ mController.setVisible(true);
- mAlignmentListener.getValue().onAlignmentStateChanged(DockManager.ALIGN_STATE_TERRIBLE);
+ mAlignmentListener.getValue().onAlignmentStateChanged(DockManager.ALIGN_STATE_TERRIBLE);
+ });
+ mInstrumentation.waitForIdleSync();
assertThat(mTextView.getText()).isEqualTo(
mContext.getResources().getString(R.string.dock_alignment_not_charging));
@@ -183,13 +188,15 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
@Test
public void onAlignmentStateChanged_whileDozing_showsSlowChargingIndication() {
- createController();
- verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
- mController.setVisible(true);
- mController.setDozing(true);
+ mInstrumentation.runOnMainSync(() -> {
+ createController();
+ verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
+ mController.setVisible(true);
+ mController.setDozing(true);
- mAlignmentListener.getValue().onAlignmentStateChanged(
- DockManager.ALIGN_STATE_POOR);
+ mAlignmentListener.getValue().onAlignmentStateChanged(DockManager.ALIGN_STATE_POOR);
+ });
+ mInstrumentation.waitForIdleSync();
assertThat(mTextView.getText()).isEqualTo(
mContext.getResources().getString(R.string.dock_alignment_slow_charging));
@@ -199,12 +206,15 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
@Test
public void onAlignmentStateChanged_whileDozing_showsNotChargingIndication() {
- createController();
- verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
- mController.setVisible(true);
- mController.setDozing(true);
+ mInstrumentation.runOnMainSync(() -> {
+ createController();
+ verify(mDockManager).addAlignmentStateListener(mAlignmentListener.capture());
+ mController.setVisible(true);
+ mController.setDozing(true);
- mAlignmentListener.getValue().onAlignmentStateChanged(DockManager.ALIGN_STATE_TERRIBLE);
+ mAlignmentListener.getValue().onAlignmentStateChanged(DockManager.ALIGN_STATE_TERRIBLE);
+ });
+ mInstrumentation.waitForIdleSync();
assertThat(mTextView.getText()).isEqualTo(
mContext.getResources().getString(R.string.dock_alignment_not_charging));