inspect_phone.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. class Log {
  2. static TAG = '[Phone]'
  3. static Debug = true
  4. static format(...msg) {
  5. let m = []
  6. for (let i = 0; i < msg.length; i++) {
  7. if (typeof msg[i] === 'object') {
  8. m.push(JSON.stringify(msg[i]))
  9. } else {
  10. m.push(msg[i])
  11. }
  12. }
  13. m = m.join(' ')
  14. return m
  15. }
  16. static i(...msg) {
  17. if (!this.Debug) return
  18. console.log(`\x1b[30m${this.TAG} ${this.format(...msg)}\x1b[0m`)
  19. }
  20. static w(...msg) {
  21. console.log(`\x1b[33m${this.TAG} ${this.format(...msg)}\x1b[0m`)
  22. }
  23. static e(...msg) {
  24. console.log(`\x1b[31m${this.TAG} ${this.format(...msg)}\x1b[0m`)
  25. }
  26. static s(...msg) {
  27. console.log(`\x1b[32m${this.TAG} ${this.format(...msg)}\x1b[0m`)
  28. }
  29. }
  30. function trace(tag) {
  31. Log.e((tag || '') + Java.use('android.util.Log').getStackTraceString(Java.use('java.lang.Throwable').$new()))
  32. }
  33. setImmediate(() => {
  34. Java.perform(function () {
  35. const SystemProperties = Java.use('android.os.SystemProperties')
  36. const PhoneInterfaceManager = Java.use('com.android.phone.PhoneInterfaceManager')
  37. PhoneInterfaceManager.getLine1NumberForDisplay.overload(
  38. 'int',
  39. 'java.lang.String',
  40. 'java.lang.String'
  41. ).implementation = function (subId, callingPackage, callingFeatureId) {
  42. const res = this.getLine1NumberForDisplay(subId, callingPackage, callingFeatureId)
  43. Log.i(
  44. `PhoneInterfaceManager.getLine1NumberForDisplay(${subId}, ${callingPackage}, ${callingFeatureId}): ${res}`
  45. )
  46. return res
  47. }
  48. PhoneInterfaceManager.getNetworkCountryIsoForPhone.overload('int').implementation = function (phoneId) {
  49. const res = this.getNetworkCountryIsoForPhone(phoneId)
  50. Log.i(`PhoneInterfaceManager.getNetworkCountryIsoForPhone(${phoneId}): ${res}`)
  51. return res
  52. }
  53. PhoneInterfaceManager.getImeiForSlot.overload('int', 'java.lang.String', 'java.lang.String').implementation =
  54. function (slotId, callingPackage, callingFeatureId) {
  55. const res = this.getImeiForSlot(slotId, callingPackage, callingFeatureId)
  56. Log.i(`PhoneInterfaceManager.getImeiForSlot(${slotId}, ${callingPackage}, ${callingFeatureId}): ${res}`)
  57. return res
  58. }
  59. SystemProperties.get.overload('java.lang.String').implementation = function (key) {
  60. const res = this.get(key)
  61. Log.i(`SystemProperties.get(${key}): ${res}`)
  62. return res
  63. }
  64. const SubscriptionController = Java.use('com.android.internal.telephony.SubscriptionController')
  65. SubscriptionController.getSimStateForSlotIndex.overload('int').implementation = function (slotIndex) {
  66. const res = this.getSimStateForSlotIndex(slotIndex)
  67. Log.i(`SubscriptionController.getSimStateForSlotIndex(${slotIndex}): ${res}`)
  68. return res
  69. }
  70. SubscriptionController.getPhoneNumberFromFirstAvailableSource.overload(
  71. 'int',
  72. 'java.lang.String',
  73. 'java.lang.String'
  74. ).implementation = function (subId, callingPackage, callingFeatureId) {
  75. const res = this.getPhoneNumberFromFirstAvailableSource(subId, callingPackage, callingFeatureId)
  76. Log.i(
  77. `SubscriptionController.getPhoneNumberFromFirstAvailableSource(${subId}, ${callingPackage}, ${callingFeatureId}): ${res}`
  78. )
  79. return res
  80. }
  81. const SubscriptionInfo = Java.use('android.telephony.SubscriptionInfo')
  82. SubscriptionController.getActiveSubscriptionInfoList.overload('java.lang.String').implementation = function (
  83. callingPackage
  84. ) {
  85. const res = this.getActiveSubscriptionInfoList(callingPackage)
  86. Log.i(`SubscriptionController.getActiveSubscriptionInfoList(${callingPackage})`)
  87. return res
  88. }
  89. SubscriptionController.getActiveSubscriptionInfoList.overload(
  90. 'java.lang.String',
  91. 'java.lang.String'
  92. ).implementation = function (callingPackage, callingFeatureId) {
  93. const res = this.getActiveSubscriptionInfoList(callingPackage, callingFeatureId)
  94. Log.i(`SubscriptionController.getActiveSubscriptionInfoList(${callingPackage}, ${callingFeatureId})`)
  95. return res
  96. }
  97. SubscriptionController.getActiveSubscriptionInfoList.overload('java.lang.String').implementation = function (
  98. callingPackage
  99. ) {
  100. const res = this.getActiveSubscriptionInfoList(callingPackage)
  101. Log.i(`SubscriptionController.getActiveSubscriptionInfoList(${callingPackage})`)
  102. return res
  103. }
  104. const PhoneSubInfoController = Java.use('com.android.internal.telephony.PhoneSubInfoController')
  105. PhoneSubInfoController.getIccSerialNumberForSubscriber.overload(
  106. 'int',
  107. 'java.lang.String',
  108. 'java.lang.String'
  109. ).implementation = function (subId, callingPackage, callingFeatureId) {
  110. const res = this.getIccSerialNumberForSubscriber(subId, callingPackage, callingFeatureId)
  111. Log.i(
  112. `PhoneInterfaceManager.getIccSerialNumberForSubscriber(${subId}, ${callingPackage}, ${callingFeatureId}): ${res}`
  113. )
  114. return res
  115. }
  116. PhoneSubInfoController.getSubscriberIdForSubscriber.overload(
  117. 'int',
  118. 'java.lang.String',
  119. 'java.lang.String'
  120. ).implementation = function (subId, callingPackage, callingFeatureId) {
  121. const res = this.getSubscriberIdForSubscriber(subId, callingPackage, callingFeatureId)
  122. Log.i(
  123. `PhoneInterfaceManager.getSubscriberIdForSubscriber(${subId}, ${callingPackage}, ${callingFeatureId}): ${res}`
  124. )
  125. return res
  126. }
  127. })
  128. })