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
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));
}
}

View File

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