...
 
Commits (8)
......@@ -2,13 +2,13 @@ buildscript {
ext {
buildConfig = [
'compileSdk' : 28,
'targetSdk' : 27,
'targetSdk' : 28,
'minSdk' : 19,
'versionCode' : 38,
'pEpEngineRevision' : 4203,
'pEpJNIAdapterRevision': 608,
'versionName' : '1.0.228',
'libpEpAdapterRevision': 137
'versionCode' : 39,
'pEpEngineRevision' : 4228,
'pEpJNIAdapterRevision': 618,
'versionName' : '1.0.229',
'libpEpAdapterRevision': 140
]
versions = [
......
......@@ -30,6 +30,8 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- Needed for Android 28+ compatibility -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<permission
android:name="${applicationId}.permission.READ_ATTACHMENT"
android:description="@string/read_attachment_desc"
......
......@@ -132,11 +132,6 @@ public class K9 extends MultiDexApplication {
public static final int VERSION_MIGRATE_OPENPGP_TO_ACCOUNTS = 63;
public static void setpEpSyncState(@NotNull SyncpEpStatus state) {
pEpSyncEnabled = state;
}
/**
* Components that are interested in knowing when the K9 instance is
* available and ready (Android invokes Application.onCreate() after other
......@@ -295,16 +290,6 @@ public class K9 extends MultiDexApplication {
WHEN_IN_LANDSCAPE
}
public enum SyncpEpStatus {
DISABLED,
ENABLED_SOLE,
ENABLED_GROUPED;
boolean isEnabled() {
return !this.equals(DISABLED);
}
}
private static boolean mMessageListCheckboxes = true;
private static boolean mMessageListStars = true;
private static int mMessageListPreviewLines = 2;
......@@ -353,9 +338,8 @@ public class K9 extends MultiDexApplication {
private static boolean pEpPassiveMode = false;
private static boolean pEpSubjectUnprotected = false;
private static boolean pEpForwardWarningEnabled = false;
//private static boolean pEpSyncEnabled = BuildConfig.WITH_KEY_SYNC;
private static SyncpEpStatus pEpSyncEnabled = BuildConfig.WITH_KEY_SYNC ? SyncpEpStatus.ENABLED_SOLE : SyncpEpStatus.DISABLED;
private static boolean grouped = false;
private static boolean pEpSyncEnabled = BuildConfig.WITH_KEY_SYNC;
private boolean grouped = false;
private static Set<String> pEpExtraKeys = Collections.emptySet();
......@@ -625,7 +609,7 @@ public class K9 extends MultiDexApplication {
editor.putBoolean("pEpPassiveMode", pEpPassiveMode);
editor.putBoolean("pEpSubjectUnprotected", pEpSubjectUnprotected);
editor.putBoolean("pEpForwardWarningEnabled", pEpForwardWarningEnabled);
editor.putString("pEpEnableSync", pEpSyncEnabled.toString());
editor.putBoolean("pEpEnableSync", pEpSyncEnabled);
fontSizes.save(editor);
}
......@@ -638,8 +622,6 @@ public class K9 extends MultiDexApplication {
StrictMode.enableDefaults();
}
PRNGFixes.apply();
super.onCreate();
initializeInjector();
......@@ -789,14 +771,14 @@ public class K9 extends MultiDexApplication {
KeySyncCleaner.queueAutoConsumeMessages();
if (Preferences.getPreferences(this.getApplicationContext()).getAccounts().size() > 0) {
if (pEpSyncEnabled.isEnabled()) {
if (pEpSyncEnabled) {
initSync();
}
}
}
public PEpProvider getpEpSyncProvider() {
if (pEpSyncEnabled.isEnabled()) return pEpSyncProvider;
if (pEpSyncEnabled) return pEpSyncProvider;
else return pEpProvider;
}
......@@ -981,13 +963,8 @@ public class K9 extends MultiDexApplication {
pEpPassiveMode = storage.getBoolean("pEpPassiveMode", false);
pEpSubjectUnprotected = storage.getBoolean("pEpSubjectUnprotected", false);
pEpForwardWarningEnabled = storage.getBoolean("pEpForwardWarningEnabled", false);
String spEpSyncEnabled = storage.getString("pEpEnableSync",null);
pEpSyncEnabled = storage.getBoolean("pEpEnableSync", BuildConfig.WITH_KEY_SYNC);
if (spEpSyncEnabled != null) {
pEpSyncEnabled = SyncpEpStatus.valueOf(spEpSyncEnabled);
} else {
pEpSyncEnabled = BuildConfig.WITH_KEY_SYNC ? SyncpEpStatus.ENABLED_SOLE : SyncpEpStatus.DISABLED;
}
mAttachmentDefaultPath = storage.getString("attachmentdefaultpath",
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString());
......@@ -1806,18 +1783,20 @@ public class K9 extends MultiDexApplication {
}
public static boolean ispEpSyncEnabled() {
return pEpSyncEnabled.isEnabled();
}
public static SyncpEpStatus getpEpSyncEnabled() {
return pEpSyncEnabled;
}
public void setpEpSyncEnabled(SyncpEpStatus ispEpSyncEnabled) {
pEpSyncEnabled = ispEpSyncEnabled;
StorageEditor editor = Preferences.getPreferences(this).getStorage().edit();
save(editor);
Executors.newSingleThreadExecutor(new NamedThreadFactory("SaveSettings")).execute(editor::commit);
public void setpEpSyncEnabled(boolean enabled) {
pEpSyncEnabled = enabled;
if (enabled) {
pEpInitSyncEnvironment();
} else if (grouped) {
leaveDeviceGroup();
} else {
shutdownSync();
}
}
public boolean needsFastPoll() {
......@@ -1870,7 +1849,7 @@ public class K9 extends MultiDexApplication {
case SyncNotifyInGroup:
needsFastPoll = false;
grouped = true;
pEpSyncEnabled = SyncpEpStatus.ENABLED_GROUPED;
pEpSyncEnabled = true;
break;
}
......@@ -1882,13 +1861,27 @@ public class K9 extends MultiDexApplication {
return this.notifyHandshakeCallback;
}
public static void setGrouped(boolean value) {
grouped = value;
public void setGrouped(boolean value) {
this.grouped = value;
}
public boolean getGrouped() {
return this.grouped;
}
public void leaveDeviceGroup() {
grouped = false;
pEpSyncProvider.leaveDeviceGroup();
pEpSyncEnabled = SyncpEpStatus.DISABLED;
if (pEpSyncProvider.isSyncRunning()) {
pEpSyncProvider.leaveDeviceGroup();
}
pEpSyncEnabled = false;
}
public void shutdownSync() {
if (pEpSyncProvider.isSyncRunning()) {
pEpSyncProvider.stopSync();
}
pEpSyncEnabled = false;
}
......
......@@ -32,7 +32,10 @@ import java.security.Security;
* The fixes need to be applied via {@link #apply()} before any use of Java
* Cryptography Architecture primitives. A good place to invoke them is in the
* application's {@code onCreate}.
*
* @Deprecated as minSdkVersion is > 18 and therefore this code is just dummy
*/
@Deprecated
public final class PRNGFixes {
private static final int VERSION_CODE_JELLY_BEAN = 16;
......@@ -48,6 +51,7 @@ public final class PRNGFixes {
*
* @throws SecurityException if a fix is needed but could not be applied.
*/
@Deprecated
public static void apply() {
applyOpenSSLFix();
installLinuxPRNGSecureRandom();
......@@ -265,7 +269,7 @@ public final class PRNGFixes {
* @return serial number or {@code null} if not available.
*/
private static String getDeviceSerialNumber() {
// We're using the Reflection API because Build.SERIAL is only available
// We're using the Reflection API becau2se Build.SERIAL is only available
// since API Level 9 (Gingerbread, Android 2.3).
try {
return (String) Build.class.getField("SERIAL").get(null);
......
......@@ -179,12 +179,6 @@ public interface PEpProvider extends AutoCloseable {
//com.fsck.k9.mail.Message getMimeMessage(Message message);
void setSyncSendMessageCallback(Sync.MessageToSendCallback callback);
void setSyncHandshakeCallback(Sync.NotifyHandshakeCallback callback);
void startSync();
void acceptHandshake(Identity identity);
void rejectHandshake(Identity identity);
......@@ -231,6 +225,14 @@ public interface PEpProvider extends AutoCloseable {
void leaveDeviceGroup();
void startSync();
void stopSync();
boolean isSyncRunning();
void setSyncSendMessageCallback(Sync.MessageToSendCallback callback);
void setSyncHandshakeCallback(Sync.NotifyHandshakeCallback callback);
class KeyDetail {
private final Address address;
private final String fpr;
......
......@@ -1166,6 +1166,18 @@ public class PEpProviderImpl implements PEpProvider {
engine.leave_device_group();
}
@Override
public void stopSync() {
createEngineInstanceIfNeeded();
engine.stopSync();
}
@Override
public boolean isSyncRunning() {
createEngineInstanceIfNeeded();
return engine.isSyncRunning();
}
private String getElementAtPosition(String chain) {
return chain.substring(1, chain.length() - 1);
......
......@@ -301,8 +301,7 @@ public class GlobalSettings {
new V(47, new BooleanSetting(false))
));
s.put("pEpEnableSync", Settings.versions(
new V(49, new EnumSetting<>(K9.SyncpEpStatus.class,
BuildConfig.WITH_KEY_SYNC? K9.SyncpEpStatus.ENABLED_SOLE: K9.SyncpEpStatus.DISABLED))
new V(49, new BooleanSetting(true))
));
SETTINGS = Collections.unmodifiableMap(s);
......
......@@ -7,6 +7,7 @@ import android.view.View
import android.widget.Toast
import androidx.preference.ListPreference
import com.fsck.k9.Account
import com.fsck.k9.BuildConfig
import com.fsck.k9.R
import com.fsck.k9.activity.ManageIdentities
import com.fsck.k9.activity.setup.AccountSetupBasics
......@@ -62,6 +63,10 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
initializeCryptoSettings(account)
initializeFolderSettings(account)
initializeAccountpEpKeyReset(account)
if (!BuildConfig.WITH_KEY_SYNC) {
hideKeySyncOptions()
}
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
......@@ -165,6 +170,10 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
}
}
private fun hideKeySyncOptions() {
findPreference(PREFERENCE_PEP_ENABLE_SYNC_ACCOUNT)?.remove()
}
private fun dopEpKeyReset(account: Account) {
disableKeyResetClickListener()
loading?.visibility = View.VISIBLE
......@@ -282,6 +291,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
private const val PREFERENCE_TRASH_FOLDER = "trash_folder"
private const val PREFERENCE_PEP_ACCOUNT_KEY_RESET = "pep_key_reset_account"
private const val PREFERENCE_PEP_ENABLE_SYNC_ACCOUNT = "pep_enable_sync_account"
private const val DELETE_POLICY_MARK_AS_READ = "MARK_AS_READ"
private val FOLDER_LIST_PREFERENCES = listOf(
......
package com.fsck.k9.ui.settings.general
import android.content.Context
import androidx.fragment.app.FragmentActivity
import androidx.preference.PreferenceDataStore
import com.fsck.k9.K9
import com.fsck.k9.K9.Theme
import com.fsck.k9.Preferences
import com.fsck.k9.pEp.ui.blacklist.PepBlacklist
import com.fsck.k9.service.MailServiceLegacy
import java.util.concurrent.ExecutorService
class GeneralSettingsDataStore(
......@@ -50,6 +47,7 @@ class GeneralSettingsDataStore(
"pep_passive_mode" -> K9.getPEpPassiveMode()
"pep_subject_unprotected" -> K9.ispEpSubjectUnprotected()
"pep_forward_warning" -> K9.ispEpForwardWarningEnabled()
"pep_enable_sync" -> K9.ispEpSyncEnabled()
else -> defValue
}
}
......@@ -88,6 +86,7 @@ class GeneralSettingsDataStore(
"pep_passive_mode" -> app.setPEpPassiveMode(value)
"pep_subject_unprotected" -> app.setpEpSubjectUnprotected(value)
"pep_forward_warning" -> app.setpEpForwardWarningEnabled(value)
"pep_enable_sync" -> app.setpEpSyncEnabled(value) //TODO: CHECK
else -> return
}
......@@ -126,7 +125,6 @@ class GeneralSettingsDataStore(
"attachment_default_path" -> K9.getAttachmentDefaultPath()
"quiet_time_starts" -> K9.getQuietTimeStarts()
"quiet_time_ends" -> K9.getQuietTimeEnds()
"pep_enable_sync" -> K9.getpEpSyncEnabled().name //TODO: CHECK
else -> defValue
}
}
......@@ -149,7 +147,6 @@ class GeneralSettingsDataStore(
"attachment_default_path" -> K9.setAttachmentDefaultPath(value)
"quiet_time_starts" -> K9.setQuietTimeStarts(value)
"quiet_time_ends" -> K9.setQuietTimeEnds(value)
"pep_enable_sync" -> K9.setpEpSyncState(K9.SyncpEpStatus.valueOf(value)) //TODO: CHECK
else -> return
}
......
......@@ -7,7 +7,7 @@ import android.os.Bundle
import android.view.View
import androidx.preference.MultiSelectListPreference
import androidx.preference.Preference
import com.fsck.k9.K9
import com.fsck.k9.BuildConfig
import com.fsck.k9.R
import com.fsck.k9.helper.FileBrowserHelper
import com.fsck.k9.notification.NotificationController
......@@ -43,7 +43,14 @@ class GeneralSettingsFragment : PreferenceFragmentCompat() {
initializeNotificationQuickDelete()
initializeExtraKeysManagement()
initializeGlobalpEpKeyReset()
initializeGlobalpEpSync()
if (!BuildConfig.WITH_KEY_SYNC) {
hideKeySyncOptions()
}
}
private fun hideKeySyncOptions() {
findPreference(PREFERENCE_PEP_ENABLE_SYNC)?.remove()
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
......@@ -152,44 +159,6 @@ class GeneralSettingsFragment : PreferenceFragmentCompat() {
}
}
private fun initializeGlobalpEpSync() {
findPreference(PREFERENCE_PEP_ENABLE_SYNC)?.apply {
when (K9.getpEpSyncEnabled()) {
K9.SyncpEpStatus.DISABLED -> this.setTitle(R.string.pep_sync_enable_global)
K9.SyncpEpStatus.ENABLED_GROUPED -> this.setTitle(R.string.pep_sync_leave_device_group)
K9.SyncpEpStatus.ENABLED_SOLE -> this.setTitle(R.string.pep_sync_disable_global)
else -> {}
}
setOnPreferenceClickListener {
val app = context.applicationContext as K9
K9.setGrouped(false)
when (K9.getpEpSyncEnabled()) {
K9.SyncpEpStatus.DISABLED -> {
app.setpEpSyncEnabled(K9.SyncpEpStatus.ENABLED_SOLE)
app.pEpInitSyncEnvironment()
}
K9.SyncpEpStatus.ENABLED_GROUPED -> {
app.leaveDeviceGroup()
}
K9.SyncpEpStatus.ENABLED_SOLE -> {
this.setTitle(R.string.pep_sync_disable_global)
app.setpEpSyncEnabled(K9.SyncpEpStatus.DISABLED)
}
else -> {}
}
initializeGlobalpEpSync()
true
}
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, result: Intent?) {
if (requestCode == REQUEST_PICK_DIRECTORY && resultCode == Activity.RESULT_OK && result != null) {
result.data?.path?.let {
......
......@@ -201,8 +201,8 @@
<string name="pep_sync">p≡p sync</string>
<string name="pep_sync_enable_account">Synchronize this account</string>
<string name="pep_sync_enable_global">Enable p≡p sync</string>
<string name="pep_sync_disable_global">Disable p≡p sync</string>
<string name="pep_sync_is_enabled_global">p≡p sync is enabled</string>
<string name="pep_sync_is_disabled_global"> p≡p sync is disabled</string>
<string name="pep_sync_leave_device_group">Leave Device group</string>
<string name="open_pgp">OpenPGP</string>
......
......@@ -348,13 +348,12 @@
android:summary="Encrypt messages with additional keys.">
</Preference>
<PreferenceCategory
android:key="pep_sync"
android:title="@string/pep_sync">
<Preference
android:key="pep_enable_sync"
android:title="@string/pep_sync_disable_global" />
</PreferenceCategory>
<SwitchPreferenceCompat
android:key="pep_enable_sync"
android:title="@string/pep_sync"
android:summaryOn="@string/pep_sync_is_enabled_global"
android:summaryOff="@string/pep_sync_is_disabled_global" />
<PreferenceCategory
android:key="pep_gpg_compatibility"
......