From 8bfdcf7a444359151c18720b01443d6f507bec7e Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Mon, 11 Mar 2013 18:02:23 +0200 Subject: [PATCH] Remove the global FonBotApplication instance. --- src/ro/ieval/fonbot/FonBotAdminReceiver.java | 2 +- src/ro/ieval/fonbot/FonBotApplication.java | 11 +---------- src/ro/ieval/fonbot/GCMIntentService.java | 2 +- src/ro/ieval/fonbot/PollServerAsyncTask.java | 6 ++++-- src/ro/ieval/fonbot/SendHttpMessageAsyncTask.java | 4 +++- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/ro/ieval/fonbot/FonBotAdminReceiver.java b/src/ro/ieval/fonbot/FonBotAdminReceiver.java index ca1102c..108b1da 100644 --- a/src/ro/ieval/fonbot/FonBotAdminReceiver.java +++ b/src/ro/ieval/fonbot/FonBotAdminReceiver.java @@ -77,7 +77,7 @@ public final class FonBotAdminReceiver extends DeviceAdminReceiver { public void onPasswordFailed(@Nullable final Context context, @Nullable final Intent intent) { if(context==null) return; - final DevicePolicyManager dpm=(DevicePolicyManager) FonBotApplication.instance.getSystemService(Context.DEVICE_POLICY_SERVICE); + final DevicePolicyManager dpm=(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); Utils.sendMessage(context, toNonNull(MessageType.WATCH_LOGIN), toNonNull(context.getString(device_login_failed_fmt, dpm.getCurrentFailedPasswordAttempts()))); } diff --git a/src/ro/ieval/fonbot/FonBotApplication.java b/src/ro/ieval/fonbot/FonBotApplication.java index 38b5b40..be774ce 100644 --- a/src/ro/ieval/fonbot/FonBotApplication.java +++ b/src/ro/ieval/fonbot/FonBotApplication.java @@ -36,26 +36,17 @@ public final class FonBotApplication extends Application { * iEval GCM sender id */ public static final String GCM_SENDER_ID = "379674287523"; - /** - * The one instance of FonBotApplication - */ - public static FonBotApplication instance=null; - /** - * The GCM registration ID - */ - public String regID=null; @Override public void onCreate() { super.onCreate(); //GCMRegistrar.checkDevice(this); - regID=GCMRegistrar.getRegistrationId(this); + final String regID=GCMRegistrar.getRegistrationId(this); if("".equals(regID)) GCMRegistrar.register(this, GCM_SENDER_ID); final TelephonyManager tman=(TelephonyManager) getSystemService(TELEPHONY_SERVICE); tman.listen(new FonBotPhoneStateListener(this), PhoneStateListener.LISTEN_CALL_STATE); - instance=this; new PollServerAsyncTask(this).execute(); diff --git a/src/ro/ieval/fonbot/GCMIntentService.java b/src/ro/ieval/fonbot/GCMIntentService.java index aea7202..bf17e5f 100644 --- a/src/ro/ieval/fonbot/GCMIntentService.java +++ b/src/ro/ieval/fonbot/GCMIntentService.java @@ -64,7 +64,7 @@ public class GCMIntentService extends GCMBaseIntentService { @Override protected void onRegistered(@Nullable final Context context, @Nullable final String regID) { - FonBotApplication.instance.regID=regID; + //do nothing } @Override diff --git a/src/ro/ieval/fonbot/PollServerAsyncTask.java b/src/ro/ieval/fonbot/PollServerAsyncTask.java index 15bf9cc..1be09c3 100644 --- a/src/ro/ieval/fonbot/PollServerAsyncTask.java +++ b/src/ro/ieval/fonbot/PollServerAsyncTask.java @@ -21,6 +21,8 @@ import android.preference.PreferenceManager; import android.util.Base64; import android.util.Log; +import com.google.android.gcm.GCMRegistrar; + /* * Copyright © 2013 Marius Gavrilescu * @@ -98,7 +100,7 @@ public final class PollServerAsyncTask extends AsyncTask