• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

[GUIDE] [ROOT] Switch off individual SIMs with Tasker.

Search This thread

kylemd

Senior Member
Aug 13, 2015
191
63
Sydney
I know that looking for this answer has bugged me for the past few years, so figured I'd x-post from Stack Overflow. I have found the solution to switching either SIM off in the Mi6 automatically. Will likely work with other phones.

The whole question and answer you can find on Stack Overflow here.

For Nougat

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

  • 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.

For Oreo it's slightly different...

TL;DR:
You need:
1. vdexExtractor from BatchApkTool
2. jadx

Step by step:
1. Pull /system/framework/arm64/boot-framework.vdex
2. extract it with vdexExtractor.
(ed: you can find vdexExtractor in the bin\bin64 folder in BatchApkTool. Use the syntax "vdexExtractor.exe -i path_to_vdex --ignore-crc-error")
3. Open the resulting class files with jadx and find the one that contains com.android.internal.telephony.ITelephony (ed: for Mi6 it was in classes2.dex)
4. Navigate to the class with jadx and locate the value of TRANSACTION_setSimPowerStateForSlot, this is your magic number. (ed: for Mi6 8.1 it's 163)

After you have the command you can use for example Tasker to enable and disable the SIM card.
The only downside of using this method is that major Android version bumps will most likely break this, as the numbers vary from android build to android build.

Using the output

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)

For example, to switch SIM2 off on my Mi6 the command on Nougat was service call phone 159 i32 1 i32 0 and for Oreo it was service call phone 163 i32 1 i32 0

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

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.

Enjoy!
 
Last edited:

ne0t

Senior Member
Feb 23, 2017
205
42
Tried this on Mi Max 2 on xiaomi.eu (China Developer ROM), but 'TRANSACTION_setSimPowerStateForSlot' is nowhere to be found..

