1
mirror of https://github.com/topjohnwu/Magisk synced 2025-11-06 21:02:30 +01:00

Compare commits

...

32 Commits
v25.1 ... v25.2

Author SHA1 Message Date
topjohnwu
6066b5cf86 Release Magisk v25.2 2022-07-20 20:13:26 -07:00
topjohnwu
5cdf95a4d0 Update v25.2 docs 2022-07-20 20:09:02 -07:00
topjohnwu
910a36fdc1 Make sepolicy.rules relative if possible 2022-07-20 19:28:38 -07:00
topjohnwu
8331206acb Clean only java projects when clean java 2022-07-20 11:20:03 -07:00
canyie
8423dc8d63 Later check persistent_properties
`daemon_entry` calls `getprop` which initializes sysprop impl and checks whether we need to load persistent property file. On FDE devices, magiskd starts before /data is actually decrypted, and the check always fails. Thus `persist_getprop("persist.sys.safemode")` will always fail.
2022-07-20 09:58:20 -07:00
Yann
6077c989a7 app: fix typo 2022-07-20 03:34:48 -07:00
topjohnwu
c97d1044fa Release new canary build 2022-07-19 17:44:19 -07:00
Hen_Ry
f42c089b26 Fix 2022-07-18 13:34:14 -07:00
Andrew Gunnerson
1f8c063dc6 Fix booting into recovery with Android 13 GKI kernels
With Android 13 GKI kernels, the boot partition has no ramdisk, so
Magisk constructs one from scratch. In this scenario, there's no backup
init binary at /.backup/init. For normal boot, magiskinit will symlink
/init -> /system/bin/init if needed. This commit implements the same
for booting into recovery. Before, magiskinit would just exec itself
over and over again because it couldn't restore the backup init.

Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
2022-07-18 13:33:50 -07:00
Hen_Ry
4874520d65 Update german translation 2022-07-14 12:32:55 -07:00
Nguyen Hoang The Vi
5e53639969 Add Bengali translation 2022-07-14 12:32:33 -07:00
Grammatopoulos Apostolos
83ab0ca6cd Greek translation updated 2022-07-14 12:31:47 -07:00
topjohnwu
70fd03d5fc Rearchitect logging 2022-07-06 01:16:08 -07:00
topjohnwu
2e52875b50 Move all logging into Rust 2022-07-05 21:13:09 -07:00
topjohnwu
fd9b990ad7 Update to ONDK r24.2 2022-07-05 01:34:48 -07:00
LONE DEVIL
69978a9442 Update russian translation 2022-07-01 15:16:44 -07:00
残页
d155da52ce More friendly and clear error message 2022-07-01 15:15:54 -07:00
Weslley Almeida
9c5b131913 Update Brazilian translation 2022-07-01 15:15:07 -07:00
Syuugo
9d740cec1a Partially fixed Japanese translation 2022-07-01 15:14:18 -07:00
vvb2060
c2978eb9c3 More log for get_manager 2022-07-01 15:13:38 -07:00
vvb2060
38abad1e44 Fix app state 2022-07-01 15:12:50 -07:00
topjohnwu
b4863eb51b Setup logging infra in the Rust side 2022-07-01 04:54:00 -07:00
LoveSy
3817167ba1 Correct ro.crypto.state check
Fix #6042

Co-authored-by: vvb2060 <vvb2060@gmail.com>
2022-06-30 19:32:43 -07:00
topjohnwu
d1a35dd2ba Fix cargo builds on Windows 2022-06-30 18:12:07 -07:00
topjohnwu
26116ac414 Setup preliminary rust infrastructure 2022-06-30 14:50:21 -07:00
topjohnwu
0b26882fce Build dynamic stub resource APK at runtime
Close #6013

Co-authored-by: vvb2060 <vvb2060@gmail.com>
2022-06-22 05:19:27 -07:00
Nicolás
a2495fb5fb Update spanish translations 2022-06-22 04:08:52 -07:00
vvb2060
0beb3bf16a Make CI builds reproducible 2022-06-22 04:08:18 -07:00
vvb2060
b68658e974 Rebuild manifest 2022-06-22 04:06:22 -07:00
LoveSy
3ae7344747 Create /dev on stub cpio 2022-06-22 04:05:50 -07:00
topjohnwu
4eb71830b3 Release new canary build 2022-06-19 03:24:36 -07:00
topjohnwu
9183a0a6ea Update README 2022-06-19 03:06:14 -07:00
64 changed files with 1233 additions and 273 deletions

3
.gitmodules vendored
View File

@@ -40,3 +40,6 @@
[submodule "zopfli"]
path = native/jni/external/zopfli
url = https://github.com/google/zopfli.git
[submodule "cxx-rs"]
path = native/jni/external/cxx-rs
url = https://github.com/topjohnwu/cxx.git

View File

