Bug 902865 - (jb-gonk) Adapt to netd protocol changes for Wifi tethering. r=mrbkap
authorVincent Chang <vchang@mozilla.com>
Thu, 08 Aug 2013 14:40:27 +0800
changeset 141852 b582bf2f4929133959aebbd378e1b9c7bc779de7
parent 141851 914bf3adc1ed28584a92f7bc63dfe8da39d0c595
child 141854 e817c429066bb272fc678783fcc8e1ffe2c6fffe
push id32251
push uservchang@mozilla.com
push dateFri, 09 Aug 2013 04:08:44 +0000
treeherdermozilla-inbound@b582bf2f4929 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs902865
milestone26.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 902865 - (jb-gonk) Adapt to netd protocol changes for Wifi tethering. r=mrbkap
dom/system/gonk/net_worker.js
--- a/dom/system/gonk/net_worker.js
+++ b/dom/system/gonk/net_worker.js
@@ -209,18 +209,18 @@ self.onmessage = function onmessage(even
   // to NetworkManager later.
   let ret = self[message.cmd](message);
   if (!message.isAsync) {
     postMessage({id: message.id, ret: ret});
   }
 };
 
 /**
-* Set DNS servers for given network interface.
-*/
+ * Set DNS servers for given network interface.
+ */
 function setDNS(options) {
   let ifprops = getIFProperties(options.ifname);
   let dns1_str = options.dns1_str || ifprops.dns1_str;
   let dns2_str = options.dns2_str || ifprops.dns2_str;
   libcutils.property_set("net.dns1", dns1_str);
   libcutils.property_set("net.dns2", dns2_str);
   // Bump the DNS change property.
   let dnschange = libcutils.property_get("net.dnschange", "0");
@@ -478,17 +478,18 @@ function stopTethering(params, callback)
 }
 
 function tetherInterface(params, callback) {
   let command = "tether interface add " + params.ifname;
   return doCommand(command, callback);
 }
 
 function preTetherInterfaceList(params, callback) {
-  let command = "tether interface list 0";
+  let command = (SDK_VERSION >= 16) ? "tether interface list"
+                                    : "tether interface list 0";
   return doCommand(command, callback);
 }
 
 function postTetherInterfaceList(params, callback) {
   params.interfaceList = params.resultReason.split(INTERFACE_DELIMIT);
 
   // Send the dummy command to continue the function chain.
   let command = DUMMY_COMMAND;
@@ -526,21 +527,31 @@ function disableNat(params, callback) {
 }
 
 function wifiFirmwareReload(params, callback) {
   let command = "softap fwreload " + params.ifname + " " + params.mode;
   return doCommand(command, callback);
 }
 
 function startAccessPointDriver(params, callback) {
+  // Skip the command for sdk version >= 16.
+  if (SDK_VERSION >= 16) {
+    callback(false, {code: "", reason: ""});
+    return true;
+  }
   let command = "softap start " + params.ifname;
   return doCommand(command, callback);
 }
 
 function stopAccessPointDriver(params, callback) {
+  // Skip the command for sdk version >= 16.
+  if (SDK_VERSION >= 16) {
+    callback(false, {code: "", reason: ""});
+    return true;
+  }
   let command = "softap stop " + params.ifname;
   return doCommand(command, callback);
 }
 
 function startSoftAP(params, callback) {
   let command = "softap startap";
   return doCommand(command, callback);
 }
@@ -562,24 +573,49 @@ function getTxBytes(params, callback) {
   return doCommand(command, callback);
 }
 
 function escapeQuote(str) {
   str = str.replace(/\\/g, "\\\\");
   return str.replace(/"/g, "\\\"");
 }
 
-// The command format is "softap set wlan0 wl0.1 hotspot456 open null 6 0 8".
+/**
+ * Command format for sdk version < 16
+ *   Arguments:
+ *     argv[2] - wlan interface
+ *     argv[3] - SSID
+ *     argv[4] - Security
+ *     argv[5] - Key
+ *     argv[6] - Channel
+ *     argv[7] - Preamble
+ *     argv[8] - Max SCB
+ *
+ * Command format for sdk version >= 16
+ *   Arguments:
+ *     argv[2] - wlan interface
+ *     argv[3] - SSID
+ *     argv[4] - Security
+ *     argv[5] - Key
+ */
 function setAccessPoint(params, callback) {
-  let command = "softap set " + params.ifname +
-                " " + params.wifictrlinterfacename +
-                " \"" + escapeQuote(params.ssid) + "\"" +
-                " " + params.security +
-                " \"" + escapeQuote(params.key) + "\"" +
-                " " + "6 0 8";
+  let command;
+  if (SDK_VERSION >= 16) {
+    command = "softap set " + params.ifname +
+              " \"" + escapeQuote(params.ssid) + "\"" +
+              " " + params.security +
+              " \"" + escapeQuote(params.key) + "\"";
+  } else {
+    command = "softap set " + params.ifname +
+              " " + params.wifictrlinterfacename +
+              " \"" + escapeQuote(params.ssid) + "\"" +
+              " " + params.security +
+              " \"" + escapeQuote(params.key) + "\"" +
+              " " + "6 0 8";
+  }
   return doCommand(command, callback);
 }
 
 function cleanUpStream(params, callback) {
   let command = "nat disable " + params.previous.internalIfname + " " +
                 params.previous.externalIfname + " " + "0";
   return doCommand(command, callback);
 }