class Log { static TAG = '[Phone]' static Debug = true static format(...msg) { let m = [] for (let i = 0; i < msg.length; i++) { if (typeof msg[i] === 'object') { m.push(JSON.stringify(msg[i])) } else { m.push(msg[i]) } } m = m.join(' ') return m } static i(...msg) { if (!this.Debug) return console.log(`\x1b[30m${this.TAG} ${this.format(...msg)}\x1b[0m`) } static w(...msg) { console.log(`\x1b[33m${this.TAG} ${this.format(...msg)}\x1b[0m`) } static e(...msg) { console.log(`\x1b[31m${this.TAG} ${this.format(...msg)}\x1b[0m`) } static s(...msg) { console.log(`\x1b[32m${this.TAG} ${this.format(...msg)}\x1b[0m`) } } function trace(tag) { Log.e((tag || '') + Java.use('android.util.Log').getStackTraceString(Java.use('java.lang.Throwable').$new())) } setImmediate(() => { Java.perform(function () { const SubscriptionController = Java.use('com.android.internal.telephony.SubscriptionController') SubscriptionController.getSubscriptionInfo.overload('int').implementation = function (slotIndex) { Log.e('getSubscriptionInfo()') return this.getSubscriptionInfo(slotIndex) } SubscriptionController.getActiveSubscriptionInfoList.overload( 'java.lang.String', 'java.lang.String' ).implementation = function (callingPackage, callingFeature) { Log.e(`getActiveSubscriptionInfoList(${callingPackage}, ${callingFeature})`) return this.getActiveSubscriptionInfoList(callingPackage, callingFeature) } const SubscriptionInfo = Java.use('android.telephony.SubscriptionInfo') SubscriptionInfo.getCarrierId.overload().implementation = function () { const carrierId = this.getCarrierId() Log.e(`getCarrierId()=${carrierId}`) return carrierId } SubscriptionInfo.getMccString.overload().implementation = function () { const mcc = this.getMccString() Log.e(`getMccString()=${mcc}`) return mcc } SubscriptionInfo.getMcc.overload().implementation = function () { const mcc = this.getMcc() Log.e(`getMcc()=${mcc}`) return mcc } const TelephoneyManager = Java.use('android.telephony.TelephonyManager') TelephoneyManager.getSimCarrierId.overload().implementation = function () { const carrierId = this.getSimCarrierId() Log.e(`getSimCarrierId()=${carrierId}`) return carrierId } }) })