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

Commit 7e2b3ed4 authored by Fabian Kozynski's avatar Fabian Kozynski Committed by Automerger Merge Worker
Browse files

Merge "Remove dependency on connectivity sticky broadcasts" into rvc-dev am: 54ba50a5

Change-Id: I8be42400615800be1f3a6b784398f958362954ee
parents fe26c0d7 54ba50a5
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -133,6 +133,35 @@ public class WifiStatusTracker {
        }
    }

    /**
     * Fetches initial state as if a WifiManager.NETWORK_STATE_CHANGED_ACTION have been received.
     * This replaces the dependency on the initial sticky broadcast.
     */
    public void fetchInitialState() {
        if (mWifiManager == null) {
            return;
        }
        updateWifiState();
        final NetworkInfo networkInfo =
                mConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        connected = networkInfo != null && networkInfo.isConnected();
        mWifiInfo = null;
        ssid = null;
        if (connected) {
            mWifiInfo = mWifiManager.getConnectionInfo();
            if (mWifiInfo != null) {
                if (mWifiInfo.isPasspointAp() || mWifiInfo.isOsuAp()) {
                    ssid = mWifiInfo.getPasspointProviderFriendlyName();
                } else {
                    ssid = getValidSsid(mWifiInfo);
                }
                updateRssi(mWifiInfo.getRssi());
                maybeRequestNetworkScore();
            }
        }
        updateStatusLabel();
    }

    public void handleBroadcast(Intent intent) {
        if (mWifiManager == null) {
            return;
+16 −3
Original line number Diff line number Diff line
@@ -1301,6 +1301,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private FingerprintManager mFpm;
    private FaceManager mFaceManager;
    private boolean mFingerprintLockedOut;
    private TelephonyManager mTelephonyManager;

    /**
     * When we receive a
@@ -1728,10 +1729,22 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        }
        updateAirplaneModeState();

        TelephonyManager telephony =
        mTelephonyManager =
                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        if (telephony != null) {
            telephony.listen(mPhoneStateListener, LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE);
        if (mTelephonyManager != null) {
            mTelephonyManager.listen(mPhoneStateListener,
                    LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE);
            // Set initial sim states values.
            for (int slot = 0; slot < mTelephonyManager.getActiveModemCount(); slot++) {
                int state = mTelephonyManager.getSimState(slot);
                int[] subIds = mSubscriptionManager.getSubscriptionIds(slot);
                if (subIds != null) {
                    for (int subId : subIds) {
                        mHandler.obtainMessage(MSG_SIM_STATE_CHANGE, subId, slot, state)
                                .sendToTarget();
                    }
                }
            }
        }
    }

+3 −1
Original line number Diff line number Diff line
@@ -85,6 +85,8 @@ import com.android.systemui.statusbar.policy.PreviewInflater;
import com.android.systemui.tuner.LockscreenFragment.LockButtonFactory;
import com.android.systemui.tuner.TunerService;

import java.util.concurrent.Executor;

/**
 * Implementation for the bottom area of the Keyguard, including camera/phone affordance and status
 * text.
@@ -553,7 +555,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
            }
        };
        if (!mKeyguardStateController.canDismissLockScreen()) {
            AsyncTask.execute(runnable);
            Dependency.get(Executor.class).execute(runnable);
        } else {
            boolean dismissShade = !TextUtils.isEmpty(mRightButtonStr)
                    && Dependency.get(TunerService.class).getValue(LOCKSCREEN_RIGHT_UNLOCK, 1) != 0;
+11 −0
Original line number Diff line number Diff line
@@ -357,7 +357,18 @@ public class NetworkControllerImpl extends BroadcastReceiver
        mBroadcastDispatcher.registerReceiverWithHandler(this, filter, mReceiverHandler);
        mListening = true;

        // Initial setup of connectivity. Handled as if we had received a sticky broadcast of
        // ConnectivityManager.CONNECTIVITY_ACTION or ConnectivityManager.INET_CONDITION_ACTION.
        mReceiverHandler.post(this::updateConnectivity);

        // Initial setup of WifiSignalController. Handled as if we had received a sticky broadcast
        // of WifiManager.WIFI_STATE_CHANGED_ACTION or WifiManager.NETWORK_STATE_CHANGED_ACTION
        mReceiverHandler.post(mWifiSignalController::fetchInitialState);
        updateMobileControllers();

        // Initial setup of emergency information. Handled as if we had received a sticky broadcast
        // of TelephonyManager.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED.
        mReceiverHandler.post(this::recalculateEmergency);
    }

    private void unregisterListeners() {
+14 −0
Original line number Diff line number Diff line
@@ -101,6 +101,20 @@ public class WifiSignalController extends
                wifiDesc, mCurrentState.isTransient, mCurrentState.statusLabel);
    }

    /**
     * Fetches wifi initial state replacing the initial sticky broadcast.
     */
    public void fetchInitialState() {
        mWifiTracker.fetchInitialState();
        mCurrentState.enabled = mWifiTracker.enabled;
        mCurrentState.connected = mWifiTracker.connected;
        mCurrentState.ssid = mWifiTracker.ssid;
        mCurrentState.rssi = mWifiTracker.rssi;
        mCurrentState.level = mWifiTracker.level;
        mCurrentState.statusLabel = mWifiTracker.statusLabel;
        notifyListenersIfNecessary();
    }

    /**
     * Extract wifi state directly from broadcasts about changes in wifi state.
     */
Loading