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

client.shell(serial, command[, callback]) loose session #65

Open
KovganIV opened this issue Mar 7, 2017 · 9 comments
Open

client.shell(serial, command[, callback]) loose session #65

KovganIV opened this issue Mar 7, 2017 · 9 comments

Comments

@KovganIV
Copy link

KovganIV commented Mar 7, 2017

client.shell(serial, command[, callback]) loose current shell session. How I can execute next commands?

 return client.shell(device.id, 'sqlite3 /data/data/com.android.providers.settings/databases/settings.db')
        .then(adb.util.raw)
        .then(function(raw) {
          var oneCall = false;
          raw.on('data', function(chunk) {
            console.log(chunk.toString());
            if (!oneCall) {
              raw.write('UPDATE secure SET value = \"8A791979883A0000\" where name=\"android_id\";');
              client.shell(device.id, 'UPDATE secure SET value = \"8A791979883A0000\" where name=\"android_id\";')
              oneCall = true;
            }
          });
        });
@KovganIV
Copy link
Author

KovganIV commented Mar 7, 2017

Value not updated
It mean that stream or shell cant write something

@sorccu
Copy link
Member

sorccu commented Mar 7, 2017

There is no adb.util.raw. Remove that line.

Also seriously just read the sqlite docs... there's a really easy way to run a query and getting the result.

@KovganIV
Copy link
Author

KovganIV commented Mar 7, 2017

You know another ways to execute sqlite3 on android emulator and work with it on nodejs code?
I search any methods, but I think that adbkit is a best way. And for my app I need root access, because need change system settings.
I need to make final step. How send command without loosing adb shell session?

@sorccu
Copy link
Member

sorccu commented Mar 7, 2017

Read the sqlite docs. There's a very easy way to make it work with readAll(). You literally have to change one line in your original version. It's not an adbkit issue, you just have to change the sqlite command.

@KovganIV
Copy link
Author

KovganIV commented Mar 7, 2017

Can I write data to raw stream? I think that it does not work.
All in this code work. Only UPDATE command does not work. It's not sqlite problem, query is right. I check it in command line adb shell.

@KovganIV
Copy link
Author

KovganIV commented Mar 7, 2017

I still in / catalog, but sent "cd /root/". Adbkit loose session.
How I can execute commands witout session loose?

return Promise.map(devices, function(device) {
      return client.shell(device.id, 'cd /root/')
        .then(adb.util.readAll)
        .then(function(output) {
          return client.shell(device.id, 'ls')
            .then(adb.util.readAll)
            .then(function(output) {
              console.log(output.toString());
            });
        });
    })

@sorccu
Copy link
Member

sorccu commented Mar 7, 2017

It's not adbkit. That's how all shells work. On your own computer, if you open two shell windows, and type cd /root in one window, and then ls in the other window, obviously it's not going to show you what /root contains (unless it was already there).

@KovganIV
Copy link
Author

KovganIV commented Mar 7, 2017

Ok, now I understand.
How I can send commands sequentially? I need simple code example, please.

@sorccu
Copy link
Member

sorccu commented Mar 7, 2017

Run them in a single .shell(). Like .shell(device.id, 'echo 1 && echo 2').

Please do your own work and stop wasting busy people's time. I will NOT write sample code for you.

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