25c557248c
Previously, we use either BroadcastReceivers or Activities to receive messages from our native daemon, but both have their own downsides. Some OEMs blocks broadcasts if the app is not running in the background, regardless of who the caller is. Activities on the other hand, despite working 100% of the time, will steal the focus of the current foreground app, even though we are just doing some logging and showing a toast. In addition, since stubs for hiding Magisk Manager is introduced, our only communication method is left with the broadcast option, as only broadcasting allows targeting a specific package name, not a component name (which will be obfuscated in the case of stubs). To make sure root requests will work on all devices, Magisk had to do some experiments every boot to test whether broadcast is deliverable or not. This makes the whole thing even more complicated then ever. So lets take a look at another kind of component in Android apps: ContentProviders. It is a vital part of Android's ecosystem, and as far as I know no OEMs will block requests to ContentProviders (or else tons of functionality will break catastrophically). Starting at API 11, the system supports calling a specific method in ContentProviders, optionally sending extra data along with the method call. This is perfect for the native daemon to start a communication with Magisk Manager. Another cool thing is that we no longer need to know the component name of the reciever, as ContentProviders identify themselves with an "authority" name, which in Magisk Manager's case is tied to the package name. We already have a mechanism to keep track of our current manager package name, so this works out of the box. So yay! No more flaky broadcast tests, no more stupid OEMs blocking broadcasts for some bizzare reasons. This method should in theory work on almost all devices and situations.
82 lines
2.7 KiB
Kotlin
82 lines
2.7 KiB
Kotlin
package com.topjohnwu.magisk
|
|
|
|
import android.os.Process
|
|
import java.io.File
|
|
|
|
object Const {
|
|
|
|
// Paths
|
|
const val MAGISK_PATH = "/sbin/.magisk/img"
|
|
var MAGISK_DISABLE_FILE = File("xxx")
|
|
const val TMP_FOLDER_PATH = "/dev/tmp"
|
|
const val MAGISK_LOG = "/cache/magisk.log"
|
|
|
|
// Versions
|
|
const val SNET_EXT_VER = 13
|
|
const val SNET_REVISION = "a6c47f86f10b310358afa9dbe837037dd5d561df"
|
|
const val BOOTCTL_REVISION = "a6c47f86f10b310358afa9dbe837037dd5d561df"
|
|
|
|
// Misc
|
|
const val ANDROID_MANIFEST = "AndroidManifest.xml"
|
|
const val MAGISK_INSTALL_LOG_FILENAME = "magisk_install_log_%s.log"
|
|
const val MANAGER_CONFIGS = ".tmp.magisk.config"
|
|
val USER_ID = Process.myUid() / 100000
|
|
|
|
object Version {
|
|
const val MIN_VERSION = "v18.0"
|
|
const val MIN_VERCODE = 18000
|
|
const val CONNECT_MODE = 20100
|
|
const val PROVIDER_CONNECT = 20102
|
|
}
|
|
|
|
object ID {
|
|
const val FETCH_ZIP = 2
|
|
const val SELECT_BOOT = 3
|
|
|
|
// notifications
|
|
const val MAGISK_UPDATE_NOTIFICATION_ID = 4
|
|
const val APK_UPDATE_NOTIFICATION_ID = 5
|
|
const val DTBO_NOTIFICATION_ID = 7
|
|
const val HIDE_MANAGER_NOTIFICATION_ID = 8
|
|
const val UPDATE_NOTIFICATION_CHANNEL = "update"
|
|
const val PROGRESS_NOTIFICATION_CHANNEL = "progress"
|
|
const val CHECK_MAGISK_UPDATE_WORKER_ID = "magisk_update"
|
|
}
|
|
|
|
object Url {
|
|
const val ZIP_URL = "https://github.com/Magisk-Modules-Repo/%s/archive/master.zip"
|
|
const val PAYPAL_URL = "https://www.paypal.me/topjohnwu"
|
|
const val PATREON_URL = "https://www.patreon.com/topjohnwu"
|
|
const val TWITTER_URL = "https://twitter.com/topjohnwu"
|
|
const val XDA_THREAD = "http://forum.xda-developers.com/showthread.php?t=3432382"
|
|
const val SOURCE_CODE_URL = "https://github.com/topjohnwu/Magisk"
|
|
|
|
const val GITHUB_RAW_URL = "https://raw.githubusercontent.com/"
|
|
const val GITHUB_API_URL = "https://api.github.com/users/Magisk-Modules-Repo/"
|
|
}
|
|
|
|
object Key {
|
|
// others
|
|
const val LINK_KEY = "Link"
|
|
const val IF_NONE_MATCH = "If-None-Match"
|
|
const val ETAG_KEY = "ETag"
|
|
// intents
|
|
const val OPEN_SECTION = "section"
|
|
const val INTENT_SET_APP = "app_json"
|
|
const val FLASH_ACTION = "action"
|
|
const val FLASH_DATA = "additional_data"
|
|
const val DISMISS_ID = "dismiss_id"
|
|
const val BROADCAST_MANAGER_UPDATE = "manager_update"
|
|
const val BROADCAST_REBOOT = "reboot"
|
|
}
|
|
|
|
object Value {
|
|
const val FLASH_ZIP = "flash"
|
|
const val PATCH_FILE = "patch"
|
|
const val FLASH_MAGISK = "magisk"
|
|
const val FLASH_INACTIVE_SLOT = "slot"
|
|
const val UNINSTALL = "uninstall"
|
|
}
|
|
|
|
}
|