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

Commit 982a770a authored by mandy's avatar mandy Committed by Bruno Martins
Browse files

Fix NPE when creates wifi tracker

When sets pin lock and reboot phone, SystemUI could not
get WifiManager when creates WifiTracker, then NullPointerException
will happen.So add null pointer checking and avoid
creating WifiTracker for encrypted device to fix this exception.

Bug: 109588864
Test: manual,set pin lock and reboot phone,systemUI can restart normally.
Change-Id: I9bf5d52fa0b1efd99d1f32686f12b5c99765b0c2
parent ea4a451f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -101,6 +101,9 @@ public class WifiStatusTracker extends ConnectivityManager.NetworkCallback {
    }

    public void handleBroadcast(Intent intent) {
        if (mWifiManager == null) {
            return;
        }
        String action = intent.getAction();
        if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
            updateWifiState();
+3 −3
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ public class WifiTracker implements LifecycleObserver, OnStart, OnStop, OnDestro
        mConnectivityManager = connectivityManager;

        // check if verbose logging developer option has been turned on or off
        sVerboseLogging = (mWifiManager.getVerboseLoggingLevel() > 0);
        sVerboseLogging = mWifiManager != null && mWifiManager.getVerboseLoggingLevel() > 0;

        mFilter = filter;

@@ -278,7 +278,7 @@ public class WifiTracker implements LifecycleObserver, OnStart, OnStop, OnDestro
            mScanner = new Scanner();
        }

        if (mWifiManager.isWifiEnabled()) {
        if (isWifiEnabled()) {
            mScanner.resume();
        }
    }
@@ -407,7 +407,7 @@ public class WifiTracker implements LifecycleObserver, OnStart, OnStop, OnDestro
    }

    public boolean isWifiEnabled() {
        return mWifiManager.isWifiEnabled();
        return mWifiManager != null && mWifiManager.isWifiEnabled();
    }

    /**
+3 −0
Original line number Diff line number Diff line
@@ -112,6 +112,9 @@ public class HotspotControllerImpl implements HotspotController, WifiManager.Sof
     * @param shouldListen whether we should start listening to various wifi statuses
     */
    private void updateWifiStateListeners(boolean shouldListen) {
        if (mWifiManager == null) {
            return;
        }
        mWifiStateReceiver.setListening(shouldListen);
        if (shouldListen) {
            mWifiManager.registerSoftApCallback(
+5 −3
Original line number Diff line number Diff line
@@ -59,10 +59,12 @@ public class WifiSignalController extends
        mHasMobileData = hasMobileData;
        Handler handler = new WifiHandler(Looper.getMainLooper());
        mWifiChannel = new AsyncChannel();
        if (wifiManager != null) {
            Messenger wifiMessenger = wifiManager.getWifiServiceMessenger();
            if (wifiMessenger != null) {
                mWifiChannel.connect(context, handler, wifiMessenger);
            }
        }
        // WiFi only has one state.
        mCurrentState.iconGroup = mLastState.iconGroup = new IconGroup(
                "Wi-Fi Icons",