Skip to content

Commit

Permalink
Merge branch 'rc-1.9.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
jenspfahl committed Apr 25, 2024
2 parents 3c9078e + 5a56197 commit d4ff7b4
Show file tree
Hide file tree
Showing 32 changed files with 340 additions and 75 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ android {
// YY=minor (new features)
// ZZZ=micro (just bugfixes)
// versionCode XXYYZZZ
versionCode 109002
versionCode 109003
// remove _rc when release
// e.g. versionName "1.3.0_rc"
versionName "1.9.2"
versionName "1.9.3"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true'
Expand Down
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 109001,
"versionName": "1.9.1",
"versionCode": 109003,
"versionName": "1.9.3",
"outputFile": "app-release.apk"
}
],
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<data android:mimeType="appliation/de.jepfa.yapm" />
<data android:mimeType="application/de.jepfa.yapm" />
</intent-filter>
</activity>
<activity
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/de/jepfa/yapm/service/PreferenceService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ object PreferenceService {
const val PREF_LOCK_TIMEOUT = PREF_PREFIX + "lock_timeout"
const val PREF_LOGOUT_TIMEOUT = PREF_PREFIX + "logout_timeout"
const val PREF_WARN_BEFORE_COPY_TO_CB = PREF_PREFIX + "warn_copy_password"
const val PREF_SHOW_NUMBER_PAD_FOR_PIN = PREF_PREFIX + "show_number_pad_for_login"
const val PREF_HIDE_NUMBER_PAD_FOR_PIN = PREF_PREFIX + "hide_number_pad_for_login"

const val PREF_USE_PREUDO_PHRASE = PREF_PREFIX + "use_pseudo_prase_all_time"
const val PREF_PASSWD_STRENGTH = PREF_PREFIX + "default_passwd_strength"
Expand Down
6 changes: 1 addition & 5 deletions app/src/main/java/de/jepfa/yapm/service/nfc/NdefTag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class NdefTag @Throws(FormatException::class) constructor(val tag: Tag, val data

init {
val technologies = tag.techList
val tagTechs = Arrays.asList(*technologies)
val tagTechs = listOf(*technologies)
if (tagTechs.contains(NDEF)) {
Log.i(LOG_PREFIX + "WritableTag", "contains ndef")
ndef = Ndef.get(tag)
Expand All @@ -47,10 +47,6 @@ class NdefTag @Throws(FormatException::class) constructor(val tag: Tag, val data
}
}

fun getUID(): Key {
return Key(tag.id)
}

fun getMaxSize(): Int? {
return ndef?.maxSize
}
Expand Down
23 changes: 17 additions & 6 deletions app/src/main/java/de/jepfa/yapm/service/nfc/NfcService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ object NfcService {
return adapter != null && adapter.isEnabled
}

fun getNdefTag(intent: Intent): NdefTag? {
fun getNdefTag(intent: Intent, activity: BaseActivity): NdefTag? {
val tagFromIntent: Tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG) ?: return null

try {
val messages = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)
val data = messages?.run { getData(this) }
val data = messages?.run { getData(this, activity) }
return NdefTag(tagFromIntent, data)
} catch (e: FormatException) {
Log.e(LOG_PREFIX + "NFC", "Unsupported tag tapped", e)
Expand All @@ -47,7 +47,7 @@ object NfcService {
fun createNdefMessage(activity: BaseActivity, payload: ByteArray, withAppRecord: Boolean) : NdefMessage {
val typeBytes = (
if (withAppRecord)
"appliation/${activity.getApp().packageName}"
getMimeType(activity)
else
"text/plain")
.toByteArray()
Expand All @@ -57,21 +57,32 @@ object NfcService {

}

private fun getData(rawMessages: Array<Parcelable>): String {
private fun getData(rawMessages: Array<Parcelable>, activity: BaseActivity): String {
val sb = StringBuilder()
for (i in rawMessages.indices) {
val message = rawMessages[i] as NdefMessage
message.records.forEach { record ->
if (record.tnf == NdefRecord.TNF_MIME_MEDIA) {
val data = String(record.payload)
sb.append(data)
// only consider own mime types
if (record.toMimeType() == getMimeType(activity) || record.toMimeType() == getLegacyMimeType(activity)) {
val data = String(record.payload)
sb.append(data)
}
}
}
}

return sb.toString()
}


private fun getMimeType(activity: BaseActivity) =
"application/${activity.getApp().packageName}"

private fun getLegacyMimeType(activity: BaseActivity) =
"appliation/${activity.getApp().packageName}"


fun scanNfcTag(fragment: BaseFragment) {
fragment.getBaseActivity()?.let {
val intent = Intent(it, NfcActivity::class.java)
Expand Down
75 changes: 75 additions & 0 deletions app/src/main/java/de/jepfa/yapm/ui/ChangeKeyboardForPinManager.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package de.jepfa.yapm.ui

import android.content.Context
import android.graphics.Typeface
import android.text.InputType
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import android.widget.ImageView
import de.jepfa.yapm.R
import de.jepfa.yapm.service.PreferenceService

/**
* List of editText is all PIN views, at least one. First view is which hold the icon
*/
open class ChangeKeyboardForPinManager(
private val context: Context,
private val editTextViews: List<EditText>,
)
{

private var showNumberPad = false

fun create(changeImeiButton: ImageView) {
val hideNumberPad = PreferenceService.getAsBool(PreferenceService.PREF_HIDE_NUMBER_PAD_FOR_PIN, context)
if (hideNumberPad) {
changeImeiButton.visibility = View.GONE
}
else {
changeImeiButton.setOnClickListener {
showNumberPad = !showNumberPad
updateShowNumberPad(changeImeiButton, showImei = true, context)
PreferenceService.putBoolean(
PreferenceService.PREF_SHOW_NUMBER_PAD_FOR_PIN,
showNumberPad,
context
)
}

showNumberPad = PreferenceService.getAsBool(PreferenceService.PREF_SHOW_NUMBER_PAD_FOR_PIN, context)
updateShowNumberPad(changeImeiButton, showImei = false, context)
}
}


private fun updateShowNumberPad(
changeImeiButton: ImageView,
showImei: Boolean,
context: Context
) {

if (showNumberPad) {
editTextViews.forEach { editTextView ->
editTextView.inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD
editTextView.typeface = Typeface.DEFAULT
}
changeImeiButton.setImageDrawable(context.getDrawable(R.drawable.baseline_abc_24))
} else {
editTextViews.forEach { editTextView ->
editTextView.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD
editTextView.typeface = Typeface.DEFAULT

}
changeImeiButton.setImageDrawable(context.getDrawable(R.drawable.baseline_123_24))
}

if (showImei) {
val firstView = editTextViews.first()
firstView.requestFocus()
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.showSoftInput(firstView, 0)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import de.jepfa.yapm.model.session.Session
import de.jepfa.yapm.service.secret.MasterPasswordService
import de.jepfa.yapm.service.secret.PbkdfIterationService
import de.jepfa.yapm.service.secret.SecretService
import de.jepfa.yapm.ui.ChangeKeyboardForPinManager
import de.jepfa.yapm.ui.SecureActivity
import de.jepfa.yapm.ui.UseCaseBackgroundLauncher
import de.jepfa.yapm.usecase.secret.ChangeVaultEncryptionUseCase
Expand Down Expand Up @@ -50,6 +51,10 @@ class ChangeEncryptionActivity : SecureActivity(), AdapterView.OnItemSelectedLis
val currentEncryptionTextView: TextView = findViewById(R.id.current_encryption_text)
val newMasterKeySwitch: SwitchCompat = findViewById(R.id.switch_generate_new_masterkey)

val pinImeiManager = ChangeKeyboardForPinManager(this, listOf(currentPinTextView))
pinImeiManager.create(findViewById(R.id.imageview_change_imei))


originCipherAlgorithm = SecretService.getCipherAlgorithm(this)
currentEncryptionTextView.text = getString(R.string.update_vault_cipher_explanation,
getString(originCipherAlgorithm.uiLabel))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import de.jepfa.yapm.model.secret.Password
import de.jepfa.yapm.model.session.LoginData
import de.jepfa.yapm.model.session.Session
import de.jepfa.yapm.service.secret.MasterPasswordService
import de.jepfa.yapm.ui.ChangeKeyboardForPinManager
import de.jepfa.yapm.ui.SecureActivity
import de.jepfa.yapm.ui.UseCaseBackgroundLauncher
import de.jepfa.yapm.usecase.credential.ShowPasswordStrengthUseCase
Expand Down Expand Up @@ -50,6 +51,9 @@ class ChangeMasterPasswordActivity : SecureActivity() {
val switchStorePasswd: SwitchCompat = findViewById(R.id.switch_store_master_password)
val generatedPasswdView: TextView = findViewById(R.id.generated_passwd)

val pinImeiManager = ChangeKeyboardForPinManager(this, listOf(currentPinTextView))
pinImeiManager.create(findViewById(R.id.imageview_change_imei))

switchStorePasswd.isChecked = MasterPasswordService.isMasterPasswordStored(this)

val masterPasswd = MasterPasswordService.getMasterPasswordFromSession(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.widget.TextView
import de.jepfa.yapm.R
import de.jepfa.yapm.model.secret.Password
import de.jepfa.yapm.model.session.Session
import de.jepfa.yapm.ui.ChangeKeyboardForPinManager
import de.jepfa.yapm.ui.SecureActivity
import de.jepfa.yapm.ui.UseCaseBackgroundLauncher
import de.jepfa.yapm.usecase.secret.ChangePinUseCase
Expand All @@ -23,7 +24,9 @@ class ChangePinActivity : SecureActivity() {
init {
enableBack = true
}


private var showNumberPad = false

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand All @@ -38,6 +41,10 @@ class ChangePinActivity : SecureActivity() {
val newPin1TextView: EditText = findViewById(R.id.first_new_pin)
val newPin2TextView: EditText = findViewById(R.id.second_new_pin)

val pinImeiManager = ChangeKeyboardForPinManager(this,
listOf(currentPinTextView, newPin1TextView, newPin2TextView))
pinImeiManager.create(findViewById(R.id.imageview_change_imei))

val explanationView: TextView = findViewById(R.id.change_pin_explanation)
explanationView.setOnLongClickListener {
if (DebugInfo.isDebug) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import de.jepfa.yapm.service.secret.AndroidKey.ALIAS_KEY_TRANSPORT
import de.jepfa.yapm.service.secret.SecretService.encryptPassword
import de.jepfa.yapm.service.secret.SecretService.getAndroidSecretKey
import de.jepfa.yapm.ui.BaseFragment
import de.jepfa.yapm.ui.ChangeKeyboardForPinManager
import de.jepfa.yapm.ui.createvault.CreateVaultActivity.Companion.ARG_ENC_MASTER_PASSWD
import de.jepfa.yapm.ui.createvault.CreateVaultActivity.Companion.ARG_ENC_PIN
import de.jepfa.yapm.util.Constants
Expand All @@ -34,11 +35,18 @@ class CreateVaultEnterPinFragment : BaseFragment() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val createVaultActivity = getBaseActivity() as CreateVaultActivity


setTitle(R.string.create_vault_enter_pin_fragment_label)

val pin1TextView: EditText = view.findViewById(R.id.first_pin)
val pin2TextView: EditText = view.findViewById(R.id.second_pin)

val pinImeiManager = ChangeKeyboardForPinManager(createVaultActivity,
listOf(pin1TextView, pin2TextView))
pinImeiManager.create(view.findViewById(R.id.imageview_change_imei))

view.findViewById<Button>(R.id.button_next).setOnClickListener {

val pin1 = Password(pin1TextView.text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import de.jepfa.yapm.service.secret.MasterKeyService
import de.jepfa.yapm.service.secret.MasterPasswordService
import de.jepfa.yapm.service.secret.SaltService
import de.jepfa.yapm.service.secret.SecretService
import de.jepfa.yapm.ui.ChangeKeyboardForPinManager
import de.jepfa.yapm.ui.SecureActivity
import de.jepfa.yapm.ui.UseCaseBackgroundLauncher
import de.jepfa.yapm.ui.credential.ListCredentialsActivity
Expand Down Expand Up @@ -40,6 +41,10 @@ class ExportPlainCredentialsActivity : SecureActivity() {

val currentPinTextView: EditText = findViewById(R.id.current_pin)

val pinImeiManager = ChangeKeyboardForPinManager(this, listOf(currentPinTextView))
pinImeiManager.create(findViewById(R.id.imageview_change_imei))


findViewById<Button>(R.id.button_export_plain_credentials).setOnClickListener {

if (checkPin(currentPinTextView)) return@setOnClickListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import de.jepfa.yapm.service.secret.AndroidKey
import de.jepfa.yapm.service.secret.MasterPasswordService
import de.jepfa.yapm.service.secret.SecretService
import de.jepfa.yapm.ui.BaseFragment
import de.jepfa.yapm.ui.ChangeKeyboardForPinManager
import de.jepfa.yapm.ui.UseCaseBackgroundLauncher
import de.jepfa.yapm.ui.createvault.CreateVaultActivity
import de.jepfa.yapm.usecase.session.LoginUseCase
Expand All @@ -38,6 +39,7 @@ import de.jepfa.yapm.util.toastText

class LoginEnterPinFragment : BaseFragment() {


override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
Expand All @@ -54,6 +56,10 @@ class LoginEnterPinFragment : BaseFragment() {
val pinTextView: EditText = view.findViewById(R.id.edittext_enter_pin)
val nextButton = view.findViewById<Button>(R.id.button_login_next)

val pinImeiManager = ChangeKeyboardForPinManager(loginActivity, listOf(pinTextView))
pinImeiManager.create(view.findViewById(R.id.imageview_change_imei))
pinTextView.requestFocus()

updateInfoText()

// this is to perform next step out of the keyboard
Expand All @@ -63,16 +69,14 @@ class LoginEnterPinFragment : BaseFragment() {
true
}

pinTextView.requestFocus()

nextButton.setOnLongClickListener{
loginActivity.showRevokeQuickAccessDialog()
true
}

nextButton.setOnClickListener {

var keyForTemp = SecretService.getAndroidSecretKey(AndroidKey.ALIAS_KEY_TRANSPORT, view.context)
val keyForTemp = SecretService.getAndroidSecretKey(AndroidKey.ALIAS_KEY_TRANSPORT, view.context)

val userPin = Password(pinTextView.text)
if (userPin.isEmpty()) {
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/de/jepfa/yapm/ui/nfc/NfcActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ class NfcActivity : NfcBaseActivity() {

private fun checkAndWriteTag(encrypted: Encrypted, t: NdefTag, withAppRecord: Boolean, setWriteProtection: Boolean) {


val tempKey = SecretService.getAndroidSecretKey(AndroidKey.ALIAS_KEY_TRANSPORT, this)
val data = SecretService.decryptPassword(tempKey, encrypted)

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/de/jepfa/yapm/ui/nfc/NfcBaseActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class NfcBaseActivity : SecureActivity() {

fun readTagFromIntent(intent: Intent?) {
intent?.let {
ndefTag = NfcService.getNdefTag(intent)
ndefTag = NfcService.getNdefTag(intent, this)
handleTag()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ object ExportEncMasterKeyUseCase: BasicUseCase<SecureActivity>() {
intent.putEncryptedExtra(QrCodeActivity.EXTRA_SUBTEXT, encSub)
intent.putEncryptedExtra(QrCodeActivity.EXTRA_QRCODE_HEADER, encQrcHeader)
intent.putEncryptedExtra(QrCodeActivity.EXTRA_QRCODE, encQrc)

// will be bypassed to NfcActivity
intent.putExtra(NfcActivity.EXTRA_WITH_APP_RECORD, true)

activity.startActivity(intent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ object ExportEncMasterPasswordUseCase:
intent.putEncryptedExtra(QrCodeActivity.EXTRA_QRCODE, encQrc)
intent.putExtra(QrCodeActivity.EXTRA_COLOR, Color.RED)
intent.putExtra(QrCodeActivity.EXTRA_NO_SESSION_CHECK, input.noSessionCheck)

// will be bypassed to NfcActivity
intent.putExtra(NfcActivity.EXTRA_WITH_APP_RECORD, true)
activity.startActivity(intent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ object GenerateMasterPasswordTokenUseCase: BasicUseCase<SecureActivity>() {
intent.putEncryptedExtra(QrCodeActivity.EXTRA_QRCODE_HEADER, encQrcHeader)
intent.putEncryptedExtra(QrCodeActivity.EXTRA_QRCODE, encQrc)
intent.putExtra(QrCodeActivity.EXTRA_COLOR, Color.BLUE)

// will be bypassed to NfcActivity
intent.putExtra(NfcActivity.EXTRA_WITH_APP_RECORD, true)
intent.putExtra(NfcActivity.EXTRA_PROTECT_COPYING_MPT, true)

Expand Down
Loading

0 comments on commit d4ff7b4

Please sign in to comment.