Bug 811635 - Part 5: Starting wpa_supplicant with proper 'p2pSupported' flag. r=vchang
☠☠ backed out by 4e8b08358660 ☠ ☠
authorHenry Chang <hchang@mozilla.com>
Tue, 29 Oct 2013 16:42:37 +0800
changeset 174242 ad72f0b9e16af506926f5bb66b4833f4becef640
parent 174241 4acc0f02807674137abf5f59442c5a75da47ebd8
child 174243 0e1a6c3f57698cccb1698caee839d3c90de36f43
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvchang
bugs811635
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 811635 - Part 5: Starting wpa_supplicant with proper 'p2pSupported' flag. r=vchang We use 'ro.moz.wifi.p2p_supported' to determine if p2p is supported.
dom/wifi/WifiUtils.cpp
--- a/dom/wifi/WifiUtils.cpp
+++ b/dom/wifi/WifiUtils.cpp
@@ -1,15 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WifiUtils.h"
 #include <dlfcn.h>
 #include <errno.h>
+#include <cutils/properties.h>
 #include "prinit.h"
 #include "js/CharacterEncoding.h"
 #include "NetUtils.h"
 
 using namespace mozilla::dom;
 
 #define BUFFER_SIZE        4096
 #define PROPERTY_VALUE_MAX 80
@@ -29,16 +30,24 @@ InitWifiLib()
 
 static void*
 GetSharedLibrary()
 {
   PR_CallOnce(&sInitWifiLib, InitWifiLib);
   return sWifiLib;
 }
 
+static bool
+GetWifiP2pSupported()
+{
+  char propP2pSupported[PROPERTY_VALUE_MAX];
+  property_get("ro.moz.wifi.p2p_supported", propP2pSupported, "0");
+  return (0 == strcmp(propP2pSupported, "1"));
+}
+
 // This is the same algorithm as in InflateUTF8StringToBuffer with Copy and
 // while ignoring invalids.
 // https://mxr.mozilla.org/mozilla-central/source/js/src/vm/CharacterEncoding.cpp#231
 
 static const uint32_t REPLACE_UTF8 = 0xFFFD;
 
 void LossyConvertUTF8toUTF16(const char* aInput, uint32_t aLength, nsAString& aOut)
 {
@@ -271,17 +280,17 @@ bool WpaSupplicant::ExecuteCommand(Comma
     aResult.mReply = value;
   } else if (aOptions.mCmd.EqualsLiteral("close_supplicant_connection")) {
     mImpl->do_wifi_close_supplicant_connection(aInterface.get());
   } else if (aOptions.mCmd.EqualsLiteral("load_driver")) {
     aResult.mStatus = mImpl->do_wifi_load_driver();
   } else if (aOptions.mCmd.EqualsLiteral("unload_driver")) {
     aResult.mStatus = mImpl->do_wifi_unload_driver();
   } else if (aOptions.mCmd.EqualsLiteral("start_supplicant")) {
-    aResult.mStatus = mImpl->do_wifi_start_supplicant(0);
+    aResult.mStatus = mImpl->do_wifi_start_supplicant(GetWifiP2pSupported() ? 1 : 0);
   } else if (aOptions.mCmd.EqualsLiteral("stop_supplicant")) {
     aResult.mStatus = mImpl->do_wifi_stop_supplicant();
   } else if (aOptions.mCmd.EqualsLiteral("connect_to_supplicant")) {
     aResult.mStatus = mImpl->do_wifi_connect_to_supplicant(aInterface.get());
   } else if (aOptions.mCmd.EqualsLiteral("ifc_enable")) {
     aResult.mStatus = mNetUtils->do_ifc_enable(GET_CHAR(mIfname));
   } else if (aOptions.mCmd.EqualsLiteral("ifc_disable")) {
     aResult.mStatus = mNetUtils->do_ifc_disable(GET_CHAR(mIfname));