Commit Graph

84 Commits

Author SHA1 Message Date
topjohnwu
9348c5bad9 Fix build script 2020-07-04 03:50:39 -07:00
topjohnwu
f6a2b1c882 Minor gradle script changes 2020-07-02 05:01:55 -07:00
topjohnwu
53904b0627 Use gradle magic to optimize resources 2020-07-02 04:02:20 -07:00
topjohnwu
ddc2f317ab Update dependencies 2020-06-29 03:58:19 -07:00
Shaka Huang
4b8e92f00a compile options should be set after evaulation process
Signed-off-by: Shaka Huang <shakalaca@gmail.com>
2020-06-27 04:58:08 -07:00
topjohnwu
099e703834 Build compatible bytecode with newer JDKs
Fix #2898, close #2899
2020-06-21 02:43:32 -07:00
topjohnwu
56602cb9a3 Update gradle files 2020-06-17 02:33:33 -07:00
topjohnwu
fde78be2b4 Update Android Studio 2020-05-30 12:50:08 -07:00
topjohnwu
f9ff814955 Update gradle files 2020-04-19 02:47:22 -07:00
topjohnwu
543ce937ec Don't need to find system_dev 2020-03-31 22:41:25 -07:00
topjohnwu
e4b20abf8e Update gradle files 2020-03-27 22:42:02 -07:00
Viktor De Pasquale
1b8813228b Updated the app to use navigation components instead of custom solution
Welcome to mid 2018.
2020-03-26 03:42:52 -07:00
topjohnwu
541fa5cb1f Update dependencies 2020-03-08 22:54:14 -07:00
topjohnwu
38af82e152 Update AS 2020-02-28 17:49:19 -08:00
topjohnwu
0ce7da1bf6 Upgrade AGP 2020-02-25 15:14:24 -08:00
topjohnwu
581419b6a3 Update dependencies 2020-02-21 23:40:20 -08:00
topjohnwu
8453282fa6 Improve flash console screen 2020-02-16 19:04:26 -08:00
topjohnwu
2eed09ef1b Upgrade AS 2020-01-30 22:04:31 +08:00
topjohnwu
342ae7c8cd Update AS 2020-01-12 04:51:52 +08:00
topjohnwu
3e275b7dba Update a bunch of stuffs 2019-12-06 00:30:00 -05:00
topjohnwu
d952cc2327 Properly solve the connection problem 2019-11-07 17:41:59 -05:00
topjohnwu
75306f658f Revert "Drop API 17 (Android 4.2) support"
Turns out that we cannot use AndroidKeystore anyways, so we don't
actually need to drop API 17. Revert this change.
2019-10-20 07:13:03 -04:00
topjohnwu
9c27d691dd Drop API 17 (Android 4.2) support 2019-10-19 03:11:54 -04:00
topjohnwu
eeb5d669f6 Assign signing keystore location in config 2019-10-17 16:20:01 -04:00
topjohnwu
40eda05a30 Make main app fully independent from the stub
- Skip 0x7f01XXXX - 0x7f05XXXX resource IDs in the main app; they are
reserved for stub resources
- Support sending additional data from host to guest
- Use resource mapping passed from host when they are being sent
to the system framework (notifications and shortcuts)
2019-10-17 02:55:42 -04:00
topjohnwu
34ff764515 Stabilize resource IDs 2019-10-15 04:37:12 -04:00
topjohnwu
5ffb9eaa5b Support loading Magisk Manager from stub on 9.0+
In the effort of preventing apps from crawling APK contents across the
whole installed app list to detect Magisk Manager, the solution here
is to NOT install the actual APK into the system, but instead
dynamically load the full app at runtime by a stub app. The full APK
will be stored in the application's private internal data where
non-root processes cannot read or scan.

The basis of this implementation is the class "AppComponentFactory"
that is introduced in API 28. If assigned, the system framework will
delegate app component instantiation to our custom implementation,
which allows us to do all sorts of crazy stuffs, in our case dynamically
load classes and create objects that does not exist in our APK.

There are a few challenges to achieve our goal though. First, Java
ClassLoaders follow the "delegation pattern", which means class loading
resolution will first be delegated to the parent loader before we get
a chance to do anything. This includes DexClassLoader, which is what
we will be using to load DEX files at runtime. This is a problem
because our stub app and full app share quite a lot of class names.
A custom ClassLoader, DynamicClassLoader, is created to overcome this
issue: it will always load classes in its current dex path before
delegating it to the parent.

Second, all app components (with the exception of runtime
BroadcastReceivers) are required to be declared in AndroidManifest.xml.
The full Magisk Manager has quite a lot of components (including
those from WorkManager and Room). The solution is to copy the complete
AndroidManifest.xml from the full app to the stub, and our
AppComponentFactory is responsible to construct the proper objects or
return dummy implementations in case the full APK isn't downloaded yet.

Third, other than classes, all resources required to run the full app
are also not bundled with the stub APK. We have to call an internal API
`AssetManager.addAssetPath(String)` to add our downloaded full APK into
AssetManager in order to access resources within our full app. That
internal API has existed forever, and is whitelisted from restricted
API access on modern Android versions, so it is pretty safe to use.

Fourth, on the subject of resources, some resources are not just being
used by our app at runtime. Resources such as the app icon, app label,
launch theme, basically everything referred in AndroidManifest.xml,
are used by the system to display the app properly. The system get these
resources via resource IDs and direct loading from the installed APK.
This subset of resources would have to be copied into the stub to make
the app work properly.

