Android emulator: Set mobile device number? - android

Does anyone know if its possible to set the emulator's mobile number? I have not been able to find information about this anywhere. Thanks.

Mostly full control of the phone number detailed at the end of this blog:
http://blog.talosintel.com/2013/04/changing-imei-provider-model-and-phone.html
First 7 are fully configurable, last 4 can be one of 16 allowed port numbers.
It turns out that the phone number is stored on the SIM card. Since there is no actual SIM card, one is emulated. This emulated SIM is hard coded in the emulator-arm binary. The reason replacements for 1555521 failed is because SIM cards have a specification that does not store the MSISDN (Mobile Subscriber Integrated Services Digital Network-Number, AKA phone number) in plain text. Instead, each set of digits is swapped in some reverse nibbled endianness nightmare.
...
A quick way to find the MSISDN is to search for %d%df%d in the binary (highlighted in red below). The corresponding source code is in external/qemu/telephony/sim_card.c on line 436 in the current repo. The following is the format string portion of that sprintf:
"+CRSM:144,0,ffffffffffffffffffffffffffffffffffff0781515525%d1%d%df%dffffffffffff"
The interesting part is 515525%d1 (highlighted in blue). Swapping each set of two digits produces 1555521%d (thanks again CodePainters). That looks like the prefix to our mobile number.
Edit it in a hex editor.

I think this webpage will show you how to do it
https://www.wikihow.com/Find-Your-Phone-Number-on-Android
here instead of about phone try searching about the emulator device

You can simulate incoming SMS and calls in the simulator (using the simulator's port) but that's all, you can not set a device number or anything like that. For that kind of thing you will need a real device.

As I have found each emulator already has a phone number. If you run two emulators you can call from one emulator to another. To find out this phone numbers you can run in the terminal window:
Path\To\Your\Android\Sdk\platform-tools>adb devices
List of devices attached
emulator-5554 device
emulator-5556 device
First phone number is +15555215554, second +15555215556, i.e. phone number is prefix +1555521 plus emulator suffix 5554 or 5556.

In your emulated device, press on the 3 dots highlighted in yellow and choose phone and then you can change the mobile number, screenshot attached in link below
https://i.stack.imgur.com/zhbSV.png

TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
// get IMEI
String imei = tm.getDeviceId();
System.out.println("gfvnchgjvbnvhjbbnvgjvbncghvmn ngvm"+imei);
// get SimSerialNumber
String simSerialNumber = tm.getSimSerialNumber();
System.out.println("854755745588954754855ngvm"+simSerialNumber);
//get SimCardNumber
String number = tm.getLine1Number();
System.out.println("gfch5652345651szdxfcgvhbjnfcgvh ngvm"+number);
And Import :]->
import android.content.Context;
import android.telephony.TelephonyManager;

The mobile number of an emulator is the port number of that emulator. For more details. please check this link:
http://developer.android.com/guide/developing/devices/emulator.html#calling

Related

Android Mobile Identification Number (MIN)

My android application needs to retrieve the phone number of the device. I'm using the method getLine1Number() to retrieve it, however on some phones it returns a wrong value.
Code:
TelephonyManager tMgr = (TelephonyManager)c.getSystemService(Context.TELEPHONY_SERVICE);
String number = tMgr.getLine1Number();
The phone returning a wrong value is a Samsung Galaxy S6 running android 6.0.1. In the phone settings under Phone number it displays the same wrong value, however under MIN the correct phone number is displayed.
Can anyone give me any ideas or solutions to this problem? I haven't been able to find any way of retrieving the MIN value from an android phone. Nor have I identified why this phone returns a wrong value.
There is no function to get the phone number of a device. Because of the ways some carriers set up SIMs, its actually possible that the device itself doesn't know what its own phone number is. If you actually need a phone number, you need to ask the user for it. If you need a unique id for the phone, other things like ANDROID_ID are more appropriate (remember not ever android device even has a phone number- tablets, watched, and TVs may not).

Get phone number from Python coded app

