@@ -10,6 +10,7 @@ import app.revanced.lib.adb.Constants.MOUNT_PATH
10
10
import app.revanced.lib.adb.Constants.MOUNT_SCRIPT
11
11
import app.revanced.lib.adb.Constants.PATCHED_APK_PATH
12
12
import app.revanced.lib.adb.Constants.PLACEHOLDER
13
+ import app.revanced.lib.adb.Constants.RESOLVE_ACTIVITY
13
14
import app.revanced.lib.adb.Constants.RESTART
14
15
import app.revanced.lib.adb.Constants.TMP_PATH
15
16
import app.revanced.lib.adb.Constants.UMOUNT
@@ -74,9 +75,14 @@ sealed class AdbManager private constructor(deviceSerial: String? = null) {
74
75
logger.info(" Installing by mounting" )
75
76
76
77
val applyReplacement = getPlaceholderReplacement(
77
- apk.packageName ? : throw IllegalArgumentException ( " Package name is required " )
78
+ apk.packageName ? : throw PackageNameRequiredException ( )
78
79
)
79
80
81
+ device.run (RESOLVE_ACTIVITY .applyReplacement()).inputStream.bufferedReader().readLine().let { line ->
82
+ if (line != " No activity found" ) return @let
83
+ throw throw FailedToFindInstalledPackageException (apk.packageName)
84
+ }
85
+
80
86
device.push(apk.file, TMP_PATH )
81
87
82
88
device.run (" $CREATE_DIR $INSTALLATION_PATH " )
@@ -142,4 +148,10 @@ sealed class AdbManager private constructor(deviceSerial: String? = null) {
142
148
Exception (deviceSerial?.let {
143
149
" The device with the ADB device serial \" $deviceSerial \" can not be found"
144
150
} ? : " No ADB device found" )
151
+
152
+ class FailedToFindInstalledPackageException internal constructor(packageName : String ) :
153
+ Exception (" Failed to find installed package \" $packageName \" because no activity was found" )
154
+
155
+ class PackageNameRequiredException internal constructor() :
156
+ Exception (" Package name is required" )
145
157
}
0 commit comments