Delay processing SMS messages until after sqlcipher migration

When screen lock passphrase is enabled

Fixes #7390
This commit is contained in:
Moxie Marlinspike 2018-02-21 18:49:08 -08:00
parent a40d7158de
commit 7318236286
3 changed files with 24 additions and 9 deletions

View file

@ -1320,6 +1320,8 @@
<string name="SQLCipherMigrationHelper_migrating_signal_database">Migrating Signal database</string>
<string name="PushDecryptJob_new_locked_message">New locked message</string>
<string name="PushDecryptJob_unlock_to_view_pending_messages">Unlock to view pending messages</string>
<string name="ExperienceUpgradeActivity_unlock_to_complete_update">Unlock to complete update</string>
<string name="ExperienceUpgradeActivity_please_unlock_signal_to_complete_update">Please unlock Signal to complete update</string>
<!-- EOF -->

View file

@ -13,8 +13,6 @@ import android.support.annotation.StringRes;
import android.support.v4.app.NotificationCompat;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import com.melnykov.fab.FloatingActionButton;
import com.nineoldandroids.animation.ArgbEvaluator;
@ -144,12 +142,7 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
pager.setAdapter(new IntroPagerAdapter(getSupportFragmentManager(), upgrade.get().getPages()));
fab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onContinue(upgrade);
}
});
fab.setOnClickListener(v -> onContinue(upgrade));
getWindow().setBackgroundDrawable(new ColorDrawable(upgrade.get().getPage(0).backgroundColor));
ServiceUtil.getNotificationManager(this).cancel(NOTIFICATION_ID);
@ -166,7 +159,7 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
intent.putExtra("next_intent", nextIntent);
startActivity(intent);
} else {
startActivity((Intent) getIntent().getParcelableExtra("next_intent"));
startActivity(getIntent().getParcelableExtra("next_intent"));
}
finish();
@ -225,6 +218,24 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity {
if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction()) &&
intent.getData().getSchemeSpecificPart().equals(context.getPackageName()))
{
if (TextSecurePreferences.getLastExperienceVersionCode(context) < 339 &&
!TextSecurePreferences.isPasswordDisabled(context))
{
Notification notification = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.icon_notification)
.setColor(context.getResources().getColor(R.color.signal_primary))
.setContentTitle(context.getString(R.string.ExperienceUpgradeActivity_unlock_to_complete_update))
.setContentText(context.getString(R.string.ExperienceUpgradeActivity_please_unlock_signal_to_complete_update))
.setStyle(new NotificationCompat.BigTextStyle().bigText(context.getString(R.string.ExperienceUpgradeActivity_please_unlock_signal_to_complete_update)))
.setAutoCancel(true)
.setContentIntent(PendingIntent.getActivity(context, 0,
context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()),
PendingIntent.FLAG_UPDATE_CURRENT))
.build();
ServiceUtil.getNotificationManager(context).notify(NOTIFICATION_ID, notification);
}
Optional<ExperienceUpgrade> experienceUpgrade = getExperienceUpgrade(context);
if (!experienceUpgrade.isPresent()) {

View file

@ -9,6 +9,7 @@ import android.util.Log;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.MessagingDatabase.InsertResult;
import org.thoughtcrime.securesms.database.SmsDatabase;
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
import org.thoughtcrime.securesms.notifications.MessageNotifier;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.sms.IncomingTextMessage;
@ -31,6 +32,7 @@ public class SmsReceiveJob extends ContextJob {
super(context, JobParameters.newBuilder()
.withPersistence()
.withWakeLock(true)
.withRequirement(new MasterSecretRequirement(context))
.create());
this.pdus = pdus;