From 6b5da7f8cf438e15e6a85db558fc0dd42118198d Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Sun, 11 Mar 2018 17:30:31 -0700 Subject: [PATCH] Disable registration lock reminders for <=KK devices Fixes #7500 --- .../securesms/lock/RegistrationLockDialog.java | 4 +++- .../securesms/lock/RegistrationLockReminders.java | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/lock/RegistrationLockDialog.java b/src/org/thoughtcrime/securesms/lock/RegistrationLockDialog.java index 3cb3ccac6d..51100fa928 100644 --- a/src/org/thoughtcrime/securesms/lock/RegistrationLockDialog.java +++ b/src/org/thoughtcrime/securesms/lock/RegistrationLockDialog.java @@ -7,6 +7,7 @@ import android.content.Context; import android.content.DialogInterface; import android.graphics.Typeface; import android.os.AsyncTask; +import android.os.Build; import android.support.annotation.NonNull; import android.support.v7.app.AlertDialog; import android.text.Editable; @@ -43,7 +44,8 @@ public class RegistrationLockDialog { private static final String TAG = RegistrationLockDialog.class.getSimpleName(); public static void showReminderIfNecessary(@NonNull Context context) { - if (!RegistrationLockReminders.needsReminder(context)) return; + if (!RegistrationLockReminders.needsReminder(context)) return; + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return; AlertDialog dialog = new AlertDialog.Builder(context, R.style.RationaleDialog) .setView(R.layout.registration_lock_reminder_view) diff --git a/src/org/thoughtcrime/securesms/lock/RegistrationLockReminders.java b/src/org/thoughtcrime/securesms/lock/RegistrationLockReminders.java index d5e265a29a..60a5bd0d96 100644 --- a/src/org/thoughtcrime/securesms/lock/RegistrationLockReminders.java +++ b/src/org/thoughtcrime/securesms/lock/RegistrationLockReminders.java @@ -44,8 +44,13 @@ public class RegistrationLockReminders { long lastReminderInterval = TextSecurePreferences.getRegistrationLockNextReminderInterval(context); long nextReminderInterval; - if (success) nextReminderInterval = INTERVAL_PROGRESSION.get(lastReminderInterval); - else nextReminderInterval = INTERVAL_REGRESSION.get(lastReminderInterval); + if (success) { + if (INTERVAL_PROGRESSION.containsKey(lastReminderInterval)) nextReminderInterval = INTERVAL_PROGRESSION.get(lastReminderInterval); + else nextReminderInterval = INTERVAL_PROGRESSION.get(TimeUnit.HOURS.toMillis(6)); + } else { + if (INTERVAL_REGRESSION.containsKey(lastReminderInterval)) nextReminderInterval = INTERVAL_REGRESSION.get(lastReminderInterval); + else nextReminderInterval = INTERVAL_REGRESSION.get(TimeUnit.HOURS.toMillis(12)); + } TextSecurePreferences.setRegistrationLockLastReminderTime(context, System.currentTimeMillis()); TextSecurePreferences.setRegistrationLockNextReminderInterval(context, nextReminderInterval);