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[])` and `readFully(InputStream, byte[], int, int)` from `ShellUtils`.
- No more `null` lists will be returned from `libsu`: 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 tool `stat` 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 internal `ExecutorService`
-`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` and `Shell.Async` is deprecated. Check the new APIs: `Shell.su(...)` and `Shell.sh(...)`
- New methods:
-`Shell.getCachedShell()`: A static method to obtain the cached global root shell from the container, or return `null` of no active shell exists
-`Shell.isRoot()`: Check root access of a root instance (Note: static method `Shell.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 a `Shell.Job`. Includes STDOUT/STDERR, and something not existing in 1.x.x: return code
-`Shell.ResultCallback`: a callback interface to get the result when you submit a `Shell.Job` to background threads
- For `Shell.Initializer`: deprecate `onShellInit(...)` and `onRootShellInit(....)`; use `onInit(Context, Shell)` instead: manually detect the shell status and handle Exceptions
- Move `Shell.ContainerApp` out of `Shell` to a separate class `ContainerApp`: easier to directly assign in `AndroidManifest.xml`
-`execSyncTask`, `execAsyncTask`, `createCmdTask`, and `createLoadStreamTask` is removed from the non-static APIs of `Shell`. These are implementation details that weren't supposed to be part of the API
### Behavior Changes
-`open` of `SuRandomAccessFile` now supports a new parameter, `mode`, just like the constructor of `RandomAccessFile`
-`onRootShellInit` of `Shell.Initializer` can now run in BusyBox environment if `BusyBox.setup(Context)` is invoked or `BusyBox.BB_PATH` is set before any `Shell` will be constructed
-`SuFile` will become a wrapper around standard `File` if no root is available
-`SuFileInputStream` and `SuFileOutputStream` will throw `FileNotFoundException` when no root is available, and opening with standard `FileInputStream` / `FileOutputStream` throws `FileNotFoundException`
-`Shell` will not be forcibly closed when an `Exception` is thrown in `Shell.Task.run`
### Improvements
- The `minSdkVersion` of `libsu` is actually 11, changed accordingly