How can I programmatically change the country & network of an Android phone's SIM without root access? I'm using this code to retrieve information:
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
System.out.println(tm.getSimCountryIso()); // prints 'us', but I want it to be 'fr'
System.out.println(tm.getNetworkCountryIso()); // prints 'us, but I want it to be 'fr'
As my SIM card is from the USA, both of the outputs are us. How can I programmatically make the output be fr (France) for example?
Basically, I want to trick my smartphone into thinking its SIM's country & network is France, for example.
Something like this would be perfect but it doesn't exist:
tm.setSimCountryIso('fr')
tm.setNetworkCountryIso('fr')
What you are asking for is not possible without root.
As already stated in the comments, it is not physically possible to change the ICCID of the SIM unless it is a special writable SIM.
As for the call to getSimCountryIso and getNetworkCountryIso() those are system API's.
Without root, there is no way to interfere with their operation.
Android is built with several layers of security including restricting app access based on user privileges, enforcing SELinux on by default, verity checks as part of verified boot and more.
If you do have root on device, you can create an Xposed framework module that can hook these functions and overwrite their return value.
If you are curious, the table used to translate ICCID info into a two letter country name is hardcoded here.
In case that link does not open right - it starts on line 316.
So changing that would require recompiling one of the core JARs of the OS.
Also note, that depending on your real purpose, altering the result of these two functions may not work at all.
For example, if you want to create a Google account from the phone for a different country, changing the SIM will not help, since Google will still look at your IP address, regardless of how you are connected to the internet.
Related
so let's say that i want to ban the country X from using my app, i banned it from the google play store but it can still be downloaded via VPN is there a way to ban this country using code (maybe trying to detect the user's location or something?)
my government has a very big problem with a neighboring country and i'll go to jail for like forever if i had users in it.
my government has a very big problem with a neighboring country and i'll go to jail for like forever if i had users in it.
There is no technological way that you can guarantee that your mobile application can't / won't be used by someone in another country. Anything that you do in your application can be defeated by a user with sufficient ingenuity / time.
You need to talk to a good local lawyer to find out precisely what your country's law means, and what you need to do to comply with it1. But if the law requires you to do things that are technically impossible, your safest bet may be to not write / publish any mobile apps. Seriously.
1 - It is unlikely that anyone here really knows. I certainly don't!
Locale.getDefault()
Gives you the locale information about the phone, this information come from settings and can be changed by user
but if you want ensure the user from specific country doesn't use you app just get the GPS position and in case of be that country close it
You can perform multiple checks like does a user's IP match banned country IPs, you can check mobile carrier, you can eventually make location check which of course will require user's permission.
I'm currently working on a native Android app for my company and ran into some problems with Salesforce lately.
I hope I can find some help here.
What I want to achieve:
The company has a lot of Accounts in Salesforce with 3 important fields for the app: Name, Business (Workshop or Parts Dealer) and location(latitude, longitude)
I would like to show those Accounts(Workshops/Parts Dealers) as markers on a google map in my Android app based on a radius around the user's current location. So it would be more than sufficient to get the data as JSON or XML(i read about sObjects, which would be nice too)
The app will be freely available on Google Play Store and every user should be able to see all the Workshops/Parts dealers around the world.
The problem I'm facing is that I can't find a way to fetch the data inside my app without authenticating every user with a Salesforce-Login.
Which API is the best to use in this case?
It would be so awesome if anybody could help me with this problem.
What I tried so far:
- SalesforceMobileSDK: If i extend SalesForceApplication() i always end up with the Salesforce-Login Screen.
It seems that every client has to be authenticated for API-calls to work. I tried using the method peekUnauthenticatedRestClient(), but this method only works on full path URL's(e.g. "https://api.spotify.com/v1/search?q=James%20Brown&type=artist"), which isn't really practical for my Use-case.
I feel like I read nearly all docs about salesforce API, but can't quite get my head around how to solve this problem, although it seems like to be a pretty common use-case.
would a salesforce-apex method which would select all records inside a set radius around the user's location to be accessible without authentication?
Thanks for your help in advance!
Roman
Try asking on salesforce.stackexchange.com. Your question is more about licensing model than a particular programming problem. It might even be the case that you don't really need Salesforce for your project, you'd be better off on Heroku (even free tier) if the login piece is an issue...
All Salesforce APIs require some form of authentication. If you're positive you don't want to hardcode "Integration user" credentials in the app and you don't want to pay for (self-)registered user licenses in your org...
Try to read about these:
Site - piece of Visualforce running under specific "guest user", letting you view & interact with SF data without having to log in. You expose SF data to the world but that means it's your job to handle security (if any) and craft the API. You want to really display the data to human? Or just return JSON content or what...
Sites are meant to be displayin some incentive to contact you. Your product catalog / basic order form. Some map of nearby locations. Maybe a "contact us" form. There's limit on the traffic so eventually they'll explode as your app gets popular:
Customer Community - typically you need named licenses (even if they're fairly cheap) to let your customers log in to your SF. You create a Contact, click magic button - boom, this Contact now has a real matching User record with its own license. Think of it as some kind of step up from Sites - it'll still have some limits but will offer more than just raw API access and you'll have better control on what's going on.
I am working on a project where I should develop an application to validate post addresses in Germany, Switzerland and Austria. For that I need to set up a address database with all information. But I don't know where i can get the data. I googled for a long time but I didn't find an answer for my problem.
I have 2 questions:
can I work with the rest service of nominatim in a productive environment? the application will process approximately over then 300000 request a day.
can I import an openstreetmap file (*.osm) in a DB (MySql) and work with that? ist there all the informations i need to validate addresses. such as streetname exists? housenumber exists? fit street to housenumber and town?
thans in advance
Achraf
Yes, you can use Nominatim in a productive environment. However not
OSM's public instance (take a look at the usage policy for the
reasons). Just install your own Nominatim instance or use one of the other alternatives.
That depends on the exact information you need. Some adress information are implicitly contained (usually address, house number), some others need to be calculated first (often the city, municipality, state, post codes etc.) because they are often not attached to the address elements directly but to administrative boundary relations instead. Nominatim does all of these processing for you.
Also take a look at other OSM search engines. And remember that OSM doesn't contain every possible address.
I am creating a java application to receive messages on pc using jsms API. Whenever a user sends a particular message to a no, it receives it and adds to the database, the phone number and the area/ region where it belongs.
The region can either be the area where the phone number is registered, or it can also be the current location of the device. Either of these information will help me.
I would be really glad if any one could any one guide me on how to proceed with finding out the region using java code.
Note: I'm not looking for the country. I'm looking for the state/ region. Preferable Indian states.
You could try out libphonenumber. It basically defines the region based on the number.
There is a JavaScript try page here you could perform some tests.
I want to know if I can rely on the telephony values like country, MCC, etc on Android for my app. Can I change them on the run using setprop? I tried changing using setprop it didn't seem to work. From my understanding telephony manager is a class/interface which represents Hardware configuration of GSM or CDMA. In case of GSM this could be sim and in case of CDMA it cud be a hardware. My questions are:
Who update these values in both the cases for the first time?
Are these values are saved by OS as read only?
What if a user travels to different country or zone will some of the values like country code and MCC values updated automatically?
Can I reset these values?
I have no intention of changing any of these values but want to understand its working! I would appreciate if someone can help me on this.
According to android documentation
Provides access to information about the telephony services on the
device. Applications can use the methods in this class to determine
telephony services and states, as well as to access some types of
subscriber information. Applications can also register a listener to
receive notification of telephony state changes.
TelephonyManager is used for reading phone information. Regarding your question about MCC & MNC codes: yes, they will change when phone will be in other country. You can subscribe to receive those events and determine that user now in different country.
#Bo
The way CDMA works is different from GSM. CDMA has always got one home base and many visitor base location. and you can always get to know about visitor Operator using TelephonyManager methods which is considered as unreliable for CDMA.
I decided to add it as answer as well...
I found a way to tackle this problem on CDMA phone.. if it is a CDMA phone , then the phone always has an ICC hardware comparable to SIM cards in GSM. All you gotta do is use the system properties associated with the hard ware . Programmatically you can use Java reflection to get this information . This is not changeable even system is rooted unlike GSM device. Class c=Class.forName("android.os.SystemProperties"); Method get = c.getMethod("get", String.class); String homeOperator = ((String) get.invoke(c, "ro.cdma.home.operator.numeric"));