summaryrefslogtreecommitdiffstats
path: root/service/java/com/android
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-02-21 05:12:31 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-02-21 05:12:31 +0000
commit5c6fde5090017c39433085af430c1287d374fe25 (patch)
tree8f35b597c6157b5dd21f443171d7ee0892cd1636 /service/java/com/android
parent395708f3850bcb0526635a2b85d1eae352a184c6 (diff)
parent5540b4250c661121b57c4d6359ebbc9798443ef8 (diff)
downloadandroid_frameworks_opt_net_wifi-5c6fde5090017c39433085af430c1287d374fe25.tar.gz
android_frameworks_opt_net_wifi-5c6fde5090017c39433085af430c1287d374fe25.tar.bz2
android_frameworks_opt_net_wifi-5c6fde5090017c39433085af430c1287d374fe25.zip
Merge changes from topic "check_vendor_hal_support"
* changes: HalDevManager: Cache the result of vendor hal support in init flow Revert "Revert "WifiP2pNative: Support devices with no vendor HAL""
Diffstat (limited to 'service/java/com/android')
-rw-r--r--service/java/com/android/server/wifi/HalDeviceManager.java10
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java3
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pNative.java77
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java28
4 files changed, 89 insertions, 29 deletions
diff --git a/service/java/com/android/server/wifi/HalDeviceManager.java b/service/java/com/android/server/wifi/HalDeviceManager.java
index 5bc52d429..a5e461eaf 100644
--- a/service/java/com/android/server/wifi/HalDeviceManager.java
+++ b/service/java/com/android/server/wifi/HalDeviceManager.java
@@ -76,6 +76,9 @@ public class HalDeviceManager {
private final Clock mClock;
+ // cache the value for supporting vendor HAL or not
+ private boolean mIsVendorHalSupported = false;
+
// public API
public HalDeviceManager(Clock clock) {
mClock = clock;
@@ -134,7 +137,7 @@ public class HalDeviceManager {
* Returns whether the vendor HAL is supported on this device or not.
*/
public boolean isSupported() {
- return isSupportedInternal();
+ return mIsVendorHalSupported;
}
/**
@@ -611,7 +614,7 @@ public class HalDeviceManager {
private void initializeInternal() {
initIServiceManagerIfNecessary();
- if (isSupportedInternal()) {
+ if (mIsVendorHalSupported) {
initIWifiIfNecessary();
}
}
@@ -685,6 +688,9 @@ public class HalDeviceManager {
Log.wtf(TAG, "Exception while operating on IServiceManager: " + e);
mServiceManager = null;
}
+
+ // Cache the result for the supporting vendor hal or not
+ mIsVendorHalSupported = isSupportedInternal();
}
}
}
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index c03c46aad..9826a4cc8 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -210,7 +210,8 @@ public class WifiInjector {
mWifiP2pMonitor = new WifiP2pMonitor(this);
mSupplicantP2pIfaceHal = new SupplicantP2pIfaceHal(mWifiP2pMonitor);
mWifiP2pNative = new WifiP2pNative(
- mWifiVendorHal, mSupplicantP2pIfaceHal, mHalDeviceManager);
+ mWifiVendorHal, mSupplicantP2pIfaceHal, mHalDeviceManager,
+ mPropertyService);
// Now get instances of all the objects that depend on the HandlerThreads
mWifiTrafficPoller = new WifiTrafficPoller(clientModeImplLooper);
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pNative.java b/service/java/com/android/server/wifi/p2p/WifiP2pNative.java
index 3e0aaa145..58ebb60e8 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pNative.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pNative.java
@@ -28,6 +28,7 @@ import android.text.TextUtils;
import android.util.Log;
import com.android.server.wifi.HalDeviceManager;
+import com.android.server.wifi.PropertyService;
import com.android.server.wifi.WifiVendorHal;
/**
@@ -41,6 +42,7 @@ public class WifiP2pNative {
private boolean mVerboseLoggingEnabled = false;
private final SupplicantP2pIfaceHal mSupplicantP2pIfaceHal;
private final HalDeviceManager mHalDeviceManager;
+ private final PropertyService mPropertyService;
private final WifiVendorHal mWifiVendorHal;
private IWifiP2pIface mIWifiP2pIface;
private InterfaceAvailableListenerInternal mInterfaceAvailableListener;
@@ -104,10 +106,12 @@ public class WifiP2pNative {
}
public WifiP2pNative(WifiVendorHal wifiVendorHal,
- SupplicantP2pIfaceHal p2pIfaceHal, HalDeviceManager halDeviceManager) {
+ SupplicantP2pIfaceHal p2pIfaceHal, HalDeviceManager halDeviceManager,
+ PropertyService propertyService) {
mWifiVendorHal = wifiVendorHal;
mSupplicantP2pIfaceHal = p2pIfaceHal;
mHalDeviceManager = halDeviceManager;
+ mPropertyService = propertyService;
}
/**
@@ -153,6 +157,41 @@ public class WifiP2pNative {
}
/**
+ * Returns whether HAL (HIDL) is supported on this device or not.
+ */
+ public boolean isHalInterfaceSupported() {
+ return mHalDeviceManager.isSupported();
+ }
+
+ private static final String P2P_IFACE_NAME = "p2p0";
+ private static final String P2P_INTERFACE_PROPERTY = "wifi.direct.interface";
+ /**
+ * Helper function to handle creation of P2P iface.
+ * For devices which do not the support the HAL, this will bypass HalDeviceManager &
+ * teardown any existing iface.
+ */
+ private String createP2pIface(Handler handler) {
+ if (mHalDeviceManager.isSupported()) {
+ mIWifiP2pIface = mHalDeviceManager
+ .createP2pIface(mInterfaceDestroyedListener, handler);
+ if (mIWifiP2pIface == null) {
+ Log.e(TAG, "Failed to create P2p iface in HalDeviceManager");
+ return null;
+ }
+ String ifaceName = HalDeviceManager.getName(mIWifiP2pIface);
+ if (TextUtils.isEmpty(ifaceName)) {
+ Log.e(TAG, "Failed to get p2p iface name");
+ teardownInterface();
+ return null;
+ }
+ return ifaceName;
+ } else {
+ Log.i(TAG, "Vendor Hal is not supported, ignoring createP2pIface.");
+ return mPropertyService.getString(P2P_INTERFACE_PROPERTY, P2P_IFACE_NAME);
+ }
+ }
+
+ /**
* Register for an interface available callbacks from HalDeviceManager.
*
* @param listener callback to be invoked when the interface is available/not available.
@@ -187,10 +226,11 @@ public class WifiP2pNative {
Handler handler) {
Log.d(TAG, "Setup P2P interface");
if (mIWifiP2pIface == null) {
- mInterfaceDestroyedListener = new InterfaceDestroyedListenerInternal(destroyedListener);
- mIWifiP2pIface = mHalDeviceManager.createP2pIface(mInterfaceDestroyedListener, handler);
- if (mIWifiP2pIface == null) {
- Log.e(TAG, "Failed to create P2p iface in HalDeviceManager");
+ mInterfaceDestroyedListener =
+ new InterfaceDestroyedListenerInternal(destroyedListener);
+ String ifaceName = createP2pIface(handler);
+ if (ifaceName == null) {
+ Log.e(TAG, "Failed to create P2p iface");
return null;
}
if (!waitForSupplicantConnection()) {
@@ -198,20 +238,19 @@ public class WifiP2pNative {
teardownInterface();
return null;
}
- String ifaceName = HalDeviceManager.getName(mIWifiP2pIface);
- if (TextUtils.isEmpty(ifaceName)) {
- Log.e(TAG, "Failed to get p2p iface name");
- teardownInterface();
- return null;
- }
if (!mSupplicantP2pIfaceHal.setupIface(ifaceName)) {
Log.e(TAG, "Failed to setup P2p iface in supplicant");
teardownInterface();
return null;
}
Log.i(TAG, "P2P interface setup completed");
+ return ifaceName;
+ } else {
+ Log.i(TAG, "P2P interface is already existed");
+ return mHalDeviceManager.isSupported()
+ ? HalDeviceManager.getName(mIWifiP2pIface)
+ : mPropertyService.getString(P2P_INTERFACE_PROPERTY, P2P_IFACE_NAME);
}
- return HalDeviceManager.getName(mIWifiP2pIface);
}
/**
@@ -219,11 +258,17 @@ public class WifiP2pNative {
*/
public void teardownInterface() {
Log.d(TAG, "Teardown P2P interface");
- if (mIWifiP2pIface != null) {
- String ifaceName = HalDeviceManager.getName(mIWifiP2pIface);
- mHalDeviceManager.removeIface(mIWifiP2pIface);
+ if (mHalDeviceManager.isSupported()) {
+ if (mIWifiP2pIface != null) {
+ String ifaceName = HalDeviceManager.getName(mIWifiP2pIface);
+ mHalDeviceManager.removeIface(mIWifiP2pIface);
+ mInterfaceDestroyedListener.teardownAndInvalidate(ifaceName);
+ Log.i(TAG, "P2P interface teardown completed");
+ }
+ } else {
+ Log.i(TAG, "HAL (HIDL) is not supported. Destroy listener for the interface.");
+ String ifaceName = mPropertyService.getString(P2P_INTERFACE_PROPERTY, P2P_IFACE_NAME);
mInterfaceDestroyedListener.teardownAndInvalidate(ifaceName);
- Log.i(TAG, "P2P interface teardown completed");
}
}
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
index 3e3da2326..430c5fd20 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
@@ -765,8 +765,8 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
});
private final WifiP2pInfo mWifiP2pInfo = new WifiP2pInfo();
private WifiP2pGroup mGroup;
- // Is the P2P interface available for use.
- private boolean mIsInterfaceAvailable = false;
+ // Is the HAL (HIDL) interface available for use.
+ private boolean mIsHalInterfaceAvailable = false;
// Is wifi on or off.
private boolean mIsWifiEnabled = false;
@@ -836,7 +836,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
}, new IntentFilter(LocationManager.MODE_CHANGED_ACTION));
// Register for interface availability from HalDeviceManager
mWifiNative.registerInterfaceAvailableListener((boolean isAvailable) -> {
- mIsInterfaceAvailable = isAvailable;
+ mIsHalInterfaceAvailable = isAvailable;
if (isAvailable) {
checkAndReEnableP2p();
}
@@ -1058,7 +1058,8 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
break;
case WifiP2pManager.REQUEST_P2P_STATE:
replyToMessage(message, WifiP2pManager.RESPONSE_P2P_STATE,
- (mIsWifiEnabled && mIsInterfaceAvailable && isLocationModeEnabled())
+ (mIsWifiEnabled && isHalInterfaceAvailable()
+ && isLocationModeEnabled())
? WifiP2pManager.WIFI_P2P_STATE_ENABLED
: WifiP2pManager.WIFI_P2P_STATE_DISABLED);
break;
@@ -2916,15 +2917,16 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
// Check & re-enable P2P if needed.
// P2P interface will be created if all of the below are true:
// a) Wifi is enabled.
- // b) P2P interface is available.
+ // b) HAL (HIDL) interface is available.
// c) There is atleast 1 client app which invoked initialize().
// d) Location is enabled.
private void checkAndReEnableP2p() {
boolean isLocationEnabled = isLocationModeEnabled();
+ boolean isHalInterfaceAvailable = isHalInterfaceAvailable();
Log.d(TAG, "Wifi enabled=" + mIsWifiEnabled + ", P2P Interface availability="
- + mIsInterfaceAvailable + ", Number of clients=" + mDeathDataByBinder.size()
- + ", Location enabled=" + isLocationEnabled);
- if (mIsWifiEnabled && mIsInterfaceAvailable
+ + isHalInterfaceAvailable + ", Number of clients="
+ + mDeathDataByBinder.size() + ", Location enabled=" + isLocationEnabled);
+ if (mIsWifiEnabled && isHalInterfaceAvailable
&& isLocationEnabled && !mDeathDataByBinder.isEmpty()) {
sendMessage(ENABLE_P2P);
}
@@ -2934,11 +2936,17 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
return mWifiPermissionsUtil.isLocationModeEnabled();
}
+ // Ignore judgement if the device do not support HAL (HIDL) interface
+ private boolean isHalInterfaceAvailable() {
+ return mWifiNative.isHalInterfaceSupported() ? mIsHalInterfaceAvailable : true;
+ }
+
private void checkAndSendP2pStateChangedBroadcast() {
boolean isLocationEnabled = isLocationModeEnabled();
+ boolean isHalInterfaceAvailable = isHalInterfaceAvailable();
Log.d(TAG, "Wifi enabled=" + mIsWifiEnabled + ", P2P Interface availability="
- + mIsInterfaceAvailable + ", Location enabled=" + isLocationEnabled);
- sendP2pStateChangedBroadcast(mIsWifiEnabled && mIsInterfaceAvailable
+ + isHalInterfaceAvailable + ", Location enabled=" + isLocationEnabled);
+ sendP2pStateChangedBroadcast(mIsWifiEnabled && isHalInterfaceAvailable
&& isLocationEnabled);
}