SuFile
will now follow symbolic links (as it always should)SuFile.length()
will no longer report block total size on block devices (as it shouldn't in the first place)SuFileInputStream
andSuFileOutputStream
now supports I/O on all file formats, including character files (e.g. files in/sys
and/proc
), and also outputs to block devices correctly
- Make
SuFile.isBlock()
,SuFile.isCharacter()
,SuFile.isSymlink()
public
- Tons internal optimizations to improve performance
- Rewrite shell backed I/O from scratch
- Added more detailed Javadoc for
SuFile
SuFile
is no longer a wrapper class aroundFile
. Calling the constructor directly will directly open a shell backedFile
instance. This change is due to the fact thatFile
wrapper class causes some issues in methods likeFile.renameTo(File)
.
- Introduce new helper methods:
SuFile.open(...)
: depending on whether the global shell has root access or not, these methods will return either a normalFile
instance orSuFile
. This is the same behavior as the previousSuFile
constructor (the only difference is thatSuFile
used to wrap around the instance).
- Update proguard rules to support R8 full mode
- Update gradle scripts to build proper Javadoc with links to Android reference
- Fix a possible NPE in
SuFile
- Publish aggregated Javadoc
- Strip out all deprecated APIs
Starting from 2.3.0, you shall stop using Shell.Container
, including ContainerApp
.
- Fix
Shell.Initializer
NPE on old API levels
Shell.Config.setContainer()
is deprecated. libsu will handle the global shell without any configurationsContainerApp
is deprecated. The class is now just a stockApplication
- When using high level APIs (
Shell.su
,Shell.sh
,Shell.rootAccess()
),NoShellException
is now silently suppressed to prevent unexpected crashes. Should no shell is possible to be created,Shell.su/sh
will immediately return aShell.Result
with no output and show failure;Shell.rootAccess()
will simply returnfalse
.
Starting from this release, libsu
is modularized into 3 parts: core
, io
, and busybox
.
If you only use the shell implementation, you just need com.github.topjohnwu.libsu:core
. com.github.topjohnwu.libsu:io
and com.github.topjohnwu.libsu:busybox
are optional: include the former to use the I/O wrapper classes, and the latter to bundle the prebuilt busybox binaries with your app. The old com.github.topjohnwu:libsu
can still be used, but all 3 components will be pulled in.
- Clean up potential garbage output before testing shell
- Prevent possible
Shell.waitAndClose(int, TimeUnit)
race conditions
- Add support for multiple
Shell.Initializer
s: new methodsvoid Shell.Config.setInitializers(...)
andvoid Shell.Config.addInitializers(...)
are added;void Shell.Config.setInitializer(Initializer.class)
is deprecated.
- Remove the class
BusyBox
. To install the prebuilt busybox, addcom.github.topjohnwu.libsu:busybox
as a dependency, and registerBusyBoxInstaller
as an initializer (Shell.Config.addInitializers(BusyBoxInstaller.class);
) - Introduce a new flag:
Shell.FLAG_USE_MAGISK_BUSYBOX
. With this flag set,/sbin/.magisk/busybox
will be prepended toPATH
, so the shell will use Magisk's internal busybox.
- Fix a bug that could cause
new SuFile(parent, name)
to fail
- When creating
SuFileInputStream
/SuFileOutputStream
/SuRandomAccessFile
with a character file, it will throwFileNotFoundException
instead of failing silently. Character file I/O is not possible with shells, useShell.su("cat <chr_file>").exec().getOut()
instead.
- Add
boolean Shell.waitAndClose(long, TimeUnit)
andvoid Shell.waitAndClose()
. You can now wait for all tasks to finish before closing the shell instance. - Add
Shell.Config.setTimeout(long)
. Use it to set the maximum time for waiting a new shell construction. The default value is 20 seconds.
Shell.isAlive()
method is updated to get process status directly via reflection rather than the traditionalProcess.exitValue()
exception handling. This optimization significantly reduces the overhead when switching between Shell tasks.
- The 1.x version APIs are completely removed
- Retrolambda is removed, you should start using AGP 3.0.0+ which comes with official Java 8 desugaring
- Return proper list in
Shell.Result.getErr()
- Calling
submit
inPendingJob
used to end up calling the overriddenexec
instead ofexec
inJobImpl
. Proxy through a private method inJobImpl
to prevent changed behavior ofJobImpl
subclasses. - Even though the parameters of
Shell.Job.add(...)
is labeled@NonNull
, it is still possible that developers still pass innull
and cause NPE. Checknull
before proceed any further. - Fix a bug that constructed shell instances weren't cached in the container when created using fallback methods (e.g. no root -> fallback to non-root shell). This would cause infinite loop when no root is available.
- Prevent
IllegalStateException
if the user provide a filter accepting.
or..
inSuFile.list()
family methods.