Publish libsu 6.0.0

This commit is contained in:
topjohnwu 2024-06-27 17:26:51 -07:00
parent 9d245f0587
commit 785fdf5dd6
2 changed files with 22 additions and 13 deletions

View File

@ -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

View File

@ -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<>();