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

Commit d9b3d551 authored by Lorenzo Colitti's avatar Lorenzo Colitti
Browse files

Catch RuntimeException in NMService notifications

Currently, NetworkManagementService only catches RemoteExceptions
when calling the BaseNetworkObserver notification methods (e.g.,
interfaceStatusChanged). However, if the observer is in the same
process, unchecked exceptions can occur as well.

When this happens, finishBroadcast does not get called, and no
further notifications can be sent, because any attempt to do so
fails with a "beginBroadcast() called while already in a
broadcast" exception.

Fix this by catching RuntimeException as well.

Bug: 8397534
Bug: 8276725
Change-Id: Icd6f32128707244978943c48a9ea3a2b952a2957
parent c8a9fdff
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -233,6 +233,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
            try {
                mObservers.getBroadcastItem(i).interfaceStatusChanged(iface, up);
            } catch (RemoteException e) {
            } catch (RuntimeException e) {
            }
        }
        mObservers.finishBroadcast();
@@ -248,6 +249,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
            try {
                mObservers.getBroadcastItem(i).interfaceLinkStateChanged(iface, up);
            } catch (RemoteException e) {
            } catch (RuntimeException e) {
            }
        }
        mObservers.finishBroadcast();
@@ -262,6 +264,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
            try {
                mObservers.getBroadcastItem(i).interfaceAdded(iface);
            } catch (RemoteException e) {
            } catch (RuntimeException e) {
            }
        }
        mObservers.finishBroadcast();
@@ -281,6 +284,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
            try {
                mObservers.getBroadcastItem(i).interfaceRemoved(iface);
            } catch (RemoteException e) {
            } catch (RuntimeException e) {
            }
        }
        mObservers.finishBroadcast();
@@ -295,6 +299,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
            try {
                mObservers.getBroadcastItem(i).limitReached(limitName, iface);
            } catch (RemoteException e) {
            } catch (RuntimeException e) {
            }
        }
        mObservers.finishBroadcast();
@@ -309,6 +314,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
            try {
                mObservers.getBroadcastItem(i).interfaceClassDataActivityChanged(label, active);
            } catch (RemoteException e) {
            } catch (RuntimeException e) {
            }
        }
        mObservers.finishBroadcast();