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

Commit 06c39e20 authored by Roman Birg's avatar Roman Birg Committed by Gerrit Code Review
Browse files

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



This can lead to the items disappearing sometimes.

Ref: CYNGNOS-1241

Change-Id: Iea3e0467b56ae17f266c99b02866f8981b5007d7
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 4432d5a1
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -19,6 +19,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;
@@ -119,13 +120,23 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
        state.visible = true;
        if (DEBUG) Log.d(TAG, "handleUpdateState arg=" + arg);
        if (arg == null) return;
        CallbackInfo cb = (CallbackInfo) arg;
        final CallbackInfo 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;