anyone know - its possible to get
"PIN CODE"
"PIN2 CODE"
"PUK1 CODE"
"PUK2 CODE"
from sim card??
im using this code for getting other info like : sim number, sim operator, sim serial.
List<SubscriptionInfo> subscriptionInfos = SubscriptionManager.from(context).getActiveSubscriptionInfoList();
for(int i=0; i<subscriptionInfos.size();i++)
{
SubscriptionInfo subInfo = subscriptionInfos.get(i);
}
but how about pin/puk codes? I need get it programmaticaly without "special number call"
Related
I have a pixel 7 with Mep enabled and i am trying to read this data in my app.
I have a physical Sim in a Work profile and an eSim in a Personal profile.
I tried the below code in my MainActivity's onCreate:
val smanager = getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE) as SubscriptionManager
Log.i("SUBS_TEST", "count -> ${smanager.activeSubscriptionInfoCount}")
smanager.activeSubscriptionInfoList.forEach {
Log.i("SUBS_TEST", "mep -> ${it.displayName}")
}
But the output of the count is always returning 0
Can someone help me on how to get the profiles ?
Is there way to programmatically adds the contact to the internal phone contacts book as a "phone contact"?
I've tried:
list.add(ContentProviderOperation
.newInsert(ContactsContract.RawContacts.CONTENT_URI)
.withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, null)
.withValue(ContactsContract.RawContacts.ACCOUNT_NAME, null)
.build());
with this parameters contact successfully saves to the phone, but in case i set up filter to "display phone contacts only" - created contact not appears. btw, i've read that contacts with null type can be loses drying accounts synchronization (haven't remember the full case)
then i tried to retrieve ACCOUNT_TYPE and ACCOUNT_NAME from existing phone contact and gets Phone and Local Phone Account strings, but when i tried to save contact with same parameters:
list.add(ContentProviderOperation
.newInsert(ContactsContract.RawContacts.CONTENT_URI)
.withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, "Phone")
.withValue(ContactsContract.RawContacts.ACCOUNT_NAME, "Local Phone Account")
.build());
the result was the same to the first case with null type.
is there any constants (or it should be another way) to save data like "phone contact"?
The "phone only" account is not fully supported by plain Android, it's usually added (or unlocked) by device makers.
Here are the ones I know of, feel free to add more in case you find more.
The format is <maker>: ACCOUNT_TYPE, ACCOUNT_NAME
samsung: "vnd.sec.contact.phone: "vnd.sec.contact.phone"
htc: "com.htc.android.pcsc: "pcsc"
sony: "com.sonyericsson.localcontacts: "Phone contacts"
lge: "com.lge.sync: "Phone"
lge (option 2): "com.lge.phone"
t-mobile: "vnd.tmobileus.contact.phone: "MobileLife Contacts"
huawei: "com.android.huawei.phone: "Phone"
lenovo: "Local Phone Account: "Phone"
xiaomi: "com.xiaomi"
oppo: "com.oppo.contacts.device"
I was trying to get the MCC and MNC number (basically I want the IMSI number but these will also suffice) in Android 5.1 device having dual Sim (both active). As 5.1 supports dual Sim so I used the Subscription manager like this:
SubscriptionManager manager = SubscriptionManager.from(this);
List<SubscriptionInfo> sil = manager.getActiveSubscriptionInfoList();
if (sil != null) {
for (SubscriptionInfo subInfo : sil) {
Log.v("TestMain", "SubInfo:" + subInfo);
}
} else {
Log.v("TestMain", "SubInfo: list is null");
}
and got the this output:
07-24 18:28:32.162 3844-3844/? V/TestMain﹕ SubInfo:{id=1, mcc 405 mnc 803, iccId=89918030914128062059 simSlotIndex=0 displayName=Aircel Karnataka carrierName=Aircel — Aircel Karnataka nameSource=0}
07-24 18:28:32.162 3844-3844/? V/TestMain﹕ SubInfo:{id=2, mcc 405 mnc 803, iccId=8991860044481968955 simSlotIndex=1 displayName=CARD 2 carrierName=Vodafone Karnataka nameSource=0}
MCC(will be same as it the same country)
notice that MNC are same though the carriers are different.
While I was switching off the phone I saw this lines in my logcat:
07-24 18:31:02.295 616-616/? V/KeyguardUpdateMonitor﹕ SubInfo:{id=1, mcc 405 mnc 803, iccId=89918030914128062059 simSlotIndex=0 displayName=CARD 1 carrierName=Emergency calls only — Aircel Karnataka nameSource=0}
07-24 18:31:02.295 616-616/? V/KeyguardUpdateMonitor﹕ SubInfo:{id=2, mcc 404 mnc 86, iccId=8991860044481968955 simSlotIndex=1 displayName=CARD 2 carrierName=Emergency calls only — Vodafone Karnataka nameSource=0}
As you can see the keyguard application gets the MNC right for both the sim.
So I explored the code of the keyguard application and found that the code is same as I was using
Code from Android Source taken from here:
protected void handleSimSubscriptionInfoChanged() {
if (DEBUG_SIM_STATES) {
Log.v(TAG, "onSubscriptionInfoChanged()");
List<SubscriptionInfo> sil = mSubscriptionManager.getActiveSubscriptionInfoList();
if (sil != null) {
for (SubscriptionInfo subInfo : sil) {
Log.v(TAG, "SubInfo:" + subInfo);
}
} else {
Log.v(TAG, "onSubscriptionInfoChanged: list is null");
}
}
I explored some more and found that even the keyguard applications gets MCC right only when the phone is switching off, other times even it is getting the same MNC for both the SIMs. But the carrier name is distinct always.
Is this a bug in Android 5.1 or am I doing something wrong?
I got the same issue in Android 5.1 in Samsung J5, but its working in Android 6.0 in Moto X Play. Since SubscriptionManager was introduced in Android 5.1, I guess this is a bug in Android 5.1, which was corrected in Android M.
This was a bug in android 5.1, it got fixed after I updated the phone
I am having a form wherein i get user details, in that i have field called phone number and Edit Text to put phone number.
i have feeling that it would be great if that edittext automatically get filled by user phone number.
is there any method which automatically fills user phone number with national code??
below code was posted on stackoverflow i think it might work in some instances can anyone help me for same?
private String getMyPhoneNumber() {
TelephonyManager mTelephonyMgr;
mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
return mTelephonyMgr.getLine1Number();
}
i have feeling that it would be great if that edittext automatically get filled by user phone
number
To solve the above problem, your best bet is to use,
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String number = tm.getLine1Number();
with the permission added of course
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
But the problem is that the documentation for getLine1Number() says this method will return null if the number is "unavailable", but it does not say when the number might be unavailable.
is there any method which automatically fills user phone number with national code??
To solve this issue, unfortunately there doesn't seem to be a direct way to get the user's current country code. But since country codes don't ever change, it is acceptable to hard code a lookup table in your application.
<?xml version='1.0' encoding='UTF-8'?>
<icc>
<AF>93</AF>
<AL>355</AL>
<DZ>213</DZ>
<AD>376</AD>
<AO>244</AO>
<AQ>672</AQ>
<AR>54</AR>
<AM>374</AM>
<AW>297</AW>
<AU>61</AU>
<AT>43</AT>
<AZ>994</AZ>
<BH>973</BH>
<BD>880</BD>
<BY>375</BY>
<BE>32</BE>
<BZ>501</BZ>
<BJ>229</BJ>
<BT>975</BT>
<BO>591</BO>
<BA>387</BA>
<BW>267</BW>
<BR>55</BR>
<BN>673</BN>
<BG>359</BG>
<BF>226</BF>
<MM>95</MM>
<BI>257</BI>
<KH>855</KH>
<CM>237</CM>
<CA>1</CA>
<CV>238</CV>
<CF>236</CF>
<TD>235</TD>
<CL>56</CL>
<CN>86</CN>
<CX>61</CX>
<CC>61</CC>
<CO>57</CO>
<KM>269</KM>
<CG>242</CG>
<CD>243</CD>
<CK>682</CK>
<CR>506</CR>
<HR>385</HR>
<CU>53</CU>
<CY>357</CY>
<CZ>420</CZ>
<DK>45</DK>
<DJ>253</DJ>
<TL>670</TL>
<EC>593</EC>
<EG>20</EG>
<SV>503</SV>
<GQ>240</GQ>
<ER>291</ER>
<EE>372</EE>
<ET>251</ET>
<FK>500</FK>
<FO>298</FO>
<FJ>679</FJ>
<FI>358</FI>
<FR>33</FR>
<PF>689</PF>
<GA>241</GA>
<GM>220</GM>
<GE>995</GE>
<DE>49</DE>
<GH>233</GH>
<GI>350</GI>
<GR>30</GR>
<GL>299</GL>
<GT>502</GT>
<GN>224</GN>
<GW>245</GW>
<GY>592</GY>
<HT>509</HT>
<HN>504</HN>
<HK>852</HK>
<HU>36</HU>
<IN>91</IN>
<ID>62</ID>
<IR>98</IR>
<IQ>964</IQ>
<IE>353</IE>
<IM>44</IM>
<IL>972</IL>
<IT>39</IT>
<CI>225</CI>
<JP>81</JP>
<JO>962</JO>
<KZ>7</KZ>
<KE>254</KE>
<KI>686</KI>
<KW>965</KW>
<KG>996</KG>
<LA>856</LA>
<LV>371</LV>
<LB>961</LB>
<LS>266</LS>
<LR>231</LR>
<LY>218</LY>
<LI>423</LI>
<LT>370</LT>
<LU>352</LU>
<MO>853</MO>
<MK>389</MK>
<MG>261</MG>
<MW>265</MW>
<MY>60</MY>
<MV>960</MV>
<ML>223</ML>
<MT>356</MT>
<MH>692</MH>
<MR>222</MR>
<MU>230</MU>
<YT>262</YT>
<MX>52</MX>
<FM>691</FM>
<MD>373</MD>
<MC>377</MC>
<MN>976</MN>
<ME>382</ME>
<MA>212</MA>
<MZ>258</MZ>
<NA>264</NA>
<NR>674</NR>
<NP>977</NP>
<NL>31</NL>
<AN>599</AN>
<NC>687</NC>
<NZ>64</NZ>
<NI>505</NI>
<NE>227</NE>
<NG>234</NG>
<NU>683</NU>
<KP>850</KP>
<NO>47</NO>
<OM>968</OM>
<PK>92</PK>
<PW>680</PW>
<PA>507</PA>
<PG>675</PG>
<PY>595</PY>
<PE>51</PE>
<PH>63</PH>
<PN>870</PN>
<PL>48</PL>
<PT>351</PT>
<PR>1</PR>
<QA>974</QA>
<RO>40</RO>
<RU>7</RU>
<RW>250</RW>
<BL>590</BL>
<WS>685</WS>
<SM>378</SM>
<ST>239</ST>
<SA>966</SA>
<SN>221</SN>
<RS>381</RS>
<SC>248</SC>
<SL>232</SL>
<SG>65</SG>
<SK>421</SK>
<SI>386</SI>
<SB>677</SB>
<SO>252</SO>
<ZA>27</ZA>
<KR>82</KR>
<ES>34</ES>
<LK>94</LK>
<SH>290</SH>
<PM>508</PM>
<SD>249</SD>
<SR>597</SR>
<SZ>268</SZ>
<SE>46</SE>
<CH>41</CH>
<SY>963</SY>
<TW>886</TW>
<TJ>992</TJ>
<TZ>255</TZ>
<TH>66</TH>
<TG>228</TG>
<TK>690</TK>
<TO>676</TO>
<TN>216</TN>
<TR>90</TR>
<TM>993</TM>
<TV>688</TV>
<AE>971</AE>
<UG>256</UG>
<GB>44</GB>
<UA>380</UA>
<UY>598</UY>
<US>1</US>
<UZ>998</UZ>
<VU>678</VU>
<VA>39</VA>
<VE>58</VE>
<VN>84</VN>
<WF>681</WF>
<YE>967</YE>
<ZM>260</ZM>
<ZW>263</ZW>
</icc>
Please set that phonenumber in your edittext like this edittext.setText(mTelephonyMgr.getLine1Number())
There is plenty of questions relating to this.
Your method relies on the phonenumber being stored on the sim, which it rarely is.
The most reliable method is to let users input the number themselves. Though it would not hurt to let the getLine1Number() method try and set the number first.
I have chosen to let my app send a SMS to the number with an unique message, which when received, completes the verification of the input number. The number then finally is stored in a sharedPreference.
This method of course runs short if the user changes sim but if you need to handle that, it could be done by also saving the IMEI so that it can be checked when app starts.
I know what the values are for MCC, MNC, LAC, & Cell ID. I want to in C write a program to calculate the position in the form of latitude and longitude values in Linux.
FYI:
MCC - Mobile Country Code
MNC - Mobile Network Code
LAC - Location Area Code; a 16 bit number thereby allowing 65536 location areas within one GSM PLMN
more info is available here on Wikipedia, Location Area Identity
Question:
How can I convert MCC,MNC,LAC,Cell ID into latitude and longitude values in linux?
Why does Cell ID varies every time,when trying to read?
To answer your questions:
You can access public databases from terminal or a browser to convert cell ID to lat/lon. Databases include:
Unwired Labs API
OpenCellID
Cell ID is the ID of the cell phone tower your phone/device is connected to. The moment you move a bit, or the signal of another tower nearby is better than the current one, your phone will switch over to that tower, and your Cell ID now reflects the ID of that tower.
i wrote a python script that can do this for you. You can get a binary from the pyc file.
#!/bin/python
"""
Written by Atissonoun - Credits to MFC & HAC
***You need to initialize the script in order to fix the import and the dependency.
This is only a Beta version of the project***
This python file works as the engine for the project.
imports, coordinates, run......
"""
#Importing modules
import requests
#defining a Api_Keys
Google_API_KEY="Your google API Key goes here"
OpenCell_Api_Key ="Your OpenCellID API Key goes here"
def Google(MMC,MNC,LAC,ID,API_KEY=Google_API_KEY):
url = "https://www.googleapis.com/geolocation/v1/geolocate?key={}".format(API_KEY)
data={
"radioType": "gsm",
"cellTowers":[
{
"cellId": ID,
"locationAreaCode": LAC,
"mobileCountryCode": MMC,
"mobileNetworkCode": MNC
}
]
}
response = requests.post(url, json=data)
if response.status_code == 200 :
lat=response.json()[u'location'][u'lat']
long = response.json()[u'location'][u'lng']
d={'LAT':lat,'LONG':long}
print('Located Cell: {}'.format(ID))
return d
else:
print('Error: {}'.format(response.status_code))
return None
def Opencell(MMC,MNC,LAC,ID,API_KEY=OpenCell_Api_Key):
url = "https://us1.unwiredlabs.com/v2/process.php"
data = {
"token": API_KEY,
"radio": "gsm",
"mcc": MMC,
"mnc": MNC,
"cells": [{
"lac": LAC,
"cid": ID
}]
}
response = requests.post(url, json=data)
if response.status_code == 200:
if response.json()[u'status']== 'error':
print('Error: {}'.format(response.json()[u'message']))
return None
else:
lat = response.json()[u'lat']
long = response.json()[u'lon']
d = {'LAT': lat, 'LONG': long}
print('Located Cell: {}'.format(ID))
return d
else:
print('Error: {}'.format(response.status_code))
return None
You either need a database
OpenCellID (they provide APIs for new cell measurement, get the position of a specific cell, etc)
or
use the "secret" API:
"http://www.google.com/glm/mmap" is a non-public API to convert cellLocation to latitude and longitude.
Many ways to do that are given in the answwers for this SO question.
You can use this simple but efficient web site that doesn't need any log in:
http://www.cell2gps.com/
while you can access to operator info like MCC and MNC to the wiki page:
http://en.wikipedia.org/wiki/Mobile_country_code#I
The result is the location GPS through Google Maps,