We have moved to a new Sailfish OS Forum. Please start new discussions there.
8

How do I connect to Android with adb or send shell commands? [answered]

asked 2013-12-30 01:47:46 +0200

Nux gravatar image

updated 2014-01-05 14:11:29 +0200

Fuzzillogic gravatar image

OK so I was able to run logcat. I still need to run commands in Android context. I've noticed there is adb in the device, but ./adb devices list no items and other commands (including the shell command) show "error: device not found".

Connecting to running android (alien) VM would be nice, any way of running shell command would be sufficient for my current needs.

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by anandrkris
close date 2014-12-18 11:10:33.577055

3 Answers

Sort by » oldest newest most voted
14

answered 2014-01-05 03:03:27 +0200

jusic gravatar image

updated 2014-01-05 08:22:20 +0200

Nux gravatar image

I was fiddling around with this and I managed to get adb to work on the device. I'm running SailfishOS 1.0.2.5.

Append the following lines to /opt/alien/system/build.prop (as root):

persist.service.adb.enable=1
service.adb.tcp.port=5555

Then, restart Alien Dalvik with systemctl restart aliendalvik.service. Now, you should see an adbdprocess running:

[root@localhost bin]# ps aux | grep adb
shell    15478  0.0  0.0   3448     4 ?        Ssl  02:25   0:00 /opt/alien/system/root/sbin/adbd
[root@localhost nemo]# lsof -p 15478 | grep android_adb
adbd    15478 shell    9u   CHR      10,26           3617 /dev/android_adb

After this, run as root:

[root@localhost bin]# /opt/alien/system/bin/adb kill-server
[root@localhost bin]# /opt/alien/system/bin/adb devices    
* daemon not running. starting it now on port 5038 *
* daemon started successfully *
List of devices attached 
emulator-5554   device

[root@localhost bin]# 

Edit: Cut out stuff that are not needed.

edit flag offensive delete publish link more

Comments

Great! Only first 2 are needed (persist.service.adb.enable=1, and service.adb.tcp.port=5555). Then restart and adb kill-server and commands start to work. Thank you so much :-)!

Nux ( 2014-01-05 07:59:51 +0200 )edit
1

And I solved your problem of remote access :-). On your PC go to "platform-tools" (I assume you have Android SDK installed). Then simply run: adb.exe connect 192.168.1.102 (replace the IP with your Jolla IP). Open monitor.bat and you should now see "unknown-alien_jolla_bionic..." B-).

Nux ( 2014-01-05 08:19:51 +0200 )edit

I've changed your answer. I hope you don't mind.

Nux ( 2014-01-05 08:23:05 +0200 )edit
1

Neat! But running adb server on device on port 5555 leaves adb wide open to internet. That can be blocked (iptables) but I reckon it's better not to have a adb server on device at all, just the daemon. Ssh port forwarding on port 5037 does the trick, but I can't get adbd running stand alone... Hints?

Fuzzillogic ( 2014-01-05 15:51:38 +0200 )edit

@Fuzzillogic: That is a clear concern, I just use this in a closed wifi. Probably you can dig deeper via alien_init, this is how I discovered the plausible flags to enable adbd: [nemo@localhost ~]$ strings /opt/alien/system/bin/alien_init | grep adb.

jusic ( 2014-01-06 01:52:19 +0200 )edit
0

answered 2014-01-03 15:05:07 +0200

simo gravatar image

Alien Dalvik is told not to be an emulator on Jolla, so there might be no devices listed. However, it's still It's a register based processing VM for running apps - You can try adb -e shell (I don't think this does anything either, but worth testing for your purpose)

Just to make sure: I suppose you've already done sudo apt-get install android-tools-adb

edit flag offensive delete publish link more

Comments

1

apt-get? You mean on my PC? I do have Android SDK installed on my PC, but Alien Dalvik is not "seen" by any tools on the PC (in neither of USB connections types). But that's not my issue here. My goal is to send information to intents from inside Jolla phone (e.g. send URL to Android browser).

Nux ( 2014-01-04 04:14:47 +0200 )edit
0

answered 2014-06-22 00:54:47 +0200

jake9xx gravatar image

Dunno if it worked before but now you need to do some extra magic.

  1. shutdown service
  2. edit build.prop
  3. start service you should see: [root@Jolla nemo]# netstat -an | grep 5555 tcp 0 0 0.0.0.0:5555 0.0.0.0:* LISTEN

and then on the host: 1. adb kill-server 2. adb connect 192.168.2.15

and voilá adb devices returns: List of devices attached 192.168.2.15:5555 device

adb logcat & adb install at least seem to work :)

