Search code examples
androidshellscriptingtororbot

How would I stop something that was started by an app for itself without stopping the app?


Note: I'm fairly new to linux/android when it comes to using the shell and commands/scripting, so if I've given some unrelevant information, or I'm trying to do something not possible, please tell me what's not relevant and why something is not possible and explain anything else to help me become better at this.


I'm trying to make a script that stop's Orbot's Tor network automatically when I exit from the Orfox app. So far, I have most of the coding down except for the stopping part for Tor. I believe there is something I can use in a shell script that would stop the Tor network right?

Currently, my script uses the command

# am force-stop org.torproject.android

to stop the app (to stop the Tor network), but I know that can't be the only way...


I know that when I press the Start button (within the Orbot app) or open up Orfox, it starts up the Tor network... When using

# ps | grep torproject

2 times (before and after starting Tor), I found that

  • u0_a291 11209 1 23092 15712 sys_epoll_ b68ecf18 S /data/data/org.torproject.android/app_bin/tor

shows up only when Tor is on.

I also found that after using

# ps | grep u0_a291

(the same way as the last command) that two shell's are started:

  • u0_a291 11150 8783 3780 1336 pipe_wait b6d9d0ac S sh

  • u0_a291 11212 8783 3780 1340 pipe_wait b6dec0ac S sh

only when tor is on.


I'm assuming some of the commands running through one or both of the shell's will give me a hint as to what commands I may need in order to stop the tor network in my script, but I have no idea how to view them or if I can. Is there a way to view them, or maybe I'm going about trying to find out how to stop Tor in the wrong way? So help me out guys, please.



Solution

  • I figured out what it was after all, and I didn't need any of the information that I provided... facepalm

    I found out what the service and intent action I needed by looking at the base.apk (in /data/app/org.torproject.android) as an archive. I looked at the AndroidManifest.xml like a text file and found the service and it's intent action to be

    • .service.TorService
    • org.torproject.android.intent.action.Start

    I concluded my script by using this to stop the tor service... I bet this might help someone else out in the future.

    # am stopservice -n org.torproject.android/.service.TorService -a org.torproject.android.intent.action.START