How the main shell works and how to configure it
masterlibsu uses a concept called the "main shell". For each process, there is a single globally shared "main shell" that is constructed on-demand and cached.
Important: You must set default configurations using Shell.setDefaultBuilder(...) before the main Shell instance is created (e.g., in a static block in your Application or Activity class).
To avoid blocking the application flow while waiting for root permission prompts, you can preload the main shell using Shell.getShell(callback) during a splash screen.
static {
// Set settings before the main shell can be created
Shell.enableVerboseLogging = BuildConfig.DEBUG;
Shell.setDefaultBuilder(Shell.Builder.create()
.setFlags(Shell.FLAG_MOUNT_MASTER)
.setInitializers(ShellInit.class)
.setTimeout(10));
}
// Preload the shell
Shell.getShell(shell -> {
// The main shell is now constructed and cached
exitSplashScreen();
});