通过adb shell/Tasker关闭第二个SIM卡-使用活动/意图 [英] Turning off second SIM via adb shell/Tasker - using activities/intents

查看:537
本文介绍了通过adb shell/Tasker关闭第二个SIM卡-使用活动/意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个支持两个SIM卡的Xiaomi Mi6.我需要弄清楚如何使用Tasker在下班时间关闭第二个SIM卡(SIM2).

I have a Xiaomi Mi6, which supports two SIMs. I need to figure out how I can switch the second SIM (SIM2) off outside business hours using Tasker.

我已经弄清楚了如何使用Tasker打开SIM2的设置页面:

I've got as far as figuring out how to open the settings page for SIM2 with Tasker:

Action: android.intent.action.MAIN
Cat: Launcher
Extra 1: subscription_id:1
Extra 2: slot_id:1
Package: com.android.phone
Class: com.android.phone.settings.MultiSimInfoEditorActivity
Target: Activity

会打开 SIM2 设置页面. 但是,我不知道如何打开或关闭SIM卡.

which brings up the settings page for SIM2, like so. However, I can't figure out how to toggle the SIM on or off.

为了找到有用的东西,我已经对com.android.phone(TeleService.apk)进行了反编译,但是由于我不了解Java,所以我不知道从这里去哪里.我知道SO上已经有Java解决方案

In hope of finding something useful I have decompiled com.android.phone (TeleService.apk) but as I don't know Java I haven't an idea where to go from here. I know there is a Java solution already on SO here but I have no idea if it works or how to adapt it to Tasker.

反编译的 MultiSimInfoEditorActivity 可以找到这里.我还记录了 logcat 当SIM卡出现时关闭并再次打开.

The decompiled MultiSimInfoEditorActivity can be found here. I have also taken a logcat of what occurs when the SIM is switched off and on again.

非常感谢您的帮助!

推荐答案

我已经解决了该问题,尽管它可能不适用于所有版本的Android.我仅在运行MIUI v9(Android版本8.0.0)的Mi6上进行过测试. 它需要root.

I've solved the issue, although it may not work for all versions of Android. I've only tested it with my Mi6 running MIUI v9, Android build 8.0.0. It requires root.

研究了我在上面的问题中链接了SO解决方案,我注意到该代码正在检索特定电话功能的索引号,然后将其用于运行命令以关闭移动数据.通过这种方式,我找到了一种实际上关闭SIM卡的方法.

After studying the SO solution linked above in my question I noticed that the code was retrieving the index number of a particular telephony function, which it would then use to run a command to switch off mobile data. Using this, I've found a way to actually switch the SIM off.

谷歌搜索产生了来自郝天邓的页面,其中显示了的这些索引ITelephony.aidl文件中列出了服务调用函数.这些就是Java代码正在获取的东西.这些都不适用于Mi6,但链接到

Googling produced this page from Haotian Deng that showed these indexes for the service call function were listed inside the ITelephony.aidl file. These are what were being fetched by the Java code . None of these worked for the Mi6, but linked to this page which explained the service call command:

# service
Usage: service [-h|-?]
    service list
    service check SERVICE
    service call SERVICE CODE [i32 INT | s16 STR] ...
Options:
  i32: Write the integer INT into the send parcel.
  s16: Write the UTF-16 string STR into the send parcel.

为此,我发现索引在设备的 framework.jar 中的 com.android.internal.telephony.ITelephony 中列出.

Armed with this I found that the indexes were listed in com.android.internal.telephony.ITelephony in the devices' framework.jar.

因此,要从设备中获取所需的索引,您需要从命令提示符处运行以下命令:

So, to get the required index out of your device, you'll need to run the following commands from command prompt:

  • 此处
  • 下载jadx
  • ADB拉设备framework.jar(adb拉/system/framework/framework.jar)
  • 使用7-Zip打开.jar文件并解压缩* .dex文件.
  • 使用jadx-gui打开每个.dex文件,直到找到具有以下树的文件: com.android.internal.telephony.ITelephony
  • 搜索项目 TRANSACTION_setSimPowerStateForSlot .注意后面的 = x ;这是索引号.
  • Download jadx from here
  • ADB pull the devices framework.jar (adb pull /system/framework/framework.jar)
  • Open the .jar file with 7-Zip and extract the *.dex files.
  • Open each .dex file with jadx-gui until you find the one with the following tree: com.android.internal.telephony.ITelephony
  • Search for the item TRANSACTION_setSimPowerStateForSlot. Note the = x after it; this is the index number.

现在您有了索引号,可以在adb shell(或Tasker中使用运行shell"功能)中测试以下命令. 您将需要在shell中"su",或将Tasker设置为"Use Root" .

Now you have the index number you can test the following command in adb shell (or Tasker, with the "run shell" function). You will need to "su" in shell, or set Tasker to "Use Root".

service call phone x i32 y i32 z

Where:           
x = index number you fetched previously,
y = your subscription ID (generally, SIM1 = 0, SIM2 = 1)
z = whether on (1) or off (0)

当然,现在您可以在Tasker中执行它,现在您可以在特定时间关闭任一SIM卡.

Of course, now that you can execute it in Tasker you can now switch either SIM off at specific times.

我已经证实它确实关闭了SIM卡(执行此命令后,电话会直接转到语音信箱),但我不确定此开关是否会产生进一步的影响.

I've verified that it does indeed switch the SIM off (calls go straight to voicemail right after this command is executed) but I'm unsure of any further effects this switch has.

享受!

这篇关于通过adb shell/Tasker关闭第二个SIM卡-使用活动/意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