From e076ca45ba69a7fb2e656ef67ec97a85d0374d73 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Thu, 17 Sep 2020 15:44:19 +0200 Subject: [PATCH] tune down usage of screen-lock for various reasons, screen-lock will be removed completely in one of the next versions. - if screen-lock was enabled before, add a warning and keep the options (user can switch screen-lock on and off until it will be finally removed) - if screen lock was disabled before, hide the corresponding options, (the user will not be able to enable screen-lock anymore) reasons for removing are: - hard maintainability on different android versions, see discussions at https://github.com/deltachat/deltachat-android/issues/1208 and https://github.com/deltachat/deltachat-android/pull/1279 and https://github.com/deltachat/deltachat-android/pull/1319 and offline. ftr, also the used api createConfirmDeviceCredentialIntent() is deprectated, so another set of api calls would be needed in the soon future. - compared to the effort, few security is added, the function is only available if the system is protected anyway, one just have to repeat the system secret. - might even worsen overall security - if app login secret is peeked, and attacker will also have the system secret. - the functions stands in the way of moving forward to a cross-platform solution (however, not sure if this will really come) --- res/xml/preferences_app_protection.xml | 2 +- .../ApplicationPreferencesActivity.java | 2 -- .../connect/ApplicationDcContext.java | 29 +++++++++++++++++++ .../AppProtectionPreferenceFragment.java | 25 ++++++++-------- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/res/xml/preferences_app_protection.xml b/res/xml/preferences_app_protection.xml index 46156b4d0..f7913571e 100644 --- a/res/xml/preferences_app_protection.xml +++ b/res/xml/preferences_app_protection.xml @@ -13,7 +13,7 @@ android:summary="@string/pref_incognito_keyboard_explain" android:title="@string/pref_incognito_keyboard" /> - + { DcEventEmitter emitter = getEventEmitter(); while (true) { diff --git a/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java index 900dd420d..e61e351df 100644 --- a/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java +++ b/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java @@ -7,18 +7,14 @@ import android.content.Intent; import android.os.Bundle; import android.provider.Settings; import androidx.annotation.Nullable; -import androidx.preference.CheckBoxPreference; import androidx.preference.Preference; +import androidx.preference.PreferenceCategory; + import android.widget.Toast; -import com.b44t.messenger.DcContext; - import org.thoughtcrime.securesms.ApplicationPreferencesActivity; -import org.thoughtcrime.securesms.BlockedAndShareContactsActivity; import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.components.SwitchPreferenceCompat; -import org.thoughtcrime.securesms.connect.ApplicationDcContext; -import org.thoughtcrime.securesms.connect.DcHelper; import org.thoughtcrime.securesms.util.Prefs; import org.thoughtcrime.securesms.util.ScreenLockUtil; @@ -73,6 +69,16 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment if (!screenLockPreference.isChecked()) { manageScreenLockChildren(false); } + + // screen-lock is deprecated + try { + if (!Prefs.getBooleanPreference(getContext(), "pref_android_screen_lock_keep_for_now", false)) { + PreferenceCategory screenLockCategory = findPreference("pref_android_screen_lock_category"); + screenLockCategory.setVisible(false); + } + } catch (Exception e) { + e.printStackTrace(); + } } private void manageScreenLockChildren(boolean enable) { @@ -105,13 +111,6 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment } } - public static CharSequence getSummary(Context context) { - final String onRes = context.getString(R.string.on); - final String offRes = context.getString(R.string.off); - String screenLockState = Prefs.isScreenLockEnabled(context) ? onRes : offRes; - return context.getString(R.string.screenlock_title) + " " + screenLockState; - } - private class ChangePassphraseClickListener implements Preference.OnPreferenceClickListener { @Override public boolean onPreferenceClick(Preference preference) {