Fifth, resource IDs are used all over the place in XMLs and Java code.
The resource IDs in the stub and full app cannot missmatch, or
somewhere, either it be the system or AssetManager, will refer to the
incorrect resource. The full app will have to include all resources in
the stub, and all of them have to be assigned to the exact same IDs in
both APKs. To achieve this, we use AAPT2's "--emit-ids" option to dump
the resource ID mapping when building the stub, and "--stable-ids" when
building the full APK to make sure all overlapping resources in full
and stub are always assigned to the same ID.

Finally, both stub and full app have to work properly independently.
On 9.0+, the stub will have to first launch an Activity to download
the full APK before it can relaunch into the full app. On pre-9.0, the
stub should behave as it always did: download and prompt installation
to upgrade itself to full Magisk Manager. In the full app, the goal
is to introduce minimal intrusion to the code base to make sure this
whole thing is maintainable in the future. Fortunately, the solution
ends up pretty slick: all ContextWrappers in the app will be injected
with custom Contexts. The custom Contexts will return our patched
Resources object and the ClassLoader that loads itself, which will be
DynamicClassLoader in the case of running as a delegate app.
By directly patching the base Context of ContextWrappers (which covers
tons of app components) and in the Koin DI, the effect propagates deep
into every aspect of the code, making this change basically fully
transparent to almost every piece of code in full Magisk Manager.

After this commit, the stub app is able to properly download and launch
the full app, with most basic functionalities working just fine.
Do not expect Magisk Manager upgrades and hiding (repackaging) to
work properly, and some other minor issues might pop up.
This feature is still in the early WIP stages.
2019-10-14 03:49:17 -04:00
topjohnwu
abbd2e6b72 Update AS 2019-10-05 17:02:08 -04:00
topjohnwu
fc886a5a47 Merge Teanity into sources 2019-09-28 01:56:16 -04:00
topjohnwu
e6adb7abca Make kotlin version a variable globally 2019-09-03 16:27:57 -04:00
topjohnwu
c859ddfb8f Upgrade Kotlin 2019-08-27 02:30:10 +08:00
topjohnwu
2e7ce2a769 Update gradle files 2019-08-21 10:38:09 +08:00
topjohnwu
0d03833cff Name module zips with version code 2019-08-11 22:46:39 -07:00
topjohnwu
8706d834b4 Update Android Studio 2019-08-02 21:26:00 -07:00
topjohnwu
63c5e00d86 Update Android Studio 2019-07-20 14:57:03 -07:00
topjohnwu
b0e49a4cc8 Kill blastula pool when magiskhide init 2019-06-27 00:49:27 -07:00
topjohnwu
e6e9dd751c Upgrade Kotlin 2019-06-21 00:53:40 -07:00
topjohnwu
4b30b224b5 Remove separate constant class 2019-06-08 00:41:03 -07:00
topjohnwu
7edfbfb764 Upgrade SDK 2019-06-05 21:33:09 -07:00
topjohnwu
4a73d634e0 Tidy things up 2019-05-31 21:46:59 -07:00
topjohnwu
75405b2b25 Upgrade AS 2019-05-24 02:48:10 -07:00
topjohnwu
fac07c3913 Update R8 version 2019-05-19 17:39:19 -07:00
topjohnwu
b152c63102 Upgrade AS 2019-05-09 23:16:21 -07:00
topjohnwu
2c9586d811 Update dependencies 2019-05-02 02:12:29 -04:00
Viktor De Pasquale
bbf650c6cf Updated gradle & AS 2019-04-26 19:32:53 +02:00
topjohnwu
0407062c1d Merge branch 'master' into pull request #1342 2019-04-19 01:28:45 -04:00
topjohnwu
f315c4416b Upgrade libsu 2019-04-19 01:07:39 -04:00
Viktor De Pasquale
605faccffd Merge remote-tracking branch 'john/master' into development
# Conflicts:
#	app/build.gradle
#	app/src/main/java/com/topjohnwu/magisk/App.java
#	app/src/main/java/com/topjohnwu/magisk/model/adapters/ReposAdapter.java
#	app/src/main/java/com/topjohnwu/magisk/model/update/UpdateCheckService.java
#	app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.java
#	app/src/main/java/com/topjohnwu/magisk/ui/SplashActivity.java
#	app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashActivity.java
#	app/src/main/java/com/topjohnwu/magisk/ui/home/MagiskFragment.java
#	app/src/main/java/com/topjohnwu/magisk/ui/log/LogFragment.java
#	app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestActivity.java
#	app/src/main/java/com/topjohnwu/magisk/utils/ValueSortedMap.java
#	app/src/main/java/com/topjohnwu/magisk/view/dialogs/InstallMethodDialog.java
#	app/src/main/java/com/topjohnwu/magisk/view/dialogs/MagiskInstallDialog.java
#	app/src/main/java/com/topjohnwu/magisk/view/dialogs/ManagerInstallDialog.java
#	build.gradle
2019-04-16 19:40:34 +02:00
Viktor De Pasquale
ebab126579 Replaced xml navigation with self-handled 2019-04-16 19:00:32 +02:00
Viktor De Pasquale
42adc7382f Updated kotlin 2019-04-14 11:07:13 +02:00