Catch ServiceSpecificException instead of IllegalStateException.

The old NetworkManagementService methods to start clatd threw
IllegalStateException, but the new netd methods throw
ServiceSpecificException. Update the catch clauses so that if
starting clatd fails, the system doesn't crash.

Also stop logging stack traces but only include the exception
message itself.

Bug: 65674744
Test: atest FrameworksNetTests
Test: connecting/disconnecting to v6-only wifi in a loop does not crash
Change-Id: I4a9ec7f104712fbbe08f4f67e3288df03e8ed873
This commit is contained in:
Lorenzo Colitti
2019-02-27 10:35:10 +09:00
parent 84298d8e5e
commit cdd4722829

View File

@@ -175,8 +175,8 @@ public class Nat464Xlat extends BaseNetworkObserver {
String addrStr = null; String addrStr = null;
try { try {
addrStr = mNetd.clatdStart(baseIface, mNat64Prefix.toString()); addrStr = mNetd.clatdStart(baseIface, mNat64Prefix.toString());
} catch (RemoteException | IllegalStateException e) { } catch (RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "Error starting clatd on " + baseIface, e); Slog.e(TAG, "Error starting clatd on " + baseIface + ": " + e);
} }
mIface = CLAT_PREFIX + baseIface; mIface = CLAT_PREFIX + baseIface;
mBaseIface = baseIface; mBaseIface = baseIface;
@@ -203,7 +203,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
try { try {
mNMService.unregisterObserver(this); mNMService.unregisterObserver(this);
} catch (RemoteException | IllegalStateException e) { } catch (RemoteException | IllegalStateException e) {
Slog.e(TAG, "Error unregistering clatd observer on " + mBaseIface, e); Slog.e(TAG, "Error unregistering clatd observer on " + mBaseIface + ": " + e);
} }
mIface = null; mIface = null;
mBaseIface = null; mBaseIface = null;
@@ -248,8 +248,8 @@ public class Nat464Xlat extends BaseNetworkObserver {
Slog.i(TAG, "Stopping clatd on " + mBaseIface); Slog.i(TAG, "Stopping clatd on " + mBaseIface);
try { try {
mNetd.clatdStop(mBaseIface); mNetd.clatdStop(mBaseIface);
} catch (RemoteException | IllegalStateException e) { } catch (RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "Error stopping clatd on " + mBaseIface, e); Slog.e(TAG, "Error stopping clatd on " + mBaseIface + ": " + e);
} }
String iface = mIface; String iface = mIface;
@@ -272,7 +272,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
mNetd.resolverStartPrefix64Discovery(getNetId()); mNetd.resolverStartPrefix64Discovery(getNetId());
mState = State.DISCOVERING; mState = State.DISCOVERING;
} catch (RemoteException | ServiceSpecificException e) { } catch (RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "Error starting prefix discovery on netId " + getNetId(), e); Slog.e(TAG, "Error starting prefix discovery on netId " + getNetId() + ": " + e);
} }
} }
@@ -280,7 +280,7 @@ public class Nat464Xlat extends BaseNetworkObserver {
try { try {
mNetd.resolverStopPrefix64Discovery(getNetId()); mNetd.resolverStopPrefix64Discovery(getNetId());
} catch (RemoteException | ServiceSpecificException e) { } catch (RemoteException | ServiceSpecificException e) {
Slog.e(TAG, "Error stopping prefix discovery on netId " + getNetId(), e); Slog.e(TAG, "Error stopping prefix discovery on netId " + getNetId() + ": " + e);
} }
} }