summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawit Pornkitprasan <p.pawit@gmail.com>2012-08-19 16:17:34 +0400
committerGerrit Code Review <gerrit@review.cyanogenmod.com>2012-08-19 16:17:34 +0400
commit78ff8a72027fac64817753beb4de1461a53b0b85 (patch)
tree7c4f051771633fa702d73ad6d844d63f6ba41df2
parente3e54b3b5246a2129c1a0f0540ee2b39906495e9 (diff)
parentc7cd74f811fc249b1c1ef0f95740134e2da54a41 (diff)
downloaddevice_samsung_aries-common-78ff8a72027fac64817753beb4de1461a53b0b85.zip
device_samsung_aries-common-78ff8a72027fac64817753beb4de1461a53b0b85.tar.gz
device_samsung_aries-common-78ff8a72027fac64817753beb4de1461a53b0b85.tar.bz2
Merge "aries-common: Add sanity checking" into jellybean
-rw-r--r--AriesParts/AndroidManifest.xml4
-rw-r--r--AriesParts/res/values/strings.xml9
-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
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();
+ }
+}