From ae7c937d9e5a93c27055701e88a4bb95018629c1 Mon Sep 17 00:00:00 2001 From: Michele Balistreri Date: Fri, 1 Nov 2019 11:56:47 +0300 Subject: [PATCH] fix compilation --- .../java/im/status/keycard/connect/card/InitCommand.kt | 5 +---- .../keycard/connect/card/OpenSecureChannelCommand.kt | 3 ++- .../im/status/keycard/connect/card/VerifyPINCommand.kt | 9 +++++---- .../java/im/status/keycard/connect/ui/InitActivity.kt | 6 +++--- .../java/im/status/keycard/connect/ui/MainActivity.kt | 9 ++------- .../java/im/status/keycard/connect/ui/PINActivity.kt | 4 ++-- .../java/im/status/keycard/connect/ui/PairingActivity.kt | 4 ++-- 7 files changed, 17 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/im/status/keycard/connect/card/InitCommand.kt b/app/src/main/java/im/status/keycard/connect/card/InitCommand.kt index 008e1a3..a2b5b15 100644 --- a/app/src/main/java/im/status/keycard/connect/card/InitCommand.kt +++ b/app/src/main/java/im/status/keycard/connect/card/InitCommand.kt @@ -2,11 +2,8 @@ package im.status.keycard.connect.card import android.app.Activity import android.content.Intent -import im.status.keycard.connect.ui.INIT_ACTIVITY_PAIRING -import im.status.keycard.connect.ui.INIT_ACTIVITY_PIN -import im.status.keycard.connect.ui.INIT_ACTIVITY_PUK +import im.status.keycard.connect.data.* import im.status.keycard.connect.ui.InitActivity -import im.status.keycard.connect.data.PairingManager import im.status.keycard.io.APDUException import java.io.IOException diff --git a/app/src/main/java/im/status/keycard/connect/card/OpenSecureChannelCommand.kt b/app/src/main/java/im/status/keycard/connect/card/OpenSecureChannelCommand.kt index 8cf3af3..48354c7 100644 --- a/app/src/main/java/im/status/keycard/connect/card/OpenSecureChannelCommand.kt +++ b/app/src/main/java/im/status/keycard/connect/card/OpenSecureChannelCommand.kt @@ -3,8 +3,9 @@ package im.status.keycard.connect.card import android.app.Activity import android.content.Intent import im.status.keycard.applet.KeycardCommandSet +import im.status.keycard.connect.data.PAIRING_ACTIVITY_PASSWORD import im.status.keycard.connect.data.PairingManager -import im.status.keycard.connect.ui.PAIRING_ACTIVITY_PASSWORD +import im.status.keycard.connect.data.REQ_INTERACTIVE_SCRIPT import im.status.keycard.connect.ui.PairingActivity import java.io.IOException diff --git a/app/src/main/java/im/status/keycard/connect/card/VerifyPINCommand.kt b/app/src/main/java/im/status/keycard/connect/card/VerifyPINCommand.kt index 66789ca..8febf29 100644 --- a/app/src/main/java/im/status/keycard/connect/card/VerifyPINCommand.kt +++ b/app/src/main/java/im/status/keycard/connect/card/VerifyPINCommand.kt @@ -3,9 +3,10 @@ package im.status.keycard.connect.card import android.app.Activity import android.content.Intent import im.status.keycard.connect.ui.PINActivity -import im.status.keycard.connect.ui.PIN_ACTIVITY_ATTEMPTS -import im.status.keycard.connect.ui.PIN_ACTIVITY_CARD_UID import im.status.keycard.connect.data.PINCache +import im.status.keycard.connect.data.PIN_ACTIVITY_ATTEMPTS +import im.status.keycard.connect.data.PIN_ACTIVITY_CARD_UID +import im.status.keycard.connect.data.REQ_INTERACTIVE_SCRIPT import im.status.keycard.io.APDUException import im.status.keycard.io.WrongPINException import java.io.IOException @@ -19,8 +20,8 @@ class VerifyPINCommand : CardCommand { putExtra(PIN_ACTIVITY_CARD_UID, instanceUID) } - mainActivity.startActivityForResult(intent, REQ_INTERACTIVE_SCRIPT) + return CommandResult.UX_ONGOING } @@ -34,7 +35,7 @@ class VerifyPINCommand : CardCommand { if (pin != null) { try { cmdSet.verifyPIN(pin).checkAuthOK() - retries = -1; + retries = -1 return CommandResult.OK } catch (e: WrongPINException) { PINCache.removePIN(cmdSet.applicationInfo.instanceUID) diff --git a/app/src/main/java/im/status/keycard/connect/ui/InitActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/InitActivity.kt index c6259cc..96c63c2 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/InitActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/InitActivity.kt @@ -25,7 +25,7 @@ class InitActivity : AppCompatActivity() { setContentView(R.layout.activity_init) pin = String.format("%06d", Crypto.randomLong(Crypto.PIN_BOUND)) - puk = String.format("%012d", Crypto.randomLong(Crypto.PUK_BOUND)); + puk = String.format("%012d", Crypto.randomLong(Crypto.PUK_BOUND)) pairing = randomToken(6) findViewById(R.id.pinView).text = pin @@ -33,7 +33,7 @@ class InitActivity : AppCompatActivity() { findViewById(R.id.pairingView).text = pairing } - fun ok(view: View) { + fun ok(@Suppress("UNUSED_PARAMETER") view: View) { val intent = Intent() intent.putExtra(INIT_ACTIVITY_PIN, pin) intent.putExtra(INIT_ACTIVITY_PUK, puk) @@ -43,7 +43,7 @@ class InitActivity : AppCompatActivity() { finish() } - fun cancel(view: View) { + fun cancel(@Suppress("UNUSED_PARAMETER") view: View) { setResult(Activity.RESULT_CANCELED) finish() } diff --git a/app/src/main/java/im/status/keycard/connect/ui/MainActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/MainActivity.kt index 8c19ef1..d263b95 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/MainActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/MainActivity.kt @@ -19,7 +19,6 @@ class MainActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) - PairingManager.init(this) nfcAdapter = NfcAdapter.getDefaultAdapter(this) @@ -33,16 +32,12 @@ class MainActivity : AppCompatActivity() { override fun onResume() { super.onResume() - if (this::nfcAdapter.isInitialized) { - nfcAdapter.enableReaderMode(this, this.cardManager,NfcAdapter.FLAG_READER_NFC_A or NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK, null) - } + nfcAdapter.enableReaderMode(this, this.cardManager,NfcAdapter.FLAG_READER_NFC_A or NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK, null) } override fun onPause() { super.onPause() - if (this::nfcAdapter.isInitialized) { - nfcAdapter.disableReaderMode(this) - } + nfcAdapter.disableReaderMode(this) } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { diff --git a/app/src/main/java/im/status/keycard/connect/ui/PINActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/PINActivity.kt index 8908d2a..6db8877 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/PINActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/PINActivity.kt @@ -31,7 +31,7 @@ class PINActivity : AppCompatActivity() { } } - fun ok(view: View) { + fun ok(@Suppress("UNUSED_PARAMETER") view: View) { val pinText = findViewById(R.id.pinText) PINCache.putPIN(cardUID, pinText.text.toString()) @@ -39,7 +39,7 @@ class PINActivity : AppCompatActivity() { finish() } - fun cancel(view: View) { + fun cancel(@Suppress("UNUSED_PARAMETER") view: View) { setResult(Activity.RESULT_CANCELED) finish() } diff --git a/app/src/main/java/im/status/keycard/connect/ui/PairingActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/PairingActivity.kt index 399ead0..4039ecc 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/PairingActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/PairingActivity.kt @@ -16,14 +16,14 @@ class PairingActivity : AppCompatActivity() { setContentView(R.layout.activity_pairing) } - fun ok(view: View) { + fun ok(@Suppress("UNUSED_PARAMETER") view: View) { val intent = Intent() intent.putExtra(PAIRING_ACTIVITY_PASSWORD, findViewById(R.id.passwordText).text.toString()) setResult(Activity.RESULT_OK, intent) finish() } - fun cancel(view: View) { + fun cancel(@Suppress("UNUSED_PARAMETER") view: View) { setResult(Activity.RESULT_CANCELED) finish() }