Commit 26618f8d authored by topjohnwu's avatar topjohnwu

Don't do broadcast tests from app

Running broadcast tests from the app does not accurately verifies
whether the broadcasts can be delivered when the app is not running in
the foreground, which is why we are running the test.

The only sane way to verify broadcasts is to trigger the broadcast test
directly from the daemon on boot complete. If it is not deliverable,
then activity mode shall be chosen.

In the meantime, cleanup AndroidManifest.xml
parent 6f7c13b8
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!--
** Special Requirements **
This AndroidManifest.xml will be copied into the stub
APK to allow APK delegation. This is why these special
requirements exist.
* Class names *
Class names a.a, a.c, a.e should not be changed as they are used
externally. All other class names can be changed.
* Resource IDs *
All resource IDs referred in AndroidManifest.xml is required to be
included into the "shared" module to make the ID match with stub.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="com.topjohnwu.magisk"> package="com.topjohnwu.magisk">
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" /> <uses-permission android:name="android.permission.USE_FINGERPRINT" />
...@@ -36,7 +18,6 @@ ...@@ -36,7 +18,6 @@
tools:replace="android:appComponentFactory"> tools:replace="android:appComponentFactory">
<!-- Splash --> <!-- Splash -->
<activity <activity
android:name="a.c" android:name="a.c"
android:configChanges="orientation|screenSize" android:configChanges="orientation|screenSize"
...@@ -48,21 +29,18 @@ ...@@ -48,21 +29,18 @@
</activity> </activity>
<!-- Main --> <!-- Main -->
<activity <activity
android:name="a.b" android:name="a.b"
android:configChanges="orientation|screenSize" android:configChanges="orientation|screenSize"
android:exported="true" /> android:exported="true" />
<!-- Flashing --> <!-- Flashing -->
<activity <activity
android:name="a.f" android:name="a.f"
android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="nosensor" /> android:screenOrientation="nosensor" />
<!-- Superuser --> <!-- Superuser -->
<activity <activity
android:name="a.m" android:name="a.m"
android:theme="@android:style/Theme.Translucent.NoTitleBar" android:theme="@android:style/Theme.Translucent.NoTitleBar"
...@@ -71,13 +49,11 @@ ...@@ -71,13 +49,11 @@
android:exported="false" /> android:exported="false" />
<!-- Receiver --> <!-- Receiver -->
<receiver <receiver
android:name="a.h" android:name="a.h"
android:directBootAware="true"> android:directBootAware="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.REBOOT" /> <action android:name="android.intent.action.REBOOT" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.LOCALE_CHANGED" /> <action android:name="android.intent.action.LOCALE_CHANGED" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
...@@ -89,7 +65,6 @@ ...@@ -89,7 +65,6 @@
</receiver> </receiver>
<!-- DownloadService --> <!-- DownloadService -->
<service <service
android:name="a.j" android:name="a.j"
android:exported="false" /> android:exported="false" />
...@@ -105,6 +80,12 @@ ...@@ -105,6 +80,12 @@
android:authorities="${applicationId}.workmanager-init" android:authorities="${applicationId}.workmanager-init"
tools:node="remove" /> tools:node="remove" />
<!-- We don't invalidate Room -->
<service
android:name="androidx.room.MultiInstanceInvalidationService"
android:exported="false"
tools:node="remove"/>
</application> </application>
</manifest> </manifest>
...@@ -24,7 +24,7 @@ object Const { ...@@ -24,7 +24,7 @@ object Const {
object Version { object Version {
const val MIN_SUPPORT = 18000 const val MIN_SUPPORT = 18000
const val CONNECT_MODE = 20002 const val CONNECT_MODE = 20100
} }
object ID { object ID {
......
...@@ -37,13 +37,8 @@ object Info { ...@@ -37,13 +37,8 @@ object Info {
val code = ShellUtils.fastCmd("magisk -V").toInt() val code = ShellUtils.fastCmd("magisk -V").toInt()
val hide = Shell.su("magiskhide --status").exec().isSuccess val hide = Shell.su("magiskhide --status").exec().isSuccess
var mode = -1 var mode = -1
if (code >= Const.Version.CONNECT_MODE) { if (code >= Const.Version.CONNECT_MODE)
mode = Shell.su("magisk --connect-mode").exec().code mode = Shell.su("magisk --connect-mode").exec().code
if (mode == 0) {
// Manually trigger broadcast test
Shell.su("magisk --broadcast-test").exec()
}
}
Env(code, str, hide, mode) Env(code, str, hide, mode)
}.getOrElse { Env() } }.getOrElse { Env() }
......
...@@ -51,17 +51,8 @@ open class GeneralReceiver : BaseReceiver() { ...@@ -51,17 +51,8 @@ open class GeneralReceiver : BaseReceiver() {
} }
when (intent.action ?: return) { when (intent.action ?: return) {
Intent.ACTION_REBOOT, Intent.ACTION_BOOT_COMPLETED -> { Intent.ACTION_REBOOT -> {
val action = intent.getStringExtra("action") when (val action = intent.getStringExtra("action") ?: return) {
if (action == null) {
// Actual boot completed event
Shell.su("mm_patch_dtbo").submit {
if (it.isSuccess)
Notifications.dtboPatched(context)
}
return
}
when (action) {
REQUEST -> { REQUEST -> {
val i = context.intent<SuRequestActivity>() val i = context.intent<SuRequestActivity>()
.setAction(action) .setAction(action)
...@@ -92,7 +83,7 @@ open class GeneralReceiver : BaseReceiver() { ...@@ -92,7 +83,7 @@ open class GeneralReceiver : BaseReceiver() {
Intent.ACTION_PACKAGE_FULLY_REMOVED -> { Intent.ACTION_PACKAGE_FULLY_REMOVED -> {
val pkg = getPkg(intent) val pkg = getPkg(intent)
policyDB.delete(pkg).blockingGet() policyDB.delete(pkg).blockingGet()
"magiskhide --rm $pkg".su().blockingGet() Shell.su("magiskhide --rm $pkg").submit()
} }
Intent.ACTION_LOCALE_CHANGED -> Shortcuts.setup(context) Intent.ACTION_LOCALE_CHANGED -> Shortcuts.setup(context)
Const.Key.BROADCAST_MANAGER_UPDATE -> { Const.Key.BROADCAST_MANAGER_UPDATE -> {
......
...@@ -60,6 +60,11 @@ open class SplashActivity : Activity() { ...@@ -60,6 +60,11 @@ open class SplashActivity : Activity() {
// Setup shortcuts // Setup shortcuts
Shortcuts.setup(this) Shortcuts.setup(this)
Shell.su("mm_patch_dtbo").submit {
if (it.isSuccess)
Notifications.dtboPatched(this)
}
DONE = true DONE = true
startActivity(intent<MainActivity>().apply { intent?.also { putExtras(it) } }) startActivity(intent<MainActivity>().apply { intent?.also { putExtras(it) } })
......
...@@ -118,3 +118,4 @@ mkdir -p /data/adb/modules 2>/dev/null ...@@ -118,3 +118,4 @@ mkdir -p /data/adb/modules 2>/dev/null
mkdir /data/adb/post-fs-data.d 2>/dev/null mkdir /data/adb/post-fs-data.d 2>/dev/null
mkdir /data/adb/services.d 2>/dev/null mkdir /data/adb/services.d 2>/dev/null
/sbin/magisk --daemon /sbin/magisk --daemon
/sbin/magisk --broadcast-test
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!--
Try to recreate the main app's AndroidManifest.xml
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="com.topjohnwu.magisk"> package="com.topjohnwu.magisk">
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" /> <uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application <application
android:name="a.e" android:name="a.e"
...@@ -58,7 +52,6 @@ ...@@ -58,7 +52,6 @@
android:directBootAware="true"> android:directBootAware="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.REBOOT" /> <action android:name="android.intent.action.REBOOT" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.LOCALE_CHANGED" /> <action android:name="android.intent.action.LOCALE_CHANGED" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment