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

Commit a1168029 authored by Oscar Shu's avatar Oscar Shu
Browse files

Catch NullPointer caused by race of setting mWifiCond

Similar to ag/25108489, but protecting all places where mWifiCond is
used. Due to many places changed, uses catch exception instead of
synchronized to minimize risk of breaking.

Bug: 327918402
Test: build and flash
Change-Id: I1760a524ac0eedbf21cea84f893be6ffd618d9d9
parent 49e4227a
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -718,6 +718,9 @@ public class WifiNl80211Manager {
        } catch (RemoteException e1) {
            Log.e(TAG, "Failed to get IClientInterface due to remote exception");
            return false;
        } catch (NullPointerException e2) {
            Log.e(TAG, "setupInterfaceForClientMode NullPointerException");
            return false;
        }

        if (clientInterface == null) {
@@ -785,6 +788,9 @@ public class WifiNl80211Manager {
        } catch (RemoteException e1) {
            Log.e(TAG, "Failed to teardown client interface due to remote exception");
            return false;
        } catch (NullPointerException e2) {
            Log.e(TAG, "tearDownClientInterface NullPointerException");
            return false;
        }
        if (!success) {
            Log.e(TAG, "Failed to teardown client interface");
@@ -816,6 +822,9 @@ public class WifiNl80211Manager {
        } catch (RemoteException e1) {
            Log.e(TAG, "Failed to get IApInterface due to remote exception");
            return false;
        } catch (NullPointerException e2) {
            Log.e(TAG, "setupInterfaceForSoftApMode NullPointerException");
            return false;
        }

        if (apInterface == null) {
@@ -854,6 +863,9 @@ public class WifiNl80211Manager {
        } catch (RemoteException e1) {
            Log.e(TAG, "Failed to teardown AP interface due to remote exception");
            return false;
        } catch (NullPointerException e2) {
            Log.e(TAG, "tearDownSoftApInterface NullPointerException");
            return false;
        }
        if (!success) {
            Log.e(TAG, "Failed to teardown AP interface");
@@ -1328,6 +1340,8 @@ public class WifiNl80211Manager {
            }
        } catch (RemoteException e1) {
            Log.e(TAG, "Failed to request getChannelsForBand due to remote exception");
        } catch (NullPointerException e2) {
            Log.e(TAG, "getChannelsMhzForBand NullPointerException");
        }
        if (result == null) {
            result = new int[0];
@@ -1352,7 +1366,8 @@ public class WifiNl80211Manager {
     */
    @Nullable public DeviceWiphyCapabilities getDeviceWiphyCapabilities(@NonNull String ifaceName) {
        if (mWificond == null) {
            Log.e(TAG, "getDeviceWiphyCapabilities: mWificond binder is null! Did wificond die?");
            Log.e(TAG, "getDeviceWiphyCapabilities: mWificond binder is null! "
                    + "Did wificond die?");
            return null;
        }

@@ -1360,6 +1375,9 @@ public class WifiNl80211Manager {
            return mWificond.getDeviceWiphyCapabilities(ifaceName);
        } catch (RemoteException e) {
            return null;
        } catch (NullPointerException e2) {
            Log.e(TAG, "getDeviceWiphyCapabilities NullPointerException");
            return null;
        }
    }

@@ -1409,6 +1427,8 @@ public class WifiNl80211Manager {
            Log.i(TAG, "Receive country code change to " + newCountryCode);
        } catch (RemoteException re) {
            re.rethrowFromSystemServer();
        } catch (NullPointerException e) {
            new RemoteException("Wificond service doesn't exist!").rethrowFromSystemServer();
        }
    }