From e97f923c1820dab0f52a4b1731a92cefdfe2ce8a Mon Sep 17 00:00:00 2001 From: Toni Barzic Date: Wed, 27 Apr 2016 18:10:58 -0700 Subject: [PATCH] Handle PhoneStatusBarPolicy user switch callbacks on main thread Said callbacks poke around StatusBarIconController, which lives on main thread and is not thread safe. BUG=27047911 Bug:28613935 Change-Id: I880d79a237b03c06d72b5dff3db24bd60c7b8839 (cherry picked from commit 4f65092f5c95b89f48a48a916467b78d2a07ff89) --- .../statusbar/phone/PhoneStatusBarPolicy.java | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java index 823af36fff5a9..d32ffa12bea1b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java @@ -411,20 +411,35 @@ public class PhoneStatusBarPolicy implements Callback, RotationLockController.Ro new SynchronousUserSwitchObserver() { @Override public void onUserSwitching(int newUserId) throws RemoteException { - mUserInfoController.reloadUserInfo(); + mHandler.post(new Runnable() { + @Override + public void run() { + mUserInfoController.reloadUserInfo(); + } + }); } @Override public void onUserSwitchComplete(int newUserId) throws RemoteException { - updateAlarm(); - profileChanged(newUserId); - updateQuietState(); - updateManagedProfile(); + mHandler.post(new Runnable() { + @Override + public void run() { + updateAlarm(); + profileChanged(newUserId); + updateQuietState(); + updateManagedProfile(); + } + }); } @Override public void onForegroundProfileSwitch(int newProfileId) { - profileChanged(newProfileId); + mHandler.post(new Runnable() { + @Override + public void run() { + profileChanged(newProfileId); + } + }); } };