Reregister GCM on every app start

Fixes #5531
// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-03-06 11:50:51 -08:00
parent bdcfabf1ee
commit b110c8a2cb
2 changed files with 15 additions and 31 deletions

View File

@ -78,7 +78,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
initializeDeveloperBuild();
initializeRandomNumberFix(); initializeRandomNumberFix();
initializeLogging(); initializeLogging();
initializeDependencyInjection(); initializeDependencyInjection();
@ -109,15 +108,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
return expiringMessageManager; 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() { private void initializeRandomNumberFix() {
PRNGFixes.apply(); PRNGFixes.apply();
} }
@ -150,9 +140,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
} }
private void initializeGcmCheck() { private void initializeGcmCheck() {
if (TextSecurePreferences.isPushRegistered(this) && if (TextSecurePreferences.isPushRegistered(this)) {
TextSecurePreferences.getGcmRegistrationId(this) == null)
{
this.jobManager.add(new GcmRefreshJob(this)); this.jobManager.add(new GcmRefreshJob(this));
} }
} }

View File

@ -62,10 +62,7 @@ public class GcmRefreshJob extends ContextJob implements InjectableType {
public void onRun() throws Exception { public void onRun() throws Exception {
if (TextSecurePreferences.isGcmDisabled(context)) return; if (TextSecurePreferences.isGcmDisabled(context)) return;
String registrationId = TextSecurePreferences.getGcmRegistrationId(context); Log.w(TAG, "Reregistering GCM...");
if (registrationId == null) {
Log.w(TAG, "GCM registrationId expired, reregistering...");
int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
if (result != ConnectionResult.SUCCESS) { if (result != ConnectionResult.SUCCESS) {
@ -84,7 +81,6 @@ public class GcmRefreshJob extends ContextJob implements InjectableType {
TextSecurePreferences.setWebsocketRegistered(context, true); TextSecurePreferences.setWebsocketRegistered(context, true);
} }
} }
}
@Override @Override
public void onCanceled() { public void onCanceled() {