• Stars
    star
    282
  • Rank 145,640 (Top 3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Easy shell access for Android apps using RxJava.

RxShell

Build Download Coverage Status

A library that helps your app interact with shells on Android.

Quickstart

Include the library in your modules build.gradle file:

implementation 'eu.darken.rxshell:<insert-latest-release>'

Now your project is ready to use the library, let's quickly talk about a few core concepts:

  1. You construct a shell using RxCmdShell.builder().
  2. The shell has to be opened before use (shell.open()), which will launch the process and give you a RxCmdShell.Session to work with.
  3. Build your commands with Cmd.builder("your command").
  4. Commands are run with session.submit(command), cmd.submit(session) or cmd.execute(session).
  5. Remember to close() the session to release resources.

Examples

Single-Shot execution

If you pass a shell builder to the command it will be used for a single shot execution.

A shell is created and opened, used and closed.

Cmd.execute(...) is shorthand for Cmd.submit(...).blockingGet(), so don't run it from a UI thread.

Cmd.Result result = Cmd.builder("echo hello").execute(RxCmdShell.builder());

Reusing a shell

If you want to issue multiple commands, you can reuse the shell which is faster and uses less resources.

RxCmdShell.Session session = RxCmdShell.builder().build().open().blockingGet();
// Blocking
Cmd.Result result1 = Cmd.builder("echo straw").execute(session);
// Async
Cmd.builder("echo berry").submit(session).subscribe(result -> Log.i("ExitCode: " + result.getExitCode()));
shell.close().blockingGet();

The default shell process is launched using sh, if you want to open a root shell (using su) tell the ShellBuilder!

Cmd.Result result = Cmd.builder("echo hello").execute(RxCmdShell.builder().root(true));

Checking root access

// General info
new RootContext.Builder(getContext()).build().subscribe(c -> {/* c.getRoot().getState() */});
// Just root state
Root root = new Root.Builder().build().blockingGet();
if(root.getState() == Root.State.ROOTED) /* yay */

Used by

  • SD Maid, which was also the motivation for this library.

Alternatives

While this is obviously :^) the best library, there are alternatives you could be interested in:

More Repositories

1

sdmaid-public

SD Maid is an Android app that helps you manage files and apps.
835
star
2

reddit-android-appstore

https://www.reddit.com/r/Android/comments/50rafp/meta_we_have_an_app_wiki_with_over_700_apps_made/
Java
312
star
3

rootvalidator

Small Android app that checks the root state of your device.
Java
111
star
4

wakelock-revamp

Rewrite of https://github.com/d4rken/wakelock
Kotlin
76
star
5

gplay-batchtool

Automatically remove all entries from Google Play > My Apps & Games > Library
Java
57
star
6

fpv-dvca

An unofficial companion app for DJI's Digital FPV System.
Kotlin
48
star
7

mvp-bakery

Android MVP library with presenter retention via ViewModel and Dagger2 support.
Kotlin
42
star
8

myolib

Android Myo library with full data access and support for multiple Myos.
Java
38
star
9

myo-android-2048

The game 2048, playable with a Myo
Java
31
star
10

android-starter-v4

An Android template project (in Kotlin) with boilerplate and current patterns.
Kotlin
26
star
11

audiobug

A simple Android app to record audio through the microphone.
Java
19
star
12

ommvplib

One More MVP Lib.
Java
15
star
13

adsbfi-companion

Android app for adsb.fi
Kotlin
9
star
14

adsb-meta-tracker

ADS-B Meta Tracker tracks meta data for ADS-B tracker.
Kotlin
9
star
15

android-kotlin-starter-v2

Kotlin
9
star
16

wakelock

An Android app to manually aquire different types of wakelocks.
Java
8
star
17

android-appicondetective

An Android app that scans the icons provided by all installed apps and displays and shows icons that are out of order.
Java
8
star
18

jt-dpm8600-psu-mqtt

Use an ESP8266 to control a JT-DPM8600 power supply using MQTT.
C++
8
star
19

codeweek-android-chat

Starter Project
Kotlin
8
star
20

android-java-starter

An Android template project (in Java) to save time when starting a new app.
Java
8
star
21

bluemusic

An Android app that automates Bluetooth device specific actions such as volume adjustments.
Kotlin
7
star
22

airplanes-live-app

airplanes.live Android App
Kotlin
7
star
23

android-kotlin-starter

An Android template project (in Kotlin) to save time when starting a new app.
Kotlin
7
star
24

ublock-seo-spam

Block list for uBlock, removes spam results from search results.
6
star
25

capod-public

A companion app for AirPods on Android.
6
star
26

arduino-weather-station-v2

C
6
star
27

jbd-bms-mqtt

Use an ESP8266 to send data from a JBD BMS (AP21S001) to a MQTT broker
C++
6
star
28

android-fms

FMS
Java
5
star
29

FlowShell

A Kotlin Flow based (root) shell for Android.
5
star
30

android-call-logger

A simple called numbers logger.
Kotlin
4
star
31

adsb-companion

An Android app showing stats ADS-B stats.
Kotlin
4
star
32

d4rken

4
star
33

naughtylist

Custom adblock list
4
star
34

octi-sync-server-kotlin

Kotlin
3
star
35

android-screenshot-framer

A really dirty port of https://developer.android.com/distribute/tools/promote/device-art.html into a node.js script
JavaScript
3
star
36

chargepreserver

Java
2
star
37

battery-sound-full-remover

Java
2
star
38

nullkeyboard

Java
2
star
39

feeder-box-sensor

Arduino based temp/humidity sensor node.
C++
2
star
40

paragliding-companion

Android app to collect and manage paragliding flight logs.
Kotlin
2
star
41

backup-butler

A backup application for Android devices.
Kotlin
2
star
42

fmdn-tool

Kotlin
2
star
43

ghettoVCB

ghettoVCB
Shell
2
star
44

diagnosis

Java
1
star
45

google.issue.161245048

Kotlin
1
star
46

ffs-spotify

FFS Spotify is an Android app that kills and restarts the Spotify app when specific bluetooth devices connect
Java
1
star
47

rollkuchen

CSS
1
star