Closed Bug 898506 Opened 9 years ago Closed 9 years ago

(jb-gonk) Adapt to netd protocol changes for USB tethering

Categories

(Firefox OS Graveyard :: General, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: m1, Assigned: poojas)

References

Details

Attachments

(1 file, 2 obsolete files)

Minor changes were made to the netd commands used to enable/disable USB tethering.  We can adapt in net_worker.js.
Below net_worker.js patch help us to enable USB tethering.

# HG changeset patch
# User poojas <poojas@codeaurora.org>
# Date 1375084372 -19800
# Node ID 35aca0b8b6d7f98a44cbde599248e2dd44a4239e
# Parent  2ade54c1de9a0257a00b3d5b1b5d2af1473317fc
Bug 898506 - (jb-gonk) Adapt to netd protocol changes for USB tethering r=<reviewer>

diff --git a/dom/system/gonk/net_worker.js b/dom/system/gonk/net_worker.js
--- a/dom/system/gonk/net_worker.js
+++ b/dom/system/gonk/net_worker.js
@@ -371,23 +371,35 @@ function nextNetdCommand() {
   [gCurrentCommand, gCurrentCallback] = gCommandQueue.shift();
   debug("Sending '" + gCurrentCommand + "' command to netd.");
   gPending = true;
   return postNetdCommand(gCurrentCommand);
 }
 
 function setInterfaceUp(params, callback) {
   let command = "interface setcfg " + params.ifname + " " + params.ip + " " +
-                params.prefix + " " + "[" + params.link + "]";
+                params.prefix + ";
+  let sdkVersion = parseInt(libcutils.property_get("ro.build.version.sdk"), 10);
+  if (sdkVersion > 15) {
+    command += params.link;
+  } else {
+    command += "[" + params.link + "]";
+  }
   return doCommand(command, callback);
 }
 
 function setInterfaceDown(params, callback) {
   let command = "interface setcfg " + params.ifname + " " + params.ip + " " +
-                params.prefix + " " + "[" + params.link + "]";
+                params.prefix + ";
+  let sdkVersion = parseInt(libcutils.property_get("ro.build.version.sdk"), 10);
+  if (sdkVersion > 15) {
+    command += params.link;
+  } else {
+    command += "[" + params.link + "]";
+  }
   return doCommand(command, callback);
 }
 
 function setIpForwardingEnabled(params, callback) {
   let command;
 
   if (params.enable) {
     command = "ipfwd enable";
PoojaS, thanks for the patch. Can you add your patch as an attachment and request review from :vchang ?

Also, I believe you can avoid reading ro.build.version.sdk more than once - you can define sdkVersion outside of the function definitions and it should work.
Attached patch usbTethering.patch (obsolete) — Splinter Review
Fix for gecko to adapt netd protocol changes for Usb tethering
Attachment #783559 - Flags: review?(vchang)
Review ping.
Flags: needinfo?(vchang)
I apply this patch to my nexus 4 in jb4.3. But I can't turn on the usb tethering successfully. Any other steps I should do to support usb tethering ?
Flags: needinfo?(vchang)
Hmm, hey Pooja could you please this this on our MR2 device?
Flags: needinfo?(poojas)
Update to latest mc makes it works. :)
Flags: needinfo?(poojas)
Comment on attachment 783559 [details] [diff] [review]
usbTethering.patch

Review of attachment 783559 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks for your patch, looks good.
Please rebase the patch before you can land it.
Attachment #783559 - Flags: review?(vchang) → review+
Attached patch Enable_USBTethering.patch (obsolete) — Splinter Review
@Please rebase the patch before you can land it.
>>> Done. attached latest patch Enable_USBTethering.patch

Thanks,
Pooja
Attachment #783559 - Attachment is obsolete: true
Attachment #788889 - Flags: review?(vchang)
Comment on attachment 788889 [details] [diff] [review]
Enable_USBTethering.patch

Review of attachment 788889 [details] [diff] [review]:
-----------------------------------------------------------------

Please fix the small nits. 
You don't need to ask for review since I have given you a r+.

::: dom/system/gonk/net_worker.js
@@ +417,5 @@
>    return postNetdCommand(command);
>  }
>  
>  function setInterfaceUp(params, callback) {
> +   let command = "interface setcfg " + params.ifname + " " + params.ip + " " +

nit: 2 spaces from the start of line.

@@ +428,5 @@
>    return doCommand(command, callback);
>  }
>  
>  function setInterfaceDown(params, callback) {
> +   let command = "interface setcfg " + params.ifname + " " + params.ip + " " +

nit: 2 spaces please.
Attachment #788889 - Flags: review?(vchang) → review+
Re-attached patch as per above review comment
Attachment #788889 - Attachment is obsolete: true
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/bcd0def8887f
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.