From 48c3e701803207ea0aa3670c855d26f907ef7492 Mon Sep 17 00:00:00 2001 From: Michele Balistreri Date: Tue, 2 Jun 2020 10:46:54 +0300 Subject: [PATCH] bump SDK version, better handling of card lost connection on pair/opensecurechannel --- app/build.gradle | 2 +- .../connect/card/OpenSecureChannelCommand.kt | 19 ++++++------------- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 829aeed..40d362e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -60,7 +60,7 @@ dependencies { implementation 'androidx.navigation:navigation-ui-ktx:2.1.0' implementation 'androidx.security:security-crypto:1.0.0-alpha02' implementation 'org.bouncycastle:bcprov-jdk15on:1.64' - implementation 'com.github.status-im.status-keycard-java:android:3.0.1' + implementation 'com.github.status-im.status-keycard-java:android:3.0.2' implementation 'com.github.walletconnect:kotlin-walletconnect-lib:0.9.4' implementation 'com.journeyapps:zxing-android-embedded:4.0.0' implementation 'com.google.zxing:core:3.4.0' 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 30bb297..74c9421 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 @@ -7,35 +7,28 @@ import im.status.keycard.connect.Registry import im.status.keycard.connect.data.PAIRING_ACTIVITY_PASSWORD import im.status.keycard.connect.data.REQ_INTERACTIVE_SCRIPT import im.status.keycard.connect.ui.PairingActivity +import im.status.keycard.io.APDUException import java.io.IOException class OpenSecureChannelCommand : CardCommand { private var pairingPassword: String? = null private fun openSecureChannel(cmdSet: KeycardCommandSet): CardCommand.Result { - try { + return runOnCard { cmdSet.autoOpenSecureChannel() - } catch (e: IOException) { - //TODO: must distinguish real IOException from card exception (to fix in SDK) - return CardCommand.Result.CANCEL } - - return CardCommand.Result.OK } private fun pair(activity: Activity, cmdSet: KeycardCommandSet): CardCommand.Result { if (pairingPassword != null) { - try { - //TODO: must distinguish real IOException from card exception (to fix in SDK) + val res = runOnCard { cmdSet.autoPair(pairingPassword) Registry.pairingManager.putPairing(cmdSet.applicationInfo.instanceUID, cmdSet.pairing) cmdSet.autoOpenSecureChannel() - return CardCommand.Result.OK - } catch(e: IOException) { - e.printStackTrace() - } finally { - pairingPassword = null } + + pairingPassword = null + return res } return promptPairingPassword(activity) diff --git a/build.gradle b/build.gradle index 1e19477..6dd6754 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.5.2' + classpath 'com.android.tools.build:gradle:4.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 50c4f57..782df84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Oct 23 15:57:59 MSK 2019 +#Tue Jun 02 10:32:00 MSK 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip