Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4197a29b authored by Amin Shaikh's avatar Amin Shaikh
Browse files

Fix flaky sysui crash in devicehealthchecks test.

Upgrade tuner on the main thread to avoid
ConcurrentModificationException.

Fixes: 133847620
Test: mp droid
Change-Id: I15ef66a19eeac2c6baf652d83e6a90669834f203
parent 6f3ca535
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
 */
package com.android.systemui.tuner;

import static com.android.systemui.Dependency.BG_HANDLER_NAME;
import static com.android.systemui.Dependency.MAIN_HANDLER_NAME;

import android.app.ActivityManager;
import android.content.ContentResolver;
@@ -82,7 +82,7 @@ public class TunerServiceImpl extends TunerService {
    /**
     */
    @Inject
    public TunerServiceImpl(Context context, @Named(BG_HANDLER_NAME) Handler bgHandler,
    public TunerServiceImpl(Context context, @Named(MAIN_HANDLER_NAME) Handler mainHandler,
            LeakDetector leakDetector) {
        mContext = context;
        mContentResolver = mContext.getContentResolver();
@@ -91,7 +91,7 @@ public class TunerServiceImpl extends TunerService {
        for (UserInfo user : UserManager.get(mContext).getUsers()) {
            mCurrentUser = user.getUserHandle().getIdentifier();
            if (getValue(TUNER_VERSION, 0) != CURRENT_TUNER_VERSION) {
                upgradeTuner(getValue(TUNER_VERSION, 0), CURRENT_TUNER_VERSION, bgHandler);
                upgradeTuner(getValue(TUNER_VERSION, 0), CURRENT_TUNER_VERSION, mainHandler);
            }
        }

@@ -112,7 +112,7 @@ public class TunerServiceImpl extends TunerService {
        mUserTracker.stopTracking();
    }

    private void upgradeTuner(int oldVersion, int newVersion, Handler bgHandler) {
    private void upgradeTuner(int oldVersion, int newVersion, Handler mainHandler) {
        if (oldVersion < 1) {
            String blacklistStr = getValue(StatusBarIconController.ICON_BLACKLIST);
            if (blacklistStr != null) {
@@ -134,7 +134,7 @@ public class TunerServiceImpl extends TunerService {
        if (oldVersion < 4) {
            // Delay this so that we can wait for everything to be registered first.
            final int user = mCurrentUser;
            bgHandler.postDelayed(
            mainHandler.postDelayed(
                    () -> clearAllFromUser(user), 5000);
        }
        setValue(TUNER_VERSION, newVersion);