Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Add support for ADB over Bluetooth #5

Closed
c99koder opened this issue Apr 28, 2015 · 12 comments
Closed

Request: Add support for ADB over Bluetooth #5

c99koder opened this issue Apr 28, 2015 · 12 comments

Comments

@c99koder
Copy link

Android Wear bluetooth debugging uses TCP port forwarding from the phone to the watch on port 4444, the correct syntax to communicate with a device connected this way is:

adb -s localhost:4444 …

instead of using the actual device's serial number. You should use the device names reported by "adb devices", as that correctly shows localhost:4444 for my Moto 360.

@mortenjust
Copy link
Owner

This would be great. Also planning on adb over wifi (mostly for Android TV). Do you think wifi could replace Bluetooth or do we need both?

@c99koder
Copy link
Author

Not all Wear devices will get WiFi support so supporting bluetooth too would be better. Not sure there would even be a difference though since they're both just going over TCP/IP from adb's perspective

@mortenjust mortenjust changed the title Doesn't work with Android Wear bluetooth debugging Add support for ADB over Bluetooth Apr 30, 2015
@mortenjust mortenjust changed the title Add support for ADB over Bluetooth Request: Add support for ADB over Bluetooth May 14, 2015
@vibin
Copy link

vibin commented May 29, 2015

I was wondering why the app wasn't working at all. I was using adb via tcp. I think it's pretty common and should be supported.

@jlhonora
Copy link
Contributor

jlhonora commented Jun 1, 2015

This should be fairly easy to implement:

diff --git a/AndroidTool/DevicePickerViewController.swift b/AndroidTool/DevicePickerViewController.swift
index d83cb81..ea385a9 100644
--- a/AndroidTool/DevicePickerViewController.swift
+++ b/AndroidTool/DevicePickerViewController.swift
@@ -30,7 +30,7 @@ class DevicePickerViewController: NSViewController, NSTableViewDelegate, NSTable
     }

     func installApkOnDevice(device:Device){
-        let serial = device.serial!
+        let adbIdentifier = device.adbIdentifier!

         for subview in view.subviews {
             var s = subview as! NSView
@@ -41,7 +41,7 @@ class DevicePickerViewController: NSViewController, NSTableViewDelegate, NSTable
         spinner.style = NSProgressIndicatorStyle.SpinningStyle
         spinner.frame.origin.x = view.bounds.maxX/2 - spinner.bounds.size.width/2

-        let args = ["\(serial)",
+        let args = ["\(adbIdentifier)",
                     "\(apkPath)"]

         //["\(serial) install -r \"\(apkPath)\""]

Tested over WiFi (and USB), works well.

I noted some more problems related to using the device's serial instead of the ADB identifier. For example:

// Device.swift:82
        ShellTasker(scriptFile: "getResolutionForSerial").run(arguments: ["\(self.serial!)"], isUserScript: false) { (output) -> Void in
            let res = output as! String

            if res.rangeOfString("Physical size:") != nil {
                self.resolution = self.getResolutionFromString(output as! String)
            } else {
                println("Awkward. No size found. What I did find was \(res)")
            }

        }

Which consequently logs:

+error: device not found
Awkward. No size found. What I did find was 
is nil
is nil

Perhaps self.adbIdentifiershould be used instead of self.serial here as well?

If you want I can prepare a PR but I don't feel too comfortable changing so many parts (basically every place where ShellTasker is called). What do you think?

@jlhonora
Copy link
Contributor

jlhonora commented Jun 2, 2015

Here's a diff that makes it work over WiFi: master...jlhonora:master

Tested APK install, screenshot, video recording and bug report script.

  • Can anyone try it with a Bluetooth device? I don't have any at hand.
  • @mortenjust , I couldn't find any contribution guidelines. Are there any? Does this fit as a pull request?

@Dibel
Copy link
Contributor

Dibel commented Jul 12, 2015

@jlhonora Thanks for your patch, it works fine with Moto 360 via bluetooth debug, including screenshot, recording(need tiny changes in the processing script) and bug report.

@jlhonora
Copy link
Contributor

@Dibel Great! Could you elaborate on the changes for the processing script?

@Dibel
Copy link
Contributor

Dibel commented Jul 13, 2015

@jlhonora Yeah, but the change is for Moto 360's resolution (320x320). I don't know why the original command can't work.

diff --git a/AndroidTool/startRecordingForSerial.sh b/AndroidTool/startRecordingForSerial.sh
index 04f6d5a..cf80486 100644
--- a/AndroidTool/startRecordingForSerial.sh
+++ b/AndroidTool/startRecordingForSerial.sh
@@ -18,7 +18,7 @@ chara=$($adb -s $serial shell getprop ro.build.characteristics)
 if [[ $chara == *"watch"* ]]
 then
     echo "Recording from watch..."
-    $adb -s $serial shell screenrecord --o raw-frames /sdcard/screencapture.raw
+    $adb -s $serial shell screenrecord --size 320x320 --o raw-frames /sdcard/screencapture.raw
 else
     echo "Recording from phone..."

@mortenjust
Copy link
Owner

If anyone wants to contribute with a pull request that can solve this for all Android Wear screen sizes, I'd be happy to merge it in. Thanks!

@jlhonora
Copy link
Contributor

Great. @Dibel, I have some changes that I'd like you to try in a real device, if that's possible. Let's talk via email (joseluishonorato at gmail) and I'll walk you through. Thanks in advance.

@Dibel
Copy link
Contributor

Dibel commented Oct 1, 2015

@mortenjust @jlhonora Tested OK on El Capitan with Moto 360. And I also migrated the app to Swift 2 to compile it on Xcode 7.

I've created a pull request #67, but please double-check it due to the huge changes.

@mortenjust
Copy link
Owner

Thanks! Went into 1.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants