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

implement backup & reboot functionality #2

Open
fiws opened this issue Dec 24, 2013 · 1 comment
Open

implement backup & reboot functionality #2

fiws opened this issue Dec 24, 2013 · 1 comment

Comments

@fiws
Copy link
Contributor

fiws commented Dec 24, 2013

these features would be nice. A possible API:

Backup

client.backup(serial, options, callback)
where the options could look like this:

{
  out: "backup.ab",
  apk: true,
  all: false,
  shared: false,
  system: true,
  packages: []
}
adb backup -f backup.ab -all (...)

Reboot

client.rebootRecovery(serial, callback)
client.rebootBootloader(serial, callback)

adb reboot [bootloader|recovery]

I would like to contribute, but I can't get my head around coffescript.

@sorccu
Copy link
Member

sorccu commented Dec 25, 2013

Reboot is a bit difficult as I'm not sure what to do about losing the connection to the device when the device reboots. Should the callback return when ADB reports success for the reboot command, or when the device becomes accessible again? Is ADB even available in recovery/bootloader mode?

Backup should also be doable, but it might take a while to implement it as we don't need it here at work right now...

Our code is CoffeeScript mainly because it makes writing callback-heavy code more enjoyable. But you're right, it takes a while to get used to it. If it helps, try running grunt coffee and reading the generated JS source code in the lib folder. You can also run grunt coffeelint to make sure there's nothing too obviosly wrong with your code (it won't catch everything however). And finally if grunt test succeeds, at least you will not have broken anything!

Personally I find that the biggest differences are that curly braces are always left out, parentheses can be omitted (e.g. foo(a, b, bar(c, d)) can be written as foo a, b, bar c, d), function(a, b) { foo } becomes (a, b) -> foo and the last expression in a function becomes its return value. After npm install -g coffee-script you can run any .coffee file via coffee foo.coffee, just like you'd do node foo.js normally. There's a small example over at https://github.com/CyberAgent/adbkit-logcat that might help illustrate a few of the differences. Also, CoffeeScripters are in high demand right now, couldn't hurt learning it ;)

Alternatively you could just write your additions in JavaScript, as .js files can be require()d normally from CoffeeScript. But I would really prefer if you didn't do that as it would make everything much more difficult to maintain.

As for implementing a new API method, aside from the complexities introduced by rebooting, the basic idea is that you create src/adb/command/host-transport/newcommand.coffee and then expose it via src/adb/client.coffee. Tests in test/adb/command/host-transport/newcommand.coffee would also be highly appreciated, but sometimes these things can be a bit difficult to test.

Anyway we'd really appreciate contributors so I hope you can look beyond the language!

paciops added a commit to paciops/adb-interface that referenced this issue Nov 12, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants