mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-26 07:30:16 +00:00
move routing logic to all activities
Fixes #2239 Closes #27923 // FREEBIE
This commit is contained in:
committed by
Moxie Marlinspike
parent
141ee6565d
commit
0ff99258ac
@@ -17,8 +17,8 @@ import android.os.PowerManager.WakeLock;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.ConversationListActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.RoutingActivity;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.SmsMigrator;
|
||||
import org.thoughtcrime.securesms.database.SmsMigrator.ProgressDescription;
|
||||
@@ -28,8 +28,8 @@ import java.util.concurrent.Executors;
|
||||
|
||||
public class ApplicationMigrationService extends Service
|
||||
implements SmsMigrator.SmsMigrationProgressListener
|
||||
{
|
||||
|
||||
{
|
||||
private static final String TAG = ApplicationMigrationService.class.getSimpleName();
|
||||
public static final String MIGRATE_DATABASE = "org.thoughtcrime.securesms.ApplicationMigration.MIGRATE_DATABSE";
|
||||
public static final String COMPLETED_ACTION = "org.thoughtcrime.securesms.ApplicationMigrationService.COMPLETED";
|
||||
private static final String PREFERENCES_NAME = "SecureSMS";
|
||||
@@ -128,7 +128,7 @@ public class ApplicationMigrationService extends Service
|
||||
builder.setContentText(getString(R.string.ApplicationMigrationService_import_in_progress));
|
||||
builder.setOngoing(true);
|
||||
builder.setProgress(100, 0, false);
|
||||
builder.setContentIntent(PendingIntent.getActivity(this, 0, new Intent(this, RoutingActivity.class), 0));
|
||||
builder.setContentIntent(PendingIntent.getActivity(this, 0, new Intent(this, ConversationListActivity.class), 0));
|
||||
|
||||
stopForeground(true);
|
||||
startForeground(4242, builder.build());
|
||||
@@ -141,7 +141,7 @@ public class ApplicationMigrationService extends Service
|
||||
|
||||
public ImportRunnable(Intent intent) {
|
||||
this.masterSecret = intent.getParcelableExtra("master_secret");
|
||||
Log.w("ApplicationMigrationService", "Service got mastersecret: " + masterSecret);
|
||||
Log.w(TAG, "Service got mastersecret: " + masterSecret);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -184,7 +184,7 @@ public class ApplicationMigrationService extends Service
|
||||
builder.setSmallIcon(R.drawable.icon_notification);
|
||||
builder.setContentTitle("Import Complete");
|
||||
builder.setContentText("TextSecure system database import is complete.");
|
||||
builder.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, RoutingActivity.class), 0));
|
||||
builder.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, ConversationListActivity.class), 0));
|
||||
builder.setWhen(System.currentTimeMillis());
|
||||
builder.setDefaults(Notification.DEFAULT_VIBRATE);
|
||||
builder.setAutoCancel(true);
|
||||
|
||||
@@ -33,10 +33,10 @@ import android.util.Log;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.ConversationListActivity;
|
||||
import org.thoughtcrime.securesms.DatabaseUpgradeActivity;
|
||||
import org.thoughtcrime.securesms.DummyActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.RoutingActivity;
|
||||
import org.thoughtcrime.securesms.crypto.InvalidPassphraseException;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
||||
@@ -121,6 +121,7 @@ public class KeyCachingService extends Service {
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
if (intent == null) return START_NOT_STICKY;
|
||||
Log.w("KeyCachingService", "onStartCommand, " + intent.getAction());
|
||||
|
||||
if (intent.getAction() != null) {
|
||||
switch (intent.getAction()) {
|
||||
@@ -138,6 +139,7 @@ public class KeyCachingService extends Service {
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
Log.w("KeyCachingService", "onCreate()");
|
||||
super.onCreate();
|
||||
this.pending = PendingIntent.getService(this, 0, new Intent(PASSPHRASE_EXPIRED_EVENT, null,
|
||||
this, KeyCachingService.class), 0);
|
||||
@@ -186,7 +188,8 @@ public class KeyCachingService extends Service {
|
||||
}
|
||||
|
||||
private void handleClearKey() {
|
||||
this.masterSecret = null;
|
||||
Log.w("KeyCachingService", "handleClearKey()");
|
||||
KeyCachingService.masterSecret = null;
|
||||
stopForeground(true);
|
||||
|
||||
Intent intent = new Intent(CLEAR_KEY_EVENT);
|
||||
@@ -216,7 +219,7 @@ public class KeyCachingService extends Service {
|
||||
private void startTimeoutIfAppropriate() {
|
||||
boolean timeoutEnabled = TextSecurePreferences.isPassphraseTimeoutEnabled(this);
|
||||
|
||||
if ((activitiesRunning == 0) && (this.masterSecret != null) && timeoutEnabled && !TextSecurePreferences.isPasswordDisabled(this)) {
|
||||
if ((activitiesRunning == 0) && (KeyCachingService.masterSecret != null) && timeoutEnabled && !TextSecurePreferences.isPasswordDisabled(this)) {
|
||||
long timeoutMinutes = TextSecurePreferences.getPassphraseTimeoutInterval(this);
|
||||
long timeoutMillis = TimeUnit.MINUTES.toMillis(timeoutMinutes);
|
||||
|
||||
@@ -230,6 +233,7 @@ public class KeyCachingService extends Service {
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
private void foregroundServiceModern() {
|
||||
Log.w("KeyCachingService", "foregrounding KCS");
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
|
||||
|
||||
builder.setContentTitle(getString(R.string.KeyCachingService_passphrase_cached));
|
||||
@@ -292,7 +296,6 @@ public class KeyCachingService extends Service {
|
||||
Log.w("service", "Broadcasting new secret...");
|
||||
|
||||
Intent intent = new Intent(NEW_KEY_EVENT);
|
||||
intent.putExtra("master_secret", masterSecret);
|
||||
intent.setPackage(getApplicationContext().getPackageName());
|
||||
|
||||
sendBroadcast(intent, KEY_PERMISSION);
|
||||
@@ -306,7 +309,7 @@ public class KeyCachingService extends Service {
|
||||
}
|
||||
|
||||
private PendingIntent buildLaunchIntent() {
|
||||
Intent intent = new Intent(this, RoutingActivity.class);
|
||||
Intent intent = new Intent(this, ConversationListActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
PendingIntent launchIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
|
||||
return launchIntent;
|
||||
|
||||
@@ -8,8 +8,8 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import org.thoughtcrime.securesms.ConversationListActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.RoutingActivity;
|
||||
|
||||
public class RegistrationNotifier extends BroadcastReceiver {
|
||||
@Override
|
||||
@@ -18,7 +18,7 @@ public class RegistrationNotifier extends BroadcastReceiver {
|
||||
builder.setSmallIcon(R.drawable.icon_notification);
|
||||
builder.setContentTitle(intent.getStringExtra(RegistrationService.NOTIFICATION_TITLE));
|
||||
builder.setContentText(intent.getStringExtra(RegistrationService.NOTIFICATION_TEXT));
|
||||
builder.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, RoutingActivity.class), 0));
|
||||
builder.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, ConversationListActivity.class), 0));
|
||||
builder.setWhen(System.currentTimeMillis());
|
||||
builder.setDefaults(Notification.DEFAULT_VIBRATE);
|
||||
builder.setAutoCancel(true);
|
||||
|
||||
Reference in New Issue
Block a user