Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
New properties on Android
Browse files Browse the repository at this point in the history
- deviceId
- deviceSoftwareVersion
- simSerialNumber
- subscriberId
- isNetworkRoaming
  • Loading branch information
pbakondy committed Nov 18, 2015
1 parent a729fb4 commit 9a82364
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 8 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
18 changes: 16 additions & 2 deletions README.md
Expand Up @@ -26,6 +26,14 @@ document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.plugins.sim.getSimInfo(successCallback, errorCallback);
}

function successCallback(result) {
console.log(result);
}

function errorCallback(error) {
console.log(error);
}
```

The plugin returns a JSON object. Return values:
Expand All @@ -46,14 +54,20 @@ You can extract country and carrier data from MCC and MNC codes, read further on

Additional return values:

* `phoneNumber`: String - phone number string for line 1, for example, the [MSISDN](http://en.wikipedia.org/wiki/MSISDN) for a GSM phone
* `phoneNumber`: String - phone number string for line 1, for example, the [MSISDN](http://en.wikipedia.org/wiki/MSISDN) for a GSM phone <sup>1</sup>
* `deviceId`: String - the unique device ID, for example, the IMEI for GSM and the MEID or ESN for CDMA phones
* `deviceSoftwareVersion`: String - the software version number for the device, for example, the IMEI/SV for GSM phones
* `simSerialNumber`: String - the serial number of the SIM, if applicable
* `subscriberId`: String - the unique subscriber ID, for example, the IMSI for a GSM phone
* `callState`: Number - the call state (cellular) on the device
* `dataActivity`: Number - the type of activity on a data connection (cellular)
* `networkType`: Number - the NETWORK_TYPE_xxxx for current data connection
* `phoneType`: Number - the device phone type. This indicates the type of radio used to transmit voice calls
* `simState`: Number - the state of the device SIM card
* `isNetworkRoaming`: Boolean - true if the device is considered roaming on the current network, for GSM purposes

Notice: the content of phoneNumber is unreliable (see [this](http://stackoverflow.com/questions/7922734/getting-reliable-msisdn-from-android-phone-voicemailnumber-line1number) and [this](http://stackoverflow.com/questions/25861064/retrieving-line1-number-from-telephonymanager-in-android) article).
<sup>1)</sup> Notice: the content of phoneNumber is unreliable (see [this](http://stackoverflow.com/questions/7922734/getting-reliable-msisdn-from-android-phone-voicemailnumber-line1number) and [this](http://stackoverflow.com/questions/25861064/retrieving-line1-number-from-telephonymanager-in-android) article).
Sometimes phoneNumber value is only an empty string.


### List of Call State Codes and Meanings
Expand Down
7 changes: 3 additions & 4 deletions package.json
@@ -1,14 +1,15 @@
{
"name": "cordova-plugin-sim",
"version": "1.0.2",
"version": "1.1.0",
"description": "A plugin to get the device's SIM data (carrier name, mcc mnc, country code, telephonenumber, etc)",
"cordova": {
"id": "cordova-plugin-sim",
"platforms": [
"android",
"ios",
"wp7",
"wp8"
"wp8",
"windows"
]
},
"repository": {
Expand All @@ -26,8 +27,6 @@
"ecosystem:cordova",
"cordova-android",
"cordova-ios",
"cordova-wp7",
"cordova-wp8",
"cordova-windows"
],
"engines": [
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-sim"
version="1.0.2">
version="1.1.0">
<name>SIM</name>
<description>A plugin to get the device's SIM data (carrier name, mcc mnc, country code, telephonenumber, etc)</description>
<license>MIT</license>
Expand Down
15 changes: 14 additions & 1 deletion src/android/com/pbakondy/Sim.java
Expand Up @@ -33,12 +33,19 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
String simOperator = manager.getSimOperator();
String carrierName = manager.getSimOperatorName();

String deviceId = manager.getDeviceId();
String deviceSoftwareVersion = manager.getDeviceSoftwareVersion();
String simSerialNumber = manager.getSimSerialNumber();
String subscriberId = manager.getSubscriberId();

int callState = manager.getCallState();
int dataActivity = manager.getDataActivity();
int networkType = manager.getNetworkType();
int phoneType = manager.getPhoneType();
int simState = manager.getSimState();

boolean isNetworkRoaming = manager.isNetworkRoaming();

String mcc = "";
String mnc = "";

Expand All @@ -47,7 +54,6 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
mnc = simOperator.substring(3);
}


JSONObject result = new JSONObject();

result.put("carrierName", carrierName);
Expand All @@ -56,12 +62,19 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
result.put("mnc", mnc);
result.put("phoneNumber", phoneNumber);

result.put("deviceId", deviceId);
result.put("deviceSoftwareVersion", deviceSoftwareVersion);
result.put("simSerialNumber", simSerialNumber);
result.put("subscriberId", subscriberId);

result.put("callState", callState);
result.put("dataActivity", dataActivity);
result.put("networkType", networkType);
result.put("phoneType", phoneType);
result.put("simState", simState);

result.put("isNetworkRoaming", isNetworkRoaming);

callbackContext.success(result);

return true;
Expand Down

0 comments on commit 9a82364

Please sign in to comment.