Sanity check for system service restarts.

This commit is contained in:
Moxie Marlinspike 2012-08-05 12:41:31 -07:00
parent 2f6642a234
commit 8520cb558a
3 changed files with 50 additions and 45 deletions

View File

@ -34,6 +34,8 @@ public class ApplicationMigrationService extends Service
@Override @Override
public void onStart(Intent intent, int startId) { public void onStart(Intent intent, int startId) {
if (intent == null) return;
if (intent.getAction() != null && intent.getAction().equals(MIGRATE_DATABASE)) { if (intent.getAction() != null && intent.getAction().equals(MIGRATE_DATABASE)) {
handleDatabaseMigration((MasterSecret)intent.getParcelableExtra("master_secret")); handleDatabaseMigration((MasterSecret)intent.getParcelableExtra("master_secret"));
} }

View File

@ -75,6 +75,8 @@ public class KeyCachingService extends Service {
@Override @Override
public void onStart(Intent intent, int startId) { public void onStart(Intent intent, int startId) {
if (intent == null) return;
if (intent.getAction() != null && intent.getAction().equals(CLEAR_KEY_ACTION)) if (intent.getAction() != null && intent.getAction().equals(CLEAR_KEY_ACTION))
handleClearKey(); handleClearKey();
else if (intent.getAction() != null && intent.getAction().equals(ACTIVITY_START_EVENT)) else if (intent.getAction() != null && intent.getAction().equals(ACTIVITY_START_EVENT))

View File

@ -16,14 +16,6 @@
*/ */
package org.thoughtcrime.securesms.service; package org.thoughtcrime.securesms.service;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.database.CanonicalSessionMigrator;
import org.thoughtcrime.securesms.util.WorkerThread;
import android.app.Service; import android.app.Service;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.ComponentName; import android.content.ComponentName;
@ -33,11 +25,18 @@ import android.content.IntentFilter;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.os.Looper;
import android.os.Message; import android.os.Message;
import android.util.Log; import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.database.CanonicalSessionMigrator;
import org.thoughtcrime.securesms.util.WorkerThread;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
/** /**
* Services that handles sending/receiving of SMS/MMS. * Services that handles sending/receiving of SMS/MMS.
* *
@ -86,6 +85,8 @@ public class SendReceiveService extends Service {
@Override @Override
public void onStart(Intent intent, int startId) { public void onStart(Intent intent, int startId) {
if (intent == null) return;
if (intent.getAction().equals(SEND_SMS_ACTION)) if (intent.getAction().equals(SEND_SMS_ACTION))
scheduleSecretRequiredIntent(SEND_SMS, intent); scheduleSecretRequiredIntent(SEND_SMS, intent);
else if (intent.getAction().equals(RECEIVE_SMS_ACTION)) else if (intent.getAction().equals(RECEIVE_SMS_ACTION))