edit flag offensive delete publish link more

Comments

Does it still works in 2.1.0.9? Can't get it working for some reasons..

ElderOrb ( 2017-02-25 12:30:58 +0200 )edit

I got it working on SFOS 2.1.1.26 by editing the build.prop as described above, then launching adbd manually using chroot /opt/alien /sbin/adbd.

raimue ( 2017-09-01 16:57:10 +0200 )edit

In case anyone gets stuck trying to set this up (or I get stuck again, idk): - if you're seeing facing "unauthorized" next to your phone on devices list, you need to ssh into your phone and manually update adbkeys list - chroot into /opt/alien is not a good idea, because environmental variables are not being propagated, so even though shell works, you can't install anything and device is not being recognized properly, it took me way too long to figure it out. How to solve this? You can copy over random lines of code from /opt/alien/system/script/start_alien.sh. I already did this for you though:

SCRIPT_DIR=/system/script
source $SCRIPT_DIR/platform_envsetup.sh
source $SCRIPT_DIR/platform_extraenvsetup.sh

export ANDROID_ROOT=/system
export ANDROID_DATA=/data

export ANDROID_ASHMEM_DIR=$ANDROID_DATA/ashmem
export ANDROID_SOCKET_DIR=$ANDROID_DATA/socket
ANDROID_SDCARD=$ANDROID_DATA/sdcard
export EXTERNAL_STORAGE=$ANDROID_SDCARD
export MEDIA_STORAGE=$ANDROID_DATA/media
export DOWNLOAD_CACHE=$ANDROID_DATA/cache
export ANDROID_STORAGE=/storage

export PATH=$ANDROID_ROOT/vendor/bin:$ANDROID_ROOT/sbin:$ANDROID_ROOT/bin:$ANDROID_ROOT/xbin:$PATH

FRAMEWORK=$ANDROID_ROOT/framework
export BOOTCLASSPATH=$FRAMEWORK/core.jar:$FRAMEWORK/conscrypt.jar:$FRAMEWORK/okhttp.jar:$FRAMEWORK/core-junit.jar:$FRAMEWORK/bouncycastle.jar:$FRAMEWORK/ext.jar:$FRAMEWORK/framework.jar:$FRAMEWORK/framework2.jar:$FRAMEWORK/telephony-common.jar:$FRAMEWORK/voip-common.jar:$FRAMEWORK/mms-common.jar:$FRAMEWORK/android.policy.jar:$FRAMEWORK/services.jar:$FRAMEWORK/apache-xml.jar:$FRAMEWORK/webviewchromium.jar

Save it as, idk, /opt/alien/alien_env. Now, run adbd this way: chroot /opt/alien /bin/bash -c "source /alien_env && adbd" (save it as a script somewhere, be lazy just like me).

Now you can deploy shitcode to AlienDalvik with Android Studio: https://i.imgur.com/QuK54g8.png

pisarz1958 ( 2017-10-07 00:19:56 +0200 )edit

How do I manually update adbkeys list please? Where are the relevant folders located on the Jolla?

rasmarc ( 2017-10-31 15:47:50 +0200 )edit
1

You need to put contents from ~/.android/adbkey.pub (on Windows, it's C:\Users\[username]\.android\adbkey.pub) into /opt/alien/data/misc/adb/adb_keys file on your Jolla. You may need to create it first.

pisarz1958 ( 2017-10-31 22:23:35 +0200 )edit

Question tools

Follow
7 followers

Stats

Asked: 2013-12-30 01:47:46 +0200

Seen: 13,167 times

Last updated: Jun 22 '14