diff --git a/src/org/thoughtcrime/securesms/ApplicationContext.java b/src/org/thoughtcrime/securesms/ApplicationContext.java index b8ab68f620..c8a8b59f48 100644 --- a/src/org/thoughtcrime/securesms/ApplicationContext.java +++ b/src/org/thoughtcrime/securesms/ApplicationContext.java @@ -78,7 +78,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc @Override public void onCreate() { super.onCreate(); - initializeDeveloperBuild(); initializeRandomNumberFix(); initializeLogging(); initializeDependencyInjection(); @@ -109,15 +108,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc return expiringMessageManager; } - private void initializeDeveloperBuild() { - if (BuildConfig.DEV_BUILD) { - StrictMode.setThreadPolicy(new ThreadPolicy.Builder().detectAll() - .penaltyLog() - .build()); - StrictMode.setVmPolicy(new VmPolicy.Builder().detectAll().penaltyLog().build()); - } - } - private void initializeRandomNumberFix() { PRNGFixes.apply(); } @@ -150,9 +140,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc } private void initializeGcmCheck() { - if (TextSecurePreferences.isPushRegistered(this) && - TextSecurePreferences.getGcmRegistrationId(this) == null) - { + if (TextSecurePreferences.isPushRegistered(this)) { this.jobManager.add(new GcmRefreshJob(this)); } } diff --git a/src/org/thoughtcrime/securesms/jobs/GcmRefreshJob.java b/src/org/thoughtcrime/securesms/jobs/GcmRefreshJob.java index 731f9ad3c1..fd2974b5d5 100644 --- a/src/org/thoughtcrime/securesms/jobs/GcmRefreshJob.java +++ b/src/org/thoughtcrime/securesms/jobs/GcmRefreshJob.java @@ -62,27 +62,23 @@ public class GcmRefreshJob extends ContextJob implements InjectableType { public void onRun() throws Exception { if (TextSecurePreferences.isGcmDisabled(context)) return; - String registrationId = TextSecurePreferences.getGcmRegistrationId(context); + Log.w(TAG, "Reregistering GCM..."); + int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); - if (registrationId == null) { - Log.w(TAG, "GCM registrationId expired, reregistering..."); - int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); + if (result != ConnectionResult.SUCCESS) { + notifyGcmFailure(); + } else { + String gcmId = GoogleCloudMessaging.getInstance(context).register(REGISTRATION_ID); + textSecureAccountManager.setGcmId(Optional.of(gcmId)); - if (result != ConnectionResult.SUCCESS) { - notifyGcmFailure(); - } else { - String gcmId = GoogleCloudMessaging.getInstance(context).register(REGISTRATION_ID); - textSecureAccountManager.setGcmId(Optional.of(gcmId)); - - try { - redPhoneAccountManager.setGcmId(Optional.of(gcmId)); - } catch (UnauthorizedException e) { - Log.w(TAG, e); - } - - TextSecurePreferences.setGcmRegistrationId(context, gcmId); - TextSecurePreferences.setWebsocketRegistered(context, true); + try { + redPhoneAccountManager.setGcmId(Optional.of(gcmId)); + } catch (UnauthorizedException e) { + Log.w(TAG, e); } + + TextSecurePreferences.setGcmRegistrationId(context, gcmId); + TextSecurePreferences.setWebsocketRegistered(context, true); } }