diff options
-rw-r--r-- | service/java/com/android/server/wifi/HostapdHal.java | 38 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java | 12 |
2 files changed, 30 insertions, 20 deletions
diff --git a/service/java/com/android/server/wifi/HostapdHal.java b/service/java/com/android/server/wifi/HostapdHal.java index a49147089..a17237b53 100644 --- a/service/java/com/android/server/wifi/HostapdHal.java +++ b/service/java/com/android/server/wifi/HostapdHal.java @@ -142,14 +142,32 @@ public class HostapdHal { * @return true if supported, false otherwise. */ private boolean isV1_1() { + return checkHalVersionByInterfaceName( + android.hardware.wifi.hostapd.V1_1.IHostapd.kInterfaceName); + } + + /** + * Uses the IServiceManager to check if the device is running V1_2 of the HAL from the VINTF for + * the device. + * @return true if supported, false otherwise. + */ + private boolean isV1_2() { + return checkHalVersionByInterfaceName( + android.hardware.wifi.hostapd.V1_2.IHostapd.kInterfaceName); + } + + private boolean checkHalVersionByInterfaceName(String interfaceName) { + if (interfaceName == null) { + return false; + } synchronized (mLock) { if (mIServiceManager == null) { - Log.e(TAG, "isV1_1: called but mServiceManager is null!?"); + Log.e(TAG, "checkHalVersionByInterfaceName called but mServiceManager is null!?"); return false; } try { return (mIServiceManager.getTransport( - android.hardware.wifi.hostapd.V1_1.IHostapd.kInterfaceName, + interfaceName, HAL_INSTANCE_NAME) != IServiceManager.Transport.EMPTY); } catch (RemoteException e) { @@ -161,20 +179,6 @@ public class HostapdHal { } /** - * Checks if the service is running HAL version 1.2 on the device. - * @return true if supported, false otherwise. - */ - private boolean isV1_2() { - try { - return (getHostapdMockableV1_2() != null); - } catch (RemoteException e) { - Log.e(TAG, "Exception while operating on IServiceManager: " + e); - handleRemoteException(e, "getHostapdMockableV1_2"); - return false; - } - } - - /** * Link to death for IServiceManager object. * @return true on success, false otherwise. */ @@ -299,11 +303,13 @@ public class HostapdHal { return false; } if (!linkToHostapdDeath(mHostapdDeathRecipient, ++mDeathRecipientCookie)) { + Log.e(TAG, "Fail to link to Hostapd Death, Stopping hostapd HIDL startup"); mIHostapd = null; return false; } // Register for callbacks for 1.1 hostapd. if (isV1_1() && !registerCallback(new HostapdCallback())) { + Log.e(TAG, "Fail to regiester Callback, Stopping hostapd HIDL startup"); mIHostapd = null; return false; } diff --git a/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java b/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java index c7e23cd49..b87c75293 100644 --- a/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java @@ -187,7 +187,8 @@ public class HostapdHalTest extends WifiBaseTest { */ @Test public void testInitialize_successV1_1() throws Exception { - when(mServiceManagerMock.getTransport(anyString(), anyString())) + when(mServiceManagerMock.getTransport(eq( + android.hardware.wifi.hostapd.V1_1.IHostapd.kInterfaceName), anyString())) .thenReturn(IServiceManager.Transport.HWBINDER); mIHostapdMockV11 = mock(android.hardware.wifi.hostapd.V1_1.IHostapd.class); executeAndValidateInitializationSequenceV1_1(false); @@ -198,7 +199,8 @@ public class HostapdHalTest extends WifiBaseTest { */ @Test public void testInitialize_registerCallbackFailureV1_1() throws Exception { - when(mServiceManagerMock.getTransport(anyString(), anyString())) + when(mServiceManagerMock.getTransport(eq( + android.hardware.wifi.hostapd.V1_1.IHostapd.kInterfaceName), anyString())) .thenReturn(IServiceManager.Transport.HWBINDER); mIHostapdMockV11 = mock(android.hardware.wifi.hostapd.V1_1.IHostapd.class); executeAndValidateInitializationSequenceV1_1(true); @@ -482,7 +484,8 @@ public class HostapdHalTest extends WifiBaseTest { */ @Test public void testAddAccessPointSuccess_Psk_BandAny_WithACS_AcsChannels() throws Exception { - when(mServiceManagerMock.getTransport(anyString(), anyString())) + when(mServiceManagerMock.getTransport(eq( + android.hardware.wifi.hostapd.V1_1.IHostapd.kInterfaceName), anyString())) .thenReturn(IServiceManager.Transport.HWBINDER); mIHostapdMockV11 = mock(android.hardware.wifi.hostapd.V1_1.IHostapd.class); // Enable ACS and set available channels in the config. @@ -622,7 +625,8 @@ public class HostapdHalTest extends WifiBaseTest { */ @Test public void testOnFailureCallbackHandling() throws Exception { - when(mServiceManagerMock.getTransport(anyString(), anyString())) + when(mServiceManagerMock.getTransport(eq( + android.hardware.wifi.hostapd.V1_1.IHostapd.kInterfaceName), anyString())) .thenReturn(IServiceManager.Transport.HWBINDER); mIHostapdMockV11 = mock(android.hardware.wifi.hostapd.V1_1.IHostapd.class); when(mIHostapdMockV11.addAccessPoint_1_1( |