public static abstract class Stub
extends Binder
implements ITelephony
{
private static final String DESCRIPTOR = "com.android.internal.telephony.ITelephony";
static final int TRANSACTION_answerRingingCall = 5;
static final int TRANSACTION_answerRingingCallForSubscriber = 6;
static final int TRANSACTION_call = 2;
static final int TRANSACTION_canChangeDtmfToneLength = 117;
static final int TRANSACTION_carrierActionSetMeteredApnsEnabled = 146;
static final int TRANSACTION_carrierActionSetRadioEnabled = 147;
static final int TRANSACTION_checkCarrierPrivilegesForPackage = 101;
static final int TRANSACTION_checkCarrierPrivilegesForPackageAnyPhone = 102;
static final int TRANSACTION_dial = 1;
static final int TRANSACTION_disableDataConnectivity = 38;
static final int TRANSACTION_disableLocationUpdates = 35;
static final int TRANSACTION_disableLocationUpdatesForSubscriber = 36;
static final int TRANSACTION_disableVisualVoicemailSmsFilter = 61;
static final int TRANSACTION_enableDataConnectivity = 37;
static final int TRANSACTION_enableLocationUpdates = 33;
static final int TRANSACTION_enableLocationUpdatesForSubscriber = 34;
static final int TRANSACTION_enableVideoCalling = 115;
static final int TRANSACTION_enableVisualVoicemailSmsFilter = 60;
static final int TRANSACTION_endCall = 3;
static final int TRANSACTION_endCallForSubscriber = 4;
static final int TRANSACTION_factoryReset = 132;
static final int TRANSACTION_getActivePhoneType = 46;
static final int TRANSACTION_getActivePhoneTypeForSlot = 47;
static final int TRANSACTION_getAidForAppType = 140;
static final int TRANSACTION_getAllCellInfo = 73;
static final int TRANSACTION_getAllowedCarriers = 145;
static final int TRANSACTION_getAtr = 139;
static final int TRANSACTION_getCalculatedPreferredNetworkType = 87;
static final int TRANSACTION_getCallState = 42;
static final int TRANSACTION_getCallStateForSlot = 43;
static final int TRANSACTION_getCarrierPackageNamesForIntentAndPhone = 103;
static final int TRANSACTION_getCarrierPrivilegeStatus = 100;
static final int TRANSACTION_getCdmaEriIconIndex = 48;
static final int TRANSACTION_getCdmaEriIconIndexForSubscriber = 49;
static final int TRANSACTION_getCdmaEriIconMode = 50;
static final int TRANSACTION_getCdmaEriIconModeForSubscriber = 51;
static final int TRANSACTION_getCdmaEriText = 52;
static final int TRANSACTION_getCdmaEriTextForSubscriber = 53;
static final int TRANSACTION_getCdmaMdn = 98;
static final int TRANSACTION_getCdmaMin = 99;
static final int TRANSACTION_getCdmaPrlVersion = 142;
static final int TRANSACTION_getCellLocation = 40;
static final int TRANSACTION_getCellNetworkScanResults = 91;
static final int TRANSACTION_getDataActivity = 44;
static final int TRANSACTION_getDataEnabled = 95;
static final int TRANSACTION_getDataNetworkType = 66;
static final int TRANSACTION_getDataNetworkTypeForSubscriber = 67;
static final int TRANSACTION_getDataState = 45;
static final int TRANSACTION_getDefaultSim = 75;
static final int TRANSACTION_getDeviceId = 128;
static final int TRANSACTION_getDeviceSoftwareVersionForSlot = 130;
static final int TRANSACTION_getEsn = 141;
static final int TRANSACTION_getImeiForSlot = 129;
static final int TRANSACTION_getLine1AlphaTagForDisplay = 106;
static final int TRANSACTION_getLine1NumberForDisplay = 105;
static final int TRANSACTION_getLocaleFromDefaultSim = 133;
static final int TRANSACTION_getLteOnCdmaMode = 71;
static final int TRANSACTION_getLteOnCdmaModeForSubscriber = 72;
static final int TRANSACTION_getMergedSubscriberIds = 107;
static final int TRANSACTION_getNeighboringCellInfo = 41;
static final int TRANSACTION_getNetworkType = 64;
static final int TRANSACTION_getNetworkTypeForSubscriber = 65;
static final int TRANSACTION_getPackagesWithCarrierPrivileges = 138;
static final int TRANSACTION_getPcscfAddress = 96;
static final int TRANSACTION_getPreferredNetworkType = 88;
static final int TRANSACTION_getRadioAccessFamily = 114;
static final int TRANSACTION_getServiceStateForSubscriber = 135;
static final int TRANSACTION_getSubIdForPhoneAccount = 131;
static final int TRANSACTION_getSystemVisualVoicemailSmsFilterSettings = 63;
static final int TRANSACTION_getTelephonyHistograms = 143;
static final int TRANSACTION_getTetherApnRequired = 89;
static final int TRANSACTION_getVisualVoicemailSmsFilterSettings = 62;
static final int TRANSACTION_getVoiceMessageCount = 56;
static final int TRANSACTION_getVoiceMessageCountForSubscriber = 57;
static final int TRANSACTION_getVoiceNetworkTypeForSubscriber = 68;
static final int TRANSACTION_getVoicemailRingtoneUri = 136;
static final int TRANSACTION_getVtDataUsage = 148;
static final int TRANSACTION_handlePinMmi = 24;
static final int TRANSACTION_handlePinMmiForSubscriber = 25;
static final int TRANSACTION_hasIccCard = 69;
static final int TRANSACTION_hasIccCardUsingSlotId = 70;
static final int TRANSACTION_iccCloseLogicalChannel = 78;
static final int TRANSACTION_iccExchangeSimIO = 81;
static final int TRANSACTION_iccOpenLogicalChannel = 76;
static final int TRANSACTION_iccOpenLogicalChannelWithP2 = 77;
static final int TRANSACTION_iccTransmitApduBasicChannel = 80;
static final int TRANSACTION_iccTransmitApduLogicalChannel = 79;
static final int TRANSACTION_invokeOemRilRequestRaw = 110;
static final int TRANSACTION_isDataConnectivityPossible = 39;
static final int TRANSACTION_isHearingAidCompatibilitySupported = 120;
static final int TRANSACTION_isIdle = 12;
static final int TRANSACTION_isIdleForSubscriber = 13;
static final int TRANSACTION_isImsRegistered = 121;
static final int TRANSACTION_isImsRegisteredForSubscriber = 122;
static final int TRANSACTION_isOffhook = 8;
static final int TRANSACTION_isOffhookForSubscriber = 9;
static final int TRANSACTION_isRadioOn = 14;
static final int TRANSACTION_isRadioOnForSubscriber = 15;
static final int TRANSACTION_isRinging = 11;
static final int TRANSACTION_isRingingForSubscriber = 10;
static final int TRANSACTION_isTtyModeSupported = 119;
static final int TRANSACTION_isVideoCallingEnabled = 116;
static final int TRANSACTION_isVideoTelephonyAvailable = 126;
static final int TRANSACTION_isVideoTelephonyWifiCallingAvailableForSubscriber = 127;
static final int TRANSACTION_isVisualVoicemailEnabled = 59;
static final int TRANSACTION_isVoWifiCallingAvailableForSubscriber = 124;
static final int TRANSACTION_isVoicemailVibrationEnabled = 137;
static final int TRANSACTION_isVolteAvailable = 125;
static final int TRANSACTION_isWifiCallingAvailable = 123;
static final int TRANSACTION_isWorldPhone = 118;
static final int TRANSACTION_needMobileRadioShutdown = 111;
static final int TRANSACTION_needsOtaServiceProvisioning = 54;
static final int TRANSACTION_nvReadItem = 83;
static final int TRANSACTION_nvResetConfig = 86;
static final int TRANSACTION_nvWriteCdmaPrl = 85;
static final int TRANSACTION_nvWriteItem = 84;
static final int TRANSACTION_requestModemActivityInfo = 134;
static final int TRANSACTION_sendEnvelopeWithStatus = 82;
static final int TRANSACTION_setAllowedCarriers = 144;
static final int TRANSACTION_setCellInfoListRate = 74;
static final int TRANSACTION_setDataEnabled = 94;
static final int TRANSACTION_setImsRegistrationState = 97;
static final int TRANSACTION_setLine1NumberForDisplayForSubscriber = 104;
static final int TRANSACTION_setNetworkSelectionModeAutomatic = 90;
static final int TRANSACTION_setNetworkSelectionModeManual = 92;
static final int TRANSACTION_setOperatorBrandOverride = 108;
static final int TRANSACTION_setPolicyDataEnabled = 149;
static final int TRANSACTION_setPreferredNetworkType = 93;
static final int TRANSACTION_setRadio = 28;
static final int TRANSACTION_setRadioCapability = 113;
static final int TRANSACTION_setRadioForSubscriber = 29;
static final int TRANSACTION_setRadioPower = 30;
static final int TRANSACTION_setRoamingOverride = 109;
static final int TRANSACTION_setVisualVoicemailEnabled = 58;
static final int TRANSACTION_setVoiceMailNumber = 55;
static final int TRANSACTION_shutdownMobileRadios = 112;
static final int TRANSACTION_silenceRinger = 7;
static final int TRANSACTION_supplyPin = 16;
static final int TRANSACTION_supplyPinForSubscriber = 17;
static final int TRANSACTION_supplyPinReportResult = 20;
static final int TRANSACTION_supplyPinReportResultForSubscriber = 21;
static final int TRANSACTION_supplyPuk = 18;
static final int TRANSACTION_supplyPukForSubscriber = 19;
static final int TRANSACTION_supplyPukReportResult = 22;
static final int TRANSACTION_supplyPukReportResultForSubscriber = 23;
static final int TRANSACTION_toggleRadioOnOff = 26;
static final int TRANSACTION_toggleRadioOnOffForSubscriber = 27;
static final int TRANSACTION_updateServiceLocation = 31;
static final int TRANSACTION_updateServiceLocationForSubscriber = 32;
 

kylemd

Senior Member
Aug 13, 2015
191
63
Sydney
Sorry for not updating this - I have discovered this method only works on Nougat ROMs. Haven't looked into a fix for Oreo yet, but I will soon.
 

ne0t

Senior Member
Feb 23, 2017
205
42
Thanks for the quick reply, My Mi Max 2 is currently on xiaomi.eu ROM based on Android 7.1.1 .

Edit :
Tried with RN5 on xiaomi.eu Android 8.1 ROM and found TRANSACTION_setSimPowerStateForSlot value (163) as per your guide in the OP, wonder where does Xiaomi store that TRANSACTION_setSimPowerStateForSlot on Android 7.x ROM?

Use Tasker with code 'service call phone 163 i32 1 i32 0' turn off SIM 2 on Redmi Note 5.

Edit 3 : with the SIM 2 power off using this code, turning off the airplane mode caused default mobile data switched to SIM 1, guess when Airplane mode OFF the phone think there is no SIM CARD in SIM 2 slot.

A workaround is by using this code ''service call phone 163 i32 1 i32 1' to power SIM 2 on, then turn OFF Airplane Mode.

Thanks a lot
 
Last edited:

projection

Senior Member
Nov 8, 2008
445
229
Good that my findings were of some use to you. I initially found this guide, but realized Oreo is different, and then hacked at it for a bit until I found the solution.
 

Tepes4

Senior Member
Jun 14, 2008
292
26
Thank you very much. Mi6 with Lineage 15.1 had code 162 and after switching the second sim off and on there was no change in default data sim.

Excellent work!!!
 

FinalSpeed

New member
May 25, 2016
2
0
Many Thanks.
Do you know to toggle PreferredNetworkType?
static final int TRANSACTION_setPreferredNetworkType = 105;
I tried to switch the preferred network type from card 1 to card 0 using "service phone 105 i32 0 i32 1", but it's not work well.

Thanks.
 
Last edited:
@kylemd thanks for your contribution and testing. I was testing this on the latest Pie updates on my OnePlus 2. I transferred both framework.jar and boot-framework.vdex to my pc to handle following your procedure. If I vdex boot-framework.vdex I get files named .cdex as in the second screenshot. If I unzip framework I get .dex files as in the first screenshot. However if I import those into jadx-gui I get errors, see the log. Any idea what's happening here??

jadx LOG after importing:

ERROR: Error load file: C:\Users\JC\Downloads\New\classes.dex
jadx.core.utils.exceptions.JadxRuntimeException: Error load file: C:\Users\JC\Downloads\New\classes.dex
at jadx.api.JadxDecompiler.loadFiles(JadxDecompiler.java:125)
at jadx.api.JadxDecompiler.load(JadxDecompiler.java:87)
at jadx.gui.JadxWrapper.openFile(JadxWrapper.java:34)
at jadx.gui.ui.MainWindow.openFile(MainWindow.java:177)
at jadx.gui.ui.MainWindow.openFile(MainWindow.java:170)
at jadx.gui.ui.MainWindow$3.actionPerformed(MainWindow.java:340)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: com.android.dex.DexException: Unexpected magic: [0x64, 0x65, 0x78, 0x0a, 0x30, 0x33, 0x39, 0x00]
at com.android.dex.TableOfContents.readHeader(TableOfContents.java:86)
at com.android.dex.TableOfContents.readFrom(TableOfContents.java:72)
at com.android.dex.Dex.loadFrom(Dex.java:142)
at com.android.dex.Dex.<init>(Dex.java:121)
at jadx.core.utils.files.InputFile.searchDexFiles(InputFile.java:51)
at jadx.core.utils.files.InputFile.addFilesFrom(InputFile.java:36)
at jadx.api.JadxDecompiler.loadFiles(JadxDecompiler.java:123)
... 43 common frames omitted
 
Jun 23, 2015
13
0
help

I know that looking for this answer has bugged me for the past few years, so figured I'd x-post from Stack Overflow. I have found the solution to switching either SIM off in the Mi6 automatically. Will likely work with other phones.

The whole question and answer you can find on Stack Overflow here.

For Nougat



For Oreo it's slightly different...



Using the output

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".



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

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.

Enjoy!

sorry to bother but i cant seems to find TRANSACTION_SetSimPowerStateForSlot even in Nougat.... i could find other things but just cant find that

---------- Post added at 02:42 PM ---------- Previous post was at 02:38 PM ----------

@kylemd thanks for your contribution and testing. I was testing this on the latest Pie updates on my OnePlus 2. I transferred both framework.jar and boot-framework.vdex to my pc to handle following your procedure. If I vdex boot-framework.vdex I get files named .cdex as in the second screenshot. If I unzip framework I get .dex files as in the first screenshot. However if I import those into jadx-gui I get errors, see the log. Any idea what's happening here??

jadx LOG after importing:

ERROR: Error load file: C:\Users\JC\Downloads\New\classes.dex
jadx.core.utils.exceptions.JadxRuntimeException: Error load file: C:\Users\JC\Downloads\New\classes.dex
at jadx.api.JadxDecompiler.loadFiles(JadxDecompiler.java:125)
at jadx.api.JadxDecompiler.load(JadxDecompiler.java:87)
at jadx.gui.JadxWrapper.openFile(JadxWrapper.java:34)
at jadx.gui.ui.MainWindow.openFile(MainWindow.java:177)
at jadx.gui.ui.MainWindow.openFile(MainWindow.java:170)
at jadx.gui.ui.MainWindow$3.actionPerformed(MainWindow.java:340)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: com.android.dex.DexException: Unexpected magic: [0x64, 0x65, 0x78, 0x0a, 0x30, 0x33, 0x39, 0x00]
at com.android.dex.TableOfContents.readHeader(TableOfContents.java:86)
at com.android.dex.TableOfContents.readFrom(TableOfContents.java:72)
at com.android.dex.Dex.loadFrom(Dex.java:142)
at com.android.dex.Dex.<init>(Dex.java:121)
at jadx.core.utils.files.InputFile.searchDexFiles(InputFile.java:51)
at jadx.core.utils.files.InputFile.addFilesFrom(InputFile.java:36)
at jadx.api.JadxDecompiler.loadFiles(JadxDecompiler.java:123)
... 43 common frames omitted


You can try online converter to convert it into java. after that, try opening it using notepad++. its easier this way.
 

isimsizkullan

Senior Member
Jul 7, 2012
131
13
@kylemd
I use Redmi 5 Plus Vince and Android 7.1.2 Nougat. I pulled /system/framework/framework.jar but framework.jar is only 318 bytes. There is no .dex files in it. It only contains META-INF folder and MANIFEST.MF file in it.
I am searching this for days, i don't know what to do. :confused:
 

Top Liked Posts

  • There are no posts matching your filters.
  • 3
    I know that looking for this answer has bugged me for the past few years, so figured I'd x-post from Stack Overflow. I have found the solution to switching either SIM off in the Mi6 automatically. Will likely work with other phones.

    The whole question and answer you can find on Stack Overflow here.

    For Nougat

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

    • 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.

    For Oreo it's slightly different...

    TL;DR:
    You need:
    1. vdexExtractor from BatchApkTool
    2. jadx

    Step by step:
    1. Pull /system/framework/arm64/boot-framework.vdex
    2. extract it with vdexExtractor.
    (ed: you can find vdexExtractor in the bin\bin64 folder in BatchApkTool. Use the syntax "vdexExtractor.exe -i path_to_vdex --ignore-crc-error")
    3. Open the resulting class files with jadx and find the one that contains com.android.internal.telephony.ITelephony (ed: for Mi6 it was in classes2.dex)
    4. Navigate to the class with jadx and locate the value of TRANSACTION_setSimPowerStateForSlot, this is your magic number. (ed: for Mi6 8.1 it's 163)

    After you have the command you can use for example Tasker to enable and disable the SIM card.
    The only downside of using this method is that major Android version bumps will most likely break this, as the numbers vary from android build to android build.

    Using the output

    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)

    For example, to switch SIM2 off on my Mi6 the command on Nougat was service call phone 159 i32 1 i32 0 and for Oreo it was service call phone 163 i32 1 i32 0

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

    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.

    Enjoy!