Making a call from a dual sim android device using adb - android

I am trying to make a call from a specific sim on a dual sim phone (SIM 0 and SIM 1) using adb and I can't figure out how to direct the call to that particular sim slot.
So far, I have tried making a call using the following command:
adb shell am start -a android.intent.action.CALL -d tel:XXXXXXXXXX
This works fine, but it always calls using SIM 0.
I tried using radiooptions as:
adb shell radiooptions
but it turns out, radiooptions is not supported on this particular device.
/system/bin/sh: radiooptions: not found
I did try it on another device, which is not dual sim, and radiooptions seems to work on that. That was the whole reason I was trying out radiooptions in the first place because it has a very clear cut implementation for selecting specific sim cards.
Anyways, I found the following questions for dual sim android phones, but they are not adb based. they are all Java questions.
Make call using a specified SIM in a Dual SIM Device
Call from second sim
They seem to help and give some clues as to how it can be done,especially this one:
SO Answer for changing SIM
This is very close to what I need, but I don't know how to convert this into a command prompt friendly code.
The method "intent" used in the above links has a documentation here:
https://developer.android.com/reference/android/content/Intent.html
Multi sim android official documentation:
https://developer.android.com/about/versions/android-5.1.html#multisim
Any help is greatly appreciated.

SIM Card is just a container. The name of the entity being used by the phone to register with the network and to make calls is SubscriberID. A single SIM Card may contain multiple SubscriberIDs.
So instead of asking how to make a call from another SIM Card you should be asking how to make a call using SubscriberID other than the default one - whether this other SubscriberID is stored on the same or another SIM Card is mostly irrelevant.
I do not know if there is a way to specify a different SubscriberID for a single call. But you should be fine with setting a new default SubscriberID before the call and then reverting it back afterwards.
To find out the current ID value run:
adb shell settings get global multi_sim_voice_call
Then change the active Subscriber via UI and run the command again to get another ID.
Use this command to switch to the appropriate ID before calling:
adb shell settings put global multi_sim_voice_call <ID>
To change data call settings - use multi_sim_data_call instead of multi_sim_voice_call.

Related

Unable to Inspect Object com.android.incallui.service.SecCallPopupService on Samsung J5

I have a problem that I think is related with Android permissions, however I need some of your expertise to confirm it.
I have testing the old Samgung J5(Not rooted) with Android 8.1.0, Appium 1.10.0 with UiAutomator2 and ADB 10.0.40 (In administration mode) on some Call Handling scenarios where I need to check if determined display elements (identity, call duration, hold activated, on transfer information, etc) are displayed to user. I have seen multiple solutions to do this task, inclusively using adb to do it, but lets focus only on this problem, using only the display elements (GUI).
Scenario, user receives call.
The com.android.incallui.service.SecCallPopupService comes into action:
User receives call
When I try to inspect the com.android.incallui.service.SecCallPopupService window the Appium cannot found it:
Appium Inpector
Neither on UiAutomatorViewer:
UitAutomatorViewer
On Comment link (xml dump) you can seen the display elements that Appium, and UiAutomatorViewer can "see". Same result was obtained by using the command adb shell uiautomator dump /data/local/tmp/uidump.xml
After that, I installed the Appium Studio and try out the Appium official "Inspector" and the result was:
Appium Studio Object Spy with full access to all display elements. Very intriguim... after some research I found the following package com.experitest.uiautomator.test (running in background) was immediatelly installed on the device when I clicked on Object Spy feature and I think that is responsible to retrieve all the interface elements.
On comment link (logcat) Some logcat logs after doind object spy on Appium Studio:
Analysing the logcat we can see that Appium studios was requesting
{"response":"true","params":[],"command":"richDump"} and the package uses
some kind of node:android.view.accessibility.AccessibilityNode. Maybe using something like the Acessibility Tree node to get the elements ? I don't know...
I have read some similar questions on Stackoverflow but some solutions involves to root the device or using de ADB (its not an option),
Tryng to su root the device and chmod 777 /data/local/tmp, but if it's really necessary, how then Appium Studio can read all display elements?
Do you know any other solution that allows me to get all interface elements without root the device? How can I call the "richDump"?
Thank You for you help.

Turning off second SIM via adb shell/Tasker - using activities/intents

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.
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
which brings up the settings page for SIM2, like so. However, I can't figure out how to toggle the SIM on or off.
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.
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.
I greatly appreciate any help!
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.
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.
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.
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:
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.
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)
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!

Android: Using tiwlan0 to determine wireless connected status for Droid

