Commit Graph

74 Commits

Author SHA1 Message Date
topjohnwu
e51aacb0b7 Update README 2022-03-01 23:54:39 -08:00
topjohnwu
f880b57544 Update README 2022-01-28 04:02:57 -08:00
topjohnwu
e8f31c78d7 Update README 2022-01-26 02:33:22 -08:00
John Wu
a4faa3f392
Update stub strings.xml path 2021-12-14 05:31:12 -08:00
HeroBuxx
0f71edee96 magisk: README: Correct string path for stub
Signed-off-by: HeroBuxx <herobuxx@conqueros.co>
2021-12-01 21:20:24 -08:00
topjohnwu
a967afc629 Update macOS JAVA_HOME path 2021-09-02 02:27:05 -07:00
topjohnwu
d93c4a5103 Update README 2021-08-28 10:45:32 -07:00
topjohnwu
2f4f257070 Publish v23.0 docs 2021-05-11 22:08:02 -07:00
topjohnwu
01b985eded Remove more pre SDK 21 stuffs 2021-04-09 21:29:42 -07:00
topjohnwu
f623b98858 Update README 2021-04-09 03:23:52 -07:00
topjohnwu
3e0b1df46d Update README 2021-03-07 04:12:32 -08:00
topjohnwu
79ee85c0f9 Update README 2021-02-23 04:22:32 -08:00
Laz M
0646f48e14 [README] Warn users that the official website is github
Google puts a number of cheeky looking websites in the results for Magisk.

I only found out they were unofficial is though issue #3435. This deserves to be shown more prominently.
2021-01-30 11:59:39 -08:00
topjohnwu
c538a77937 Tweak build configs and scripts 2021-01-27 02:36:32 -08:00
topjohnwu
b4e52f6135 Better development workflow 2021-01-23 16:50:55 -08:00
topjohnwu
f5593e051c Update README 2021-01-17 06:19:56 -08:00
topjohnwu
2f5331ab48 Update README 2021-01-16 05:02:39 -08:00
topjohnwu
541bb53553 Update links in README 2021-01-10 20:36:58 -08:00
topjohnwu
246997f273 Update links 2020-12-28 15:58:53 -08:00
topjohnwu
d3e4b29e62 Update README.md 2020-12-27 22:36:03 -08:00
topjohnwu
1469b82aa2 Update README 2020-11-13 04:38:17 -08:00
topjohnwu
2da5fcb00b ANDROID_HOME is deprecated 2020-10-17 06:42:34 -07:00
topjohnwu
d4d837a562 Update docs and README 2020-10-08 01:13:00 -07:00
topjohnwu
8dc62a0232 Update docs and README 2020-10-06 05:10:19 -07:00
topjohnwu
d80c6b42a6 Update README 2020-10-03 04:28:43 -07:00
topjohnwu
fbb4f85ef0 Update documentation 2020-10-03 02:53:10 -07:00
topjohnwu
c2e6622016 Update README
Recommend Android Studio embedded JDK again
2020-07-02 04:16:02 -07:00
topjohnwu
0850bca9d3 Update README 2020-06-20 04:58:54 -07:00
topjohnwu
9317401d57 Update Windows instruction for Python 2020-04-03 16:52:28 -07:00
topjohnwu
67d746a62c Let build.py setup NDK 2020-04-03 03:34:07 -07:00
John Wu
e9f0a10175
Update stable release badges 2020-03-27 21:43:52 -07:00
John Wu
2a93d1c652
Update shields.io URL for caching 2020-03-25 09:08:10 -07:00
topjohnwu
6b2f23712c Add live download counts 2020-03-25 04:00:21 -07:00
topjohnwu
d5962e9d71 Update README.MD 2020-03-23 04:45:06 -07:00
topjohnwu
ffaa264bd3 Update documentation 2020-03-23 04:24:20 -07:00
topjohnwu
33f006655d Update README 2020-03-13 02:12:35 -07:00
topjohnwu
a49002bb2c Reorganize string resources 2019-10-15 03:33:22 -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
Salim B
13a2520ea5 Fix typo and add link to GH issues 2019-09-09 17:39:15 -04:00
topjohnwu
ac9c55dbc1 Add info regarding signing certificates
Close #961
2019-05-01 03:27:06 -04:00
topjohnwu
ab0cc78d2c Update README.md 2019-03-08 10:23:42 -05:00
Aidan Holland
65ebb0d2f8 Misc Formatting
* PEP8 and linting
* empty exceptions
2019-02-11 03:18:15 -05:00
topjohnwu
6ee08b6717 Temporary remove API 16 support 2019-02-03 16:42:16 -05:00
topjohnwu
190cdaddf8 Update README 2018-10-16 02:06:07 -04:00
topjohnwu
2cb198c38c Update README 2018-10-05 17:52:40 -04:00
John Wu
0a4ee3ffc7
Update README.MD 2018-09-21 12:01:59 -04:00
John Wu
37221a508d
Update README.MD 2018-09-09 12:25:22 -04:00
topjohnwu
0f34f0033c Switch to FrankeNDK for building native 2018-08-11 18:46:55 +08:00
topjohnwu
27851bdefa Update README.md 2018-07-28 15:10:06 +08:00
topjohnwu
3fdeb40ddf Update SNET extension dialog interface 2018-07-28 14:56:14 +08:00