@@ -18,8 +18,8 @@ Some highlight features:
[Github](https://github.com/topjohnwu/Magisk/) is the only source where you can get official Magisk information and downloads.
[![](https://img.shields.io/badge/Magisk-v24.3-blue)](https://github.com/topjohnwu/Magisk/releases/tag/v24.3)
[![](https://img.shields.io/badge/Magisk%20Beta-v25.0-blue)](https://github.com/topjohnwu/Magisk/releases/tag/v25.0)
[![](https://img.shields.io/badge/Magisk-v25.1-blue)](https://github.com/topjohnwu/Magisk/releases/tag/v25.1)
[![](https://img.shields.io/badge/Magisk%20Beta-v25.1-blue)](https://github.com/topjohnwu/Magisk/releases/tag/v25.1)
[![](https://img.shields.io/badge/Magisk-Canary-red)](https://raw.githubusercontent.com/topjohnwu/magisk-files/canary/app-release.apk)
[![](https://img.shields.io/badge/Magisk-Debug-red)](https://raw.githubusercontent.com/topjohnwu/magisk-files/canary/app-debug.apk)
@@ -51,7 +51,7 @@ For Magisk app crashes, record and upload the logcat when the crash occurs.
- Run `./build.py ndk` to let the script download and install NDK for you
- To start building, run `build.py` to see your options. \
For each action, use `-h` to access help (e.g. `./build.py all -h`)
- To start development, open the project with Android Studio. The IDE can be used for both app (Kotlin/Java) and native (C++/C) sources.
- To start development, open the project with Android Studio. The IDE can be used for both app (Kotlin/Java) and native sources.
- Optionally, set custom configs with `config.prop`. A sample `config.prop.sample` is provided.
## Signing and Distribution

View File

@@ -94,6 +94,7 @@ class HomeViewModel(
("${magisk.version} (${magisk.versionCode}) (${stub.versionCode})" +
if (isDebug) " (D)" else "").asText()
} ?: run {
appState = State.INVALID
managerRemoteVersion = R.string.not_available.asText()
}
ensureEnv()
@@ -112,7 +113,7 @@ class HomeViewModel(
fun onDeletePressed() = UninstallDialog().publish()
fun onManagerPressed() = when (magiskState) {
fun onManagerPressed() = when (appState) {
State.LOADING -> SnackbarEvent(R.string.loading).publish()
State.INVALID -> SnackbarEvent(R.string.no_connection).publish()
else -> withExternalRW {

View File

@@ -54,8 +54,8 @@ public class ConcealableBottomNavigationView extends BottomNavigationView {
toHidden.setDuration(175);
toHidden.setInterpolator(new FastOutLinearInInterpolator());
Animator toUnhidden = ObjectAnimator.ofFloat(this, "translationY", 0);
toHidden.setDuration(225);
toHidden.setInterpolator(new FastOutLinearInInterpolator());
toUnhidden.setDuration(225);
toUnhidden.setInterpolator(new FastOutLinearInInterpolator());
StateListAnimator animator = new StateListAnimator();

File diff suppressed because one or more lines are too long

View File

@@ -22,6 +22,7 @@
<string name="home_notice_content">Laden Sie Magisk NUR von der offiziellen Github Seite herunter. Dateien aus unbekannten Quellen können bösartig sein!</string>
<string name="home_support_title">Unterstützen Sie uns</string>
<string name="home_follow_title">Folgen Sie uns</string>
<string name="home_item_source">Quelle</string>
<string name="home_support_content">Magisk ist und wird immer frei und quelloffen sein. Sie können uns jedoch jederzeit mit einer kleinen Spende unterstützen.</string>
<string name="home_installed_version">Installiert</string>
@@ -111,6 +112,7 @@
<string name="suspend_text_riru">Modul ausgesetzt, weil %1$s aktiviert ist</string>
<string name="suspend_text_zygisk">Modul ausgesetzt, weil %1$s nicht aktiviert ist</string>
<string name="zygisk_module_unloaded">Zygisk-Modul aufgrund von Inkompatibilität nicht geladen</string>
<string name="module_empty">Kein Modul installiert</string>
<!--Settings-->
<string name="settings_dark_mode_title">Themen-Modus</string>
@@ -190,9 +192,12 @@
<!--Notifications-->
<string name="update_channel">Magisk Updates</string>
<string name="progress_channel">Fortschrittsmitteilungen</string>
<string name="updated_channel">Update abgeschlossen</string>
<string name="download_complete">Download abgeschlossen</string>
<string name="download_file_error">Fehler beim Herunterladen der Datei</string>
<string name="magisk_update_title">Magisk Update verfügbar!</string>
<string name="updated_title">Magisk aktualisiert</string>
<string name="updated_text">Tippen, um die App zu öffnen</string>
<!--Toasts, Dialogs-->
<string name="yes">Ja</string>
@@ -225,6 +230,8 @@
<string name="unsupport_nonroot_stub_msg">App kann im versteckten Zustand nicht weiter funktionieren, da Root verloren gegangen ist. Ursprüngliche APK bitte wiederherstellen.</string>
<string name="unsupport_nonroot_stub_title">@string/settings_restore_app_title</string>
<string name="external_rw_permission_denied">Speichererlaubnis erteilen, um diese Funktion zu aktivieren</string>
<string name="install_unknown_denied">Unbekannte Apps installieren erlauben, um diese Funktion zu aktivieren</string>
<string name="add_shortcut_title">Verknüpfung zum Startbildschirm hinzufügen</string>
<string name="add_shortcut_msg">Nachdem Sie diese App verstecken, wird der Name und das Symbol eventuell schwer zu erkennen sein. Möchten Sie zum Startbildschirm eine schöne Verknüpfung hinzufügen?</string>
<string name="app_not_found">Keine App gefunden, die diese Aktion verarbeitet</string>

View File

@@ -8,6 +8,7 @@
<string name="install">Εγκατάσταση</string>
<string name="section_home">Αρχική</string>
<string name="section_theme">Θέματα</string>
<string name="denylist">Λίστα Απορρίψεων</string>
<!--Home-->
<string name="no_connection">Δεν υπάρχει διαθέσιμη σύνδεση</string>
@@ -21,6 +22,7 @@
<string name="home_notice_content">Κάντε λήψη του Magisk ΜΟΝΟ από την επίσημη σελίδα του GitHub. Τα αρχεία από άγνωστες πηγές μπορεί να είναι κακόβουλα!</string>
<string name="home_support_title">Υποστήριξη</string>
<string name="home_follow_title">Ακολούθησε μας</string>
<string name="home_item_source">Πηγή</string>
<string name="home_support_content">Το Magisk είναι, και θα είναι για πάντα, δωρεάν και ανοιχτού κώδικα. Μπορείτε ωστόσο να μας δείξετε ότι ενδιαφέρεστε στέλνοντας μια μικρή δωρεά.</string>
<string name="home_installed_version">Τρέχουσα έκδοση</string>
@@ -32,6 +34,7 @@
<!--Install-->
<string name="keep_force_encryption">Διατήρηση επιβεβλημένης κρυπτογράφησης</string>
<string name="keep_dm_verity">Διατήρηση AVB 2.0/dm-verity</string>
<string name="patch_vbmeta">Patch vbmeta στην εικόνα του boot</string>
<string name="recovery_mode">Μέσω Recovery mode</string>
<string name="install_options_title">Επιλογές</string>
<string name="install_method_title">Μέθοδος</string>
@@ -76,6 +79,7 @@
<string name="superuser_toggle_notification">Ειδοποιήσεις</string>
<string name="superuser_toggle_revoke">Ανακάλεσε</string>
<string name="superuser_policy_none">Καμία εφαρμογή δεν έχει ζητήσει άδεια υπερχρήστη.</string>
<!--Logs-->
<string name="log_data_none">Δεν υπάρχουν αρχεία καταγραφής, δοκιμάστε να χρησιμοποιήσετε περισσότερο τις εφαρμογές με δυνατότητα SU</string>
<string name="log_data_magisk_none">Τα αρχεία καταγραφής του Magisk είναι κενά, αυτό είναι περίεργο</string>
@@ -105,6 +109,10 @@
<string name="module_state_restore">Επαναφορά</string>
<string name="module_action_install_external">Εγκατάσταση από χώρο αποθήκευσης</string>
<string name="update_available">Διαθέσιμη Ενημέρωση</string>
<string name="suspend_text_riru">Η επέκταση έχει ανασταλεί επειδή το %1$s είναι ενεργοποιημένο</string>
<string name="suspend_text_zygisk">Η επέκταση έχει ανασταλεί επειδή το %1$s δεν είναι ενεργοποιημένο</string>
<string name="zygisk_module_unloaded">Zygisk module not loaded due to incompatibility</string>
<string name="module_empty">Δεν υπάρχουν εγκατεστημένες επεκτάσεις</string>
<!--Settings-->
<string name="settings_dark_mode_title">Λειτουργία θέματος</string>
@@ -127,6 +135,12 @@
<string name="settings_update_beta">Δοκιμαστικό</string>
<string name="settings_update_custom">Προσαρμοσμένο</string>
<string name="settings_update_custom_msg">Εισαγωγή ενός custom URL</string>
<string name="settings_zygisk_summary">Εκτέλεση μέρους του Magisk μέσα στο zygote daemon</string>
<string name="settings_denylist_title">Επιβολή Λίστας Απορρίψεων</string>
<string name="settings_denylist_summary">Επαναφορά όλων των τροποποιήσεων του Magisk για της διεργασίες στην λίστα απορρίψεων</string>
<string name="settings_denylist_error">Αυτή η λειτουργεία απαιτεί τη %1$s να είναι ενεργοποιημένη</string>
<string name="settings_denylist_config_title">Τροποποίηση της Λίστας Απορρίψεων</string>
<string name="settings_denylist_config_summary">Επιλογή διεργασίας για να συμπεριληφθεί στη λίστα απορρίψεων</string>
<string name="settings_hosts_title">Systemless hosts</string>
<string name="settings_hosts_summary">Υποστήριξη Systemless hosts για εφαρμογές Adblock</string>
<string name="settings_hosts_toast">Προσθήκη αρθρώματος systemless hosts</string>
@@ -178,9 +192,12 @@
<!--Notifications-->
<string name="update_channel">Ενημερώσεις Magisk</string>
<string name="progress_channel">Ειδοποιήσεις προόδου</string>
<string name="updated_channel">Η Αναβάθμηση Ολοκληρώθηκε</string>
<string name="download_complete">Η λήψη ολοκληρώθηκε</string>
<string name="download_file_error">Σφάλμα στη λήψη του αρχείου</string>
<string name="magisk_update_title">Νέα Ενημέρωση Magisk Διαθέσιμη!</string>
<string name="updated_title">Το Magisk Ενημερώθηκε</string>
<string name="updated_text">Πατήστε για άνοιγμα εφαρμογής</string>
<!--Toasts, Dialogs-->
<string name="yes">Ναι</string>
@@ -206,10 +223,18 @@
<string name="authenticate">Αυθεντικοποίηση</string>
<string name="unsupport_magisk_title">Μη υποστηριζόμενη έκδοση Magisk</string>
<string name="unsupport_magisk_msg">Αυτή η έκδοση της εφαρμογής δεν υποστηρίζει έκδοση Magisk χαμηλότερη από %1$s.\n\nΗ εφαρμογή θα συμπεριφέρεται σαν να μην έχει εγκατασταθεί το Magisk, αναβαθμίστε το Magisk το συντομότερο δυνατό.</string>
<string name="external_rw_permission_denied">Παραχωρήστε άδεια αποθήκευσης για να ενεργοποιήσετε αυτήν τη λειτουργία</string>
<string name="unsupport_general_title">Μη Φυσιολογική Κατάσταση</string>
<string name="unsupport_system_app_msg">Η εκτέλεση αυτής της εφαρμογής ως εφαρμογής συστήματος δεν υποστηρίζεται. Επαναφέρετε την εφαρμογή σε εφαρμογή χρήστη.</string>
<string name="unsupport_other_su_msg">Εντοπίστηκε ένα \"su\" binary που δεν είναι από το Magisk. Καταργήστε οποιαδήποτε άλλη root μέθοδο και/ή επανεγκαταστήστε το Magisk.</string>
<string name="unsupport_external_storage_msg">Το Magisk είναι εγκατεστημένο σε εξωτερικό χώρο αποθήκευσης. Μετακινήστε την εφαρμογή στον εσωτερικό χώρο αποθήκευσης.</string>
<string name="unsupport_nonroot_stub_msg">Η κρυφή εφαρμογή Magisk δεν μπορεί να συνεχίσει να λειτουργεί επειδή χάθηκε το root. Παρακαλώ επαναφέρετε το αρχικό APK.</string>
<string name="external_rw_permission_denied">Παραχωρήστε άδεια αποθήκευσης για να ενεργοποιήσετε αυτήν τη λειτουργία</string>
<string name="install_unknown_denied">Επιτρέψτε την "εγκατάσταση άγνωστων εφαρμογών" για να ενεργοποιήσετε αυτήν τη λειτουργία</string>
<string name="add_shortcut_title">Προσθέστε συντόμευση στην αρχική οθόνη</string>
<string name="add_shortcut_msg">Μετά την απόκρυψη αυτής της εφαρμογής, το όνομα και το εικονίδιο της ενδέχεται να είναι δύσκολο να αναγνωριστούν. Θέλετε να προσθέσετε μια όμορφη συντόμευση στην αρχική οθόνη;</string>
<string name="app_not_found">Δεν βρέθηκε εφαρμογή που να χειρίζεται αυτήν την ενέργεια</string>
<string name="reboot_apply_change">Επανεκκινήστε για να εφαρμόσετε της αλλαγές</string>
<string name="restore_app_confirmation">Αυτό θα επαναφέρει την κρυφή εφαρμογή πίσω στην αρχική εφαρμογή. Θέλετε πραγματικά να το κάνετε αυτό;</string>
</resources>

View File

@@ -22,6 +22,7 @@
<string name="home_notice_content">Descarga Magisk SÓLO de la página de GitHub oficial. Archivos de fuentes desconocidas pueden resultar maliciosos!</string>
<string name="home_support_title">Apóyenos</string>
<string name="home_follow_title">Síganos</string>
<string name="home_item_source">Código fuente</string>
<string name="home_support_content">Magisk es, y siempre será gratuito y de código abierto. Sin embargo, puede apoyarnos enviando una pequeña donación.</string>
<string name="home_installed_version">Instalado</string>
@@ -33,6 +34,7 @@
<!--Install-->
<string name="keep_force_encryption">Mantener cifrado forzado</string>
<string name="keep_dm_verity">Mantener AVB 2.0/dm-verity</string>
<string name="patch_vbmeta">Parche vbmeta en la imagen de arranque</string>
<string name="recovery_mode">Modo recovery</string>
<string name="install_options_title">Opciones</string>
<string name="install_method_title">Método</string>
@@ -109,6 +111,8 @@
<string name="update_available">Actualización disponible</string>
<string name="suspend_text_riru">Módulo suspendido porque %1$s está habilitado</string>
<string name="suspend_text_zygisk">Módulo suspendido porque %1$s no está habilitado</string>
<string name="zygisk_module_unloaded">Módulo Zygisk no cargado debido a incompatibilidad</string>
<string name="module_empty">Ningún módulo instalado</string>
<!--Settings -->
<string name="settings_dark_mode_title">Elegir modo</string>
@@ -188,9 +192,12 @@
<!--Notifications-->
<string name="update_channel">Actualización de Magisk</string>
<string name="progress_channel">Notificaciones de progreso</string>
<string name="updated_channel">Actualización completa</string>
<string name="download_complete">Descarga Completa</string>
<string name="download_file_error">Error descargando archivo</string>
<string name="magisk_update_title">¡Actualización de Magisk disponible!</string>
<string name="updated_title">Magisk Actualizado</string>
<string name="updated_text">Toca para abrir la aplicación</string>
<!--Toasts, Dialogs-->
<string name="yes">Sí</string>
@@ -216,10 +223,18 @@
<string name="authenticate">Autenticar</string>
<string name="unsupport_magisk_title">Versión de Magisk no soportada</string>
<string name="unsupport_magisk_msg">Esta versión de la app no soporta versiones de Magisk inferiores a la %1$s.\n\nLa aplicación se comportará como si no tuvieses Magisk instalado, por favor actualiza Magisk tan pronto como sea posible.</string>
<string name="unsupport_general_title">Estado anormal</string>
<string name="unsupport_system_app_msg">No se admite la ejecución de esta aplicación como una aplicación del sistema. Revierta la aplicación a una aplicación de usuario.</string>
<string name="unsupport_other_su_msg">Se ha detectado un binario \"su\" que no es de Magisk. Elimine cualquier solución raíz de la competencia y/o reinstale Magisk.</string>
<string name="unsupport_external_storage_msg">Magisk está instalado en el almacenamiento externo. Mueva la aplicación al almacenamiento interno.</string>
<string name="unsupport_nonroot_stub_msg">La aplicación Magisk oculta no puede seguir funcionando porque se perdió la raíz. Restaura el APK original.</string>
<string name="unsupport_nonroot_stub_title">@string/settings_restore_app_title</string>
<string name="external_rw_permission_denied">Conceder permiso de almacenamiento para habilitar esta funcionalidad</string>
<string name="install_unknown_denied">Permitir "instalar aplicaciones desconocidas" para habilitar esta funcionalidad</string>
<string name="add_shortcut_title">Añadir un atajo a la pantalla de inicio</string>
<string name="add_shortcut_msg">Tras esconder la app, su nombre e icono pueden resultar difíciles de reconocer. ¿Quieres añadir un acceso directo más bonito a la pantalla principal?</string>
<string name="app_not_found">No se ha encontrado ninguna app para manejar esta acción</string>
<string name="reboot_apply_change">Reiniciar para aplicar cambios</string>
<string name="restore_app_confirmation">Esto restaurará la aplicación oculta a la aplicación original. ¿Realmente quieres hacer esto?</string>
</resources>

View File

@@ -20,16 +20,16 @@
<string name="home_package">パッケージ ID </string>
<string name="home_app_title">アプリ</string>
<string name="home_notice_content">Magisk は必ず公式 GitHub ページからダウンロードしてください。その他の提供元では悪意あるコードを含んでいる可能性があります!</string>
<string name="home_notice_content">Magisk は必ず公式 GitHub ページからダウンロードしてください。その他の提供元では悪意あるコードを含んでいる可能性があります!</string>
<string name="home_support_title">サポートする</string>
<string name="home_follow_title">フォローする</string>
<string name="home_item_source">ソース</string>
<string name="home_support_content">Magisk はフリーでオープンソースです。寄付を送ることで Magisk の開発を支援できます。</string>
<string name="home_support_content">Magisk はフリーでオープンソースです。寄付を送ることで Magisk の開発を支援することができます。</string>
<string name="home_installed_version">インストール済</string>
<string name="home_latest_version">最新版</string>
<string name="invalid_update_channel">不正な更新チャンネルです</string>
<string name="uninstall_magisk_title">Magisk のアンインストール</string>
<string name="uninstall_magisk_msg">すべてのモジュールが無効化/削除されます。\nアンインストール後は root が無効化されストレージが暗号化されていない場合暗号化される場合があります。</string>
<string name="uninstall_magisk_msg">すべてのモジュールが無効化/削除されます。\nアンインストール後は root が削除されストレージが暗号化されていない場合暗号化される場合があります。</string>
<!--Install-->
<string name="keep_force_encryption">暗号化を維持する</string>
@@ -40,7 +40,7 @@
<string name="install_method_title">方法</string>
<string name="install_next">次へ</string>
<string name="install_start">はじめる</string>
<string name="manager_download_install">タップダウンロードしてインストールします</string>
<string name="manager_download_install">タップしてダウンロードインストールします</string>
<string name="direct_install">直接インストール (推奨)</string>
<string name="install_inactive_slot">別のスロットにインストール (OTA 後)</string>
<string name="install_inactive_slot_msg">お使いのデバイスは再起動後に現在とは別のスロットで強制的に起動されます!\nこのオプションは OTA の完了後にのみ使用してください。\n続行しますか</string>
@@ -52,7 +52,7 @@
<!--Superuser-->
<string name="su_request_title">スーパーユーザー権限の要求</string>
<string name="touch_filtered_warning">スーパーユーザー権限の要求ダイアログが他のアプリで隠れているため、Magisk はあなたの応答を確認できません。</string>
<string name="touch_filtered_warning">他のアプリがスーパーユーザー権限の要求ダイアログを隠しているため、Magisk はあなたの応答を確認できません。</string>
<string name="deny">拒否</string>
<string name="prompt">尋ねる</string>
<string name="grant">許可</string>
@@ -206,7 +206,7 @@
<string name="download">ダウンロード</string>
<string name="reboot">再起動</string>
<string name="release_notes">更新履歴</string>
<string name="flashing">書き込み中…</string>
<string name="flashing">書中…</string>
<string name="done">完了!</string>
<string name="failure">失敗!</string>
<string name="hide_app_title">Magisk アプリを隠しています…</string>
@@ -218,7 +218,7 @@
<string name="restore_fail">Stock のバックアップがありません!</string>
<string name="setup_fail">セットアップに失敗しました</string>
<string name="env_fix_title">追加のセットアップが必要です</string>
<string name="env_fix_msg">Magisk を正常に動作させるために追加のセットアップが必要です。今すぐ再起動しますか?</string>
<string name="env_fix_msg">Magisk を正常に動作させるために追加のセットアップが必要です。今すぐ再起動しますか?</string>
<string name="setup_msg">追加セットアップを実行中…</string>
<string name="authenticate">認証</string>
<string name="unsupport_magisk_title">対応していない Magisk バージョンです</string>
@@ -227,7 +227,7 @@
<string name="unsupport_system_app_msg">このアプリをシステムアプリとして起動することはサポートされていません。ユーザーアプリに戻してください。</string>
<string name="unsupport_other_su_msg">Magisk 以外の \"su\" バイナリが検出されました。競合する root 権限取得ソフトを削除し、Magisk をインストールし直してください。</string>
<string name="unsupport_external_storage_msg">Magisk が外部ストレージにインストールされています。内部ストレージに移動してください。</string>
<string name="unsupport_nonroot_stub_msg">root 権限が失われたためMagisk の隠しアプリが動作できなくなりました。元の APK を復元してください。</string>
<string name="unsupport_nonroot_stub_msg">root 権限が失われたため、隠し Magisk アプリが動作できなくなりました。元の APK を復元してください。</string>
<string name="unsupport_nonroot_stub_title">@string/settings_restore_app_title</string>
<string name="external_rw_permission_denied">この機能を有効にするにはストレージ権限を許可してください</string>
<string name="install_unknown_denied">この機能を有効化するには、不明なソースからのインストールを許可してください</string>

View File

@@ -119,7 +119,7 @@
<string name="settings_download_path_title">Caminho para Baixar</string>
<string name="settings_download_path_message">Os arquivos serão salvos em %1$s</string>
<string name="settings_hide_app_title">Ocultar o app do Magisk</string>
<string name="settings_hide_app_summary">Instala o app ooulto com ID aleatório e nome personalizado</string>
<string name="settings_hide_app_summary">Instala o app oculto com ID aleatório e nome personalizado</string>
<string name="settings_restore_app_title">Restaurar o App do Magisk</string>
<string name="settings_restore_app_summary">Desoculta o app do Magisk e restaura o APK original</string>
<string name="language">Idioma</string>

View File

@@ -2,7 +2,7 @@
<!--Sections-->
<string name="modules">Модули</string>
<string name="superuser">Суперпользователь</string>
<string name="superuser">Superuser</string>
<string name="logs">Лог</string>
<string name="settings">Настройки</string>
<string name="install">Установка</string>

140
build.py
View File

@@ -37,10 +37,10 @@ def vprint(str):
is_windows = os.name == 'nt'
is_ci = 'CI' in os.environ and os.environ['CI'] == 'true'
EXE_EXT = '.exe' if is_windows else ''
if not is_ci and is_windows:
import colorama
colorama.init()
# Environment checks
@@ -58,16 +58,20 @@ except FileNotFoundError:
cpu_count = multiprocessing.cpu_count()
archs = ['armeabi-v7a', 'x86', 'arm64-v8a', 'x86_64']
triples = ['armv7a-linux-androideabi', 'i686-linux-android', 'aarch64-linux-android', 'x86_64-linux-android']
default_targets = ['magisk', 'magiskinit', 'magiskboot', 'magiskpolicy', 'busybox']
support_targets = default_targets + ['resetprop', 'test']
rust_targets = ['magisk', 'magiskinit', 'magiskboot', 'magiskpolicy']
sdk_path = os.environ['ANDROID_SDK_ROOT']
ndk_root = op.join(sdk_path, 'ndk')
ndk_path = op.join(ndk_root, 'magisk')
ndk_build = op.join(ndk_path, 'ndk-build')
rust_bin = op.join(ndk_path, 'toolchains', 'rust', 'bin')
cargo = op.join(rust_bin, 'cargo' + EXE_EXT)
gradlew = op.join('.', 'gradlew' + ('.bat' if is_windows else ''))
adb_path = op.join(sdk_path, 'platform-tools', 'adb' + ('.exe' if is_windows else ''))
native_gen_path = op.join('native', 'out', 'generated')
adb_path = op.join(sdk_path, 'platform-tools', 'adb' + EXE_EXT)
native_gen_path = op.realpath(op.join('native', 'out', 'generated'))
# Global vars
config = {}
@@ -123,16 +127,17 @@ def mkdir_p(path, mode=0o755):
os.makedirs(path, mode, exist_ok=True)
def execv(cmd):
return subprocess.run(cmd, stdout=STDOUT)
def execv(cmd, env=None):
return subprocess.run(cmd, stdout=STDOUT, env=env)
def system(cmd):
return subprocess.run(cmd, shell=True, stdout=STDOUT)
def cmd_out(cmd):
return subprocess.check_output(cmd).strip().decode('utf-8')
def cmd_out(cmd, env=None):
return subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, env=env) \
.stdout.strip().decode('utf-8')
def xz(data):
@@ -180,15 +185,6 @@ def load_config(args):
STDOUT = None if args.verbose else subprocess.DEVNULL
def collect_binary():
for arch in archs:
mkdir_p(op.join('native', 'out', arch))
for bin in support_targets + ['libpreload.so']:
source = op.join('native', 'libs', arch, bin)
target = op.join('native', 'out', arch, bin)
mv(source, target)
def clean_elf():
if is_windows:
elf_cleaner = op.join('tools', 'elf-cleaner.exe')
@@ -203,48 +199,6 @@ def clean_elf():
execv(args)
def find_build_tools():
global build_tools
if build_tools:
return build_tools
build_tools_root = op.join(os.environ['ANDROID_SDK_ROOT'], 'build-tools')
ls = os.listdir(build_tools_root)
# Use the latest build tools available
ls.sort()
build_tools = op.join(build_tools_root, ls[-1])
return build_tools
# Unused but keep this code
def sign_zip(unsigned):
if 'keyStore' not in config:
return
msg = '* Signing APK'
apksigner = op.join(find_build_tools(), 'apksigner' + ('.bat' if is_windows else ''))
exec_args = [apksigner, 'sign',
'--ks', config['keyStore'],
'--ks-pass', f'pass:{config["keyStorePass"]}',
'--ks-key-alias', config['keyAlias'],
'--key-pass', f'pass:{config["keyPass"]}',
'--v1-signer-name', 'CERT',
'--v4-signing-enabled', 'false']
if unsigned.endswith('.zip'):
msg = '* Signing zip'
exec_args.extend(['--min-sdk-version', '17',
'--v2-signing-enabled', 'false',
'--v3-signing-enabled', 'false'])
exec_args.append(unsigned)
header(msg)
proc = execv(exec_args)
if proc.returncode != 0:
error('Signing failed!')
def binary_dump(src, var_name):
out_str = f'constexpr unsigned char {var_name}[] = {{'
for i, c in enumerate(xz(src.read())):
@@ -261,7 +215,70 @@ def run_ndk_build(flags):
if proc.returncode != 0:
error('Build binary failed!')
os.chdir('..')
collect_binary()
for arch in archs:
for tgt in support_targets + ['libpreload.so']:
source = op.join('native', 'libs', arch, tgt)
target = op.join('native', 'out', arch, tgt)
mv(source, target)
def run_cargo_build(args):
os.chdir(op.join('native', 'rust'))
targets = set(args.target) & set(rust_targets)
env = os.environ.copy()
env['CARGO_BUILD_RUSTC'] = op.join(rust_bin, 'rustc' + EXE_EXT)
# Install cxxbridge and generate C++ bindings
native_out = op.join('..', '..', 'native', 'out')
local_cargo_root = op.join(native_out, '.cargo')
mkdir_p(local_cargo_root)
cmds = [cargo, 'install', '--root', local_cargo_root, 'cxxbridge-cmd']
if not args.verbose:
cmds.append('-q')
proc = execv(cmds, env)
if proc.returncode != 0:
error('cxxbridge-cmd installation failed!')
cxxbridge = op.join(local_cargo_root, 'bin', 'cxxbridge' + EXE_EXT)
mkdir(native_gen_path)
for p in ['base', 'boot', 'core', 'init', 'sepolicy']:
text = cmd_out([cxxbridge, op.join(p, 'src', 'lib.rs')])
write_if_diff(op.join(native_gen_path, f'{p}-rs.cpp'), text)
text = cmd_out([cxxbridge, '--header', op.join(p, 'src', 'lib.rs')])
write_if_diff(op.join(native_gen_path, f'{p}-rs.hpp'), text)
# Start building the actual build commands
cmds = [cargo, 'build', '-Z', 'build-std=std,panic_abort',
'-Z', 'build-std-features=panic_immediate_abort']
for target in targets:
cmds.append('-p')
cmds.append(target)
rust_out = 'debug'
if args.release:
cmds.append('-r')
rust_out = 'release'
if not args.verbose:
cmds.append('-q')
os_name = platform.system().lower()
llvm_bin = op.join(ndk_path, 'toolchains', 'llvm', 'prebuilt', f'{os_name}-x86_64', 'bin')
env['TARGET_CC'] = op.join(llvm_bin, 'clang' + EXE_EXT)
env['RUSTFLAGS'] = '-Clinker-plugin-lto'
for (arch, triple) in zip(archs, triples):
env['TARGET_CFLAGS'] = f'--target={triple}21'
rust_triple = 'thumbv7neon-linux-androideabi' if triple.startswith('armv7') else triple
proc = execv([*cmds, '--target', rust_triple], env)
if proc.returncode != 0:
error('Build binary failed!')
arch_out = op.join(native_out, arch)
mkdir(arch_out)
for tgt in targets:
source = op.join('target', rust_triple, rust_out, f'lib{tgt}.a')
target = op.join(arch_out, f'lib{tgt}-rs.a')
mv(source, target)
os.chdir(op.join('..', '..'))
def write_if_diff(file_name, text):
@@ -326,6 +343,8 @@ def build_binary(args):
header('* Building binaries: ' + ' '.join(args.target))
run_cargo_build(args)
dump_flag_header()
flag = ''
@@ -402,10 +421,11 @@ def cleanup(args):
rm_rf(op.join('native', 'out'))
rm_rf(op.join('native', 'libs'))
rm_rf(op.join('native', 'obj'))
rm_rf(op.join('native', 'rust', 'target'))
if 'java' in args.target:
header('* Cleaning java')
execv([gradlew, 'clean'])
execv([gradlew, 'app:clean', 'app:shared:clean', 'stub:clean'])
def setup_ndk(args):

View File

@@ -11,7 +11,8 @@ import javax.crypto.spec.SecretKeySpec
import kotlin.random.asKotlinRandom
// Set non-zero value here to fix the random seed for reproducible builds
const val RAND_SEED = 0
// CI builds are always reproducible
val RAND_SEED = if (System.getenv("CI") != null) 42 else 0
private lateinit var RANDOM: Random
private val kRANDOM get() = RANDOM.asKotlinRandom()

View File

@@ -24,6 +24,7 @@ import java.io.PrintStream
import java.security.KeyStore
import java.security.cert.X509Certificate
import java.util.*
import java.util.jar.JarFile
import java.util.zip.*
private fun Project.androidBase(configure: Action<BaseExtension>) =
@@ -90,6 +91,7 @@ private fun addComment(apkPath: File, signConfig: SigningConfig, minSdk: Int, eo
SigningExtension(signingOptions).register(it)
it.eocdComment = eocdComment.toByteArray()
it.get(IncrementalPackager.APP_METADATA_ENTRY_PATH)?.delete()
it.get(JarFile.MANIFEST_NAME)?.delete()
}
}
@@ -133,11 +135,8 @@ private fun Project.setupAppCommon() {
android.applicationVariants.all {
val projectName = project.name.toLowerCase(Locale.ROOT)
val variantCapped = name.capitalize(Locale.ROOT)
val variant = name.toLowerCase(Locale.ROOT)
tasks.getByPath(":$projectName:package$variantCapped").doLast {
val apkDir = if (properties["android.injected.invoked.from.ide"] == "true")
"intermediates" else "outputs"
val apk = File(buildDir, "${apkDir}/apk/${variant}/$projectName-${variant}.apk")
val apk = outputs.files.asFileTree.filter { it.name.endsWith(".apk") }.singleFile
val comment = "version=${Config.version}\nversionCode=${Config.versionCode}"
addComment(apk, signingConfig, android.defaultConfig.minSdk!!, comment)
}
@@ -270,27 +269,20 @@ fun Project.setupStub() {
commandLine(aapt, "optimize", "-o", apkTmp, "--collapse-resource-names", apk)
}
val buffer = ByteArrayOutputStream()
apkTmp.inputStream().use {
object : GZIPOutputStream(buffer) {
init {
def.setLevel(Deflater.BEST_COMPRESSION)
}
}.use { o ->
it.transferTo(o)
val bos = ByteArrayOutputStream()
ZipFile(apkTmp).use { src ->
ZipOutputStream(apk.outputStream()).use {
it.setLevel(Deflater.BEST_COMPRESSION)
it.putNextEntry(ZipEntry("AndroidManifest.xml"))
src.getInputStream(src.getEntry("AndroidManifest.xml")).transferTo(it)
it.closeEntry()
}
}
ZipFile(apkTmp).use { o ->
ZipOutputStream(apk.outputStream()).use { n ->
n.setLevel(Deflater.BEST_COMPRESSION)
n.putNextEntry(ZipEntry("AndroidManifest.xml"))
o.getInputStream(o.getEntry("AndroidManifest.xml")).transferTo(n)
n.closeEntry()
n.finish()
DeflaterOutputStream(bos, Deflater(Deflater.BEST_COMPRESSION)).use {
src.getInputStream(src.getEntry("resources.arsc")).transferTo(it)
}
}
apkTmp.delete()
genEncryptedResources(ByteArrayInputStream(buffer.toByteArray()), outSrcDir)
genEncryptedResources(ByteArrayInputStream(bos.toByteArray()), outSrcDir)
}
}
registerJavaGeneratingTask(genSrcTask, outSrcDir)

View File

@@ -1,5 +1,13 @@
# Magisk Changelog
### v25.2
- [MagiskInit] Fix a potential issue when stub cpio is used
- [MagiskInit] Fix reboot to recovery when stub cpio is used
- [MagiskInit] Fix sepolicy.rules symlink for rootfs devices
- [General] Better data encryption detection
- [General] Move the whole logging infrastructure into Rust
### v25.1
- [MagiskBoot] Fix ramdisk backup being incorrectly skipped

11
docs/releases/25200.md Normal file
View File

@@ -0,0 +1,11 @@
## 2022.7.20 Magisk v25.2
Maintenance release fixing various issues.
- [MagiskInit] Fix a potential issue when stub cpio is used
- [MagiskInit] Fix reboot to recovery when stub cpio is used
- [MagiskInit] Fix sepolicy.rules symlink for rootfs devices
- [General] Better data encryption detection
- [General] Move the whole logging infrastructure into Rust
### Full Changelog: [here](https://topjohnwu.github.io/Magisk/changes.html)

View File

@@ -1,5 +1,6 @@
# Release Notes
- [v25.2](25200.md)
- [v25.1](25100.md)
- [v25.0](25000.md)
- [v24.3](24300.md)

View File

@@ -27,6 +27,6 @@ android.injected.testOnly=false
android.nonTransitiveRClass=true
# Magisk
magisk.stubVersion=32
magisk.versionCode=25100
magisk.ondkVersion=r24.1
magisk.stubVersion=33
magisk.versionCode=25200
magisk.ondkVersion=r24.2

34
native/README.md Normal file
View File

@@ -0,0 +1,34 @@
# Native Development
## Prerequisite
Install the NDK required to build and develop Magisk with `./build.py ndk`. The NDK will be installed to `$ANDROID_SDK_ROOT/ndk/magisk`. You don't need to manually install a Rust toolchain with `rustup`, as the NDK installed already has a Rust toolchain bundled.
## Code Paths
- `jni`: Magisk's code in C++
- `jni/external`: external dependencies, mostly submodules
- `rust`: Magisk's code in Rust
- `src`: irrelevant, only exists to setup a native Android Studio project
## Build Configs
All C/C++ code and its dependencies are built with [`ndk-build`](https://developer.android.com/ndk/guides/ndk-build) and configured with several `*.mk` files scatterred in many places.
The `rust` folder is a proper Cargo workspace, and all Rust code is built with `cargo` just like any other Rust projects.
## Rust + C/C++
To reduce complexity involved in linking, all Rust code is built as `staticlib` and linked to C++ targets to ensure our final product is built with an officially supported NDK build system. Each C++ target can at most link to **one** Rust `staticlib` or else multiple definitions error will occur.
We use the [`cxx`](https://cxx.rs) project for interop between Rust and C++. Although cxx supports interop in both directions, for Magisk, it is strongly advised to avoid calling C++ functions in Rust; if some functionality required in Rust is already implemented in C++, the desired solution is to port the C++ implementation into Rust and export the migrated function back to C++.
## Development / IDE
All C++ code should be recognized and properly indexed by Android Studio out of the box. For Rust:
- Install the [Rust plugin](https://www.jetbrains.com/rust/) in Android Studio
- In Preferences > Languages & Frameworks > Rust, set `$ANDROID_SDK_ROOT/ndk/magisk/toolchains/rust/bin` as the toolchain location
- Open `native/rust/Cargo.toml`, and select "Attach" in the "No Cargo projects found" banner
Note: run `./build.py binary` before developing to make sure generated code is created.

25
native/jni/Android-rs.mk Normal file
View File

@@ -0,0 +1,25 @@
LOCAL_PATH := $(call my-dir)
###########################
# Rust compilation outputs
###########################
include $(CLEAR_VARS)
LOCAL_MODULE := magisk-rs
LOCAL_SRC_FILES := ../out/$(TARGET_ARCH_ABI)/libmagisk-rs.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := boot-rs
LOCAL_SRC_FILES := ../out/$(TARGET_ARCH_ABI)/libmagiskboot-rs.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := init-rs
LOCAL_SRC_FILES := ../out/$(TARGET_ARCH_ABI)/libmagiskinit-rs.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := policy-rs
LOCAL_SRC_FILES := ../out/$(TARGET_ARCH_ABI)/libmagiskpolicy-rs.a
include $(PREBUILT_STATIC_LIBRARY)

View File

@@ -14,7 +14,8 @@ LOCAL_STATIC_LIBRARIES := \
libsystemproperties \
libphmap \
libxhook \
libmincrypt
libmincrypt \
libmagisk-rs
LOCAL_SRC_FILES := \
core/applets.cpp \
@@ -68,7 +69,8 @@ LOCAL_STATIC_LIBRARIES := \
libbase \
libcompat \
libpolicy \
libxz
libxz \
libinit-rs
LOCAL_SRC_FILES := \
init/init.cpp \
@@ -95,7 +97,8 @@ LOCAL_STATIC_LIBRARIES := \
libbz2 \
libfdt \
libz \
libzopfli
libzopfli \
libboot-rs
LOCAL_SRC_FILES := \
boot/main.cpp \
@@ -119,7 +122,8 @@ LOCAL_MODULE := magiskpolicy
LOCAL_STATIC_LIBRARIES := \
libbase \
libbase \
libpolicy
libpolicy \
libpolicy-rs
LOCAL_SRC_FILES := sepolicy/main.cpp
@@ -135,7 +139,8 @@ LOCAL_STATIC_LIBRARIES := \
libbase \
libcompat \
libnanopb \
libsystemproperties
libsystemproperties \
libmagisk-rs
LOCAL_SRC_FILES := \
core/applet_stub.cpp \
@@ -181,6 +186,7 @@ LOCAL_SRC_FILES := \
sepolicy/statement.cpp
include $(BUILD_STATIC_LIBRARY)
include jni/Android-rs.mk
include jni/base/Android.mk
include jni/external/Android.mk

View File

@@ -15,7 +15,8 @@ LOCAL_SRC_FILES := \
selinux.cpp \
logging.cpp \
xwrap.cpp \
stream.cpp
stream.cpp \
../external/cxx-rs/src/cxx.cc
include $(BUILD_STATIC_LIBRARY)
# All static executables should link with libcompat

View File

@@ -6,7 +6,7 @@
#undef _FORTIFY_SOURCE
extern int __vloge(const char* fmt, va_list ap);
extern void __vloge(const char* fmt, va_list ap);
static inline __noreturn __printflike(1, 2) void __fortify_fatal(const char* fmt, ...) {
va_list args;

View File

@@ -5,3 +5,4 @@
#include "../files.hpp"
#include "../misc.hpp"
#include "../logging.hpp"
#include <base-rs.hpp>

View File

@@ -1,62 +1,75 @@
#include <cstdio>
#include <cstdlib>
#include <flags.h>
#include <android/log.h>
#include "logging.hpp"
#include <flags.h>
#include <base.hpp>
// Just need to include it somewhere
#include <base-rs.cpp>
using namespace std;
int nop_log(const char *, va_list) { return 0; }
void nop_ex(int) {}
log_callback log_cb = {
.d = nop_log,
.i = nop_log,
.w = nop_log,
.e = nop_log,
.ex = nop_ex
};
void no_logging() {
log_cb.d = nop_log;
log_cb.i = nop_log;
log_cb.w = nop_log;
log_cb.e = nop_log;
log_cb.ex = nop_ex;
static int fmt_and_log_with_rs(LogLevel level, const char *fmt, va_list ap) {
char buf[4096];
int ret = vsnprintf(buf, sizeof(buf), fmt, ap);
log_with_rs(level, rust::Str(buf, ret));
return ret;
}
static int vprintfe(const char *fmt, va_list ap) {
return vfprintf(stderr, fmt, ap);
int (*cpp_logger)(LogLevel level, const char *fmt, va_list ap) = fmt_and_log_with_rs;
// Used to override external C library logging
extern "C" int magisk_log_print(int prio, const char *tag, const char *fmt, ...) {
LogLevel level;
switch (prio) {
case ANDROID_LOG_DEBUG:
level = LogLevel::Debug;
break;
case ANDROID_LOG_INFO:
level = LogLevel::Info;
break;
case ANDROID_LOG_WARN:
level = LogLevel::Warn;
break;
case ANDROID_LOG_ERROR:
level = LogLevel::Error;
break;
default:
return 0;
}
char fmt_buf[4096];
auto len = strlcpy(fmt_buf, tag, sizeof(fmt_buf));
// Prevent format specifications in the tag
std::replace(fmt_buf, fmt_buf + len, '%', '_');
snprintf(fmt_buf + len, sizeof(fmt_buf) - len, ": %s", fmt);
va_list argv;
va_start(argv, fmt);
int ret = cpp_logger(level, fmt_buf, argv);
va_end(argv);
return ret;
}
void cmdline_logging() {
log_cb.d = vprintfe;
log_cb.i = vprintf;
log_cb.w = vprintfe;
log_cb.e = vprintfe;
log_cb.ex = exit;
}
#define LOG_BODY(prio) { \
#define LOG_BODY(level) { \
va_list argv; \
va_start(argv, fmt); \
log_cb.prio(fmt, argv); \
cpp_logger(LogLevel::level, fmt, argv); \
va_end(argv); \
}
// LTO will optimize out the NOP function
#if MAGISK_DEBUG
void LOGD(const char *fmt, ...) { LOG_BODY(d) }
void LOGD(const char *fmt, ...) { LOG_BODY(Debug) }
#else
void LOGD(const char *fmt, ...) {}
#endif
void LOGI(const char *fmt, ...) { LOG_BODY(i) }
void LOGW(const char *fmt, ...) { LOG_BODY(w) }
void LOGE(const char *fmt, ...) { LOG_BODY(e); log_cb.ex(EXIT_FAILURE); }
void LOGI(const char *fmt, ...) { LOG_BODY(Info) }
void LOGW(const char *fmt, ...) { LOG_BODY(Warn) }
void LOGE(const char *fmt, ...) { LOG_BODY(Error) }
// Export raw symbol to fortify compat
extern "C" int __vloge(const char* fmt, va_list ap) {
return log_cb.e(fmt, ap);
extern "C" void __vloge(const char* fmt, va_list ap) {
cpp_logger(LogLevel::Error, fmt, ap);
}

View File

@@ -3,24 +3,12 @@
#include <cerrno>
#include <cstdarg>
struct log_callback {
int (*d)(const char* fmt, va_list ap);
int (*i)(const char* fmt, va_list ap);
int (*w)(const char* fmt, va_list ap);
int (*e)(const char* fmt, va_list ap);
void (*ex)(int code);
};
#include <base-rs.hpp>
extern log_callback log_cb;
extern int (*cpp_logger)(LogLevel level, const char *fmt, va_list ap);
void LOGD(const char *fmt, ...) __printflike(1, 2);
void LOGI(const char *fmt, ...) __printflike(1, 2);
void LOGW(const char *fmt, ...) __printflike(1, 2);
void LOGE(const char *fmt, ...) __printflike(1, 2);
#define PLOGE(fmt, args...) LOGE(fmt " failed with %d: %s\n", ##args, errno, std::strerror(errno))
int nop_log(const char *, va_list);
void nop_ex(int);
void no_logging();
void cmdline_logging();

View File

@@ -188,7 +188,7 @@ static bool check_data() {
return false;
auto crypto = getprop("ro.crypto.state");
if (!crypto.empty()) {
if (crypto == "unencrypted") {
if (crypto != "encrypted") {
// Unencrypted, we can directly access data
return true;
} else {

View File

@@ -20,7 +20,6 @@ void unlock_blocks();
void reboot();
void start_log_daemon();
void setup_logfile(bool reset);
void magisk_logging();
std::string read_certificate(int fd, int version = -1);
// Module stuffs

View File

@@ -11,6 +11,8 @@
#include <resetprop.hpp>
#include <flags.h>
#include <core-rs.cpp>
#include "core.hpp"
using namespace std;

View File

@@ -35,7 +35,7 @@ void setup_logfile(bool reset) {
}
// Maximum message length for pipes to transfer atomically
#define MAX_MSG_LEN (PIPE_BUF - sizeof(log_meta))
#define MAX_MSG_LEN (int) (PIPE_BUF - sizeof(log_meta))
static void *logfile_writer(void *arg) {
int pipefd = (long) arg;
@@ -124,11 +124,11 @@ static void *logfile_writer(void *arg) {
}
}
int magisk_log(int prio, const char *fmt, va_list ap) {
char buf[MAX_MSG_LEN + 1];
int len = vsnprintf(buf, sizeof(buf), fmt, ap);
void magisk_log_write(int prio, const char *msg, int len) {
if (logd_fd >= 0) {
// Truncate
len = std::min(MAX_MSG_LEN, len);
log_meta meta = {
.prio = prio,
.len = len,
@@ -139,7 +139,7 @@ int magisk_log(int prio, const char *fmt, va_list ap) {
iovec iov[2];
iov[0].iov_base = &meta;
iov[0].iov_len = sizeof(meta);
iov[1].iov_base = buf;
iov[1].iov_base = (void *) msg;
iov[1].iov_len = len;
if (writev(logd_fd, iov, 2) < 0) {
@@ -147,41 +147,6 @@ int magisk_log(int prio, const char *fmt, va_list ap) {
close(logd_fd.exchange(-1));
}
}
__android_log_write(prio, "Magisk", buf);
return len;
}
// Used to override external C library logging
extern "C" int magisk_log_print(int prio, const char *tag, const char *fmt, ...) {
char buf[4096];
auto len = strlcpy(buf, tag, sizeof(buf));
// Prevent format specifications in the tag
std::replace(buf, buf + len, '%', '_');
snprintf(buf + len, sizeof(buf) - len, ": %s", fmt);
va_list argv;
va_start(argv, fmt);
int ret = magisk_log(prio, buf, argv);
va_end(argv);
return ret;
}
#define mlog(prio) [](auto fmt, auto ap){ return magisk_log(ANDROID_LOG_##prio, fmt, ap); }
void magisk_logging() {
log_cb.d = mlog(DEBUG);
log_cb.i = mlog(INFO);
log_cb.w = mlog(WARN);
log_cb.e = mlog(ERROR);
log_cb.ex = nop_ex;
}
#define alog(prio) [](auto fmt, auto ap){ return __android_log_vprint(ANDROID_LOG_##prio, "Magisk", fmt, ap); }
void android_logging() {
log_cb.d = alog(DEBUG);
log_cb.i = alog(INFO);
log_cb.w = alog(WARN);
log_cb.e = alog(ERROR);
log_cb.ex = nop_ex;
}
void start_log_daemon() {

View File

@@ -127,6 +127,7 @@ int magisk_main(int argc, char *argv[]) {
#if 0
/* Entry point for testing stuffs */
else if (argv[1] == "--test"sv) {
rust_test_entry();
return 0;
}
#endif

View File

@@ -103,8 +103,10 @@ int get_manager(int user_id, string *pkg, bool install) {
snprintf(app_path, sizeof(app_path),
"%s/%d/%s/dyn/current.apk", APP_DATA_DIR, u, mgr_pkg->data());
int dyn = open(app_path, O_RDONLY | O_CLOEXEC);
if (dyn < 0)
if (dyn < 0) {
LOGW("pkg: no dyn APK, ignore\n");
return false;
}
bool mismatch = default_cert && read_certificate(dyn, MAGISK_VER_CODE) != *default_cert;
close(dyn);
if (mismatch) {
@@ -270,7 +272,8 @@ int get_manager(int user_id, string *pkg, bool install) {
install_stub();
not_found:
LOGW("pkg: cannot find manager for user=[%d]\n", user_id);
const char *name = mgr_pkg->empty() ? JAVA_PACKAGE_NAME : mgr_pkg->data();
LOGW("pkg: cannot find %s for user=[%d]\n", name, user_id);
if (pkg) pkg->clear();
return -1;
}

Some files were not shown because too many files have changed in this diff Show More