I'm making an android app with python. I made an authentication server which receives phone's status (serial number, phone number...) and compares it with another server to figure out if the user purchased this app or not.
At this point I've got a problem. I can't find the way how to extract phone number with python made app.
What I figured out is there's a function called 'TelephonyManager' which works in java.
TelephonyManager telephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)
Isn't there any module or function in Python to replace that?
If you use Python under SL4A:
import android
droid = android.Android()
print droid.getLine1Number().result
However, as in Java this might not work depending on SIM card. See TelephonyManager.getLine1Number() failing?

Retrieving Line1 number from TelephonyManager in Android

TelephonyManager manager1 = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String strMobile1 = manager1.getLine1Number();
This is my code for getting mobile number of but its not working. I have also take necessary permission in manifest file
We had the same problem in our project. The conclusion was that it depends on the SIM card.
What happened to us:
Galaxy S with AT&T SIM card: can read phone number, Settings shows number
Same Galaxy with an European SIM card: cannot read the number and "unknown" in Settings (cell phone was perfectly functional, just couldn't read the number)
This has been reported in other forums as well.
In the end we decided to ask the user for the phone number. A bit more involved, actually: if( "SIM card present" && "cannot read the cell number") "ask user"; . Otherwise we will keep bugging the user that doesn't a SIM card in the first place.
getLine1Number() only get the number stored on the sim card..a lot of operators don't write there the sim number..on some phones (nokia, blackberry, some olds android, iphone) you can set your own mobile number and the phone will store it on the sim card, at that point getLine1Number() will return the phone number
The method you are using is the only one part of the SDK to do this, and only works on devices where the number is stored on the SIM card, which only some carriers do.
For all other carriers, you will have to ask the user to enter the phone number manually, as the number is simply not stored anywhere on the device from where you can retrieve it.
source here

TelephonyManager.getLine1Number() failing?

I want to get phone number of android device. I use this code:
TelephonyManager tm = (TelephonyManager)this.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber= tm.getLine1Number();
On my phone (HTC Wildfire) I can not get phone number - all I get is empty string. If I run code on emulatur, phone number is normally showed.
If I go to Settings=>About phone=>Phone identity->Phone number, phone number is "Unknown".
Where is the problem? Is something wrong with my SIM?
We had the same problem in our project. The conclusion was that it depends on the SIM card.
What happened to us:
Galaxy S with AT&T SIM card: can read phone number, Settings shows number
Same Galaxy with an European SIM card: cannot read the number and "unknown" in Settings (cell phone was perfectly functional, just couldn't read the number)
This has been reported in other forums as well.
In the end we decided to ask the user for the phone number. A bit more involved, actually: if( "SIM card present" && "cannot read the cell number") "ask user"; . Otherwise we will keep bugging the user that doesn't a SIM card in the first place.
Instead of the phone number use the SIM card serial number, which always exists and is always a valid value.
telephonyManager.getSimSerialNumber();
SIM serial number is unique within the operator at least. So combined with
telephonyManager.getNetworkOperator();
you'll have a unique identifier for a subscriber within a country.
This combined with
telephonyManager.getNetworkCountryIso();
you'll have a globally unique identifier for a subscriber.
Hope this will help.
Cheers.
SIM card stores phone number and it can be edited by you. Cant say for Android, but on WM you can easily edit your phone number, which is stored on SIM card.
Of course, it does not mean that you can change your phone number on the fly. Actually, you are free to write there any number you like, and the programs will believe, that this is your real number :)
When I've moved a SIM card into a new phone, I've sometimes found that the phone number does not show up in Settings -> About phone -> Status -> My phone number.
My data points:
AT&T Atrix putting completely new SIM in it says “Voice MSISDN Line1 null”.
T-Mobile G1 putting new SIM card into it correctly displays the phone number.
T-Mobile G2 moving SIM card from my old G1 into is says "Unknown".
Telephone number available if the SIM card is allows it get his.
In our company I found only one SIM, which is allowed get number. I'm tetsting this SIM on all android device. All ok. getLine1Number() is ok.
Now I'm looking for get phone number for other SIM. Have send sms to our sms-server or other android device(with the processing of SMS)
I use a simcard which only permits data transfer. It doesn't permit phone calls.
When I try to get phonenumber with getLine1Number(), I get empty string.

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