diff options
author | Jimmy Chen <jimmycmchen@google.com> | 2019-08-23 10:53:39 +0800 |
---|---|---|
committer | Jimmy Chen <jimmycmchen@google.com> | 2019-10-23 09:42:20 +0800 |
commit | 0168a4be789b816415f1f3e8e7acacfd62c09153 (patch) | |
tree | 44856258182753582dee58c00eedf10745e2d4eb /service | |
parent | f6185e0b31a8258a762b31dd9839a4d731db8946 (diff) |
p2p: mirgrate p2p into tethering modes
If there is a valid p2p interface pattern defined,
using Android tethering modes instead of doing
tethering in p2p service.
Bug: 137602441
Bug: 139783330
Test: atest FrameworksNetTests
Test: atest FrameworksWifiTests
Test: CtsVerifier - Wi-Fi Direct
Test: Enable hotspot when P2P GO is running
* P2P GO is terminated
* hotspot is running
Test: Enable P2P GO when hotspot is running
* hotspot is intact
* P2P GO could not be launched
Change-Id: I9b880f18ecfa7cb951c26d17e0edee139c992023
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java index ec480af81..dbfd051d4 100644 --- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java +++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java @@ -462,6 +462,25 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { } /** + * If wifi p2p interface name pattern is defined, + * {@link com.android.server.connectivity.Tethering} listens to + * {@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_CONNECTION_CHANGED_ACTION} + * events and takes over the DHCP server management automatically. + */ + private boolean isDhcpServerHostedByDnsmasq() { + try { + String[] tetherableWifiP2pRegexs = mContext.getResources().getStringArray( + com.android.internal.R.array.config_tether_wifi_p2p_regexs); + return (tetherableWifiP2pRegexs == null || tetherableWifiP2pRegexs.length == 0); + } catch (Resources.NotFoundException e404) { + if (mVerboseLoggingEnabled) { + Log.d(TAG, "No P2P tetherable interface pattern"); + } + } + return true; + } + + /** * Obtains the service interface for Managements services */ public void connectivityServiceReady() { @@ -3016,6 +3035,8 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { } private void startDhcpServer(String intf) { + if (!isDhcpServerHostedByDnsmasq()) return; + InterfaceConfiguration ifcg = null; try { ifcg = mNwService.getInterfaceConfig(intf); @@ -3042,6 +3063,8 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub { } private void stopDhcpServer(String intf) { + if (!isDhcpServerHostedByDnsmasq()) return; + try { mNwService.untetherInterface(intf); for (String temp : mNwService.listTetheredInterfaces()) { |