mirror of
https://github.com/topjohnwu/libsu.git
synced 2024-11-23 03:59:43 +00:00
Publish libsu 6.0.0
This commit is contained in:
parent
9d245f0587
commit
785fdf5dd6
12
CHANGELOG.md
12
CHANGELOG.md
@ -1,11 +1,21 @@
|
||||
## 5.3.0
|
||||
## 6.0.0
|
||||
|
||||
(5.3.0 release notes are merged into 6.0.0)
|
||||
|
||||
- [core] New API `Shell.Builder.setCommands(String...)`
|
||||
- [core] New API `Shell.submitTask(Task)`
|
||||
- [core] New API `Shell.Job.shellDied()`
|
||||
- [core] New internal task scheduling implementation
|
||||
- [core] Remove deprecated `Shell.sh/su` methods
|
||||
- [core] Deprecate `FLAG_REDIRECT_STDERR`
|
||||
- [service] Fix support on pre-6.0 devices
|
||||
- [service] Fix crashes on some LG devices
|
||||
|
||||
### Migration Guide
|
||||
|
||||
- Usage of `Shell.sh/su` methods should be directly replaced with `Shell.cmd`. If you only want to run certain jobs if the shell is running as root, manually check with `Shell.isRoot()` before creating the job.
|
||||
- The behavior of `FLAG_REDIRECT_STDERR` changed and usage is deprecated. Setting `FLAG_REDIRECT_STDERR` in `Shell.Builder.setFlags(int)` will start to internally enable `Shell.enableLegacyStderrRedirection` as a best-effort backwards compatibility support to emulate its behavior. Please note that the new `Shell.enableLegacyStderrRedirection` flag controls the behavior of the entire program, NOT on a per-shell basis as it used to be. If you want to redirect STDERR to STDOUT, please switch over to setting the same output list for both STDOUT and STDERR with `Shell.Job.to(List, List)` as soon as possible.
|
||||
|
||||
## 5.2.2
|
||||
|
||||
- [service] Disable `dex2oat` when loading trampoline JAR
|
||||
|
23
README.md
23
README.md
@ -24,7 +24,7 @@ repositories {
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
dependencies {
|
||||
def libsuVersion = '5.3.0'
|
||||
def libsuVersion = '6.0.0'
|
||||
|
||||
// The core module that provides APIs to a shell
|
||||
implementation "com.github.topjohnwu.libsu:core:${libsuVersion}"
|
||||
@ -52,23 +52,21 @@ public class SplashActivity extends Activity {
|
||||
// Set settings before the main shell can be created
|
||||
Shell.enableVerboseLogging = BuildConfig.DEBUG;
|
||||
Shell.setDefaultBuilder(Shell.Builder.create()
|
||||
.setFlags(Shell.FLAG_REDIRECT_STDERR)
|
||||
.setTimeout(10)
|
||||
);
|
||||
.setFlags(Shell.FLAG_MOUNT_MASTER)
|
||||
.setInitializers(ShellInit.class)
|
||||
.setTimeout(10));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// Preheat the main root shell in the splash screen
|
||||
// so the app can use it afterwards without interrupting
|
||||
// application flow (e.g. root permission prompt)
|
||||
showSplashScreen();
|
||||
// As an example, preload the main root shell in the splash screen
|
||||
// so the app can use it afterwards without interrupting application
|
||||
// flow (e.g. waiting for root permission prompt)
|
||||
Shell.getShell(shell -> {
|
||||
// The main shell is now constructed and cached
|
||||
// Exit splash screen and enter main activity
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
exitSplashScreen();
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -95,8 +93,9 @@ boolean ok = result.isSuccess(); // return code == 0?
|
||||
// Async APIs
|
||||
Shell.cmd("setenforce 0").submit(); // submit and don't care results
|
||||
Shell.cmd("sleep 5", "echo hello").submit(result -> updateUI(result));
|
||||
Future<Shell.Result> futureResult = Shell.cmd("sleep 5", "echo hello").enqueue();
|
||||
|
||||
// Run tasks and output to specific Lists
|
||||
// Run commands and output to specific Lists
|
||||
List<String> mmaps = new ArrayList<>();
|
||||
Shell.cmd("cat /proc/1/maps").to(mmaps).exec();
|
||||
List<String> stdout = new ArrayList<>();
|
||||
|
Loading…
Reference in New Issue
Block a user