@@ -19,6 +19,7 @@ import android.widget.Toast
1919import androidx.core.content.FileProvider
2020import androidx.preference.ListPreference
2121import androidx.preference.Preference
22+ import dalvik.system.PathClassLoader
2223import java.io.ByteArrayInputStream
2324import java.io.File
2425import java.io.FileInputStream
@@ -29,6 +30,23 @@ object ImsSettings : Settings {
2930 val forceEnableSettings = " key_ims_force_enable_setting"
3031 val installImsApk = " key_ims_install_apn"
3132
33+ fun checkHasPhhSignature (): Boolean {
34+ try {
35+ val cl = PathClassLoader (
36+ " /system/framework/services.jar" ,
37+ ClassLoader .getSystemClassLoader()
38+ )
39+ val pmUtils = cl.loadClass(" com.android.server.pm.PackageManagerServiceUtils" )
40+ val field = pmUtils.getDeclaredField(" PHH_SIGNATURE" )
41+ Log .d(" PHH" , " checkHasPhhSignature Field $field " )
42+ return true
43+ } catch (t: Throwable ) {
44+ Log .d(" PHH" , " checkHasPhhSignature Field failed" )
45+ return false
46+ }
47+ }
48+
49+
3250 override fun enabled () = true
3351}
3452
@@ -97,19 +115,21 @@ class ImsSettingsFragment : SettingsFragment() {
97115 Log .d(" PHH" , " Qualcomm HIDL radio = ${Ims .gotQcomHidl} " )
98116 Log .d(" PHH" , " Qualcomm AIDL radio = ${Ims .gotQcomAidl} " )
99117
118+ val signSuffix = if (ImsSettings .checkHasPhhSignature()) " -resigned" else " "
119+
100120 val (url, message) =
101121 when {
102122 (Ims .gotMtkR || Ims .gotMtkS || Ims .gotMtkAidl) && Build .VERSION .SDK_INT >= 34
103- -> Pair (" https://treble.phh.me/ims-mtk-u.apk" , " MediaTek R+ vendor" )
104- Ims .gotMtkP -> Pair (" https://treble.phh.me/stable/ims-mtk-p.apk" , " MediaTek P vendor" )
105- Ims .gotMtkQ -> Pair (" https://treble.phh.me/stable/ims-mtk-q.apk" , " MediaTek Q vendor" )
106- Ims .gotMtkR -> Pair (" https://treble.phh.me/stable/ims-mtk-r.apk" , " MediaTek R vendor" )
107- Ims .gotMtkS -> Pair (" https://treble.phh.me/stable/ims-mtk-s.apk" , " MediaTek S vendor" )
123+ -> Pair (" https://treble.phh.me/ims-mtk-u$signSuffix .apk" , " MediaTek R+ vendor" )
124+ Ims .gotMtkP -> Pair (" https://treble.phh.me/stable/ims-mtk-p$signSuffix .apk" , " MediaTek P vendor" )
125+ Ims .gotMtkQ -> Pair (" https://treble.phh.me/stable/ims-mtk-q$signSuffix .apk" , " MediaTek Q vendor" )
126+ Ims .gotMtkR -> Pair (" https://treble.phh.me/stable/ims-mtk-r$signSuffix .apk" , " MediaTek R vendor" )
127+ Ims .gotMtkS -> Pair (" https://treble.phh.me/stable/ims-mtk-s$signSuffix .apk" , " MediaTek S vendor" )
108128 (Ims .gotQcomHidl || Ims .gotQcomAidl) && Build .VERSION .SDK_INT >= 34
109- -> Pair (" https://treble.phh.me/ims-caf-u.apk" , " Qualcomm vendor" )
110- Ims .gotQcomHidlMoto -> Pair (" https://treble.phh.me/stable/ims-caf-moto.apk" , " Qualcomm pre-S vendor (Motorola)" )
111- Ims .gotQcomHidl -> Pair (" https://treble.phh.me/stable/ims-q.64.apk" , " Qualcomm pre-S vendor" )
112- Ims .gotQcomAidl -> Pair (" https://treble.phh.me/stable/ims-caf-s.apk" , " Qualcomm S+ vendor" )
129+ -> Pair (" https://treble.phh.me/ims-caf-u$signSuffix .apk" , " Qualcomm vendor" )
130+ Ims .gotQcomHidlMoto -> Pair (" https://treble.phh.me/stable/ims-caf-moto$signSuffix .apk" , " Qualcomm pre-S vendor (Motorola)" )
131+ Ims .gotQcomHidl -> Pair (" https://treble.phh.me/stable/ims-q.64$signSuffix .apk" , " Qualcomm pre-S vendor" )
132+ Ims .gotQcomAidl -> Pair (" https://treble.phh.me/stable/ims-caf-s$signSuffix .apk" , " Qualcomm S+ vendor" )
113133 else -> Pair (" " , " NOT SUPPORTED" )
114134 }
115135
0 commit comments