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)

Change-Id: Ie0a32a9062c722327a27c6de13e3bb8d9588bebb
This commit is contained in:
markchien
2020-04-27 11:03:09 +08:00
parent 3db6cae8d4
commit 6b3afbe447

View File

@@ -41,6 +41,7 @@ import java.io.IOException;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.net.SocketException; import java.net.SocketException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.NoSuchElementException;
/** /**
@@ -143,7 +144,7 @@ public class OffloadHardwareInterface {
IOffloadConfig offloadConfig; IOffloadConfig offloadConfig;
try { try {
offloadConfig = IOffloadConfig.getService(true /*retry*/); offloadConfig = IOffloadConfig.getService(true /*retry*/);
} catch (RemoteException e) { } catch (RemoteException | NoSuchElementException e) {
mLog.e("getIOffloadConfig error " + e); mLog.e("getIOffloadConfig error " + e);
return false; return false;
} }
@@ -239,8 +240,8 @@ public class OffloadHardwareInterface {
if (mOffloadControl == null) { if (mOffloadControl == null) {
try { try {
mOffloadControl = IOffloadControl.getService(); mOffloadControl = IOffloadControl.getService(true /*retry*/);
} catch (RemoteException e) { } catch (RemoteException | NoSuchElementException e) {
mLog.e("tethering offload control not supported: " + e); mLog.e("tethering offload control not supported: " + e);
return false; return false;
} }