mirror of
https://github.com/topjohnwu/libsu.git
synced 2024-10-07 01:03:22 +00:00
5.0 KiB
5.0 KiB
2.1.1
Bug fixes
- Fix a bug that could cause
new SuFile(parent, name)
to fail
Behavior Changes
- 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.
API Changes
- 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. - Deprecate
ContainerApp
. libsu can now automatically inject root shells directly into Application contexts without any configuration, soContainerApp
is no longer needed. This class will be removed in the next update.
2.0.3
Improvements
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.
API Changes
- 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
2.0.2
Fixes
- Return proper list in
Shell.Result.getErr()
2.0.1
Fixes / Improvements
- 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.
2.0.0
Massive API improvements! Nearly all APIs in 1.x.x versions are deprecated. A compatibility layer is created to make the migration easier for existing developers: your existing code will work with libsu
2.0.0 without any modifications.
However, the compatibility layer will be removed in a future update, please do update your code to utilize the new APIs since it is much cleaner and more flexible!
Incompatible API Changes
- Remove
readFully(InputStream, byte[])
andreadFully(InputStream, byte[], int, int)
fromShellUtils
.
Fixes / Improvements / Behavior Changes
- Global shell is now set before
Shell.Initializer
runs: this means you can now use high level APIs and root I/O classes in your initializer - No more
null
lists will be returned fromlibsu
: all methods will return empty lists if no output is available SuFile.list()
family methods shall return hidden files now (filenames starting with'.'
) (also fix #15)SuFile
will use the toolstat
in more methods for consistent results (fix #11)- No longer uses raw threads and
AsyncTask.THREAD_POOL_EXECUTOR
for running code in background threads, switch to an internalExecutorService
Shell.GetShellCallback.onShell(Shell)
will run on the main thread- Add Proguard rules to strip out logging code when minify and optimization (
proguard-android-optimize.txt
) is enabled - Lower
minSdkVersion
to 9
API 2.0 Migration
Note: The following list is ONLY to point out a brief direction for migration, check the examples and documentation to know the details!
- All configuration methods are moved to the nested class
Shell.Config
- Everything in
Shell.Sync
andShell.Async
is deprecated. Check the new APIs:Shell.su(...)
andShell.sh(...)
- New methods:
Shell.getCachedShell()
: A static method to obtain the cached global root shell from the container, or returnnull
of no active shell existsShell.isRoot()
: Check root access of a root instance (Note: static methodShell.rootAccess()
is used to check the global shell)Shell.Config.newContainer()
: construct a pre-configured shell container, used to simplify registering a container
- New classes:
Shell.Job
: represent a job that outputs to a single result object. You can chain additional operations, assign output destination, execute or submit the job.Shell.Result
: stores the result of aShell.Job
. Includes STDOUT/STDERR, and something not existing in 1.x.x: return codeShell.ResultCallback
: a callback interface to get the result when you submit aShell.Job
to background threads
- For
Shell.Initializer
: deprecateonShellInit(...)
andonRootShellInit(....)
; useonInit(Context, Shell)
instead: manually detect the shell status and handle Exceptions - Move
Shell.ContainerApp
out ofShell
to a separate classContainerApp
: easier to directly assign inAndroidManifest.xml