diff options
author | Daniel Bateman <jetison.24@gmail.com> | 2012-08-15 01:05:14 -0500 |
---|---|---|
committer | Daniel Bateman <jetison.24@gmail.com> | 2012-08-19 01:55:24 -0500 |
commit | c7cd74f811fc249b1c1ef0f95740134e2da54a41 (patch) | |
tree | 72c65303004d1acf3339350eae9fec4eefb81b0e /AriesParts | |
parent | b50b05e4ef8ae74f52b79ccbfe616d3da23ef1bd (diff) | |
download | device_samsung_aries-common-c7cd74f811fc249b1c1ef0f95740134e2da54a41.zip device_samsung_aries-common-c7cd74f811fc249b1c1ef0f95740134e2da54a41.tar.gz device_samsung_aries-common-c7cd74f811fc249b1c1ef0f95740134e2da54a41.tar.bz2 |
aries-common: Add sanity checking
Purpose: Verify the integrity of select things including the IMEI.
The IMEI specifically, if invalid, could cause emergency
calling issues (i.e. inability to call at all).
Warn the user if any issues are detected. Currently only the IMEI
is checked against the generic IMEI (004999010640000).
Change-Id: I8fb76b7535cc7110142b72892cf9d4fc1cbc25e7
Diffstat (limited to 'AriesParts')
-rw-r--r-- | AriesParts/AndroidManifest.xml | 4 | ||||
-rw-r--r-- | AriesParts/res/values/strings.xml | 9 | ||||
-rw-r--r-- | AriesParts/src/com/cyanogenmod/settings/device/Sanity.java | 38 | ||||
-rw-r--r-- | AriesParts/src/com/cyanogenmod/settings/device/Startup.java | 1 | ||||
-rw-r--r-- | AriesParts/src/com/cyanogenmod/settings/device/WarnActivity.java | 43 |
5 files changed, 95 insertions, 0 deletions
diff --git a/AriesParts/AndroidManifest.xml b/AriesParts/AndroidManifest.xml index 7debe38..137d83d 100644 --- a/AriesParts/AndroidManifest.xml +++ b/AriesParts/AndroidManifest.xml @@ -3,6 +3,7 @@ package="com.cyanogenmod.settings.device" android:sharedUserId="android.uid.system"> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> + <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <application android:label="@string/app_name" android:icon="@drawable/icon"> <activity android:name=".DeviceSettings" @@ -14,5 +15,8 @@ </intent-filter> </receiver> <service android:name=".TvOutService" /> + <activity android:name=".WarnActivity" + android:label="@string/generic_warning_title" + android:theme="@android:style/Theme.Translucent"></activity> </application> </manifest> diff --git a/AriesParts/res/values/strings.xml b/AriesParts/res/values/strings.xml index 80679a0..ef450f3 100644 --- a/AriesParts/res/values/strings.xml +++ b/AriesParts/res/values/strings.xml @@ -50,4 +50,13 @@ <string name="deskdock_audio_summary_on">Desk dock audio enabled</string> <string name="deskdock_audio_summary_off">Desk dock audio disabled</string> + <!-- Used for activity title. Usually not visible, except on the + multi-task screen --> + <string name="generic_warning_title">Warning</string> + + <!-- Invalid IMEI --> + <string name="imei_not_sane_title">Warning!</string> + <string name="imei_not_sane_message">A problem was detected with your device. Your device IMEI number is invalid. An invalid IMEI number could cause network issues including the inability to call emergency numbers.</string> + <string name="imei_not_sane_ok">OK</string> + </resources> diff --git a/AriesParts/src/com/cyanogenmod/settings/device/Sanity.java b/AriesParts/src/com/cyanogenmod/settings/device/Sanity.java new file mode 100644 index 0000000..981b884 --- /dev/null +++ b/AriesParts/src/com/cyanogenmod/settings/device/Sanity.java @@ -0,0 +1,38 @@ +package com.cyanogenmod.settings.device; + +import android.content.Context; +import android.content.Intent; +import android.telephony.TelephonyManager; +import android.util.Log; + +public class Sanity { + private static final String TAG = "AriesParts"; + private static final String BAD_IMEI[] = { + "004999010640000" + }; + + public static void check(Context context) { + TelephonyManager tm = (TelephonyManager) context.getSystemService( + Context.TELEPHONY_SERVICE); + String id = tm.getDeviceId(); + if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM && !ensureIMEISanity(id)) { + Log.e(TAG, "Invalid IMEI!"); + Intent intent = new Intent(context, WarnActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.putExtra(WarnActivity.KEY_REASON, WarnActivity.REASON_INVALID_IMEI); + context.startActivity(intent); + return; + } + Log.d(TAG, "Device is sane."); + } + + public static boolean ensureIMEISanity(String id) { + Log.d(TAG, "Current IMEI: " + id); + for (int j = 0; j < BAD_IMEI.length; j++) { + if (BAD_IMEI[j].equals(id)) { + return false; + } + } + return true; + } +} diff --git a/AriesParts/src/com/cyanogenmod/settings/device/Startup.java b/AriesParts/src/com/cyanogenmod/settings/device/Startup.java index 901f47e..924a95d 100644 --- a/AriesParts/src/com/cyanogenmod/settings/device/Startup.java +++ b/AriesParts/src/com/cyanogenmod/settings/device/Startup.java @@ -14,6 +14,7 @@ public class Startup extends BroadcastReceiver { Hspa.restore(context); VolumeBoostPreference.restore(context); DockAudio.restore(context); + Sanity.check(context); } } diff --git a/AriesParts/src/com/cyanogenmod/settings/device/WarnActivity.java b/AriesParts/src/com/cyanogenmod/settings/device/WarnActivity.java new file mode 100644 index 0000000..34488ee --- /dev/null +++ b/AriesParts/src/com/cyanogenmod/settings/device/WarnActivity.java @@ -0,0 +1,43 @@ +package com.cyanogenmod.settings.device; + +import android.os.Bundle; +import android.content.Intent; +import android.app.Dialog; +import android.app.Activity; +import android.app.AlertDialog; +import android.view.Window; +import android.content.DialogInterface; +import android.util.Log; + +public class WarnActivity extends Activity { + public static final String KEY_REASON = "sanity_reason"; + public static final String REASON_INVALID_IMEI = "invalid_imei"; + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + requestWindowFeature(Window.FEATURE_NO_TITLE); + + Bundle extras = getIntent().getExtras(); + String reason = extras.getString(KEY_REASON); + + if (REASON_INVALID_IMEI.equals(reason)) { + showInvalidImei(); + } + } + + private void showInvalidImei() { + new AlertDialog.Builder(this) + .setTitle(getString(R.string.imei_not_sane_title)) + .setMessage(getString(R.string.imei_not_sane_message)) + .setPositiveButton(getString(R.string.imei_not_sane_ok), + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.cancel(); + finish(); + } + }) + .setCancelable(false) + .create().show(); + } +} |