diff options
author | Roshan Pius <rpius@google.com> | 2017-05-12 16:45:05 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2017-05-17 23:16:36 +0000 |
commit | 8131b04dc799cb0c75240c7b9eb0517ba1f00be8 (patch) | |
tree | 609b6180e75fa17f8a45af2a52a01d3f341894e5 /service | |
parent | 0c96f88c6d9f031ab76392cdb1255bd249212ad3 (diff) |
WifiNative: Add VINTF check for vendor HAL
Currently, we're ignoring HAL start failures to support devices like
gce, hikey which did not have any vendor HAL support previously.
To solve that problem:
1. Remove the Vendor HAL daemon (HIDL shim) from such device's
device.mk.
Handled by other CL's in the topic.
2. Add the Wifi HAL's to the VINTF (manifest.xml) on all devices which
has the Vendor HAL daemon running. (Unfortunately, there is no automatic
translation from the module missing in device.mk to manifest.xml
currently).
Handled by other CL's in the topic.
3. Use the HalDeviceManager to query the VINTF to figure out if the
Vendor HAL is present on the device or not.
4a. If the Vendor HAL is not supported, ignore start/stop calls.
4b. If the Vendor HAL is present, report failure if start/stop fails.
Also, fixed a few invalid mock expectations set.
Bug: 36886769
Test: Device boots up and connects to wifi on 2017 devices.
Test: Unit tests.
Change-Id: Ia3d90c8fafe2f8c156c843f5f47b94deaabe5a56
(cherry picked from commit 30f34829e0e7e49dc09c897c72dd0ded7d9805eb)
Diffstat (limited to 'service')
3 files changed, 59 insertions, 9 deletions
diff --git a/service/java/com/android/server/wifi/HalDeviceManager.java b/service/java/com/android/server/wifi/HalDeviceManager.java index c54be9b9a..b34c944a1 100644 --- a/service/java/com/android/server/wifi/HalDeviceManager.java +++ b/service/java/com/android/server/wifi/HalDeviceManager.java @@ -67,6 +67,8 @@ public class HalDeviceManager { // attempt. @VisibleForTesting public static final int START_HAL_RETRY_TIMES = 3; + @VisibleForTesting + public static final String HAL_INSTANCE_NAME = "default"; // public API public HalDeviceManager() { @@ -108,6 +110,13 @@ public class HalDeviceManager { } /** + * Returns whether the vendor HAL is supported on this device or not. + */ + public boolean isSupported() { + return isSupportedInternal(); + } + + /** * Returns the current status of the HalDeviceManager: whether or not it is ready to execute * commands. A return of 'false' indicates that the HAL service (IWifi) is not available. Use * the registerStatusListener() to listener for status changes. @@ -582,6 +591,29 @@ public class HalDeviceManager { } } + /** + * Uses the IServiceManager to query if the vendor HAL is present in the VINTF for the device + * or not. + * @return true if supported, false otherwise. + */ + private boolean isSupportedInternal() { + if (DBG) Log.d(TAG, "isSupportedInternal"); + + synchronized (mLock) { + if (mServiceManager == null) { + Log.wtf(TAG, "isSupported: called but mServiceManager is null!?"); + return false; + } + try { + return (mServiceManager.getTransport(IWifi.kInterfaceName, HAL_INSTANCE_NAME) + != IServiceManager.Transport.EMPTY); + } catch (RemoteException e) { + Log.wtf(TAG, "Exception while operating on IServiceManager: " + e); + return false; + } + } + } + private final HwRemoteBinder.DeathRecipient mIWifiDeathRecipient = cookie -> { Log.e(TAG, "IWifi HAL service died! Have a listener for it ... cookie=" + cookie); diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index eb2412311..cc0d277a4 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -102,9 +102,9 @@ public class WifiNative { * Returns null on failure. */ public IClientInterface setupForClientMode() { - if (!startHal(true)) { - // TODO(b/34859006): Handle failures. + if (!startHalIfNecessary(true)) { Log.e(mTAG, "Failed to start HAL for client mode"); + return null; } return mWificondControl.setupDriverForClientMode(); } @@ -119,9 +119,9 @@ public class WifiNative { * Returns null on failure. */ public IApInterface setupForSoftApMode() { - if (!startHal(false)) { - // TODO(b/34859006): Handle failures. + if (!startHalIfNecessary(false)) { Log.e(mTAG, "Failed to start HAL for AP mode"); + return null; } return mWificondControl.setupDriverForSoftApMode(); } @@ -140,7 +140,7 @@ public class WifiNative { Log.e(mTAG, "Failed to teardown interfaces from Wificond"); return false; } - stopHal(); + stopHalIfNecessary(); return true; } @@ -802,18 +802,27 @@ public class WifiNative { } /** - * Bring up the Vendor HAL and configure for STA mode or AP mode. + * Bring up the Vendor HAL and configure for STA mode or AP mode, if vendor HAL is supported. * * @param isStaMode true to start HAL in STA mode, false to start in AP mode. + * @return false if the HAL start fails, true if successful or if vendor HAL not supported. */ - public boolean startHal(boolean isStaMode) { + private boolean startHalIfNecessary(boolean isStaMode) { + if (!mWifiVendorHal.isVendorHalSupported()) { + Log.i(mTAG, "Vendor HAL not supported, Ignore start..."); + return true; + } return mWifiVendorHal.startVendorHal(isStaMode); } /** - * Stops the HAL + * Stops the HAL, if vendor HAL is supported. */ - public void stopHal() { + private void stopHalIfNecessary() { + if (!mWifiVendorHal.isVendorHalSupported()) { + Log.i(mTAG, "Vendor HAL not supported, Ignore stop..."); + return; + } mWifiVendorHal.stopVendorHal(); } diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java index 31c000c59..9c1ae94b5 100644 --- a/service/java/com/android/server/wifi/WifiVendorHal.java +++ b/service/java/com/android/server/wifi/WifiVendorHal.java @@ -247,6 +247,15 @@ public class WifiVendorHal { } /** + * Returns whether the vendor HAL is supported on this device or not. + */ + public boolean isVendorHalSupported() { + synchronized (sLock) { + return mHalDeviceManager.isSupported(); + } + } + + /** * Bring up the HIDL Vendor HAL and configure for AP (Access Point) mode * * @return true for success |