From d8f09912a32d6507e893597eedd593e15992e103 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Wed, 25 Jan 2012 13:29:45 -0800 Subject: [PATCH] Fixed a bug with C2DM registration --- .../com/timsu/astrid/C2DMReceiver.java | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/astrid/plugin-src/com/timsu/astrid/C2DMReceiver.java b/astrid/plugin-src/com/timsu/astrid/C2DMReceiver.java index a0090f564..30c195563 100644 --- a/astrid/plugin-src/com/timsu/astrid/C2DMReceiver.java +++ b/astrid/plugin-src/com/timsu/astrid/C2DMReceiver.java @@ -12,7 +12,6 @@ import android.content.Context; import android.content.Intent; import android.os.Build; import android.provider.Settings.Secure; -import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; @@ -77,31 +76,22 @@ public class C2DMReceiver extends BroadcastReceiver { }; private static String getDeviceID() { - String id = ((TelephonyManager) ContextManager.getContext().getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId(); + String id = Secure.getString(ContextManager.getContext().getContentResolver(), Secure.ANDROID_ID);; + if(AndroidUtilities.getSdkVersion() > 8) { //Gingerbread and above - if(id == null) { // check for devices that do not have a Telephony Manager device id - - if(AndroidUtilities.getSdkVersion() > 8) { //Gingerbread and above - - //the following uses relection to get android.os.Build.SERIAL to avoid having to build with Gingerbread - try { + //the following uses relection to get android.os.Build.SERIAL to avoid having to build with Gingerbread + try { + if(!Build.UNKNOWN.equals(Build.SERIAL)) id = Build.SERIAL; - if(Build.UNKNOWN.equals(id)) - id = ""; - } catch(Exception e) { - e.printStackTrace(); - id = ""; - } - - } else { - id = Secure.getString(ContextManager.getContext().getContentResolver(), Secure.ANDROID_ID); - } - - if ("".equals(id) || "9774d56d682e549c".equals(id)) { // check for failure or devices affected by the "9774d56d682e549c" bug - return null; + } catch(Exception e) { + // Ah well } + } + if (TextUtils.isEmpty(id) || "9774d56d682e549c".equals(id)) { // check for failure or devices affected by the "9774d56d682e549c" bug + return null; } + return id; }