Notify ClockChangedListeners on main thread

Bug: 146033031
Test: install clock plugin that is direct boot aware. Reboot, and check
that custom clock appears on lock screen.

Change-Id: I350c3d21a11a2c64078c31af3bee9364e3cd9062
This commit is contained in:
Robert Snoeberger
2019-12-13 12:25:25 -05:00
parent 91270ddb55
commit c64a3fefd5

View File

@@ -243,11 +243,12 @@ public final class ClockManager {
mPreviewClocks.reloadCurrentClock();
mListeners.forEach((listener, clocks) -> {
clocks.reloadCurrentClock();
ClockPlugin clock = clocks.getCurrentClock();
if (clock instanceof DefaultClockController) {
listener.onClockChanged(null);
final ClockPlugin clock = clocks.getCurrentClock();
if (Looper.myLooper() == Looper.getMainLooper()) {
listener.onClockChanged(clock instanceof DefaultClockController ? null : clock);
} else {
listener.onClockChanged(clock);
mMainHandler.post(() -> listener.onClockChanged(
clock instanceof DefaultClockController ? null : clock));
}
});
}