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

Commit fdbad834 authored by Roman Birg's avatar Roman Birg
Browse files

Wifi tile: don't set items visible from non-ui thread



This can lead to the items disappearing sometimes.

Ref: CYNGNOS-1241 CYNGNOS-1644

Change-Id: Iea3e0467b56ae17f266c99b02866f8981b5007d7
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent b4c3428e
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ package com.android.systemui.qs.tiles;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Looper;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
@@ -131,16 +132,28 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
    protected void handleUpdateState(SignalState state, Object arg) {
        state.visible = true;
        if (DEBUG) Log.d(TAG, "handleUpdateState arg=" + arg);
        CallbackInfo cb = (CallbackInfo) arg;
        if (cb == null) {
        final CallbackInfo cb;
        if (arg == null) {
            cb = mSignalCallback.mInfo;
        } else {
            cb = (CallbackInfo) arg;
        }

        boolean wifiConnected = cb.enabled && (cb.wifiSignalIconId > 0) && (cb.enabledDesc != null);
        boolean wifiNotConnected = (cb.wifiSignalIconId > 0) && (cb.enabledDesc == null);
        boolean enabledChanging = state.enabled != cb.enabled;
        if (enabledChanging) {
            if (Looper.myLooper() == Looper.getMainLooper()) {
                // on main thread, bypass the handler
                mDetailAdapter.setItemsVisible(cb.enabled);
            } else {
                mUiHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        mDetailAdapter.setItemsVisible(cb.enabled);
                    }
                });
            }
            fireToggleStateChanged(cb.enabled);
        }
        state.enabled = cb.enabled;