Skip to content

Commit

Permalink
SIM Methods Exception Handling
Browse files Browse the repository at this point in the history
Seems that the SIM specific TelephonyManager methods can cause some serious issues
with some devices so all accesses have now been wrapped in try catch blocks to
provide stability to these devices.
  • Loading branch information
xLaMbChOpSx committed May 3, 2014
1 parent 247ece5 commit 1af417d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.SecUpwN.AIMSICD"
android:versionCode="6"
android:versionName="0.1.6" >
android:versionCode="13"
android:versionName="0.1.13" >

<uses-feature
android:glEsVersion="0x00020000"
Expand Down
48 changes: 37 additions & 11 deletions app/src/main/java/com/SecUpwN/AIMSICD/service/AimsicdService.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ private void refreshDeviceInfo() {
}*/

//SIM Information
mSimCountry = tm.getSimCountryIso();
mSimOperator = tm.getSimOperator();
mSimOperatorName = tm.getSimOperatorName();
mSimSerial = tm.getSimSerialNumber();
mSimSubs = tm.getSubscriberId();
mSimCountry = getSimCountry(true);
mSimOperator = getSimOperator(true);
mSimOperatorName = getSimOperatorName(true);
mSimSerial = getSimSerial(true);
mSimSubs = getSimSubs(true);

mDataActivityType = getActivityDesc();
mDataState = getStateDesc();
Expand Down Expand Up @@ -355,7 +355,11 @@ public int getPhoneID() {
*/
public String getSimCountry(boolean force) {
if (mSimCountry.isEmpty() || force) {
mSimCountry = tm.getSimCountryIso();
try {
mSimCountry = tm.getSimCountryIso();
} catch (Exception e) {
//SIM methods can cause Exceptions on some devices
}
}

return mSimCountry;
Expand All @@ -368,7 +372,11 @@ public String getSimCountry(boolean force) {
*/
public String getSimOperator(boolean force) {
if (mSimOperator.isEmpty() || force) {
mSimOperator = tm.getSimOperator();
try {
mSimOperator = tm.getSimOperator();
} catch (Exception e) {
//SIM methods can cause Exceptions on some devices
}
}

return mSimOperator;
Expand All @@ -381,7 +389,11 @@ public String getSimOperator(boolean force) {
*/
public String getSimOperatorName(boolean force) {
if (mSimOperatorName.isEmpty() || force) {
mSimOperatorName = tm.getSimOperatorName();
try {
mSimOperatorName = tm.getSimOperatorName();
}catch (Exception e) {
//SIM methods can cause Exceptions on some devices
}
}

return mSimOperatorName;
Expand All @@ -394,7 +406,12 @@ public String getSimOperatorName(boolean force) {
*/
public String getSimSubs(boolean force) {
if (mSimSubs.isEmpty() || force) {
mSimSubs = tm.getSubscriberId();
try {
mSimSubs = tm.getSubscriberId();
} catch (Exception e) {
//Some devices don't like this method
}

}

return mSimSubs;
Expand All @@ -407,7 +424,11 @@ public String getSimSubs(boolean force) {
*/
public String getSimSerial(boolean force) {
if (mSimSerial.isEmpty() || force) {
mSimSerial = tm.getSimSerialNumber();
try {
mSimSerial = tm.getSimSerialNumber();
} catch (Exception e) {
//SIM methods can cause Exceptions on some devices
}
}

return mSimSerial;
Expand Down Expand Up @@ -484,7 +505,12 @@ public String getPhoneNumber(boolean force) {

//Check if Phone Number successfully retrieved and if not try subscriber
if (mPhoneNum.isEmpty())
mPhoneNum = tm.getSubscriberId();
try {
mPhoneNum = tm.getSubscriberId();
} catch (NullPointerException npe) {
//Seems some devices don't like this on either
}


return mPhoneNum;
}
Expand Down

0 comments on commit 1af417d

Please sign in to comment.