Git Product home page Git Product logo

promise-android-tools's People

Contributors

amartinz avatar dependabot[bot] avatar flohack74 avatar gsilvapt avatar maciek134 avatar mariogrip avatar neothethird avatar strazzere avatar universalsuperbox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

promise-android-tools's Issues

ES6

Move to ES6 for the awesome of it all. CommonJS who?

Publish latest on npm / enable installing from repo

Thanks for all the great work on the conversion to typescript - this actually cleared up many things on my side.

Was wondering if we could get a push to the npm repository of the latest, at there seems to be a version/code mismatch.

I can submit a PR for the following changes as well;

strazzere@1939df6

Though essentially I added rollup back as a dev dependency, added it to the build command since the main entry point in the package.json has no was to be created. Then I added the prepare script which allows a user to do a direct npm install https://github.com/theuser/therepo.

Add support for more fastboot flash flags

  --disable-verity                         Set the disable-verity flag in the
                                           the vbmeta image being flashed.
  --disable-verification                   Set the disable-verification flag in                                           the vbmeta image being flashed.

Refactor adb.push() and adb.pushArray() functions

adb push already supports multiple files. These functions could be a lot leaner with a lot less code. It is of course imperative that we keep the option to report the progress at set intervals.

Re-design module.js to incorporate generic functions

To accomplish things like detecting any connected device (eg. ubports/ubports-installer#902), we could reshape module.js to be its own class with instances of all available tools as properties. That way we could create some convenience functions like a tool-agnositc waitForDevice() using something along the lines of Promise.race([adb.waitForDevice(),fastboot.waitForDevice(),heimdall.waitForDevice()]) and returning a string describing the connected mode. You could also go further and attempt os detection and device name detection.

Implement child_process.spawn for long-running tasks

For long-running tasks, child_process.exec() is not suitable, because it can lead to process termination when the stdout buffer is full. We also do not have access to the stdout as it is being generated, making it impossible to make use of things like adb push progress reporting and requiring dirty hacks.

Batching through dataloader?

We might think about batching execs (across tools?) through dataloader to make sure the device isn't bombarded with too many things at once.

Create a super-class

There are some things shared among all tools. Creating a super-class would allow us to get rid of some duplicate (testing-)code and improve maintainability.

Issue with `_withEnv` implementation within electron environment

This took quiet a while to track down and implement a work around - though I must admit, it feels like there should be another way to do this. Please take this report with a grain of salt as I may be missing the actual underlying issue as it only reproduces in some environments.

While attempting to do a simple adb operation like this following;

 const { Adb } = require("promise-android-tools")
 adb = new Adb({serialno:"12345" })
 await adb.push(['tsconfig.json'], '/data/local/tmp/derp')

The package would spit out a TypeError: Illegal Instruction on the line this.signal.throwIfAborted() inside Tool._withEnv.

This does not reproduce when running solely in a node environment, the this object appears fine. However in the electron environment where it fails, the this object appears to be a "less than deep" clone, or the this context appears to get mangled somehow - this part is a bit unclear to me.

I believe this is based on how Object.create doesn't actually run the constructor. Tested a few other methods for deep cloning the object (Object.assign({}, this), { ... this}, ...) - thought none of them seemed to solve them. Since the type is unpredictable (Adb, FastBoot, Heimdall) it seemed best to try to reflectively call this's own type constructor and just pass this to it. This resulted in the following patch;

diff --git a/src/tool.ts b/src/tool.ts
index c19b017..c1b678b 100644
--- a/src/tool.ts
+++ b/src/tool.ts
@@ -227,7 +227,8 @@ export abstract class Tool extends Interface {
 
   /** returns clone with variation in env vars */
   public _withEnv(env: NodeJS.ProcessEnv): this {
-    const ret = Object.create(this);
+    // @ts-ignore-next-line
+    const ret = new this.constructor(this);
     ret.extraEnv = { ...this.extraEnv };
     for (const key in env) {
       if (Object.hasOwnProperty.call(env, key)) {

This does work for my usecase, and seemingly all other spawn commands I tried, though I honestly hate it due to the ts-ignore.

Hoping to potentially learn something here if anyone knows a better way to fix this issue, or if maybe I'm completely misunderstanding this issue. Whatever the solution, it would likely need to be applied to a few other spots which utilize the Object.create(this) pattern.

If the solution I found above seems the best fitting, I can always draft a PR to fix this and other instance with a bit of a commented explanation.

Cheers!

Unentagle error handling

It was a really stupid idea of mine to put error handling for the different tools into the common module. Split it to separate functions inside the respective modules.

JSDoc/Typedoc housekeeping

If someone is ever looking for something ✨ fun ✨ to do: The docs comments could use someone going through them and simplifying/standardizing them in a way that improves their usefulness and accessibility.

Finish heimdall support

Someone at Samsung decided it was a good idea to not follow standards, and i hope to god there is a special place in hell for them where they suffer eternal damnation. We can already get our own suffering on by preparing to support Heimdall.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.