From 7adcbd6f7b0baef1e4186376b0b43789303856cf Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Wed, 22 Mar 2017 11:15:50 -0700 Subject: Add try/catch blocks for incoming HAL params Add try/catch blocks for handling exceptions raised during handling incoming params to the HAL calling code. While there, Rename SupplicantStaIfaceHal.addNetwork to SupplicantStaIfaceHal.addNetworkAndSaveConfig Bug: 36510794 Bug: 36510113 Test: Compiles & able to connect to wifi networks Change-Id: Idc52d6ea63c4c23e9a3c8f12827f7b6ef1ea07b8 --- .../android/server/wifi/SupplicantStaIfaceHalTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java index abf533d1f..8a2ceaf08 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java @@ -500,6 +500,24 @@ public class SupplicantStaIfaceHalTest { verify(mISupplicantStaIfaceMock, times(2)).removeNetwork(anyInt()); } + /** + * Tests connection to a specified network failure due to exception in network save. + */ + @Test + public void testConnectFailureDueToNetworkSaveException() throws Exception { + executeAndValidateInitializationSequence(); + setupMocksForConnectSequence(true); + + doThrow(new IllegalArgumentException("Some error!!!")) + .when(mSupplicantStaNetworkMock).saveWifiConfiguration( + any(WifiConfiguration.class)); + + assertFalse(mDut.connectToNetwork(new WifiConfiguration(), false)); + // We should have removed the existing network once before connection and once more + // on failure to save network configuration. + verify(mISupplicantStaIfaceMock, times(2)).removeNetwork(anyInt()); + } + /** * Tests connection to a specified network failure due to network select. */ -- cgit v1.2.3