Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

notes on setting up from linux #1

Open
dominictarr opened this issue May 24, 2016 · 11 comments
Open

notes on setting up from linux #1

dominictarr opened this issue May 24, 2016 · 11 comments

Comments

@dominictarr
Copy link

I'm on ubuntu, after messing around loads trying to install adb from google's site (and it not even working) I realized I could use apt-get

sudo apt-get install android-tools-adb android-tools-fastboot

https://developer.mozilla.org/en-US/docs/Archive/Firefox_OS/Debugging/Installing_ADB says it's obselete but hey it worked.

you'll need to switch your phone into developer mode.
on my phone, that means knowing a cheat code.
http://www.androidcentral.com/how-enable-samsung-galaxy-s5-developer-options

then plug in phone and adb devices (you might need to auth something on your phone)
if that lists something you are ready.
adb shell gets you to a command line (except most of the regular tools arn't there)
adb push copies. my phone didn't have tar so I had to copy the opened files
with adb push ./dir /data/local/tmp/dir that takes ages.

but it can't copy symlinks, but luckly we don't need symlinks, can just delete them.

this script lists all symlinks under the current directory, then delete them.

var pull = require('pull-stream')
var glob = require('pull-glob')
var para = require('pull-paramap')
var fs = require('fs')

pull(
  glob((process.argv[2] || process.cwd())+'/**'),
  para(function (file, cb) {
    fs.lstat(file, function (err, stat) {
      if(!stat.isSymbolicLink()) cb()
      else cb(err, file)
    })
  }),
  pull.filter(Boolean),
  pull.drain(console.log)
)

that is what i did @mixmix
I havn't figured out how to run it in the background yet (have to be connect to a adb shell session, but once we have that we'll have this running on a phone!)

@dominictarr
Copy link
Author

we can probably adapt this to get an apk: https://github.com/jxcore/jxcore-cordova

@dominictarr
Copy link
Author

okay so looking more deeply into this, we unfortunately cannot create a child process from cordova.
https://developer.android.com/guide/components/fundamentals.html

I did some experiments with: https://github.com/petervojtek/cordova-plugin-shell-exec
and could run commands like ls but not the node command. I also tried with https://github.com/jackpal/Android-Terminal-Emulator and had the same problem. I can only run those commands via adb shell which isn't gonna work...

the conclusion I'm coming to, is that we need to make a java binding for node (it doesn't need any functions, though, just start node and pass in cli arguments. the only thing is it's gotta run in the same process)

@dominictarr
Copy link
Author

Okay, I did some more digging here... at least, I figured out a hello world that has C++ inside of Java.
https://github.com/dominictarr/hello-jni
next step is figure out how to build node as a library instead of an executable

@dominictarr
Copy link
Author

some resources that might be useful:

@dominictarr
Copy link
Author

just saw this: https://github.com/brodybits/java-node it's a java binding to node, so maybe we can use that?

@gardner
Copy link
Owner

gardner commented May 27, 2016

I started creating a cordova plugin that interfaces with sbot/patchwork: https://github.com/gardner/cordova-plugin-patchwork

It needs more work to be functional. It's on one of the burners (i think in the back).

@dominictarr
Copy link
Author

@gardner but how does it work? I don't see anything that starts the sbot process

@gardner
Copy link
Owner

gardner commented May 27, 2016

It hasn't been tested yet and currently the code just runs find in hopes of learning more about the file structure. It's going to try to run patchwork. Check it out: https://github.com/gardner/cordova-plugin-patchwork/blob/master/src/android/Patchwork.java#L61

EDIT: Pointing to the correct line.

@dominictarr
Copy link
Author

does that execute a process? this was the docs I was able to find:
http://www.qnx.com/developers/docs/660/index.jsp?topic=%2Fcom.qnx.doc.web_inspector%2Ftopic%2Fcordova_exec.html

On Fri, May 27, 2016 at 6:38 PM, Gardner Bickford notifications@github.com
wrote:

It hasn't been tested yet and looking at the code it looks like it would
need more path information. It's going to try to run patchwork. Check it
out:
https://github.com/gardner/cordova-plugin-patchwork/blob/master/www/patchwork.js#L8


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#1 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAP1Lg7aAEU3GZzgHzzJPpHVudzrnGSpks5qFpFsgaJpZM4IlDoA
.

@gardner
Copy link
Owner

gardner commented May 27, 2016

Sorry, I updated my comment, it was pointing at the wrong line. The line is in Patchwork.java (line 61)
p = Runtime.getRuntime().exec("/system/bin/find .");

@dominictarr
Copy link
Author

I tried this approach, but I could only run the built in tools and not a node process... though, if node is part of the same apk then maybe it's owned by the same user and then it works?

I couldn't figure out what path your apk contents ends up in

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

No branches or pull requests

2 participants