summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-03-17 13:33:01 -0700
committerRoshan Pius <rpius@google.com>2017-03-21 11:25:53 -0700
commit163f9765f9e4c3f868b1e0d630b6adeaa115fb4a (patch)
treef4fd01f950876c954780d25a8ad0745cbc7262ae /service
parent2a1078dc3729bab248bbd28c8336749481e045cf (diff)
Split up WifiNative/WifiMonitor into STA-AP/P2P
With HIDL, there isn't any dependencies between the STA & P2P WifiNative's. So, split up WifiNative/WifiMonitor into 2, one for P2P & non-P2P cases. The WifiP2pNative, WifiP2pMonitor & SupplicantP2pIfaceHal classes are now moved to p2p package. Also, added couple of missing methods in SupplicantP2pIfaceHal from SupplicantStaIfaceHal. Bug: 36371256 Test: Compiles, device boots up and connect to wifi networks. Change-Id: I85ea84355ab2a1803053f663f207b42b793c552c
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiConfigStoreLegacy.java1
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java25
-rw-r--r--service/java/com/android/server/wifi/WifiMonitor.java272
-rw-r--r--service/java/com/android/server/wifi/WifiNative.java531
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java2
-rw-r--r--service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java (renamed from service/java/com/android/server/wifi/SupplicantP2pIfaceCallback.java)26
-rw-r--r--service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java (renamed from service/java/com/android/server/wifi/SupplicantP2pIfaceHal.java)90
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pMonitor.java509
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pNative.java600
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java200
10 files changed, 1326 insertions, 930 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java b/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java
index 42a91de67..867775511 100644
--- a/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java
+++ b/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java
@@ -303,7 +303,6 @@ public class WifiConfigStoreLegacy {
Log.e(TAG, "Removing networks from wpa_supplicant failed");
return false;
}
- mWifiNative.saveConfig();
// Now remove the ipconfig.txt file.
if (!IP_CONFIG_FILE.delete()) {
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index 54f157616..6fee22c1a 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -45,6 +45,9 @@ import com.android.server.wifi.hotspot2.LegacyPasspointConfigParser;
import com.android.server.wifi.hotspot2.PasspointManager;
import com.android.server.wifi.hotspot2.PasspointNetworkEvaluator;
import com.android.server.wifi.hotspot2.PasspointObjectFactory;
+import com.android.server.wifi.p2p.SupplicantP2pIfaceHal;
+import com.android.server.wifi.p2p.WifiP2pMonitor;
+import com.android.server.wifi.p2p.WifiP2pNative;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
@@ -71,8 +74,9 @@ public class WifiInjector {
private final BackupManagerProxy mBackupManagerProxy = new BackupManagerProxy();
private final WifiApConfigStore mWifiApConfigStore;
private final WifiNative mWifiNative;
- private final WifiNative mWifiP2pNative;
private final WifiMonitor mWifiMonitor;
+ private final WifiP2pNative mWifiP2pNative;
+ private final WifiP2pMonitor mWifiP2pMonitor;
private final SupplicantStaIfaceHal mSupplicantStaIfaceHal;
private final SupplicantP2pIfaceHal mSupplicantP2pIfaceHal;
private final WifiVendorHal mWifiVendorHal;
@@ -151,11 +155,12 @@ public class WifiInjector {
mWifiVendorHal = new WifiVendorHal(mHalDeviceManager, mWifiStateMachineHandlerThread);
mSupplicantStaIfaceHal = new SupplicantStaIfaceHal(mContext, mWifiMonitor);
mWificondControl = new WificondControl(this, mWifiMonitor);
- mSupplicantP2pIfaceHal = new SupplicantP2pIfaceHal(mWifiMonitor);
mWifiNative = new WifiNative(SystemProperties.get("wifi.interface", "wlan0"),
- mWifiVendorHal, mSupplicantStaIfaceHal, mSupplicantP2pIfaceHal, mWificondControl);
- mWifiP2pNative = new WifiNative(SystemProperties.get("wifi.direct.interface", "p2p0"),
- mWifiVendorHal, mSupplicantStaIfaceHal, mSupplicantP2pIfaceHal, mWificondControl);
+ mWifiVendorHal, mSupplicantStaIfaceHal, mWificondControl);
+ mWifiP2pMonitor = new WifiP2pMonitor(this);
+ mSupplicantP2pIfaceHal = new SupplicantP2pIfaceHal(mWifiP2pMonitor);
+ mWifiP2pNative = new WifiP2pNative(SystemProperties.get("wifi.direct.interface", "p2p0"),
+ mSupplicantP2pIfaceHal);
// Now get instances of all the objects that depend on the HandlerThreads
mTrafficPoller = new WifiTrafficPoller(mContext, mWifiServiceHandlerThread.getLooper(),
@@ -444,11 +449,15 @@ public class WifiInjector {
return mWifiNative;
}
- public WifiNative getP2pWifiNative() {
+ public WifiMonitor getWifiMonitor() {
+ return mWifiMonitor;
+ }
+
+ public WifiP2pNative getWifiP2pNative() {
return mWifiP2pNative;
}
- public WifiMonitor getWifiMonitor() {
- return mWifiMonitor;
+ public WifiP2pMonitor getWifiP2pMonitor() {
+ return mWifiP2pMonitor;
}
}
diff --git a/service/java/com/android/server/wifi/WifiMonitor.java b/service/java/com/android/server/wifi/WifiMonitor.java
index e29f67261..317d3991c 100644
--- a/service/java/com/android/server/wifi/WifiMonitor.java
+++ b/service/java/com/android/server/wifi/WifiMonitor.java
@@ -20,11 +20,6 @@ import android.net.wifi.SupplicantState;
import android.net.wifi.WifiEnterpriseConfig;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiSsid;
-import android.net.wifi.p2p.WifiP2pConfig;
-import android.net.wifi.p2p.WifiP2pDevice;
-import android.net.wifi.p2p.WifiP2pGroup;
-import android.net.wifi.p2p.WifiP2pProvDiscEvent;
-import android.net.wifi.p2p.nsd.WifiP2pServiceResponse;
import android.os.Handler;
import android.os.Message;
import android.util.ArraySet;
@@ -37,17 +32,15 @@ import com.android.internal.util.StateMachine;
import com.android.server.wifi.hotspot2.AnqpEvent;
import com.android.server.wifi.hotspot2.IconEvent;
import com.android.server.wifi.hotspot2.WnmData;
-import com.android.server.wifi.p2p.WifiP2pServiceImpl.P2pStatus;
import com.android.server.wifi.util.TelephonyUtil.SimAuthRequestData;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Listens for events from the wpa_supplicant server, and passes them on
- * to the {@link StateMachine} for handling. Runs in its own thread.
+ * to the {@link StateMachine} for handling.
*
* @hide
*/
@@ -95,30 +88,6 @@ public class WifiMonitor {
public static final int SCAN_FAILED_EVENT = BASE + 17;
- /* P2P events */
- public static final int P2P_DEVICE_FOUND_EVENT = BASE + 21;
- public static final int P2P_DEVICE_LOST_EVENT = BASE + 22;
- public static final int P2P_GO_NEGOTIATION_REQUEST_EVENT = BASE + 23;
- public static final int P2P_GO_NEGOTIATION_SUCCESS_EVENT = BASE + 25;
- public static final int P2P_GO_NEGOTIATION_FAILURE_EVENT = BASE + 26;
- public static final int P2P_GROUP_FORMATION_SUCCESS_EVENT = BASE + 27;
- public static final int P2P_GROUP_FORMATION_FAILURE_EVENT = BASE + 28;
- public static final int P2P_GROUP_STARTED_EVENT = BASE + 29;
- public static final int P2P_GROUP_REMOVED_EVENT = BASE + 30;
- public static final int P2P_INVITATION_RECEIVED_EVENT = BASE + 31;
- public static final int P2P_INVITATION_RESULT_EVENT = BASE + 32;
- public static final int P2P_PROV_DISC_PBC_REQ_EVENT = BASE + 33;
- public static final int P2P_PROV_DISC_PBC_RSP_EVENT = BASE + 34;
- public static final int P2P_PROV_DISC_ENTER_PIN_EVENT = BASE + 35;
- public static final int P2P_PROV_DISC_SHOW_PIN_EVENT = BASE + 36;
- public static final int P2P_FIND_STOPPED_EVENT = BASE + 37;
- public static final int P2P_SERV_DISC_RESP_EVENT = BASE + 38;
- public static final int P2P_PROV_DISC_FAILURE_EVENT = BASE + 39;
-
- /* hostap events */
- public static final int AP_STA_DISCONNECTED_EVENT = BASE + 41;
- public static final int AP_STA_CONNECTED_EVENT = BASE + 42;
-
/* Indicates assoc reject event */
public static final int ASSOCIATION_REJECTION_EVENT = BASE + 43;
public static final int ANQP_DONE_EVENT = BASE + 44;
@@ -185,8 +154,7 @@ public class WifiMonitor {
Boolean val = mMonitoringMap.get(iface);
if (val == null) {
return false;
- }
- else {
+ } else {
return val.booleanValue();
}
}
@@ -211,21 +179,16 @@ public class WifiMonitor {
/**
* Wait for wpa_supplicant's control interface to be ready.
*
- * @param isStaIface Whether STA or P2P iface.
* TODO: Add unit tests for these once we remove the legacy code.
*/
- private boolean ensureConnectedLocked(boolean isStaIface) {
+ private boolean ensureConnectedLocked() {
if (mConnected) {
return true;
}
if (mVerboseLoggingEnabled) Log.d(TAG, "connecting to supplicant");
int connectTries = 0;
while (true) {
- if (isStaIface) {
- mConnected = mWifiInjector.getWifiNative().connectToStaSupplicant();
- } else {
- mConnected = mWifiInjector.getP2pWifiNative().connectToP2pSupplicant();
- }
+ mConnected = mWifiInjector.getWifiNative().connectToSupplicant();
if (mConnected) {
return true;
}
@@ -244,17 +207,13 @@ public class WifiMonitor {
* Start Monitoring for wpa_supplicant events.
*
* @param iface Name of iface.
- * @param isStaIface Whether STA or P2P iface.
* TODO: Add unit tests for these once we remove the legacy code.
*/
public synchronized void startMonitoring(String iface, boolean isStaIface) {
- Log.d(TAG, "startMonitoring(" + iface + ") with mConnected = " + mConnected);
-
- if (ensureConnectedLocked(isStaIface)) {
+ if (ensureConnectedLocked()) {
setMonitoring(iface, true);
broadcastSupplicantConnectionEvent(iface);
- }
- else {
+ } else {
boolean originalMonitoring = isMonitoring(iface);
setMonitoring(iface, true);
broadcastSupplicantDisconnectionEvent(iface);
@@ -263,6 +222,12 @@ public class WifiMonitor {
}
}
+ /**
+ * Stop Monitoring for wpa_supplicant events.
+ *
+ * @param iface Name of iface.
+ * TODO: Add unit tests for these once we remove the legacy code.
+ */
public synchronized void stopMonitoring(String iface) {
if (mVerboseLoggingEnabled) Log.d(TAG, "stopMonitoring(" + iface + ")");
setMonitoring(iface, true);
@@ -270,6 +235,11 @@ public class WifiMonitor {
setMonitoring(iface, false);
}
+ /**
+ * Stop Monitoring for wpa_supplicant events.
+ *
+ * TODO: Add unit tests for these once we remove the legacy code.
+ */
public synchronized void stopAllMonitoring() {
mConnected = false;
setMonitoringNone();
@@ -312,8 +282,7 @@ public class WifiMonitor {
if (firstHandler) {
firstHandler = false;
sendMessage(handler, message);
- }
- else {
+ } else {
sendMessage(handler, Message.obtain(message));
}
}
@@ -335,8 +304,7 @@ public class WifiMonitor {
if (firstHandler) {
firstHandler = false;
sendMessage(handler, message);
- }
- else {
+ } else {
sendMessage(handler, Message.obtain(message));
}
}
@@ -595,206 +563,4 @@ public class WifiMonitor {
public void broadcastSupplicantDisconnectionEvent(String iface) {
sendMessage(iface, SUP_DISCONNECTION_EVENT);
}
-
- /**
- * Broadcast new p2p device discovered event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- * @param device Device that has been discovered during recent scan.
- */
- public void broadcastP2pDeviceFound(String iface, WifiP2pDevice device) {
- if (device != null) {
- sendMessage(iface, P2P_DEVICE_FOUND_EVENT, device);
- }
- }
-
- /**
- * Broadcast p2p device lost event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- * @param device Device that has been lost in recent scan.
- */
- public void broadcastP2pDeviceLost(String iface, WifiP2pDevice device) {
- if (device != null) {
- sendMessage(iface, P2P_DEVICE_LOST_EVENT, device);
- }
- }
-
- /**
- * Broadcast scan termination event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- */
- public void broadcastP2pFindStopped(String iface) {
- sendMessage(iface, P2P_FIND_STOPPED_EVENT);
- }
-
- /**
- * Broadcast group owner negotiation request event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- * @param config P2p configuration.
- */
- public void broadcastP2pGoNegotiationRequest(String iface, WifiP2pConfig config) {
- if (config != null) {
- sendMessage(iface, P2P_GO_NEGOTIATION_REQUEST_EVENT, config);
- }
- }
-
- /**
- * Broadcast group owner negotiation success event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- */
- public void broadcastP2pGoNegotiationSuccess(String iface) {
- sendMessage(iface, P2P_GO_NEGOTIATION_SUCCESS_EVENT);
- }
-
- /**
- * Broadcast group owner negotiation failure event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- * @param reason Failure reason.
- */
- public void broadcastP2pGoNegotiationFailure(String iface, P2pStatus reason) {
- sendMessage(iface, P2P_GO_NEGOTIATION_FAILURE_EVENT, reason);
- }
-
- /**
- * Broadcast group formation success event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- */
- public void broadcastP2pGroupFormationSuccess(String iface) {
- sendMessage(iface, P2P_GROUP_FORMATION_SUCCESS_EVENT);
- }
-
- /**
- * Broadcast group formation failure event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- * @param reason Failure reason.
- */
- public void broadcastP2pGroupFormationFailure(String iface, String reason) {
- P2pStatus err = P2pStatus.UNKNOWN;
- if (reason.equals("FREQ_CONFLICT")) {
- err = P2pStatus.NO_COMMON_CHANNEL;
- }
- sendMessage(iface, P2P_GROUP_FORMATION_FAILURE_EVENT, err);
- }
-
- /**
- * Broadcast group started event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- * @param group Started group.
- */
- public void broadcastP2pGroupStarted(String iface, WifiP2pGroup group) {
- if (group != null) {
- sendMessage(iface, P2P_GROUP_STARTED_EVENT, group);
- }
- }
-
- /**
- * Broadcast group removed event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- * @param group Removed group.
- */
- public void broadcastP2pGroupRemoved(String iface, WifiP2pGroup group) {
- if (group != null) {
- sendMessage(iface, P2P_GROUP_REMOVED_EVENT, group);
- }
- }
-
- /**
- * Broadcast invitation received event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- * @param group Group to which invitation has been received.
- */
- public void broadcastP2pInvitationReceived(String iface, WifiP2pGroup group) {
- if (group != null) {
- sendMessage(iface, P2P_INVITATION_RECEIVED_EVENT, group);
- }
- }
-
- /**
- * Broadcast invitation result event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- * @param result Result of invitation.
- */
- public void broadcastP2pInvitationResult(String iface, P2pStatus result) {
- sendMessage(iface, P2P_INVITATION_RESULT_EVENT, result);
- }
-
- /**
- * Broadcast PB discovery request event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- * @param event Provision discovery request event.
- */
- public void broadcastP2pProvisionDiscoveryPbcRequest(String iface, WifiP2pProvDiscEvent event) {
- if (event != null) {
- sendMessage(iface, P2P_PROV_DISC_PBC_REQ_EVENT, event);
- }
- }
-
- /**
- * Broadcast PB discovery response event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- * @param event Provision discovery response event.
- */
- public void broadcastP2pProvisionDiscoveryPbcResponse(
- String iface, WifiP2pProvDiscEvent event) {
- if (event != null) {
- sendMessage(iface, P2P_PROV_DISC_PBC_RSP_EVENT, event);
- }
- }
-
- /**
- * Broadcast PIN discovery request event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- * @param event Provision discovery request event.
- */
- public void broadcastP2pProvisionDiscoveryEnterPin(String iface, WifiP2pProvDiscEvent event) {
- if (event != null) {
- sendMessage(iface, P2P_PROV_DISC_ENTER_PIN_EVENT, event);
- }
- }
-
- /**
- * Broadcast PIN discovery response event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- * @param event Provision discovery response event.
- */
- public void broadcastP2pProvisionDiscoveryShowPin(String iface, WifiP2pProvDiscEvent event) {
- if (event != null) {
- sendMessage(iface, P2P_PROV_DISC_SHOW_PIN_EVENT, event);
- }
- }
-
- /**
- * Broadcast P2P discovery failure event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- */
- public void broadcastP2pProvisionDiscoveryFailure(String iface) {
- sendMessage(iface, P2P_PROV_DISC_FAILURE_EVENT);
- }
-
- /**
- * Broadcast service discovery response event to all handlers registered for this event.
- *
- * @param iface Name of iface on which this occurred.
- * @param services List of discovered services.
- */
- public void broadcastP2pServiceDiscoveryResponse(
- String iface, List<WifiP2pServiceResponse> services) {
- sendMessage(iface, P2P_SERV_DISC_RESP_EVENT, services);
- }
}
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index fb8c0e612..68da5fbc4 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -27,10 +27,6 @@ import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiLinkLayerStats;
import android.net.wifi.WifiScanner;
import android.net.wifi.WifiWakeReasonAndCounts;
-import android.net.wifi.p2p.WifiP2pConfig;
-import android.net.wifi.p2p.WifiP2pGroup;
-import android.net.wifi.p2p.WifiP2pGroupList;
-import android.net.wifi.p2p.nsd.WifiP2pServiceInfo;
import android.os.SystemClock;
import android.util.Log;
import android.util.SparseArray;
@@ -66,18 +62,15 @@ public class WifiNative {
private final String mTAG;
private final String mInterfaceName;
private final SupplicantStaIfaceHal mSupplicantStaIfaceHal;
- private final SupplicantP2pIfaceHal mSupplicantP2pIfaceHal;
private final WifiVendorHal mWifiVendorHal;
private final WificondControl mWificondControl;
public WifiNative(String interfaceName, WifiVendorHal vendorHal,
- SupplicantStaIfaceHal staIfaceHal, SupplicantP2pIfaceHal p2pIfaceHal,
- WificondControl condControl) {
+ SupplicantStaIfaceHal staIfaceHal, WificondControl condControl) {
mTAG = "WifiNative-" + interfaceName;
mInterfaceName = interfaceName;
mWifiVendorHal = vendorHal;
mSupplicantStaIfaceHal = staIfaceHal;
- mSupplicantP2pIfaceHal = p2pIfaceHal;
mWificondControl = condControl;
}
@@ -256,7 +249,7 @@ public class WifiNative {
* @return true if connection is established, false otherwise.
* TODO: Add unit tests for these once we remove the legacy code.
*/
- public boolean connectToStaSupplicant() {
+ public boolean connectToSupplicant() {
// Start initialization if not already started.
if (!mSupplicantStaIfaceHal.isInitializationStarted()
&& !mSupplicantStaIfaceHal.initialize()) {
@@ -267,22 +260,6 @@ public class WifiNative {
}
/**
- * This method is called repeatedly until the connection to wpa_supplicant is established.
- *
- * @return true if connection is established, false otherwise.
- * TODO: Add unit tests for these once we remove the legacy code.
- */
- public boolean connectToP2pSupplicant() {
- // Start initialization if not already started.
- if (!mSupplicantP2pIfaceHal.isInitializationStarted()
- && !mSupplicantP2pIfaceHal.initialize()) {
- return false;
- }
- // Check if the initialization is complete.
- return mSupplicantP2pIfaceHal.isInitializationComplete();
- }
-
- /**
* Close supplicant connection.
*/
public void closeSupplicantConnection() {
@@ -801,510 +778,6 @@ public class WifiNative {
public String getNfcWpsConfigurationToken(int netId) {
return mSupplicantStaIfaceHal.getCurrentNetworkWpsNfcConfigurationToken();
}
-
- /**
- * Populate list of available networks or update existing list.
- *
- * @return true, if list has been modified.
- */
- public boolean p2pListNetworks(WifiP2pGroupList groups) {
- return mSupplicantP2pIfaceHal.loadGroups(groups);
- }
-
- /**
- * Initiate WPS Push Button setup.
- * The PBC operation requires that a button is also pressed at the
- * AP/Registrar at about the same time (2 minute window).
- *
- * @param iface Group interface name to use.
- * @param bssid BSSID of the AP. Use zero'ed bssid to indicate wildcard.
- * @return true, if operation was successful.
- */
- public boolean startWpsPbc(String iface, String bssid) {
- return mSupplicantP2pIfaceHal.startWpsPbc(iface, bssid);
- }
-
- /**
- * Initiate WPS Pin Keypad setup.
- *
- * @param iface Group interface name to use.
- * @param pin 8 digit pin to be used.
- * @return true, if operation was successful.
- */
- public boolean startWpsPinKeypad(String iface, String pin) {
- return mSupplicantP2pIfaceHal.startWpsPinKeypad(iface, pin);
- }
-
- /**
- * Initiate WPS Pin Display setup.
- *
- * @param iface Group interface name to use.
- * @param bssid BSSID of the AP. Use zero'ed bssid to indicate wildcard.
- * @return generated pin if operation was successful, null otherwise.
- */
- public String startWpsPinDisplay(String iface, String bssid) {
- return mSupplicantP2pIfaceHal.startWpsPinDisplay(iface, bssid);
- }
-
- /**
- * Remove network with provided id.
- *
- * @param netId Id of the network to lookup.
- * @return true, if operation was successful.
- */
- public boolean removeP2pNetwork(int netId) {
- return mSupplicantP2pIfaceHal.removeNetwork(netId);
- }
-
- /**
- * Set WPS device name.
- *
- * @param name String to be set.
- * @return true if request is sent successfully, false otherwise.
- */
- public boolean setP2pDeviceName(String name) {
- return mSupplicantP2pIfaceHal.setWpsDeviceName(name);
- }
-
- /**
- * Set WPS device type.
- *
- * @param type Type specified as a string. Used format: <categ>-<OUI>-<subcateg>
- * @return true if request is sent successfully, false otherwise.
- */
- public boolean setP2pDeviceType(String type) {
- return mSupplicantP2pIfaceHal.setWpsDeviceType(type);
- }
-
- /**
- * Set the postfix to be used for P2P SSID's.
- *
- * @param postfix String to be appended to SSID.
- *
- * @return boolean value indicating whether operation was successful.
- */
- public boolean setP2pSsidPostfix(String postfix) {
- return mSupplicantP2pIfaceHal.setSsidPostfix(postfix);
- }
-
- /**
- * Set the Maximum idle time in seconds for P2P groups.
- * This value controls how long a P2P group is maintained after there
- * is no other members in the group. As a group owner, this means no
- * associated stations in the group. As a P2P client, this means no
- * group owner seen in scan results.
- *
- * @param iface Group interface name to use.
- * @param time Timeout value in seconds.
- *
- * @return boolean value indicating whether operation was successful.
- */
- public boolean setP2pGroupIdle(String iface, int time) {
- return mSupplicantP2pIfaceHal.setGroupIdle(iface, time);
- }
-
- /**
- * Turn on/off power save mode for the interface.
- *
- * @param iface Group interface name to use.
- * @param enabled Indicate if power save is to be turned on/off.
- *
- * @return boolean value indicating whether operation was successful.
- */
- public boolean setP2pPowerSave(String iface, boolean enabled) {
- return mSupplicantP2pIfaceHal.setPowerSave(iface, enabled);
- }
-
- /**
- * Enable/Disable Wifi Display.
- *
- * @param enable true to enable, false to disable.
- * @return true, if operation was successful.
- */
- public boolean setWfdEnable(boolean enable) {
- return mSupplicantP2pIfaceHal.enableWfd(enable);
- }
-
- /**
- * Set Wifi Display device info.
- *
- * @param hex WFD device info as described in section 5.1.2 of WFD technical
- * specification v1.0.0.
- * @return true, if operation was successful.
- */
- public boolean setWfdDeviceInfo(String hex) {
- return mSupplicantP2pIfaceHal.setWfdDeviceInfo(hex);
- }
-
- /**
- * Initiate a P2P service discovery indefinitely.
- *
- * @return boolean value indicating whether operation was successful.
- */
- public boolean p2pFind() {
- return p2pFind(0);
- }
-
- /**
- * Initiate a P2P service discovery with a (optional) timeout.
- *
- * @param timeout Max time to be spent is peforming discovery.
- * Set to 0 to indefinely continue discovery untill and explicit
- * |stopFind| is sent.
- * @return boolean value indicating whether operation was successful.
- */
- public boolean p2pFind(int timeout) {
- return mSupplicantP2pIfaceHal.find(timeout);
- }
-
- /**
- * Stop an ongoing P2P service discovery.
- *
- * @return boolean value indicating whether operation was successful.
- */
- public boolean p2pStopFind() {
- return mSupplicantP2pIfaceHal.stopFind();
- }
-
- /**
- * Configure Extended Listen Timing.
- *
- * If enabled, listen state must be entered every |intervalInMillis| for at
- * least |periodInMillis|. Both values have acceptable range of 1-65535
- * (with interval obviously having to be larger than or equal to duration).
- * If the P2P module is not idle at the time the Extended Listen Timing
- * timeout occurs, the Listen State operation must be skipped.
- *
- * @param enable Enables or disables listening.
- * @param period Period in milliseconds.
- * @param interval Interval in milliseconds.
- *
- * @return true, if operation was successful.
- */
- public boolean p2pExtListen(boolean enable, int period, int interval) {
- return mSupplicantP2pIfaceHal.configureExtListen(enable, period, interval);
- }
-
- /**
- * Set P2P Listen channel.
- *
- * When specifying a social channel on the 2.4 GHz band (1/6/11) there is no
- * need to specify the operating class since it defaults to 81. When
- * specifying a social channel on the 60 GHz band (2), specify the 60 GHz
- * operating class (180).
- *
- * @param lc Wifi channel. eg, 1, 6, 11.
- * @param oc Operating Class indicates the channel set of the AP
- * indicated by this BSSID
- *
- * @return true, if operation was successful.
- */
- public boolean p2pSetChannel(int lc, int oc) {
- return mSupplicantP2pIfaceHal.setListenChannel(lc, oc);
- }
-
- /**
- * Flush P2P peer table and state.
- *
- * @return boolean value indicating whether operation was successful.
- */
- public boolean p2pFlush() {
- return mSupplicantP2pIfaceHal.flush();
- }
-
- /**
- * Start P2P group formation with a discovered P2P peer. This includes
- * optional group owner negotiation, group interface setup, provisioning,
- * and establishing data connection.
- *
- * @param config Configuration to use to connect to remote device.
- * @param joinExistingGroup Indicates that this is a command to join an
- * existing group as a client. It skips the group owner negotiation
- * part. This must send a Provision Discovery Request message to the
- * target group owner before associating for WPS provisioning.
- *
- * @return String containing generated pin, if selected provision method
- * uses PIN.
- */
- public String p2pConnect(WifiP2pConfig config, boolean joinExistingGroup) {
- return mSupplicantP2pIfaceHal.connect(config, joinExistingGroup);
- }
-
- /**
- * Cancel an ongoing P2P group formation and joining-a-group related
- * operation. This operation unauthorizes the specific peer device (if any
- * had been authorized to start group formation), stops P2P find (if in
- * progress), stops pending operations for join-a-group, and removes the
- * P2P group interface (if one was used) that is in the WPS provisioning
- * step. If the WPS provisioning step has been completed, the group is not
- * terminated.
- *
- * @return boolean value indicating whether operation was successful.
- */
- public boolean p2pCancelConnect() {
- return mSupplicantP2pIfaceHal.cancelConnect();
- }
-
- /**
- * Send P2P provision discovery request to the specified peer. The
- * parameters for this command are the P2P device address of the peer and the
- * desired configuration method.
- *
- * @param config Config class describing peer setup.
- *
- * @return boolean value indicating whether operation was successful.
- */
- public boolean p2pProvisionDiscovery(WifiP2pConfig config) {
- return mSupplicantP2pIfaceHal.provisionDiscovery(config);
- }
-
- /**
- * Set up a P2P group owner manually.
- * This is a helper method that invokes groupAdd(networkId, isPersistent) internally.
- *
- * @param persistent Used to request a persistent group to be formed.
- *
- * @return true, if operation was successful.
- */
- public boolean p2pGroupAdd(boolean persistent) {
- return mSupplicantP2pIfaceHal.groupAdd(persistent);
- }
-
- /**
- * Set up a P2P group owner manually (i.e., without group owner
- * negotiation with a specific peer). This is also known as autonomous
- * group owner.
- *
- * @param netId Used to specify the restart of a persistent group.
- *
- * @return true, if operation was successful.
- */
- public boolean p2pGroupAdd(int netId) {
- return mSupplicantP2pIfaceHal.groupAdd(netId, true);
- }
-
- /**
- * Terminate a P2P group. If a new virtual network interface was used for
- * the group, it must also be removed. The network interface name of the
- * group interface is used as a parameter for this command.
- *
- * @param iface Group interface name to use.
- * @return true, if operation was successful.
- */
- public boolean p2pGroupRemove(String iface) {
- return mSupplicantP2pIfaceHal.groupRemove(iface);
- }
-
- /**
- * Reject connection attempt from a peer (specified with a device
- * address). This is a mechanism to reject a pending group owner negotiation
- * with a peer and request to automatically block any further connection or
- * discovery of the peer.
- *
- * @param deviceAddress MAC address of the device to reject.
- *
- * @return boolean value indicating whether operation was successful.
- */
- public boolean p2pReject(String deviceAddress) {
- return mSupplicantP2pIfaceHal.reject(deviceAddress);
- }
-
- /**
- * Invite a device to a persistent group.
- * If the peer device is the group owner of the persistent group, the peer
- * parameter is not needed. Otherwise it is used to specify which
- * device to invite. |goDeviceAddress| parameter may be used to override
- * the group owner device address for Invitation Request should it not be
- * known for some reason (this should not be needed in most cases).
- *
- * @param group Group object to use.
- * @param deviceAddress MAC address of the device to invite.
- *
- * @return boolean value indicating whether operation was successful.
- */
- public boolean p2pInvite(WifiP2pGroup group, String deviceAddress) {
- return mSupplicantP2pIfaceHal.invite(group, deviceAddress);
- }
-
- /**
- * Reinvoke a device from a persistent group.
- *
- * @param netId Used to specify the persistent group.
- * @param deviceAddress MAC address of the device to reinvoke.
- *
- * @return true, if operation was successful.
- */
- public boolean p2pReinvoke(int netId, String deviceAddress) {
- return mSupplicantP2pIfaceHal.reinvoke(netId, deviceAddress);
- }
-
- /**
- * Gets the operational SSID of the device.
- *
- * @param deviceAddress MAC address of the peer.
- *
- * @return SSID of the device.
- */
- public String p2pGetSsid(String deviceAddress) {
- return mSupplicantP2pIfaceHal.getSsid(deviceAddress);
- }
-
- /**
- * Gets the MAC address of the device.
- *
- * @return MAC address of the device.
- */
- public String p2pGetDeviceAddress() {
- return mSupplicantP2pIfaceHal.getDeviceAddress();
- }
-
- /**
- * Gets the capability of the group which the device is a
- * member of.
- *
- * @param deviceAddress MAC address of the peer.
- *
- * @return combination of |GroupCapabilityMask| values.
- */
- public int getGroupCapability(String deviceAddress) {
- return mSupplicantP2pIfaceHal.getGroupCapability(deviceAddress);
- }
-
- /**
- * This command can be used to add a upnp/bonjour service.
- *
- * @param servInfo List of service queries.
- *
- * @return true, if operation was successful.
- */
- public boolean p2pServiceAdd(WifiP2pServiceInfo servInfo) {
- return mSupplicantP2pIfaceHal.serviceAdd(servInfo);
- }
-
- /**
- * This command can be used to remove a upnp/bonjour service.
- *
- * @param servInfo List of service queries.
- *
- * @return true, if operation was successful.
- */
- public boolean p2pServiceDel(WifiP2pServiceInfo servInfo) {
- return mSupplicantP2pIfaceHal.serviceRemove(servInfo);
- }
-
- /**
- * This command can be used to flush all services from the
- * device.
- *
- * @return boolean value indicating whether operation was successful.
- */
- public boolean p2pServiceFlush() {
- return mSupplicantP2pIfaceHal.serviceFlush();
- }
-
- /**
- * Schedule a P2P service discovery request. The parameters for this command
- * are the device address of the peer device (or 00:00:00:00:00:00 for
- * wildcard query that is sent to every discovered P2P peer that supports
- * service discovery) and P2P Service Query TLV(s) as hexdump.
- *
- * @param addr MAC address of the device to discover.
- * @param query Hex dump of the query data.
- * @return identifier Identifier for the request. Can be used to cancel the
- * request.
- */
- public String p2pServDiscReq(String addr, String query) {
- return mSupplicantP2pIfaceHal.requestServiceDiscovery(addr, query);
- }
-
- /**
- * Cancel a previous service discovery request.
- *
- * @param id Identifier for the request to cancel.
- * @return true, if operation was successful.
- */
- public boolean p2pServDiscCancelReq(String id) {
- return mSupplicantP2pIfaceHal.cancelServiceDiscovery(id);
- }
-
- /**
- * Send driver command to set Miracast mode.
- *
- * @param mode Mode of Miracast.
- * 0 = disabled
- * 1 = operating as source
- * 2 = operating as sink
- */
- public void setMiracastMode(int mode) {
- mSupplicantP2pIfaceHal.setMiracastMode(mode);
- }
-
- /**
- * Get NFC handover request message.
- *
- * @return select message if created successfully, null otherwise.
- */
- public String getNfcHandoverRequest() {
- return mSupplicantP2pIfaceHal.getNfcHandoverRequest();
- }
-
- /**
- * Get NFC handover select message.
- *
- * @return select message if created successfully, null otherwise.
- */
- public String getNfcHandoverSelect() {
- return mSupplicantP2pIfaceHal.getNfcHandoverSelect();
- }
-
- /**
- * Report NFC handover select message.
- *
- * @return true if reported successfully, false otherwise.
- */
- public boolean initiatorReportNfcHandover(String selectMessage) {
- return mSupplicantP2pIfaceHal.initiatorReportNfcHandover(selectMessage);
- }
-
- /**
- * Report NFC handover request message.
- *
- * @return true if reported successfully, false otherwise.
- */
- public boolean responderReportNfcHandover(String requestMessage) {
- return mSupplicantP2pIfaceHal.responderReportNfcHandover(requestMessage);
- }
-
- /**
- * Set the client list for the provided network.
- *
- * @param netId Id of the network.
- * @return Space separated list of clients if successfull, null otherwise.
- */
- public String getP2pClientList(int netId) {
- return mSupplicantP2pIfaceHal.getClientList(netId);
- }
-
- /**
- * Set the client list for the provided network.
- *
- * @param netId Id of the network.
- * @param list Space separated list of clients.
- * @return true, if operation was successful.
- */
- public boolean setP2pClientList(int netId, String list) {
- return mSupplicantP2pIfaceHal.setClientList(netId, list);
- }
-
- /**
- * Save the current configuration to p2p_supplicant.conf.
- *
- * @return true on success, false otherwise.
- */
- public boolean saveConfig() {
- return mSupplicantP2pIfaceHal.saveConfig();
- }
-
/********************************************************
* Vendor HAL operations
********************************************************/
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index d743a3cd1..b49268163 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -4209,6 +4209,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
// Disable wpa_supplicant from auto reconnecting.
mWifiNative.enableStaAutoReconnect(false);
+ // STA has higher priority over P2P
+ mWifiNative.setConcurrencyPriority(true);
}
@Override
diff --git a/service/java/com/android/server/wifi/SupplicantP2pIfaceCallback.java b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java
index 829d32e1e..6f3878cf4 100644
--- a/service/java/com/android/server/wifi/SupplicantP2pIfaceCallback.java
+++ b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java
@@ -14,11 +14,10 @@
* limitations under the License.
*/
-package com.android.server.wifi;
+package com.android.server.wifi.p2p;
import android.hardware.wifi.supplicant.V1_0.ISupplicantP2pIface;
import android.hardware.wifi.supplicant.V1_0.ISupplicantP2pIfaceCallback;
-import android.hardware.wifi.supplicant.V1_0.WpsConfigMethods;
import android.net.wifi.WpsInfo;
import android.net.wifi.p2p.WifiP2pConfig;
import android.net.wifi.p2p.WifiP2pDevice;
@@ -36,14 +35,17 @@ import libcore.util.HexEncoding;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Class used for processing all P2P callbacks.
+ */
public class SupplicantP2pIfaceCallback extends ISupplicantP2pIfaceCallback.Stub {
private static final String TAG = "SupplicantP2pIfaceCallback";
private static final boolean DBG = true;
private final String mInterface;
- private final WifiMonitor mMonitor;
+ private final WifiP2pMonitor mMonitor;
- public SupplicantP2pIfaceCallback(String iface, WifiMonitor monitor) {
+ public SupplicantP2pIfaceCallback(String iface, WifiP2pMonitor monitor) {
mInterface = iface;
mMonitor = monitor;
}
@@ -56,7 +58,7 @@ public class SupplicantP2pIfaceCallback extends ISupplicantP2pIfaceCallback.Stub
/**
* Used to indicate that a new network has been added.
*
- * @param id Network ID allocated to the corresponding network.
+ * @param networkId Network ID allocated to the corresponding network.
*/
public void onNetworkAdded(int networkId) {
}
@@ -65,7 +67,7 @@ public class SupplicantP2pIfaceCallback extends ISupplicantP2pIfaceCallback.Stub
/**
* Used to indicate that a network has been removed.
*
- * @param id Network ID allocated to the corresponding network.
+ * @param networkId Network ID allocated to the corresponding network.
*/
public void onNetworkRemoved(int networkId) {
}
@@ -84,7 +86,7 @@ public class SupplicantP2pIfaceCallback extends ISupplicantP2pIfaceCallback.Stub
* device.
* @param deviceCapabilities Refer to section 4.1.4 of Wifi P2P Technical
* specification v1.2.
- * @param groupCapabilites Refer to section 4.1.4 of Wifi P2P Technical
+ * @param groupCapabilities Refer to section 4.1.4 of Wifi P2P Technical
* specification v1.2.
* @param wfdDeviceInfo WFD device info as described in section 5.1.2 of WFD
* technical specification v1.0.0.
@@ -323,7 +325,7 @@ public class SupplicantP2pIfaceCallback extends ISupplicantP2pIfaceCallback.Stub
*
* @param srcAddress MAC address of the device that sent the invitation.
* @param goDeviceAddress MAC Address of the owner of this group.
- * @param Bssid Bssid of the group.
+ * @param bssid Bssid of the group.
* @param persistentNetworkId Persistent network Id of the group.
* @param operatingFrequency Frequency on which the invitation was received.
*/
@@ -362,7 +364,7 @@ public class SupplicantP2pIfaceCallback extends ISupplicantP2pIfaceCallback.Stub
/**
* Used to indicate the result of the P2P invitation request.
*
- * @param Bssid Bssid of the group.
+ * @param bssid Bssid of the group.
* @param status Status of the invitation.
*/
public void onInvitationResult(byte[] bssid, int status) {
@@ -389,8 +391,8 @@ public class SupplicantP2pIfaceCallback extends ISupplicantP2pIfaceCallback.Stub
return;
}
- logd("Provision discovery " + (isRequest ? "request" : "response") +
- " for WPS Config method: " + configMethods);
+ logd("Provision discovery " + (isRequest ? "request" : "response")
+ + " for WPS Config method: " + configMethods);
WifiP2pProvDiscEvent event = new WifiP2pProvDiscEvent();
event.device = new WifiP2pDevice();
@@ -527,7 +529,7 @@ public class SupplicantP2pIfaceCallback extends ISupplicantP2pIfaceCallback.Stub
case P2pStatusCode.FAIL_REJECTED_BY_USER:
result = P2pStatus.REJECTED_BY_USER;
break;
- };
+ }
return result;
}
}
diff --git a/service/java/com/android/server/wifi/SupplicantP2pIfaceHal.java b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java
index 6a90f875f..6464a4c13 100644
--- a/service/java/com/android/server/wifi/SupplicantP2pIfaceHal.java
+++ b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceHal.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.server.wifi;
+package com.android.server.wifi.p2p;
import android.hardware.wifi.supplicant.V1_0.ISupplicant;
import android.hardware.wifi.supplicant.V1_0.ISupplicantIface;
@@ -25,6 +25,7 @@ import android.hardware.wifi.supplicant.V1_0.ISupplicantP2pNetwork;
import android.hardware.wifi.supplicant.V1_0.IfaceType;
import android.hardware.wifi.supplicant.V1_0.SupplicantStatus;
import android.hardware.wifi.supplicant.V1_0.SupplicantStatusCode;
+import android.hardware.wifi.supplicant.V1_0.WpsConfigMethods;
import android.hidl.manager.V1_0.IServiceManager;
import android.hidl.manager.V1_0.IServiceNotification;
import android.net.wifi.WpsInfo;
@@ -108,10 +109,10 @@ public class SupplicantP2pIfaceHal {
}
};
- private final WifiMonitor mMonitor;
+ private final WifiP2pMonitor mMonitor;
private SupplicantP2pIfaceCallback mCallback = null;
- public SupplicantP2pIfaceHal(WifiMonitor monitor) {
+ public SupplicantP2pIfaceHal(WifiP2pMonitor monitor) {
mMonitor = monitor;
}
@@ -411,7 +412,7 @@ public class SupplicantP2pIfaceHal {
* be automatically deleted when the corresponding client process is dead or
* if this interface is removed.
*
- * @param callback An instance of the |ISupplicantP2pIfaceCallback| HIDL
+ * @param receiver An instance of the |ISupplicantP2pIfaceCallback| HIDL
* interface object.
* @return boolean value indicating whether operation was successful.
*/
@@ -565,7 +566,7 @@ public class SupplicantP2pIfaceHal {
}
SupplicantResult<Void> result = new SupplicantResult(
- "setGroupIdle(" + groupIfName + ", " + timeoutInSec+ ")");
+ "setGroupIdle(" + groupIfName + ", " + timeoutInSec + ")");
try {
result.setResult(mISupplicantP2pIface.setGroupIdle(groupIfName, timeoutInSec));
} catch (RemoteException e) {
@@ -816,8 +817,8 @@ public class SupplicantP2pIfaceHal {
}
SupplicantResult<Void> result = new SupplicantResult(
- "invite(" + group.getInterface() + ", " +
- group.getOwner().deviceAddress + ", " + peerAddress + ")");
+ "invite(" + group.getInterface() + ", " + group.getOwner().deviceAddress
+ + ", " + peerAddress + ")");
try {
result.setResult(mISupplicantP2pIface.invite(
group.getInterface(), ownerMacAddress, peerMacAddress));
@@ -1129,8 +1130,8 @@ public class SupplicantP2pIfaceHal {
// Verify that the integers are not negative. Leave actual parameter validation to
// supplicant.
if (periodInMillis < 0 || intervalInMillis < 0) {
- Log.e(TAG, "Invalid parameters supplied to configureExtListen: " +
- periodInMillis + ", " + intervalInMillis);
+ Log.e(TAG, "Invalid parameters supplied to configureExtListen: " + periodInMillis
+ + ", " + intervalInMillis);
return false;
}
@@ -1169,8 +1170,8 @@ public class SupplicantP2pIfaceHal {
// Verify that the integers are not negative. Leave actual parameter validation to
// supplicant.
if (channel < 0 || operatingClass < 0) {
- Log.e(TAG, "Invalid values supplied to setListenChannel: " +
- channel + ", " + operatingClass);
+ Log.e(TAG, "Invalid values supplied to setListenChannel: " + channel + ", "
+ + operatingClass);
return false;
}
@@ -1900,6 +1901,32 @@ public class SupplicantP2pIfaceHal {
}
/**
+ * Set WPS config methods
+ *
+ * @param configMethodsStr List of config methods.
+ * @return true if request is sent successfully, false otherwise.
+ */
+ public boolean setWpsConfigMethods(String configMethodsStr) {
+ synchronized (mLock) {
+ if (!checkSupplicantP2pIfaceAndLogFailure("setWpsConfigMethods")) return false;
+ SupplicantResult<Void> result =
+ new SupplicantResult("setWpsConfigMethods(" + configMethodsStr + ")");
+ short configMethodsMask = 0;
+ String[] configMethodsStrArr = configMethodsStr.split("\\s+");
+ for (int i = 0; i < configMethodsStrArr.length; i++) {
+ configMethodsMask |= stringToWpsConfigMethod(configMethodsStrArr[i]);
+ }
+ try {
+ result.setResult(mISupplicantP2pIface.setWpsConfigMethods(configMethodsMask));
+ } catch (RemoteException e) {
+ Log.e(TAG, "ISupplicantP2pIface exception: " + e);
+ supplicantServiceDiedHandler();
+ }
+ return result.isSuccess();
+ }
+ }
+
+ /**
* Get NFC handover request message.
*
* @return select message if created successfully, null otherwise.
@@ -2090,6 +2117,45 @@ public class SupplicantP2pIfaceHal {
}
}
+ /**
+ * Converts the Wps config method string to the equivalent enum value.
+ */
+ private static short stringToWpsConfigMethod(String configMethod) {
+ switch (configMethod) {
+ case "usba":
+ return WpsConfigMethods.USBA;
+ case "ethernet":
+ return WpsConfigMethods.ETHERNET;
+ case "label":
+ return WpsConfigMethods.LABEL;
+ case "display":
+ return WpsConfigMethods.DISPLAY;
+ case "int_nfc_token":
+ return WpsConfigMethods.INT_NFC_TOKEN;
+ case "ext_nfc_token":
+ return WpsConfigMethods.EXT_NFC_TOKEN;
+ case "nfc_interface":
+ return WpsConfigMethods.NFC_INTERFACE;
+ case "push_button":
+ return WpsConfigMethods.PUSHBUTTON;
+ case "keypad":
+ return WpsConfigMethods.KEYPAD;
+ case "virtual_push_button":
+ return WpsConfigMethods.VIRT_PUSHBUTTON;
+ case "physical_push_button":
+ return WpsConfigMethods.PHY_PUSHBUTTON;
+ case "p2ps":
+ return WpsConfigMethods.P2PS;
+ case "virtual_display":
+ return WpsConfigMethods.VIRT_DISPLAY;
+ case "physical_display":
+ return WpsConfigMethods.PHY_DISPLAY;
+ default:
+ throw new IllegalArgumentException(
+ "Invalid WPS config method: " + configMethod);
+ }
+ }
+
/** Container class allowing propagation of status and/or value
* from callbacks.
*
@@ -2101,7 +2167,7 @@ public class SupplicantP2pIfaceHal {
private SupplicantStatus mStatus;
private E mValue;
- public SupplicantResult(String methodName) {
+ SupplicantResult(String methodName) {
mMethodName = methodName;
mStatus = null;
mValue = null;
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pMonitor.java b/service/java/com/android/server/wifi/p2p/WifiP2pMonitor.java
new file mode 100644
index 000000000..37b4d6807
--- /dev/null
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pMonitor.java
@@ -0,0 +1,509 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.wifi.p2p;
+
+import android.net.wifi.p2p.WifiP2pConfig;
+import android.net.wifi.p2p.WifiP2pDevice;
+import android.net.wifi.p2p.WifiP2pGroup;
+import android.net.wifi.p2p.WifiP2pProvDiscEvent;
+import android.net.wifi.p2p.nsd.WifiP2pServiceResponse;
+import android.os.Handler;
+import android.os.Message;
+import android.util.ArraySet;
+import android.util.Log;
+import android.util.SparseArray;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.util.Protocol;
+import com.android.server.wifi.WifiInjector;
+import com.android.server.wifi.p2p.WifiP2pServiceImpl.P2pStatus;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Listens for events from the wpa_supplicant, and passes them on
+ * to the {@link WifiP2pServiceImpl} for handling.
+ *
+ * @hide
+ */
+public class WifiP2pMonitor {
+ private static final String TAG = "WifiP2pMonitor";
+
+ /* Supplicant events reported to a state machine */
+ private static final int BASE = Protocol.BASE_WIFI_MONITOR;
+
+ /* Connection to supplicant established */
+ public static final int SUP_CONNECTION_EVENT = BASE + 1;
+ /* Connection to supplicant lost */
+ public static final int SUP_DISCONNECTION_EVENT = BASE + 2;
+
+ /* P2P events */
+ public static final int P2P_DEVICE_FOUND_EVENT = BASE + 21;
+ public static final int P2P_DEVICE_LOST_EVENT = BASE + 22;
+ public static final int P2P_GO_NEGOTIATION_REQUEST_EVENT = BASE + 23;
+ public static final int P2P_GO_NEGOTIATION_SUCCESS_EVENT = BASE + 25;
+ public static final int P2P_GO_NEGOTIATION_FAILURE_EVENT = BASE + 26;
+ public static final int P2P_GROUP_FORMATION_SUCCESS_EVENT = BASE + 27;
+ public static final int P2P_GROUP_FORMATION_FAILURE_EVENT = BASE + 28;
+ public static final int P2P_GROUP_STARTED_EVENT = BASE + 29;
+ public static final int P2P_GROUP_REMOVED_EVENT = BASE + 30;
+ public static final int P2P_INVITATION_RECEIVED_EVENT = BASE + 31;
+ public static final int P2P_INVITATION_RESULT_EVENT = BASE + 32;
+ public static final int P2P_PROV_DISC_PBC_REQ_EVENT = BASE + 33;
+ public static final int P2P_PROV_DISC_PBC_RSP_EVENT = BASE + 34;
+ public static final int P2P_PROV_DISC_ENTER_PIN_EVENT = BASE + 35;
+ public static final int P2P_PROV_DISC_SHOW_PIN_EVENT = BASE + 36;
+ public static final int P2P_FIND_STOPPED_EVENT = BASE + 37;
+ public static final int P2P_SERV_DISC_RESP_EVENT = BASE + 38;
+ public static final int P2P_PROV_DISC_FAILURE_EVENT = BASE + 39;
+
+ /* hostap events */
+ public static final int AP_STA_DISCONNECTED_EVENT = BASE + 41;
+ public static final int AP_STA_CONNECTED_EVENT = BASE + 42;
+
+
+ private final WifiInjector mWifiInjector;
+ private boolean mVerboseLoggingEnabled = false;
+ private boolean mConnected = false;
+
+ public WifiP2pMonitor(WifiInjector wifiInjector) {
+ mWifiInjector = wifiInjector;
+ }
+
+ void enableVerboseLogging(int verbose) {
+ if (verbose > 0) {
+ mVerboseLoggingEnabled = true;
+ } else {
+ mVerboseLoggingEnabled = false;
+ }
+ }
+
+ // TODO(b/27569474) remove support for multiple handlers for the same event
+ private final Map<String, SparseArray<Set<Handler>>> mHandlerMap = new HashMap<>();
+
+ /**
+ * Registers a callback handler for the provided event.
+ */
+ public synchronized void registerHandler(String iface, int what, Handler handler) {
+ SparseArray<Set<Handler>> ifaceHandlers = mHandlerMap.get(iface);
+ if (ifaceHandlers == null) {
+ ifaceHandlers = new SparseArray<>();
+ mHandlerMap.put(iface, ifaceHandlers);
+ }
+ Set<Handler> ifaceWhatHandlers = ifaceHandlers.get(what);
+ if (ifaceWhatHandlers == null) {
+ ifaceWhatHandlers = new ArraySet<>();
+ ifaceHandlers.put(what, ifaceWhatHandlers);
+ }
+ ifaceWhatHandlers.add(handler);
+ }
+
+ private final Map<String, Boolean> mMonitoringMap = new HashMap<>();
+ private boolean isMonitoring(String iface) {
+ Boolean val = mMonitoringMap.get(iface);
+ if (val == null) {
+ return false;
+ } else {
+ return val.booleanValue();
+ }
+ }
+
+ /**
+ * Enable/Disable monitoring for the provided iface.
+ *
+ * @param iface Name of the iface.
+ * @param enabled true to enable, false to disable.
+ */
+ @VisibleForTesting
+ public void setMonitoring(String iface, boolean enabled) {
+ mMonitoringMap.put(iface, enabled);
+ }
+
+ private void setMonitoringNone() {
+ for (String iface : mMonitoringMap.keySet()) {
+ setMonitoring(iface, false);
+ }
+ }
+
+ /**
+ * Wait for wpa_supplicant's control interface to be ready.
+ *
+ * TODO: Add unit tests for these once we remove the legacy code.
+ */
+ private boolean ensureConnectedLocked() {
+ if (mConnected) {
+ return true;
+ }
+ if (mVerboseLoggingEnabled) Log.d(TAG, "connecting to supplicant");
+ int connectTries = 0;
+ while (true) {
+ mConnected = mWifiInjector.getWifiP2pNative().connectToSupplicant();
+ if (mConnected) {
+ return true;
+ }
+ if (connectTries++ < 5) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignore) {
+ }
+ } else {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Start Monitoring for wpa_supplicant events.
+ *
+ * @param iface Name of iface.
+ * TODO: Add unit tests for these once we remove the legacy code.
+ */
+ public synchronized void startMonitoring(String iface) {
+ if (ensureConnectedLocked()) {
+ setMonitoring(iface, true);
+ broadcastSupplicantConnectionEvent(iface);
+ } else {
+ boolean originalMonitoring = isMonitoring(iface);
+ setMonitoring(iface, true);
+ broadcastSupplicantDisconnectionEvent(iface);
+ setMonitoring(iface, originalMonitoring);
+ Log.e(TAG, "startMonitoring(" + iface + ") failed!");
+ }
+ }
+
+ /**
+ * Stop Monitoring for wpa_supplicant events.
+ *
+ * @param iface Name of iface.
+ * TODO: Add unit tests for these once we remove the legacy code.
+ */
+ public synchronized void stopMonitoring(String iface) {
+ if (mVerboseLoggingEnabled) Log.d(TAG, "stopMonitoring(" + iface + ")");
+ setMonitoring(iface, true);
+ broadcastSupplicantDisconnectionEvent(iface);
+ setMonitoring(iface, false);
+ }
+
+ /**
+ * Stop Monitoring for wpa_supplicant events.
+ *
+ * TODO: Add unit tests for these once we remove the legacy code.
+ */
+ public synchronized void stopAllMonitoring() {
+ mConnected = false;
+ setMonitoringNone();
+ }
+
+ /**
+ * Similar functions to Handler#sendMessage that send the message to the registered handler
+ * for the given interface and message what.
+ * All of these should be called with the WifiMonitor class lock
+ */
+ private void sendMessage(String iface, int what) {
+ sendMessage(iface, Message.obtain(null, what));
+ }
+
+ private void sendMessage(String iface, int what, Object obj) {
+ sendMessage(iface, Message.obtain(null, what, obj));
+ }
+
+ private void sendMessage(String iface, int what, int arg1) {
+ sendMessage(iface, Message.obtain(null, what, arg1, 0));
+ }
+
+ private void sendMessage(String iface, int what, int arg1, int arg2) {
+ sendMessage(iface, Message.obtain(null, what, arg1, arg2));
+ }
+
+ private void sendMessage(String iface, int what, int arg1, int arg2, Object obj) {
+ sendMessage(iface, Message.obtain(null, what, arg1, arg2, obj));
+ }
+
+ private void sendMessage(String iface, Message message) {
+ SparseArray<Set<Handler>> ifaceHandlers = mHandlerMap.get(iface);
+ if (iface != null && ifaceHandlers != null) {
+ if (isMonitoring(iface)) {
+ boolean firstHandler = true;
+ Set<Handler> ifaceWhatHandlers = ifaceHandlers.get(message.what);
+ if (ifaceWhatHandlers != null) {
+ for (Handler handler : ifaceWhatHandlers) {
+ if (firstHandler) {
+ firstHandler = false;
+ sendMessage(handler, message);
+ } else {
+ sendMessage(handler, Message.obtain(message));
+ }
+ }
+ }
+ } else {
+ if (mVerboseLoggingEnabled) {
+ Log.d(TAG, "Dropping event because (" + iface + ") is stopped");
+ }
+ }
+ } else {
+ if (mVerboseLoggingEnabled) {
+ Log.d(TAG, "Sending to all monitors because there's no matching iface");
+ }
+ boolean firstHandler = true;
+ for (Map.Entry<String, SparseArray<Set<Handler>>> entry : mHandlerMap.entrySet()) {
+ if (isMonitoring(entry.getKey())) {
+ Set<Handler> ifaceWhatHandlers = entry.getValue().get(message.what);
+ for (Handler handler : ifaceWhatHandlers) {
+ if (firstHandler) {
+ firstHandler = false;
+ sendMessage(handler, message);
+ } else {
+ sendMessage(handler, Message.obtain(message));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void sendMessage(Handler handler, Message message) {
+ if (handler != null) {
+ message.setTarget(handler);
+ message.sendToTarget();
+ }
+ }
+
+ /**
+ * Broadcast the connection to wpa_supplicant event to all the handlers registered for
+ * this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ */
+ public void broadcastSupplicantConnectionEvent(String iface) {
+ sendMessage(iface, SUP_CONNECTION_EVENT);
+ }
+
+ /**
+ * Broadcast the loss of connection to wpa_supplicant event to all the handlers registered for
+ * this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ */
+ public void broadcastSupplicantDisconnectionEvent(String iface) {
+ sendMessage(iface, SUP_DISCONNECTION_EVENT);
+ }
+
+ /**
+ * Broadcast new p2p device discovered event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ * @param device Device that has been discovered during recent scan.
+ */
+ public void broadcastP2pDeviceFound(String iface, WifiP2pDevice device) {
+ if (device != null) {
+ sendMessage(iface, P2P_DEVICE_FOUND_EVENT, device);
+ }
+ }
+
+ /**
+ * Broadcast p2p device lost event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ * @param device Device that has been lost in recent scan.
+ */
+ public void broadcastP2pDeviceLost(String iface, WifiP2pDevice device) {
+ if (device != null) {
+ sendMessage(iface, P2P_DEVICE_LOST_EVENT, device);
+ }
+ }
+
+ /**
+ * Broadcast scan termination event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ */
+ public void broadcastP2pFindStopped(String iface) {
+ sendMessage(iface, P2P_FIND_STOPPED_EVENT);
+ }
+
+ /**
+ * Broadcast group owner negotiation request event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ * @param config P2p configuration.
+ */
+ public void broadcastP2pGoNegotiationRequest(String iface, WifiP2pConfig config) {
+ if (config != null) {
+ sendMessage(iface, P2P_GO_NEGOTIATION_REQUEST_EVENT, config);
+ }
+ }
+
+ /**
+ * Broadcast group owner negotiation success event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ */
+ public void broadcastP2pGoNegotiationSuccess(String iface) {
+ sendMessage(iface, P2P_GO_NEGOTIATION_SUCCESS_EVENT);
+ }
+
+ /**
+ * Broadcast group owner negotiation failure event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ * @param reason Failure reason.
+ */
+ public void broadcastP2pGoNegotiationFailure(String iface, P2pStatus reason) {
+ sendMessage(iface, P2P_GO_NEGOTIATION_FAILURE_EVENT, reason);
+ }
+
+ /**
+ * Broadcast group formation success event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ */
+ public void broadcastP2pGroupFormationSuccess(String iface) {
+ sendMessage(iface, P2P_GROUP_FORMATION_SUCCESS_EVENT);
+ }
+
+ /**
+ * Broadcast group formation failure event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ * @param reason Failure reason.
+ */
+ public void broadcastP2pGroupFormationFailure(String iface, String reason) {
+ P2pStatus err = P2pStatus.UNKNOWN;
+ if (reason.equals("FREQ_CONFLICT")) {
+ err = P2pStatus.NO_COMMON_CHANNEL;
+ }
+ sendMessage(iface, P2P_GROUP_FORMATION_FAILURE_EVENT, err);
+ }
+
+ /**
+ * Broadcast group started event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ * @param group Started group.
+ */
+ public void broadcastP2pGroupStarted(String iface, WifiP2pGroup group) {
+ if (group != null) {
+ sendMessage(iface, P2P_GROUP_STARTED_EVENT, group);
+ }
+ }
+
+ /**
+ * Broadcast group removed event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ * @param group Removed group.
+ */
+ public void broadcastP2pGroupRemoved(String iface, WifiP2pGroup group) {
+ if (group != null) {
+ sendMessage(iface, P2P_GROUP_REMOVED_EVENT, group);
+ }
+ }
+
+ /**
+ * Broadcast invitation received event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ * @param group Group to which invitation has been received.
+ */
+ public void broadcastP2pInvitationReceived(String iface, WifiP2pGroup group) {
+ if (group != null) {
+ sendMessage(iface, P2P_INVITATION_RECEIVED_EVENT, group);
+ }
+ }
+
+ /**
+ * Broadcast invitation result event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ * @param result Result of invitation.
+ */
+ public void broadcastP2pInvitationResult(String iface, P2pStatus result) {
+ sendMessage(iface, P2P_INVITATION_RESULT_EVENT, result);
+ }
+
+ /**
+ * Broadcast PB discovery request event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ * @param event Provision discovery request event.
+ */
+ public void broadcastP2pProvisionDiscoveryPbcRequest(String iface, WifiP2pProvDiscEvent event) {
+ if (event != null) {
+ sendMessage(iface, P2P_PROV_DISC_PBC_REQ_EVENT, event);
+ }
+ }
+
+ /**
+ * Broadcast PB discovery response event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ * @param event Provision discovery response event.
+ */
+ public void broadcastP2pProvisionDiscoveryPbcResponse(
+ String iface, WifiP2pProvDiscEvent event) {
+ if (event != null) {
+ sendMessage(iface, P2P_PROV_DISC_PBC_RSP_EVENT, event);
+ }
+ }
+
+ /**
+ * Broadcast PIN discovery request event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ * @param event Provision discovery request event.
+ */
+ public void broadcastP2pProvisionDiscoveryEnterPin(String iface, WifiP2pProvDiscEvent event) {
+ if (event != null) {
+ sendMessage(iface, P2P_PROV_DISC_ENTER_PIN_EVENT, event);
+ }
+ }
+
+ /**
+ * Broadcast PIN discovery response event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ * @param event Provision discovery response event.
+ */
+ public void broadcastP2pProvisionDiscoveryShowPin(String iface, WifiP2pProvDiscEvent event) {
+ if (event != null) {
+ sendMessage(iface, P2P_PROV_DISC_SHOW_PIN_EVENT, event);
+ }
+ }
+
+ /**
+ * Broadcast P2P discovery failure event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ */
+ public void broadcastP2pProvisionDiscoveryFailure(String iface) {
+ sendMessage(iface, P2P_PROV_DISC_FAILURE_EVENT);
+ }
+
+ /**
+ * Broadcast service discovery response event to all handlers registered for this event.
+ *
+ * @param iface Name of iface on which this occurred.
+ * @param services List of discovered services.
+ */
+ public void broadcastP2pServiceDiscoveryResponse(
+ String iface, List<WifiP2pServiceResponse> services) {
+ sendMessage(iface, P2P_SERV_DISC_RESP_EVENT, services);
+ }
+}
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pNative.java b/service/java/com/android/server/wifi/p2p/WifiP2pNative.java
new file mode 100644
index 000000000..bae3faa62
--- /dev/null
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pNative.java
@@ -0,0 +1,600 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.wifi.p2p;
+
+import android.net.wifi.p2p.WifiP2pConfig;
+import android.net.wifi.p2p.WifiP2pGroup;
+import android.net.wifi.p2p.WifiP2pGroupList;
+import android.net.wifi.p2p.nsd.WifiP2pServiceInfo;
+
+/**
+ * Native calls for bring up/shut down of the supplicant daemon and for
+ * sending requests to the supplicant daemon
+ *
+ * {@hide}
+ */
+public class WifiP2pNative {
+ private final String mTAG;
+ private final String mInterfaceName;
+ private final SupplicantP2pIfaceHal mSupplicantP2pIfaceHal;
+
+ public WifiP2pNative(String interfaceName, SupplicantP2pIfaceHal p2pIfaceHal) {
+ mTAG = "WifiP2pNative-" + interfaceName;
+ mInterfaceName = interfaceName;
+ mSupplicantP2pIfaceHal = p2pIfaceHal;
+ }
+
+ public String getInterfaceName() {
+ return mInterfaceName;
+ }
+
+ /**
+ * Enable verbose logging for all sub modules.
+ */
+ public void enableVerboseLogging(int verbose) {
+ }
+
+ /********************************************************
+ * Supplicant operations
+ ********************************************************/
+ /**
+ * This method is called repeatedly until the connection to wpa_supplicant is established.
+ *
+ * @return true if connection is established, false otherwise.
+ * TODO: Add unit tests for these once we remove the legacy code.
+ */
+ public boolean connectToSupplicant() {
+ // Start initialization if not already started.
+ if (!mSupplicantP2pIfaceHal.isInitializationStarted()
+ && !mSupplicantP2pIfaceHal.initialize()) {
+ return false;
+ }
+ // Check if the initialization is complete.
+ return mSupplicantP2pIfaceHal.isInitializationComplete();
+ }
+
+ /**
+ * Close supplicant connection.
+ */
+ public void closeSupplicantConnection() {
+ // Nothing to do for HIDL.
+ }
+
+ /**
+ * Set WPS device name.
+ *
+ * @param name String to be set.
+ * @return true if request is sent successfully, false otherwise.
+ */
+ public boolean setDeviceName(String name) {
+ return mSupplicantP2pIfaceHal.setWpsDeviceName(name);
+ }
+
+ /**
+ * Populate list of available networks or update existing list.
+ *
+ * @return true, if list has been modified.
+ */
+ public boolean p2pListNetworks(WifiP2pGroupList groups) {
+ return mSupplicantP2pIfaceHal.loadGroups(groups);
+ }
+
+ /**
+ * Initiate WPS Push Button setup.
+ * The PBC operation requires that a button is also pressed at the
+ * AP/Registrar at about the same time (2 minute window).
+ *
+ * @param iface Group interface name to use.
+ * @param bssid BSSID of the AP. Use zero'ed bssid to indicate wildcard.
+ * @return true, if operation was successful.
+ */
+ public boolean startWpsPbc(String iface, String bssid) {
+ return mSupplicantP2pIfaceHal.startWpsPbc(iface, bssid);
+ }
+
+ /**
+ * Initiate WPS Pin Keypad setup.
+ *
+ * @param iface Group interface name to use.
+ * @param pin 8 digit pin to be used.
+ * @return true, if operation was successful.
+ */
+ public boolean startWpsPinKeypad(String iface, String pin) {
+ return mSupplicantP2pIfaceHal.startWpsPinKeypad(iface, pin);
+ }
+
+ /**
+ * Initiate WPS Pin Display setup.
+ *
+ * @param iface Group interface name to use.
+ * @param bssid BSSID of the AP. Use zero'ed bssid to indicate wildcard.
+ * @return generated pin if operation was successful, null otherwise.
+ */
+ public String startWpsPinDisplay(String iface, String bssid) {
+ return mSupplicantP2pIfaceHal.startWpsPinDisplay(iface, bssid);
+ }
+
+ /**
+ * Remove network with provided id.
+ *
+ * @param netId Id of the network to lookup.
+ * @return true, if operation was successful.
+ */
+ public boolean removeP2pNetwork(int netId) {
+ return mSupplicantP2pIfaceHal.removeNetwork(netId);
+ }
+
+ /**
+ * Set WPS device name.
+ *
+ * @param name String to be set.
+ * @return true if request is sent successfully, false otherwise.
+ */
+ public boolean setP2pDeviceName(String name) {
+ return mSupplicantP2pIfaceHal.setWpsDeviceName(name);
+ }
+
+ /**
+ * Set WPS device type.
+ *
+ * @param type Type specified as a string. Used format: <categ>-<OUI>-<subcateg>
+ * @return true if request is sent successfully, false otherwise.
+ */
+ public boolean setP2pDeviceType(String type) {
+ return mSupplicantP2pIfaceHal.setWpsDeviceType(type);
+ }
+
+ /**
+ * Set WPS config methods
+ *
+ * @param cfg List of config methods.
+ * @return true if request is sent successfully, false otherwise.
+ */
+ public boolean setConfigMethods(String cfg) {
+ return mSupplicantP2pIfaceHal.setWpsConfigMethods(cfg);
+ }
+
+ /**
+ * Set the postfix to be used for P2P SSID's.
+ *
+ * @param postfix String to be appended to SSID.
+ *
+ * @return boolean value indicating whether operation was successful.
+ */
+ public boolean setP2pSsidPostfix(String postfix) {
+ return mSupplicantP2pIfaceHal.setSsidPostfix(postfix);
+ }
+
+ /**
+ * Set the Maximum idle time in seconds for P2P groups.
+ * This value controls how long a P2P group is maintained after there
+ * is no other members in the group. As a group owner, this means no
+ * associated stations in the group. As a P2P client, this means no
+ * group owner seen in scan results.
+ *
+ * @param iface Group interface name to use.
+ * @param time Timeout value in seconds.
+ *
+ * @return boolean value indicating whether operation was successful.
+ */
+ public boolean setP2pGroupIdle(String iface, int time) {
+ return mSupplicantP2pIfaceHal.setGroupIdle(iface, time);
+ }
+
+ /**
+ * Turn on/off power save mode for the interface.
+ *
+ * @param iface Group interface name to use.
+ * @param enabled Indicate if power save is to be turned on/off.
+ *
+ * @return boolean value indicating whether operation was successful.
+ */
+ public boolean setP2pPowerSave(String iface, boolean enabled) {
+ return mSupplicantP2pIfaceHal.setPowerSave(iface, enabled);
+ }
+
+ /**
+ * Enable/Disable Wifi Display.
+ *
+ * @param enable true to enable, false to disable.
+ * @return true, if operation was successful.
+ */
+ public boolean setWfdEnable(boolean enable) {
+ return mSupplicantP2pIfaceHal.enableWfd(enable);
+ }
+
+ /**
+ * Set Wifi Display device info.
+ *
+ * @param hex WFD device info as described in section 5.1.2 of WFD technical
+ * specification v1.0.0.
+ * @return true, if operation was successful.
+ */
+ public boolean setWfdDeviceInfo(String hex) {
+ return mSupplicantP2pIfaceHal.setWfdDeviceInfo(hex);
+ }
+
+ /**
+ * Initiate a P2P service discovery indefinitely.
+ * Will trigger {@link WifiP2pMonitor#P2P_DEVICE_FOUND_EVENT} on finding devices.
+ *
+ * @return boolean value indicating whether operation was successful.
+ */
+ public boolean p2pFind() {
+ return p2pFind(0);
+ }
+
+ /**
+ * Initiate a P2P service discovery with a (optional) timeout.
+ *
+ * @param timeout Max time to be spent is peforming discovery.
+ * Set to 0 to indefinely continue discovery untill and explicit
+ * |stopFind| is sent.
+ * @return boolean value indicating whether operation was successful.
+ */
+ public boolean p2pFind(int timeout) {
+ return mSupplicantP2pIfaceHal.find(timeout);
+ }
+
+ /**
+ * Stop an ongoing P2P service discovery.
+ *
+ * @return boolean value indicating whether operation was successful.
+ */
+ public boolean p2pStopFind() {
+ return mSupplicantP2pIfaceHal.stopFind();
+ }
+
+ /**
+ * Configure Extended Listen Timing.
+ *
+ * If enabled, listen state must be entered every |intervalInMillis| for at
+ * least |periodInMillis|. Both values have acceptable range of 1-65535
+ * (with interval obviously having to be larger than or equal to duration).
+ * If the P2P module is not idle at the time the Extended Listen Timing
+ * timeout occurs, the Listen State operation must be skipped.
+ *
+ * @param enable Enables or disables listening.
+ * @param period Period in milliseconds.
+ * @param interval Interval in milliseconds.
+ *
+ * @return true, if operation was successful.
+ */
+ public boolean p2pExtListen(boolean enable, int period, int interval) {
+ return mSupplicantP2pIfaceHal.configureExtListen(enable, period, interval);
+ }
+
+ /**
+ * Set P2P Listen channel.
+ *
+ * When specifying a social channel on the 2.4 GHz band (1/6/11) there is no
+ * need to specify the operating class since it defaults to 81. When
+ * specifying a social channel on the 60 GHz band (2), specify the 60 GHz
+ * operating class (180).
+ *
+ * @param lc Wifi channel. eg, 1, 6, 11.
+ * @param oc Operating Class indicates the channel set of the AP
+ * indicated by this BSSID
+ *
+ * @return true, if operation was successful.
+ */
+ public boolean p2pSetChannel(int lc, int oc) {
+ return mSupplicantP2pIfaceHal.setListenChannel(lc, oc);
+ }
+
+ /**
+ * Flush P2P peer table and state.
+ *
+ * @return boolean value indicating whether operation was successful.
+ */
+ public boolean p2pFlush() {
+ return mSupplicantP2pIfaceHal.flush();
+ }
+
+ /**
+ * Start P2P group formation with a discovered P2P peer. This includes
+ * optional group owner negotiation, group interface setup, provisioning,
+ * and establishing data connection.
+ *
+ * @param config Configuration to use to connect to remote device.
+ * @param joinExistingGroup Indicates that this is a command to join an
+ * existing group as a client. It skips the group owner negotiation
+ * part. This must send a Provision Discovery Request message to the
+ * target group owner before associating for WPS provisioning.
+ *
+ * @return String containing generated pin, if selected provision method
+ * uses PIN.
+ */
+ public String p2pConnect(WifiP2pConfig config, boolean joinExistingGroup) {
+ return mSupplicantP2pIfaceHal.connect(config, joinExistingGroup);
+ }
+
+ /**
+ * Cancel an ongoing P2P group formation and joining-a-group related
+ * operation. This operation unauthorizes the specific peer device (if any
+ * had been authorized to start group formation), stops P2P find (if in
+ * progress), stops pending operations for join-a-group, and removes the
+ * P2P group interface (if one was used) that is in the WPS provisioning
+ * step. If the WPS provisioning step has been completed, the group is not
+ * terminated.
+ *
+ * @return boolean value indicating whether operation was successful.
+ */
+ public boolean p2pCancelConnect() {
+ return mSupplicantP2pIfaceHal.cancelConnect();
+ }
+
+ /**
+ * Send P2P provision discovery request to the specified peer. The
+ * parameters for this command are the P2P device address of the peer and the
+ * desired configuration method.
+ *
+ * @param config Config class describing peer setup.
+ *
+ * @return boolean value indicating whether operation was successful.
+ */
+ public boolean p2pProvisionDiscovery(WifiP2pConfig config) {
+ return mSupplicantP2pIfaceHal.provisionDiscovery(config);
+ }
+
+ /**
+ * Set up a P2P group owner manually.
+ * This is a helper method that invokes groupAdd(networkId, isPersistent) internally.
+ *
+ * @param persistent Used to request a persistent group to be formed.
+ *
+ * @return true, if operation was successful.
+ */
+ public boolean p2pGroupAdd(boolean persistent) {
+ return mSupplicantP2pIfaceHal.groupAdd(persistent);
+ }
+
+ /**
+ * Set up a P2P group owner manually (i.e., without group owner
+ * negotiation with a specific peer). This is also known as autonomous
+ * group owner.
+ *
+ * @param netId Used to specify the restart of a persistent group.
+ *
+ * @return true, if operation was successful.
+ */
+ public boolean p2pGroupAdd(int netId) {
+ return mSupplicantP2pIfaceHal.groupAdd(netId, true);
+ }
+
+ /**
+ * Terminate a P2P group. If a new virtual network interface was used for
+ * the group, it must also be removed. The network interface name of the
+ * group interface is used as a parameter for this command.
+ *
+ * @param iface Group interface name to use.
+ * @return true, if operation was successful.
+ */
+ public boolean p2pGroupRemove(String iface) {
+ return mSupplicantP2pIfaceHal.groupRemove(iface);
+ }
+
+ /**
+ * Reject connection attempt from a peer (specified with a device
+ * address). This is a mechanism to reject a pending group owner negotiation
+ * with a peer and request to automatically block any further connection or
+ * discovery of the peer.
+ *
+ * @param deviceAddress MAC address of the device to reject.
+ *
+ * @return boolean value indicating whether operation was successful.
+ */
+ public boolean p2pReject(String deviceAddress) {
+ return mSupplicantP2pIfaceHal.reject(deviceAddress);
+ }
+
+ /**
+ * Invite a device to a persistent group.
+ * If the peer device is the group owner of the persistent group, the peer
+ * parameter is not needed. Otherwise it is used to specify which
+ * device to invite. |goDeviceAddress| parameter may be used to override
+ * the group owner device address for Invitation Request should it not be
+ * known for some reason (this should not be needed in most cases).
+ *
+ * @param group Group object to use.
+ * @param deviceAddress MAC address of the device to invite.
+ *
+ * @return boolean value indicating whether operation was successful.
+ */
+ public boolean p2pInvite(WifiP2pGroup group, String deviceAddress) {
+ return mSupplicantP2pIfaceHal.invite(group, deviceAddress);
+ }
+
+ /**
+ * Reinvoke a device from a persistent group.
+ *
+ * @param netId Used to specify the persistent group.
+ * @param deviceAddress MAC address of the device to reinvoke.
+ *
+ * @return true, if operation was successful.
+ */
+ public boolean p2pReinvoke(int netId, String deviceAddress) {
+ return mSupplicantP2pIfaceHal.reinvoke(netId, deviceAddress);
+ }
+
+ /**
+ * Gets the operational SSID of the device.
+ *
+ * @param deviceAddress MAC address of the peer.
+ *
+ * @return SSID of the device.
+ */
+ public String p2pGetSsid(String deviceAddress) {
+ return mSupplicantP2pIfaceHal.getSsid(deviceAddress);
+ }
+
+ /**
+ * Gets the MAC address of the device.
+ *
+ * @return MAC address of the device.
+ */
+ public String p2pGetDeviceAddress() {
+ return mSupplicantP2pIfaceHal.getDeviceAddress();
+ }
+
+ /**
+ * Gets the capability of the group which the device is a
+ * member of.
+ *
+ * @param deviceAddress MAC address of the peer.
+ *
+ * @return combination of |GroupCapabilityMask| values.
+ */
+ public int getGroupCapability(String deviceAddress) {
+ return mSupplicantP2pIfaceHal.getGroupCapability(deviceAddress);
+ }
+
+ /**
+ * This command can be used to add a upnp/bonjour service.
+ *
+ * @param servInfo List of service queries.
+ *
+ * @return true, if operation was successful.
+ */
+ public boolean p2pServiceAdd(WifiP2pServiceInfo servInfo) {
+ return mSupplicantP2pIfaceHal.serviceAdd(servInfo);
+ }
+
+ /**
+ * This command can be used to remove a upnp/bonjour service.
+ *
+ * @param servInfo List of service queries.
+ *
+ * @return true, if operation was successful.
+ */
+ public boolean p2pServiceDel(WifiP2pServiceInfo servInfo) {
+ return mSupplicantP2pIfaceHal.serviceRemove(servInfo);
+ }
+
+ /**
+ * This command can be used to flush all services from the
+ * device.
+ *
+ * @return boolean value indicating whether operation was successful.
+ */
+ public boolean p2pServiceFlush() {
+ return mSupplicantP2pIfaceHal.serviceFlush();
+ }
+
+ /**
+ * Schedule a P2P service discovery request. The parameters for this command
+ * are the device address of the peer device (or 00:00:00:00:00:00 for
+ * wildcard query that is sent to every discovered P2P peer that supports
+ * service discovery) and P2P Service Query TLV(s) as hexdump.
+ *
+ * @param addr MAC address of the device to discover.
+ * @param query Hex dump of the query data.
+ * @return identifier Identifier for the request. Can be used to cancel the
+ * request.
+ */
+ public String p2pServDiscReq(String addr, String query) {
+ return mSupplicantP2pIfaceHal.requestServiceDiscovery(addr, query);
+ }
+
+ /**
+ * Cancel a previous service discovery request.
+ *
+ * @param id Identifier for the request to cancel.
+ * @return true, if operation was successful.
+ */
+ public boolean p2pServDiscCancelReq(String id) {
+ return mSupplicantP2pIfaceHal.cancelServiceDiscovery(id);
+ }
+
+ /**
+ * Send driver command to set Miracast mode.
+ *
+ * @param mode Mode of Miracast.
+ * 0 = disabled
+ * 1 = operating as source
+ * 2 = operating as sink
+ */
+ public void setMiracastMode(int mode) {
+ mSupplicantP2pIfaceHal.setMiracastMode(mode);
+ }
+
+ /**
+ * Get NFC handover request message.
+ *
+ * @return select message if created successfully, null otherwise.
+ */
+ public String getNfcHandoverRequest() {
+ return mSupplicantP2pIfaceHal.getNfcHandoverRequest();
+ }
+
+ /**
+ * Get NFC handover select message.
+ *
+ * @return select message if created successfully, null otherwise.
+ */
+ public String getNfcHandoverSelect() {
+ return mSupplicantP2pIfaceHal.getNfcHandoverSelect();
+ }
+
+ /**
+ * Report NFC handover select message.
+ *
+ * @return true if reported successfully, false otherwise.
+ */
+ public boolean initiatorReportNfcHandover(String selectMessage) {
+ return mSupplicantP2pIfaceHal.initiatorReportNfcHandover(selectMessage);
+ }
+
+ /**
+ * Report NFC handover request message.
+ *
+ * @return true if reported successfully, false otherwise.
+ */
+ public boolean responderReportNfcHandover(String requestMessage) {
+ return mSupplicantP2pIfaceHal.responderReportNfcHandover(requestMessage);
+ }
+
+ /**
+ * Set the client list for the provided network.
+ *
+ * @param netId Id of the network.
+ * @return Space separated list of clients if successfull, null otherwise.
+ */
+ public String getP2pClientList(int netId) {
+ return mSupplicantP2pIfaceHal.getClientList(netId);
+ }
+
+ /**
+ * Set the client list for the provided network.
+ *
+ * @param netId Id of the network.
+ * @param list Space separated list of clients.
+ * @return true, if operation was successful.
+ */
+ public boolean setP2pClientList(int netId, String list) {
+ return mSupplicantP2pIfaceHal.setClientList(netId, list);
+ }
+
+ /**
+ * Save the current configuration to p2p_supplicant.conf.
+ *
+ * @return true on success, false otherwise.
+ */
+ public boolean saveConfig() {
+ return mSupplicantP2pIfaceHal.saveConfig();
+ }
+}
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
index 49e25a92b..21ded6f11 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
@@ -78,8 +78,6 @@ import com.android.internal.util.Protocol;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
import com.android.server.wifi.WifiInjector;
-import com.android.server.wifi.WifiMonitor;
-import com.android.server.wifi.WifiNative;
import com.android.server.wifi.WifiStateMachine;
import com.android.server.wifi.util.WifiAsyncChannel;
import com.android.server.wifi.util.WifiHandler;
@@ -576,8 +574,8 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
private UserAuthorizingJoinState mUserAuthorizingJoinState = new UserAuthorizingJoinState();
private OngoingGroupRemovalState mOngoingGroupRemovalState = new OngoingGroupRemovalState();
- private WifiNative mWifiNative = WifiInjector.getInstance().getP2pWifiNative();
- private WifiMonitor mWifiMonitor = WifiInjector.getInstance().getWifiMonitor();
+ private WifiP2pNative mWifiNative = WifiInjector.getInstance().getWifiP2pNative();
+ private WifiP2pMonitor mWifiMonitor = WifiInjector.getInstance().getWifiP2pMonitor();
private final WifiP2pDeviceList mPeers = new WifiP2pDeviceList();
// WifiInjector is lazy initialized in P2p Service
private WifiInjector mWifiInjector;
@@ -637,67 +635,49 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
setLogOnlyTransitions(true);
String interfaceName = mWifiNative.getInterfaceName();
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.AP_STA_CONNECTED_EVENT, getHandler());
+ WifiP2pMonitor.AP_STA_CONNECTED_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.AP_STA_DISCONNECTED_EVENT, getHandler());
+ WifiP2pMonitor.AP_STA_DISCONNECTED_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.AUTHENTICATION_FAILURE_EVENT, getHandler());
+ WifiP2pMonitor.P2P_DEVICE_FOUND_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.NETWORK_CONNECTION_EVENT, getHandler());
+ WifiP2pMonitor.P2P_DEVICE_LOST_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.NETWORK_DISCONNECTION_EVENT, getHandler());
+ WifiP2pMonitor.P2P_FIND_STOPPED_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_DEVICE_FOUND_EVENT, getHandler());
+ WifiP2pMonitor.P2P_GO_NEGOTIATION_FAILURE_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_DEVICE_LOST_EVENT, getHandler());
+ WifiP2pMonitor.P2P_GO_NEGOTIATION_REQUEST_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_FIND_STOPPED_EVENT, getHandler());
+ WifiP2pMonitor.P2P_GO_NEGOTIATION_SUCCESS_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_GO_NEGOTIATION_FAILURE_EVENT, getHandler());
+ WifiP2pMonitor.P2P_GROUP_FORMATION_FAILURE_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_GO_NEGOTIATION_REQUEST_EVENT, getHandler());
+ WifiP2pMonitor.P2P_GROUP_FORMATION_SUCCESS_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_GO_NEGOTIATION_SUCCESS_EVENT, getHandler());
+ WifiP2pMonitor.P2P_GROUP_REMOVED_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_GROUP_FORMATION_FAILURE_EVENT, getHandler());
+ WifiP2pMonitor.P2P_GROUP_STARTED_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_GROUP_FORMATION_SUCCESS_EVENT, getHandler());
+ WifiP2pMonitor.P2P_INVITATION_RECEIVED_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_GROUP_REMOVED_EVENT, getHandler());
+ WifiP2pMonitor.P2P_INVITATION_RESULT_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_GROUP_STARTED_EVENT, getHandler());
+ WifiP2pMonitor.P2P_PROV_DISC_ENTER_PIN_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_INVITATION_RECEIVED_EVENT, getHandler());
+ WifiP2pMonitor.P2P_PROV_DISC_FAILURE_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_INVITATION_RESULT_EVENT, getHandler());
+ WifiP2pMonitor.P2P_PROV_DISC_PBC_REQ_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_PROV_DISC_ENTER_PIN_EVENT, getHandler());
+ WifiP2pMonitor.P2P_PROV_DISC_PBC_RSP_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_PROV_DISC_FAILURE_EVENT, getHandler());
+ WifiP2pMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_PROV_DISC_PBC_REQ_EVENT, getHandler());
+ WifiP2pMonitor.P2P_SERV_DISC_RESP_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_PROV_DISC_PBC_RSP_EVENT, getHandler());
+ WifiP2pMonitor.SUP_CONNECTION_EVENT, getHandler());
mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT, getHandler());
- mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.P2P_SERV_DISC_RESP_EVENT, getHandler());
- mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.SCAN_RESULTS_EVENT, getHandler());
- mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.SUP_CONNECTION_EVENT, getHandler());
- mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.SUP_DISCONNECTION_EVENT, getHandler());
- mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT, getHandler());
- mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.WPS_FAIL_EVENT, getHandler());
- mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.WPS_OVERLAP_EVENT, getHandler());
- mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.WPS_SUCCESS_EVENT, getHandler());
- mWifiMonitor.registerHandler(interfaceName,
- WifiMonitor.WPS_TIMEOUT_EVENT, getHandler());
+ WifiP2pMonitor.SUP_DISCONNECTION_EVENT, getHandler());
}
class DefaultState extends State {
@@ -844,23 +824,14 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
replyToMessage(message, WifiP2pManager.REPORT_NFC_HANDOVER_FAILED,
WifiP2pManager.BUSY);
break;
- case WifiMonitor.P2P_INVITATION_RESULT_EVENT:
- case WifiMonitor.SCAN_RESULTS_EVENT:
- case WifiMonitor.SUP_CONNECTION_EVENT:
- case WifiMonitor.SUP_DISCONNECTION_EVENT:
- case WifiMonitor.NETWORK_CONNECTION_EVENT:
- case WifiMonitor.NETWORK_DISCONNECTION_EVENT:
- case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT:
- case WifiMonitor.AUTHENTICATION_FAILURE_EVENT:
- case WifiMonitor.WPS_SUCCESS_EVENT:
- case WifiMonitor.WPS_FAIL_EVENT:
- case WifiMonitor.WPS_OVERLAP_EVENT:
- case WifiMonitor.WPS_TIMEOUT_EVENT:
- case WifiMonitor.P2P_GROUP_REMOVED_EVENT:
- case WifiMonitor.P2P_DEVICE_FOUND_EVENT:
- case WifiMonitor.P2P_DEVICE_LOST_EVENT:
- case WifiMonitor.P2P_FIND_STOPPED_EVENT:
- case WifiMonitor.P2P_SERV_DISC_RESP_EVENT:
+ case WifiP2pMonitor.P2P_INVITATION_RESULT_EVENT:
+ case WifiP2pMonitor.SUP_CONNECTION_EVENT:
+ case WifiP2pMonitor.SUP_DISCONNECTION_EVENT:
+ case WifiP2pMonitor.P2P_GROUP_REMOVED_EVENT:
+ case WifiP2pMonitor.P2P_DEVICE_FOUND_EVENT:
+ case WifiP2pMonitor.P2P_DEVICE_LOST_EVENT:
+ case WifiP2pMonitor.P2P_FIND_STOPPED_EVENT:
+ case WifiP2pMonitor.P2P_SERV_DISC_RESP_EVENT:
case PEER_CONNECTION_USER_ACCEPT:
case PEER_CONNECTION_USER_REJECT:
case DISCONNECT_WIFI_RESPONSE:
@@ -873,7 +844,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
case IPM_DHCP_RESULTS:
case IPM_PROVISIONING_SUCCESS:
case IPM_PROVISIONING_FAILURE:
- case WifiMonitor.P2P_PROV_DISC_FAILURE_EVENT:
+ case WifiP2pMonitor.P2P_PROV_DISC_FAILURE_EVENT:
case SET_MIRACAST_MODE:
case WifiP2pManager.START_LISTEN:
case WifiP2pManager.STOP_LISTEN:
@@ -889,13 +860,13 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
loge("Unexpected disable request when WifiChannel is null");
}
break;
- case WifiMonitor.P2P_GROUP_STARTED_EVENT:
+ case WifiP2pMonitor.P2P_GROUP_STARTED_EVENT:
// unexpected group created, remove
mGroup = (WifiP2pGroup) message.obj;
loge("Unexpected group creation, remove " + mGroup);
mWifiNative.p2pGroupRemove(mGroup.getInterface());
break;
- case WifiMonitor.P2P_GROUP_FORMATION_FAILURE_EVENT:
+ case WifiP2pMonitor.P2P_GROUP_FORMATION_FAILURE_EVENT:
// A group formation failure is always followed by
// a group removed event. Flushing things at group formation
// failure causes supplicant issues. Ignore right now.
@@ -1015,7 +986,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
public boolean processMessage(Message message) {
if (DBG) logd(getName() + message.toString());
switch (message.what) {
- case WifiMonitor.SUP_DISCONNECTION_EVENT:
+ case WifiP2pMonitor.SUP_DISCONNECTION_EVENT:
if (DBG) logd("p2p socket connection lost");
transitionTo(mP2pDisabledState);
break;
@@ -1063,7 +1034,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
} catch (IllegalStateException ie) {
loge("Unable to change interface settings: " + ie);
}
- mWifiMonitor.startMonitoring(mWifiNative.getInterfaceName(), false);
+ mWifiMonitor.startMonitoring(mWifiNative.getInterfaceName());
transitionTo(mP2pEnablingState);
break;
default:
@@ -1083,11 +1054,11 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
public boolean processMessage(Message message) {
if (DBG) logd(getName() + message.toString());
switch (message.what) {
- case WifiMonitor.SUP_CONNECTION_EVENT:
+ case WifiP2pMonitor.SUP_CONNECTION_EVENT:
if (DBG) logd("P2p socket connection successful");
transitionTo(mInactiveState);
break;
- case WifiMonitor.SUP_DISCONNECTION_EVENT:
+ case WifiP2pMonitor.SUP_DISCONNECTION_EVENT:
loge("P2p socket connection failed");
transitionTo(mP2pDisabledState);
break;
@@ -1116,7 +1087,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
public boolean processMessage(Message message) {
if (DBG) logd(getName() + message.toString());
switch (message.what) {
- case WifiMonitor.SUP_DISCONNECTION_EVENT:
+ case WifiP2pMonitor.SUP_DISCONNECTION_EVENT:
loge("Unexpected loss of p2p socket connection");
transitionTo(mP2pDisabledState);
break;
@@ -1195,7 +1166,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
WifiP2pManager.ERROR);
}
break;
- case WifiMonitor.P2P_FIND_STOPPED_EVENT:
+ case WifiP2pMonitor.P2P_FIND_STOPPED_EVENT:
sendP2pDiscoveryChangedBroadcast(false);
break;
case WifiP2pManager.STOP_DISCOVERY:
@@ -1225,13 +1196,13 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
WifiP2pManager.ERROR);
}
break;
- case WifiMonitor.P2P_DEVICE_FOUND_EVENT:
+ case WifiP2pMonitor.P2P_DEVICE_FOUND_EVENT:
WifiP2pDevice device = (WifiP2pDevice) message.obj;
if (mThisDevice.deviceAddress.equals(device.deviceAddress)) break;
mPeers.updateSupplicantDetails(device);
sendPeersChangedBroadcast();
break;
- case WifiMonitor.P2P_DEVICE_LOST_EVENT:
+ case WifiP2pMonitor.P2P_DEVICE_LOST_EVENT:
device = (WifiP2pDevice) message.obj;
// Gets current details for the one removed
device = mPeers.remove(device.deviceAddress);
@@ -1278,7 +1249,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
clearServiceRequests(message.replyTo);
replyToMessage(message, WifiP2pManager.CLEAR_SERVICE_REQUESTS_SUCCEEDED);
break;
- case WifiMonitor.P2P_SERV_DISC_RESP_EVENT:
+ case WifiP2pMonitor.P2P_SERV_DISC_RESP_EVENT:
if (DBG) logd(getName() + " receive service response");
List<WifiP2pServiceResponse> sdRespList =
(List<WifiP2pServiceResponse>) message.obj;
@@ -1398,7 +1369,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
WifiP2pManager.ERROR);
}
break;
- case WifiMonitor.P2P_GO_NEGOTIATION_REQUEST_EVENT:
+ case WifiP2pMonitor.P2P_GO_NEGOTIATION_REQUEST_EVENT:
config = (WifiP2pConfig) message.obj;
if (isConfigInvalid(config)) {
loge("Dropping GO neg request " + config);
@@ -1409,7 +1380,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
mJoinExistingGroup = false;
transitionTo(mUserAuthorizingNegotiationRequestState);
break;
- case WifiMonitor.P2P_INVITATION_RECEIVED_EVENT:
+ case WifiP2pMonitor.P2P_INVITATION_RECEIVED_EVENT:
WifiP2pGroup group = (WifiP2pGroup) message.obj;
WifiP2pDevice owner = group.getOwner();
@@ -1455,9 +1426,9 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
mJoinExistingGroup = true;
transitionTo(mUserAuthorizingInviteRequestState);
break;
- case WifiMonitor.P2P_PROV_DISC_PBC_REQ_EVENT:
- case WifiMonitor.P2P_PROV_DISC_ENTER_PIN_EVENT:
- case WifiMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT:
+ case WifiP2pMonitor.P2P_PROV_DISC_PBC_REQ_EVENT:
+ case WifiP2pMonitor.P2P_PROV_DISC_ENTER_PIN_EVENT:
+ case WifiP2pMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT:
// We let the supplicant handle the provision discovery response
// and wait instead for the GO_NEGOTIATION_REQUEST_EVENT.
// Handling provision discovery and issuing a p2p_connect before
@@ -1488,7 +1459,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
// remain at this state.
}
break;
- case WifiMonitor.P2P_GROUP_STARTED_EVENT:
+ case WifiP2pMonitor.P2P_GROUP_STARTED_EVENT:
mGroup = (WifiP2pGroup) message.obj;
if (DBG) logd(getName() + " group started");
@@ -1590,7 +1561,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
transitionTo(mInactiveState);
}
break;
- case WifiMonitor.P2P_DEVICE_LOST_EVENT:
+ case WifiP2pMonitor.P2P_DEVICE_LOST_EVENT:
WifiP2pDevice device = (WifiP2pDevice) message.obj;
if (!mSavedPeerConfig.deviceAddress.equals(device.deviceAddress)) {
if (DBG) {
@@ -1621,7 +1592,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
transitionTo(mInactiveState);
replyToMessage(message, WifiP2pManager.CANCEL_CONNECT_SUCCEEDED);
break;
- case WifiMonitor.P2P_GO_NEGOTIATION_SUCCESS_EVENT:
+ case WifiP2pMonitor.P2P_GO_NEGOTIATION_SUCCESS_EVENT:
// We hit this scenario when NFC handover is invoked.
mAutonomousGroup = false;
transitionTo(mGroupNegotiationState);
@@ -1719,7 +1690,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
WifiP2pProvDiscEvent provDisc;
WifiP2pDevice device;
switch (message.what) {
- case WifiMonitor.P2P_PROV_DISC_PBC_RSP_EVENT:
+ case WifiP2pMonitor.P2P_PROV_DISC_PBC_RSP_EVENT:
provDisc = (WifiP2pProvDiscEvent) message.obj;
device = provDisc.device;
if (!device.deviceAddress.equals(mSavedPeerConfig.deviceAddress)) break;
@@ -1730,7 +1701,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
transitionTo(mGroupNegotiationState);
}
break;
- case WifiMonitor.P2P_PROV_DISC_ENTER_PIN_EVENT:
+ case WifiP2pMonitor.P2P_PROV_DISC_ENTER_PIN_EVENT:
provDisc = (WifiP2pProvDiscEvent) message.obj;
device = provDisc.device;
if (!device.deviceAddress.equals(mSavedPeerConfig.deviceAddress)) break;
@@ -1747,7 +1718,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
}
}
break;
- case WifiMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT:
+ case WifiP2pMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT:
provDisc = (WifiP2pProvDiscEvent) message.obj;
device = provDisc.device;
if (!device.deviceAddress.equals(mSavedPeerConfig.deviceAddress)) break;
@@ -1760,7 +1731,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
transitionTo(mGroupNegotiationState);
}
break;
- case WifiMonitor.P2P_PROV_DISC_FAILURE_EVENT:
+ case WifiP2pMonitor.P2P_PROV_DISC_FAILURE_EVENT:
loge("provision discovery failed");
handleGroupCreationFailure();
transitionTo(mInactiveState);
@@ -1784,11 +1755,11 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
switch (message.what) {
// We ignore these right now, since we get a GROUP_STARTED notification
// afterwards
- case WifiMonitor.P2P_GO_NEGOTIATION_SUCCESS_EVENT:
- case WifiMonitor.P2P_GROUP_FORMATION_SUCCESS_EVENT:
+ case WifiP2pMonitor.P2P_GO_NEGOTIATION_SUCCESS_EVENT:
+ case WifiP2pMonitor.P2P_GROUP_FORMATION_SUCCESS_EVENT:
if (DBG) logd(getName() + " go success");
break;
- case WifiMonitor.P2P_GROUP_STARTED_EVENT:
+ case WifiP2pMonitor.P2P_GROUP_STARTED_EVENT:
mGroup = (WifiP2pGroup) message.obj;
if (DBG) logd(getName() + " group started");
@@ -1834,19 +1805,19 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
}
transitionTo(mGroupCreatedState);
break;
- case WifiMonitor.P2P_GO_NEGOTIATION_FAILURE_EVENT:
+ case WifiP2pMonitor.P2P_GO_NEGOTIATION_FAILURE_EVENT:
P2pStatus status = (P2pStatus) message.obj;
if (status == P2pStatus.NO_COMMON_CHANNEL) {
transitionTo(mFrequencyConflictState);
break;
}
// continue with group removal handling
- case WifiMonitor.P2P_GROUP_REMOVED_EVENT:
+ case WifiP2pMonitor.P2P_GROUP_REMOVED_EVENT:
if (DBG) logd(getName() + " go failure");
handleGroupCreationFailure();
transitionTo(mInactiveState);
break;
- case WifiMonitor.P2P_GROUP_FORMATION_FAILURE_EVENT:
+ case WifiP2pMonitor.P2P_GROUP_FORMATION_FAILURE_EVENT:
// A group formation failure is always followed by
// a group removed event. Flushing things at group formation
// failure causes supplicant issues. Ignore right now.
@@ -1856,7 +1827,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
break;
}
break;
- case WifiMonitor.P2P_INVITATION_RESULT_EVENT:
+ case WifiP2pMonitor.P2P_INVITATION_RESULT_EVENT:
status = (P2pStatus) message.obj;
if (status == P2pStatus.SUCCESS) {
// invocation was succeeded.
@@ -1946,18 +1917,18 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
public boolean processMessage(Message message) {
if (DBG) logd(getName() + message.toString());
switch (message.what) {
- case WifiMonitor.P2P_GO_NEGOTIATION_SUCCESS_EVENT:
- case WifiMonitor.P2P_GROUP_FORMATION_SUCCESS_EVENT:
+ case WifiP2pMonitor.P2P_GO_NEGOTIATION_SUCCESS_EVENT:
+ case WifiP2pMonitor.P2P_GROUP_FORMATION_SUCCESS_EVENT:
loge(getName() + "group sucess during freq conflict!");
break;
- case WifiMonitor.P2P_GROUP_STARTED_EVENT:
+ case WifiP2pMonitor.P2P_GROUP_STARTED_EVENT:
loge(getName() + "group started after freq conflict, handle anyway");
deferMessage(message);
transitionTo(mGroupNegotiationState);
break;
- case WifiMonitor.P2P_GO_NEGOTIATION_FAILURE_EVENT:
- case WifiMonitor.P2P_GROUP_REMOVED_EVENT:
- case WifiMonitor.P2P_GROUP_FORMATION_FAILURE_EVENT:
+ case WifiP2pMonitor.P2P_GO_NEGOTIATION_FAILURE_EVENT:
+ case WifiP2pMonitor.P2P_GROUP_REMOVED_EVENT:
+ case WifiP2pMonitor.P2P_GROUP_FORMATION_FAILURE_EVENT:
// Ignore failures since we retry again
break;
case DROP_WIFI_USER_REJECT:
@@ -2018,7 +1989,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
public boolean processMessage(Message message) {
if (DBG) logd(getName() + message.toString());
switch (message.what) {
- case WifiMonitor.AP_STA_CONNECTED_EVENT:
+ case WifiP2pMonitor.AP_STA_CONNECTED_EVENT:
WifiP2pDevice device = (WifiP2pDevice) message.obj;
String deviceAddress = device.deviceAddress;
// Clear timeout that was set when group was started.
@@ -2037,7 +2008,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
}
sendP2pConnectionChangedBroadcast();
break;
- case WifiMonitor.AP_STA_DISCONNECTED_EVENT:
+ case WifiP2pMonitor.AP_STA_DISCONNECTED_EVENT:
device = (WifiP2pDevice) message.obj;
deviceAddress = device.deviceAddress;
if (deviceAddress != null) {
@@ -2103,7 +2074,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
WifiP2pManager.ERROR);
}
break;
- case WifiMonitor.P2P_GROUP_REMOVED_EVENT:
+ case WifiP2pMonitor.P2P_GROUP_REMOVED_EVENT:
// We do not listen to NETWORK_DISCONNECTION_EVENT for group removal
// handling since supplicant actually tries to reconnect after a temporary
// disconnect until group idle time out. Eventually, a group removal event
@@ -2118,7 +2089,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
handleGroupRemoved();
transitionTo(mInactiveState);
break;
- case WifiMonitor.P2P_DEVICE_LOST_EVENT:
+ case WifiP2pMonitor.P2P_DEVICE_LOST_EVENT:
device = (WifiP2pDevice) message.obj;
// Device loss for a connected device indicates
// it is not in discovery any more
@@ -2146,7 +2117,8 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
ret = mWifiNative.startWpsPbc(mGroup.getInterface(), null);
} else {
if (wps.pin == null) {
- String pin = mWifiNative.startWpsPinDisplay(mGroup.getInterface());
+ String pin = mWifiNative.startWpsPinDisplay(
+ mGroup.getInterface(), null);
try {
Integer.parseInt(pin);
notifyInvitationSent(pin, "any");
@@ -2181,7 +2153,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
// TODO: figure out updating the status to declined
// when invitation is rejected
break;
- case WifiMonitor.P2P_INVITATION_RESULT_EVENT:
+ case WifiP2pMonitor.P2P_INVITATION_RESULT_EVENT:
P2pStatus status = (P2pStatus) message.obj;
if (status == P2pStatus.SUCCESS) {
// invocation was succeeded.
@@ -2205,15 +2177,15 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
}
}
break;
- case WifiMonitor.P2P_PROV_DISC_PBC_REQ_EVENT:
- case WifiMonitor.P2P_PROV_DISC_ENTER_PIN_EVENT:
- case WifiMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT:
+ case WifiP2pMonitor.P2P_PROV_DISC_PBC_REQ_EVENT:
+ case WifiP2pMonitor.P2P_PROV_DISC_ENTER_PIN_EVENT:
+ case WifiP2pMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT:
WifiP2pProvDiscEvent provDisc = (WifiP2pProvDiscEvent) message.obj;
mSavedPeerConfig = new WifiP2pConfig();
mSavedPeerConfig.deviceAddress = provDisc.device.deviceAddress;
- if (message.what == WifiMonitor.P2P_PROV_DISC_ENTER_PIN_EVENT) {
+ if (message.what == WifiP2pMonitor.P2P_PROV_DISC_ENTER_PIN_EVENT) {
mSavedPeerConfig.wps.setup = WpsInfo.KEYPAD;
- } else if (message.what == WifiMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT) {
+ } else if (message.what == WifiP2pMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT) {
mSavedPeerConfig.wps.setup = WpsInfo.DISPLAY;
mSavedPeerConfig.wps.pin = provDisc.pin;
} else {
@@ -2221,7 +2193,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
}
transitionTo(mUserAuthorizingJoinState);
break;
- case WifiMonitor.P2P_GROUP_STARTED_EVENT:
+ case WifiP2pMonitor.P2P_GROUP_STARTED_EVENT:
loge("Duplicate group creation event notice, ignore");
break;
default:
@@ -2249,9 +2221,9 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
public boolean processMessage(Message message) {
if (DBG) logd(getName() + message.toString());
switch (message.what) {
- case WifiMonitor.P2P_PROV_DISC_PBC_REQ_EVENT:
- case WifiMonitor.P2P_PROV_DISC_ENTER_PIN_EVENT:
- case WifiMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT:
+ case WifiP2pMonitor.P2P_PROV_DISC_PBC_REQ_EVENT:
+ case WifiP2pMonitor.P2P_PROV_DISC_ENTER_PIN_EVENT:
+ case WifiP2pMonitor.P2P_PROV_DISC_SHOW_PIN_EVENT:
// Ignore more client requests
break;
case PEER_CONNECTION_USER_ACCEPT:
@@ -2842,8 +2814,6 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
// Supplicant defaults to using virtual display with display
// which refers to a remote display. Use physical_display
mWifiNative.setConfigMethods("virtual_push_button physical_display keypad");
- // STA has higher priority over P2P
- mWifiNative.setConcurrencyPriority(true);
mThisDevice.deviceAddress = mWifiNative.p2pGetDeviceAddress();
updateThisDevice(WifiP2pDevice.AVAILABLE);