Remove PGPainless feature flag

This commit is contained in:
Harsh Shandilya
2022-07-15 13:48:08 +05:30
parent 29dbcaabba
commit a6bcdd1d9d
9 changed files with 12 additions and 72 deletions

View File

@@ -31,8 +31,6 @@ import app.passwordstore.util.autofill.AutofillMatcher
import app.passwordstore.util.autofill.AutofillPreferences import app.passwordstore.util.autofill.AutofillPreferences
import app.passwordstore.util.autofill.DirectoryStructure import app.passwordstore.util.autofill.DirectoryStructure
import app.passwordstore.util.extensions.viewBinding import app.passwordstore.util.extensions.viewBinding
import app.passwordstore.util.features.Feature
import app.passwordstore.util.features.Features
import app.passwordstore.util.viewmodel.FilterMode import app.passwordstore.util.viewmodel.FilterMode
import app.passwordstore.util.viewmodel.ListMode import app.passwordstore.util.viewmodel.ListMode
import app.passwordstore.util.viewmodel.SearchMode import app.passwordstore.util.viewmodel.SearchMode
@@ -40,7 +38,6 @@ import app.passwordstore.util.viewmodel.SearchableRepositoryAdapter
import app.passwordstore.util.viewmodel.SearchableRepositoryViewModel import app.passwordstore.util.viewmodel.SearchableRepositoryViewModel
import com.github.androidpasswordstore.autofillparser.FormOrigin import com.github.androidpasswordstore.autofillparser.FormOrigin
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import logcat.LogPriority.ERROR import logcat.LogPriority.ERROR
import logcat.logcat import logcat.logcat
@@ -84,7 +81,6 @@ class AutofillFilterView : AppCompatActivity() {
} }
} }
@Inject lateinit var features: Features
private lateinit var formOrigin: FormOrigin private lateinit var formOrigin: FormOrigin
private lateinit var directoryStructure: DirectoryStructure private lateinit var directoryStructure: DirectoryStructure
private val binding by viewBinding(ActivityOreoAutofillFilterBinding::inflate) private val binding by viewBinding(ActivityOreoAutofillFilterBinding::inflate)
@@ -231,11 +227,7 @@ class AutofillFilterView : AppCompatActivity() {
AutofillMatcher.addMatchFor(applicationContext, formOrigin, item.file) AutofillMatcher.addMatchFor(applicationContext, formOrigin, item.file)
// intent?.extras? is checked to be non-null in onCreate // intent?.extras? is checked to be non-null in onCreate
decryptAction.launch( decryptAction.launch(
if (features.isEnabled(Feature.EnablePGPainlessBackend)) { AutofillDecryptActivityV2.makeDecryptFileIntent(item.file, intent!!.extras!!, this)
AutofillDecryptActivityV2.makeDecryptFileIntent(item.file, intent!!.extras!!, this)
} else {
AutofillDecryptActivity.makeDecryptFileIntent(item.file, intent!!.extras!!, this)
}
) )
} }
} }

View File