I want to be able to check the status of Droid's wireless and I was hoping that by reading /sys/class/net/tiwlan0/wireless/status I could find out if it was actually connected or not. I already know that I can check if my wireless is enabled/disabled but I want my app to notify the user if the wireless gets disconnected.
However, the Droid I have is not rooted and I do not have permission from the owner to root it and I need to know the type of the value (e.g. long, boolean, byte) before I can proceed.
Any help or suggestions about other ways I can go about this would be greatly appreciated!
Thanks
You should just be able to listen to the SUPPLICANT_STATE_CHANGED_ACTION broadcast. It will notify you of a change (scanning, association, disconnection, etc.) in the form of a SupplicantState object inside an extra.
Install terminal emulater, run it and type the following at the command line: "ifconfig -a". Read the IP address listed under tiwlan0.

Set Data roaming on/off

How could I programmatically set data roaming on/off in my android application ?
Apologies in advance for reopening a dead post but I have managed to achieve it by calling this executable:
su -c settings put global data_roaming0 1
Also to get the roaming setting for first SIM card:
su -c settings get global data_roaming0
If your app is signatureOrSystem/Privileged app (app resides in /system/priv-app) and your have valid android.permission.WRITE_SECURE_SETTINGS permission in system/etc/permissions. Then you can do it as below.
Enable :
Settings.Global.putInt(context.getContentResolver(), Settings.Global.DATA_ROAMING, 1)
Disable :
Settings.Global.putInt(context.getContentResolver(), Settings.Global.DATA_ROAMING, 0)
I hope that it's not possible to turn on data roaming programmatically as this would be a serious security issue from my point of view ...
Data roaming (i.e. UMTS data transfer via a foreign network) may result in a huge bill from your network provider - at least in europe.
If data roaming is currently on, then I think you can manipulate the Access Points Names in order to make it appear that a data service isn't available. See this post which also links to apndroid. You could browse their source and see the approach they have taken.
If data roaming has been set to off by the user, then this approach won't work. Though you could prompt users to turn it on as part of your install/setup process, which is the route apndroid take.
apndroid also provide an API for changing these kind of settings, which might be more convenient than reimplementing the same functionality.
On rooted devices when using su to enable data roaming, on multi sim devices the data roaming setting is sim specific.
So you need to get the sim number that is active for data calls
sim_num = settings get global multi_sim_data_call
and use this in the data_roaming + sim_num setting. EG sim_num 3
settings get global data_roaming3
if this is null then not multi sim device and use data_roaming otherwise use
settings put global data_roaming3
I was able to enable data roaming on my dual sim Motorola G8 without the need to root it via ADB. I'm posting here the procedure, because the phone has a bug that prevents data roaming from being enabled normally.
You need a computer and to install ADB installed
Enable developer mode and USB debugging in your phone
Connect the phone to the computer via USB and accept the debugging connection.
Start an "adb shell", be sure that it is correctly connected to your phone.
Issue the command
settings put global data_roaming1 1
to enable data roaming for SIM card 1, or
settings put global data_roaming2 1
to enable it for SIM 2
Note: if you do not have the USB cable, this can be done via wifi, but the pairing process is a bit complicated and version dependent.
If you do not have a computer, it may be possible to run the commands directly on the phone using a "local adb" app (there are a few on the play store), but I have not tested any.

Android emulators with phone numbers?

I'm working on a client-server Android application and trying to figure out how to identify different phones/users to the server unambiguously. My first attempt would be to use the phone number on the SIM card. Although now that I think about it, how common is it these days that your phone number changes when you e.g. change carrier? I guess it depends from country to country etc.
Anyway, I've been trying to figure out, since I don't have actual Android phones, how to change the phone number of the emulator phone to simulate different users. Is it possible or should I just think about alternative ways of identification?
The android_id is supposed to uniquely identify the device, however, it has been noted that the id can be changed if you know how Spoofing android_id
import android.provider.Settings.System;
String android_id = System.getString(this.getContentResolver(), System.ANDROID_ID);
In the emulator, the android_id does not have a value, so you will need to put a debugging routine in to assign a value yourself.
However, if you want to identify the user, and let the user access your service from different devices with one user id you are better off assigning them a user id and having them authenticate to your service using this user id as their credential. This would let them use their id's on many different devices, unless you used it in conjunction with the android_id (and the android_id wasn't spoofed) then you could limit them to one device.
You should use the number present by the emulator. Eg. usually first emulator that is running has number 5554, second 5555, and so on.
You can use these numbers to make calls, send text messages from emulator to emulator. This, I think, simulates different numbers/users for your purposes.
The SIM card info is hard-coded into the emulator-arm and emulator-x86 binaries. Changing the phone number (MSISDN) is detailed at the end of this blog post: new link, web archive
The SIM card stores the phone number with each 2 digits swapped. So (the first 7 of the phone number) 1555521 becomes 515525%d1 in the binary. While a little tedious, patching it for each test isn't the end of the world. You could also use sed:
cd path/to/android-sdk-linux/tools/
cp emulator-arm emulator-arm.backup
sed -i 's/515525%d1/816745%d3/g' emulator-arm
That will change the number to 1-876-543-[PORT NUMBER]. Details on why are in the linked blog post.

Categories

Resources