summaryrefslogtreecommitdiffstats
path: root/AriesParts/src
diff options
context:
space:
mode:
authorDaniel Bateman <jetison.24@gmail.com>2012-08-15 01:05:14 -0500
committerDaniel Bateman <jetison.24@gmail.com>2012-08-19 01:55:24 -0500
commitc7cd74f811fc249b1c1ef0f95740134e2da54a41 (patch)
tree72c65303004d1acf3339350eae9fec4eefb81b0e /AriesParts/src
parentb50b05e4ef8ae74f52b79ccbfe616d3da23ef1bd (diff)
downloaddevice_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/src')
-rw-r--r--AriesParts/src/com/cyanogenmod/settings/device/Sanity.java38
-rw-r--r--AriesParts/src/com/cyanogenmod/settings/device/Startup.java1
-rw-r--r--AriesParts/src/com/cyanogenmod/settings/device/WarnActivity.java43
3 files changed, 82 insertions, 0 deletions
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();
+ }
+}