@@ -21,14 +21,11 @@ import app.passwordstore.util.autofill.AutofillMatcher
import app.passwordstore.util.autofill.AutofillPreferences import app.passwordstore.util.autofill.AutofillPreferences
import app.passwordstore.util.autofill.AutofillResponseBuilder import app.passwordstore.util.autofill.AutofillResponseBuilder
import app.passwordstore.util.extensions.unsafeLazy import app.passwordstore.util.extensions.unsafeLazy
import app.passwordstore.util.features.Feature
import app.passwordstore.util.features.Features
import com.github.androidpasswordstore.autofillparser.AutofillAction import com.github.androidpasswordstore.autofillparser.AutofillAction
import com.github.androidpasswordstore.autofillparser.Credentials import com.github.androidpasswordstore.autofillparser.Credentials
import com.github.androidpasswordstore.autofillparser.FormOrigin import com.github.androidpasswordstore.autofillparser.FormOrigin
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import java.io.File import java.io.File
import javax.inject.Inject
import logcat.LogPriority.ERROR import logcat.LogPriority.ERROR
import logcat.logcat import logcat.logcat
@@ -108,17 +105,11 @@ class AutofillSaveActivity : AppCompatActivity() {
} }
} }
@Inject lateinit var features: Features
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val repo = PasswordRepository.getRepositoryDirectory() val repo = PasswordRepository.getRepositoryDirectory()
val creationActivity =
if (features.isEnabled(Feature.EnablePGPainlessBackend))
PasswordCreationActivityV2::class.java
else PasswordCreationActivity::class.java
val saveIntent = val saveIntent =
Intent(this, creationActivity).apply { Intent(this, PasswordCreationActivityV2::class.java).apply {
putExtras( putExtras(
bundleOf( bundleOf(
"REPO_PATH" to repo.absolutePath, "REPO_PATH" to repo.absolutePath,

View File

@@ -25,7 +25,6 @@ import app.passwordstore.util.extensions.clipboard
import app.passwordstore.util.extensions.getString import app.passwordstore.util.extensions.getString
import app.passwordstore.util.extensions.snackbar import app.passwordstore.util.extensions.snackbar
import app.passwordstore.util.extensions.unsafeLazy import app.passwordstore.util.extensions.unsafeLazy
import app.passwordstore.util.features.Feature
import app.passwordstore.util.features.Features import app.passwordstore.util.features.Features
import app.passwordstore.util.services.ClipboardService import app.passwordstore.util.services.ClipboardService
import app.passwordstore.util.settings.PreferenceKeys import app.passwordstore.util.settings.PreferenceKeys
@@ -130,7 +129,7 @@ open class BasePgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBou
/** Method for subclasses to initiate binding with [OpenPgpServiceConnection]. */ /** Method for subclasses to initiate binding with [OpenPgpServiceConnection]. */
fun bindToOpenKeychain(onBoundListener: OpenPgpServiceConnection.OnBound) { fun bindToOpenKeychain(onBoundListener: OpenPgpServiceConnection.OnBound) {
if (features.isEnabled(Feature.EnablePGPainlessBackend)) return if (true) return
val installed = val installed =
runCatching { runCatching {
packageManager.getPackageInfo(OPENPGP_PROVIDER, 0) packageManager.getPackageInfo(OPENPGP_PROVIDER, 0)

View File

@@ -54,11 +54,7 @@ class LaunchActivity : AppCompatActivity() {
} }
private fun getDecryptIntent(): Intent { private fun getDecryptIntent(): Intent {
return if (features.isEnabled(Feature.EnablePGPainlessBackend)) { return Intent(this, DecryptActivityV2::class.java)
Intent(this, DecryptActivityV2::class.java)
} else {
Intent(this, DecryptActivity::class.java)
}
} }
private fun startTargetActivity(noAuth: Boolean) { private fun startTargetActivity(noAuth: Boolean) {

View File

@@ -29,9 +29,7 @@ import app.passwordstore.data.password.PasswordItem
import app.passwordstore.data.repo.PasswordRepository import app.passwordstore.data.repo.PasswordRepository
import app.passwordstore.ui.crypto.BasePgpActivity import app.passwordstore.ui.crypto.BasePgpActivity
import app.passwordstore.ui.crypto.BasePgpActivity.Companion.getLongName import app.passwordstore.ui.crypto.BasePgpActivity.Companion.getLongName
import app.passwordstore.ui.crypto.DecryptActivity
import app.passwordstore.ui.crypto.DecryptActivityV2 import app.passwordstore.ui.crypto.DecryptActivityV2
import app.passwordstore.ui.crypto.PasswordCreationActivity
import app.passwordstore.ui.crypto.PasswordCreationActivityV2 import app.passwordstore.ui.crypto.PasswordCreationActivityV2
import app.passwordstore.ui.dialogs.FolderCreationDialogFragment import app.passwordstore.ui.dialogs.FolderCreationDialogFragment
import app.passwordstore.ui.folderselect.SelectFolderActivity import app.passwordstore.ui.folderselect.SelectFolderActivity
@@ -46,8 +44,6 @@ import app.passwordstore.util.extensions.getString
import app.passwordstore.util.extensions.isInsideRepository import app.passwordstore.util.extensions.isInsideRepository
import app.passwordstore.util.extensions.listFilesRecursively import app.passwordstore.util.extensions.listFilesRecursively
import app.passwordstore.util.extensions.sharedPrefs import app.passwordstore.util.extensions.sharedPrefs
import app.passwordstore.util.features.Feature
import app.passwordstore.util.features.Features
import app.passwordstore.util.settings.AuthMode import app.passwordstore.util.settings.AuthMode
import app.passwordstore.util.settings.PreferenceKeys import app.passwordstore.util.settings.PreferenceKeys
import app.passwordstore.util.shortcuts.ShortcutHandler import app.passwordstore.util.shortcuts.ShortcutHandler
@@ -73,7 +69,6 @@ const val PASSWORD_FRAGMENT_TAG = "PasswordsList"
@AndroidEntryPoint @AndroidEntryPoint
class PasswordStore : BaseGitActivity() { class PasswordStore : BaseGitActivity() {
@Inject lateinit var features: Features
@Inject lateinit var shortcutHandler: ShortcutHandler @Inject lateinit var shortcutHandler: ShortcutHandler
private lateinit var searchItem: MenuItem private lateinit var searchItem: MenuItem
private val settings by lazy { sharedPrefs } private val settings by lazy { sharedPrefs }
@@ -388,14 +383,7 @@ class PasswordStore : BaseGitActivity() {
val authDecryptIntent = item.createAuthEnabledIntent(this) val authDecryptIntent = item.createAuthEnabledIntent(this)
val decryptIntent = val decryptIntent =
(authDecryptIntent.clone() as Intent).setComponent( (authDecryptIntent.clone() as Intent).setComponent(
ComponentName( ComponentName(this, DecryptActivityV2::class.java)
this,
if (features.isEnabled(Feature.EnablePGPainlessBackend)) {
DecryptActivityV2::class.java
} else {
DecryptActivity::class.java
}
)
) )
startActivity(decryptIntent) startActivity(decryptIntent)
@@ -419,11 +407,7 @@ class PasswordStore : BaseGitActivity() {
if (!validateState()) return if (!validateState()) return
val currentDir = currentDir val currentDir = currentDir
logcat(INFO) { "Adding file to : ${currentDir.absolutePath}" } logcat(INFO) { "Adding file to : ${currentDir.absolutePath}" }
val creationActivity = val intent = Intent(this, PasswordCreationActivityV2::class.java)
if (features.isEnabled(Feature.EnablePGPainlessBackend))
PasswordCreationActivityV2::class.java
else PasswordCreationActivity::class.java
val intent = Intent(this, creationActivity)
intent.putExtra(BasePgpActivity.EXTRA_FILE_PATH, currentDir.absolutePath) intent.putExtra(BasePgpActivity.EXTRA_FILE_PATH, currentDir.absolutePath)
intent.putExtra( intent.putExtra(
BasePgpActivity.EXTRA_REPO_PATH, BasePgpActivity.EXTRA_REPO_PATH,

View File

@@ -8,9 +8,7 @@ package app.passwordstore.ui.settings
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import app.passwordstore.ui.pgp.PGPKeyImportActivity import app.passwordstore.ui.pgp.PGPKeyImportActivity
import app.passwordstore.util.extensions.launchActivity import app.passwordstore.util.extensions.launchActivity
import app.passwordstore.util.features.Feature
import de.Maxr1998.modernpreferences.PreferenceScreen import de.Maxr1998.modernpreferences.PreferenceScreen
import de.Maxr1998.modernpreferences.helpers.checkBox
import de.Maxr1998.modernpreferences.helpers.onClick import de.Maxr1998.modernpreferences.helpers.onClick
import de.Maxr1998.modernpreferences.helpers.pref import de.Maxr1998.modernpreferences.helpers.pref
@@ -18,15 +16,9 @@ class PGPSettings(private val activity: FragmentActivity) : SettingsProvider {
override fun provideSettings(builder: PreferenceScreen.Builder) { override fun provideSettings(builder: PreferenceScreen.Builder) {
builder.apply { builder.apply {
val enablePGPainless =
checkBox(Feature.EnablePGPainlessBackend.configKey) {
title = "Enable new PGP backend"
persistent = true
}
pref("_") { pref("_") {
title = "Import PGP key" title = "Import PGP key"
persistent = false persistent = false
dependency = enablePGPainless.key
onClick { onClick {
activity.launchActivity(PGPKeyImportActivity::class.java) activity.launchActivity(PGPKeyImportActivity::class.java)
false false

View File

@@ -15,13 +15,10 @@ import android.view.inputmethod.InlineSuggestionsRequest
import android.widget.inline.InlinePresentationSpec import android.widget.inline.InlinePresentationSpec
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import app.passwordstore.autofill.oreo.ui.AutofillSmsActivity import app.passwordstore.autofill.oreo.ui.AutofillSmsActivity
import app.passwordstore.ui.autofill.AutofillDecryptActivity
import app.passwordstore.ui.autofill.AutofillDecryptActivityV2 import app.passwordstore.ui.autofill.AutofillDecryptActivityV2
import app.passwordstore.ui.autofill.AutofillFilterView import app.passwordstore.ui.autofill.AutofillFilterView
import app.passwordstore.ui.autofill.AutofillPublisherChangedActivity import app.passwordstore.ui.autofill.AutofillPublisherChangedActivity
import app.passwordstore.ui.autofill.AutofillSaveActivity import app.passwordstore.ui.autofill.AutofillSaveActivity
import app.passwordstore.util.features.Feature
import app.passwordstore.util.features.Features
import com.github.androidpasswordstore.autofillparser.AutofillAction import com.github.androidpasswordstore.autofillparser.AutofillAction
import com.github.androidpasswordstore.autofillparser.FillableForm import com.github.androidpasswordstore.autofillparser.FillableForm
import com.github.androidpasswordstore.autofillparser.fillWith import com.github.androidpasswordstore.autofillparser.fillWith
@@ -40,7 +37,6 @@ class Api30AutofillResponseBuilder
@AssistedInject @AssistedInject
constructor( constructor(
@Assisted form: FillableForm, @Assisted form: FillableForm,
private val features: Features,
) { ) {
@AssistedFactory @AssistedFactory
@@ -85,12 +81,7 @@ constructor(
): Dataset? { ): Dataset? {
if (!scenario.hasFieldsToFillOn(AutofillAction.Match)) return null if (!scenario.hasFieldsToFillOn(AutofillAction.Match)) return null
val metadata = makeFillMatchMetadata(context, file) val metadata = makeFillMatchMetadata(context, file)
val intentSender = val intentSender = AutofillDecryptActivityV2.makeDecryptFileIntentSender(file, context)
if (features.isEnabled(Feature.EnablePGPainlessBackend)) {
AutofillDecryptActivityV2.makeDecryptFileIntentSender(file, context)
} else {
AutofillDecryptActivity.makeDecryptFileIntentSender(file, context)
}
return makeIntentDataset(context, AutofillAction.Match, intentSender, metadata, imeSpec) return makeIntentDataset(context, AutofillAction.Match, intentSender, metadata, imeSpec)
} }

View File

@@ -14,13 +14,10 @@ import android.service.autofill.FillResponse
import android.service.autofill.SaveInfo import android.service.autofill.SaveInfo
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import app.passwordstore.autofill.oreo.ui.AutofillSmsActivity import app.passwordstore.autofill.oreo.ui.AutofillSmsActivity
import app.passwordstore.ui.autofill.AutofillDecryptActivity
import app.passwordstore.ui.autofill.AutofillDecryptActivityV2 import app.passwordstore.ui.autofill.AutofillDecryptActivityV2
import app.passwordstore.ui.autofill.AutofillFilterView import app.passwordstore.ui.autofill.AutofillFilterView
import app.passwordstore.ui.autofill.AutofillPublisherChangedActivity import app.passwordstore.ui.autofill.AutofillPublisherChangedActivity
import app.passwordstore.ui.autofill.AutofillSaveActivity import app.passwordstore.ui.autofill.AutofillSaveActivity
import app.passwordstore.util.features.Feature
import app.passwordstore.util.features.Features
import com.github.androidpasswordstore.autofillparser.AutofillAction import com.github.androidpasswordstore.autofillparser.AutofillAction
import com.github.androidpasswordstore.autofillparser.AutofillScenario import com.github.androidpasswordstore.autofillparser.AutofillScenario
import com.github.androidpasswordstore.autofillparser.Credentials import com.github.androidpasswordstore.autofillparser.Credentials
@@ -40,7 +37,6 @@ class AutofillResponseBuilder
@AssistedInject @AssistedInject
constructor( constructor(
@Assisted form: FillableForm, @Assisted form: FillableForm,
private val features: Features,
) { ) {
@AssistedFactory @AssistedFactory
@@ -74,12 +70,7 @@ constructor(
private fun makeMatchDataset(context: Context, file: File): Dataset? { private fun makeMatchDataset(context: Context, file: File): Dataset? {
if (!scenario.hasFieldsToFillOn(AutofillAction.Match)) return null if (!scenario.hasFieldsToFillOn(AutofillAction.Match)) return null
val metadata = makeFillMatchMetadata(context, file) val metadata = makeFillMatchMetadata(context, file)
val intentSender = val intentSender = AutofillDecryptActivityV2.makeDecryptFileIntentSender(file, context)
if (features.isEnabled(Feature.EnablePGPainlessBackend)) {
AutofillDecryptActivityV2.makeDecryptFileIntentSender(file, context)
} else {
AutofillDecryptActivity.makeDecryptFileIntentSender(file, context)
}
return makeIntentDataset(context, AutofillAction.Match, intentSender, metadata) return makeIntentDataset(context, AutofillAction.Match, intentSender, metadata)
} }

View File

@@ -14,6 +14,10 @@ enum class Feature(
) { ) {
/** Opt into the new PGP backend powered by the PGPainless library. */ /** Opt into the new PGP backend powered by the PGPainless library. */
@Deprecated(
"The PGPainless backend is now the only available one",
level = DeprecationLevel.ERROR
)
EnablePGPainlessBackend(false, "enable_pgp_v2_backend"), EnablePGPainlessBackend(false, "enable_pgp_v2_backend"),
; ;