Commit Graph

82 Commits

Author SHA1 Message Date
topjohnwu
6c6368fd81 Reduce usage of delegation 2020-07-15 01:21:57 -07:00
topjohnwu
2c12fe6eb2 More efficient databinding 2020-07-12 03:17:50 -07:00
topjohnwu
b41b2283f4 Rename package 2020-07-11 05:36:31 -07:00
topjohnwu
8647ba4729 Remove more RxJava 2020-07-09 04:49:14 -07:00
topjohnwu
18dab28c32 Remove usage of KObservableField 2020-07-08 06:14:32 -07:00
topjohnwu
f191db2fe0 Allow ViewModel to opt-out RxJava
Transition period
2020-07-08 01:50:28 -07:00
topjohnwu
23a33b4351 Remove core only mode
Replaced by native safe mode
2020-06-21 15:59:06 -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
5c0e86383c Add test button toggle in code 2020-02-28 11:53:25 -08:00
topjohnwu
b90e0430f8 Don't do layered cards 2020-02-27 01:43:00 -08:00
topjohnwu
40f971d18a Add entrypoint for testing
Should do it with proper unit test, but duh
2020-02-15 21:57:03 -08:00
topjohnwu
ce7cb1eeae Remove device section 2020-02-12 13:26:10 -08:00
topjohnwu
9a8274130b Manually set referenced resource ID for barriers 2020-02-11 20:54:23 -08:00
topjohnwu
c586106e51 Remove confusing scrambled "Manager" text 2020-02-11 19:55:21 -08:00
topjohnwu
d51d549a28 Refactor string resources 2020-02-10 01:43:28 -08:00
topjohnwu
64f35744c4 Reorganize home screen layout 2020-02-09 17:03:05 -08:00
Viktor De Pasquale
db4ef1443d Removed unnecessary code 2020-02-09 03:20:14 -08:00
Viktor De Pasquale
97d24a7d4d Removed single-use reboot menu
This addition will be used in modules as soon as the homepage gets merged
2020-02-09 03:20:14 -08:00
Viktor De Pasquale
1d831d65f3 Added overflow menu for reboot 2020-02-09 03:20:14 -08:00
Viktor De Pasquale
373092af16 Updated homepage layout
The updated layout has extended features such as reboot (not implemented yet), more details with not text ellipsis and easy extendability with further parameters, detail or whatever
More improvements to homescreen to come in upcoming commits.
2020-02-09 03:20:14 -08:00
topjohnwu
497efc9f5e Make scrambled text prettier 2020-01-31 04:48:02 +08:00
topjohnwu
d0112f989c Cleanup classes 2020-01-29 01:49:59 +08:00
Viktor De Pasquale
7bf7bfb9c6 Updated Flash / SuRequest activities with app themes
CompatActivity/Fragment logic has been moved to respective BaseUI. Some deprecated and unused styles have been removed in favor or newer themes.
2020-01-29 01:12:21 +08:00
topjohnwu
0dc9f5c324 Rename some string IDs 2020-01-23 02:34:18 +08:00
topjohnwu
707d7b3342 Separate core components 2020-01-13 22:01:46 +08:00
topjohnwu
84f1e78660 Consolidate base viewmodel implementation 2020-01-13 03:56:03 +08:00
topjohnwu
3490ba0a56 Redesign is now the new norm 2020-01-13 00:43:09 +08:00
topjohnwu
9094cf7ce3 Replace old design with redesign (p2) 2020-01-12 16:07:30 +08:00
topjohnwu
da159e4655 Better environment status detection 2019-11-16 17:38:10 -05:00
topjohnwu
0f34457a10 Directly store strings in viewmodel 2019-10-31 15:33:13 -04:00
topjohnwu
31e003bda5 Fix bug in version detection 2019-10-30 05:24:22 -04:00
topjohnwu
7693024c29 Replace general resources with platform 2019-10-26 19:23:57 -04:00
topjohnwu
0b87108174 Move things around 2019-10-24 05:21:42 -04:00
topjohnwu
25c64db0a1 Treat outdated stub as outdated manager 2019-10-24 03:54:16 -04:00
topjohnwu
d459859361 Show stub version 2019-10-24 00:54:40 -04:00
topjohnwu
a18c552ddf Guard env state behind cached objects 2019-10-22 15:37:55 -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
06dc6df270 Allow dalvik runtime to load snet 2019-10-11 03:58:04 -04:00
topjohnwu
5b7ddbbb01 Fix status report UI 2019-09-30 15:32:28 -04:00
topjohnwu
d3f49334e2 Move function as extension 2019-09-28 12:17:34 -04:00
topjohnwu
6b317f918e Rename base class names 2019-09-28 03:50:11 -04:00
topjohnwu
08b528dc4f Reorganize classes
- Move base classes to its own package
- Move most logic out of MagiskActivity to MainActivity
2019-09-28 03:37:24 -04:00
topjohnwu
fc886a5a47 Merge Teanity into sources 2019-09-28 01:56:16 -04:00
topjohnwu
86481c74ff Allow user to select recovery mode
Close #1674
2019-09-08 00:44:26 -04:00
Viktor De Pasquale
39e9622205 Fixed magisk version
Added refreshing versions before and after the request to remote
2019-08-22 08:03:17 +02:00
topjohnwu
a797d5d396 Update snet extension 2019-08-08 04:18:32 -07:00
topjohnwu
f2494374f8 Eliminate any traces of Java in app 2019-08-08 00:59:23 -07:00
topjohnwu
48395ba860 Remove unused files 2019-08-08 00:29:27 -07:00
Viktor De Pasquale
3c7ece1605 Fixed not showing current version
Current version was not displaying under circumstances that involve loss of connection. Versions are displayed whether the device is connected or not.
2019-08-07 03:07:18 -07:00
Viktor De Pasquale
085ede6d93 Added simple ui blocks for whenever connection drops out 2019-08-07 03:07:18 -07:00