From 27cdaf679a83f1764b2cc3954dffd6e1b621e8f9 Mon Sep 17 00:00:00 2001 From: Mark Chien Date: Mon, 27 Apr 2020 09:12:37 +0000 Subject: [PATCH] Unbreak tethering for no offload supported devices Catch NoSuchElementException to unbreak no offload devices. To consistent with fetching offload config service, retry fetcheing offload control service. b/152430668#comment4 assert that the fetch will be retried only if the service is installed on the device. Bug: 155026033 Test: run TetheringCoverageTests in virtual devices(do not support offload) Merged-In: Ie0a32a9062c722327a27c6de13e3bb8d9588bebb Change-Id: Ie0a32a9062c722327a27c6de13e3bb8d9588bebb --- .../networkstack/tethering/OffloadHardwareInterface.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Tethering/src/com/android/networkstack/tethering/OffloadHardwareInterface.java b/Tethering/src/com/android/networkstack/tethering/OffloadHardwareInterface.java index 55344fc75d..c4a1078d0b 100644 --- a/Tethering/src/com/android/networkstack/tethering/OffloadHardwareInterface.java +++ b/Tethering/src/com/android/networkstack/tethering/OffloadHardwareInterface.java @@ -41,6 +41,7 @@ import java.io.IOException; import java.net.SocketAddress; import java.net.SocketException; import java.util.ArrayList; +import java.util.NoSuchElementException; /** @@ -143,7 +144,7 @@ public class OffloadHardwareInterface { IOffloadConfig offloadConfig; try { offloadConfig = IOffloadConfig.getService(true /*retry*/); - } catch (RemoteException e) { + } catch (RemoteException | NoSuchElementException e) { mLog.e("getIOffloadConfig error " + e); return false; } @@ -239,8 +240,8 @@ public class OffloadHardwareInterface { if (mOffloadControl == null) { try { - mOffloadControl = IOffloadControl.getService(); - } catch (RemoteException e) { + mOffloadControl = IOffloadControl.getService(true /*retry*/); + } catch (RemoteException | NoSuchElementException e) { mLog.e("tethering offload control not supported: " + e); return false; }