From f713828f74b08b6ab70adefe7342a418b1d489ae Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Tue, 1 Mar 2016 19:27:23 -0700 Subject: [PATCH] When system server goes down, crash apps more. Apps making calls into the system server may end up persisting internal state or making security decisions based on the perceived success or failure of a call, or the default values returned. The reality is that if the system process just died, init will be along shortly to kill all running apps, so we should have no problem rethrowing the RemoteException as a RuntimeException. Bug: 27364859 Change-Id: Ife0bcb079636c88d54c44d17eb580409fd79028b --- core/java/android/net/EthernetManager.java | 17 ++++++++++------- core/java/android/net/nsd/NsdManager.java | 6 ++++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/core/java/android/net/EthernetManager.java b/core/java/android/net/EthernetManager.java index f45737a66e..664b7b4089 100644 --- a/core/java/android/net/EthernetManager.java +++ b/core/java/android/net/EthernetManager.java @@ -87,8 +87,8 @@ public class EthernetManager { public IpConfiguration getConfiguration() { try { return mService.getConfiguration(); - } catch (NullPointerException | RemoteException e) { - return new IpConfiguration(); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -98,7 +98,8 @@ public class EthernetManager { public void setConfiguration(IpConfiguration config) { try { mService.setConfiguration(config); - } catch (NullPointerException | RemoteException e) { + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -109,8 +110,8 @@ public class EthernetManager { public boolean isAvailable() { try { return mService.isAvailable(); - } catch (NullPointerException | RemoteException e) { - return false; + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } @@ -127,7 +128,8 @@ public class EthernetManager { if (mListeners.size() == 1) { try { mService.addListener(mServiceListener); - } catch (NullPointerException | RemoteException e) { + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } } @@ -145,7 +147,8 @@ public class EthernetManager { if (mListeners.isEmpty()) { try { mService.removeListener(mServiceListener); - } catch (NullPointerException | RemoteException e) { + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); } } } diff --git a/core/java/android/net/nsd/NsdManager.java b/core/java/android/net/nsd/NsdManager.java index 377ed88997..86bd502826 100644 --- a/core/java/android/net/nsd/NsdManager.java +++ b/core/java/android/net/nsd/NsdManager.java @@ -619,7 +619,9 @@ public final class NsdManager { public void setEnabled(boolean enabled) { try { mService.setEnabled(enabled); - } catch (RemoteException e) { } + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } } /** @@ -632,7 +634,7 @@ public final class NsdManager { try { return mService.getMessenger(); } catch (RemoteException e) { - return null; + throw e.rethrowFromSystemServer(); } } }