[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-android] 02/04: [wallet] don't crash on serialization error
From: |
gnunet |
Subject: |
[taler-taler-android] 02/04: [wallet] don't crash on serialization errors from wallet-core |
Date: |
Tue, 01 Sep 2020 16:29:05 +0200 |
This is an automated email from the git hooks/post-receive script.
torsten-grote pushed a commit to branch master
in repository taler-android.
commit c59243c9bdabf07137ad0f070b6ecbde57e66466
Author: Torsten Grote <t@grobox.de>
AuthorDate: Tue Sep 1 09:54:21 2020 -0300
[wallet] don't crash on serialization errors from wallet-core
This should not be necessary if we had a stable API with documentated
and versioned changes, but well...
---
.idea/runConfigurations/taler_android__check_.xml | 21 +++++++++++++++++++++
anastasis-ui/src/main/res/layout/fragment_intro.xml | 4 ++--
build.gradle | 2 ++
cashier/build.gradle | 8 ++++----
merchant-terminal/build.gradle | 6 +++---
wallet/build.gradle | 8 ++++----
.../net/taler/wallet/backend/WalletBackendApi.kt | 15 +++++++++++----
.../taler/wallet/payment/PaymentResponsesTest.kt | 1 -
8 files changed, 47 insertions(+), 18 deletions(-)
diff --git a/.idea/runConfigurations/taler_android__check_.xml
b/.idea/runConfigurations/taler_android__check_.xml
new file mode 100644
index 0000000..5d12227
--- /dev/null
+++ b/.idea/runConfigurations/taler_android__check_.xml
@@ -0,0 +1,21 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="taler-android [check]"
type="GradleRunConfiguration" factoryName="Gradle">
+ <ExternalSystemSettings>
+ <option name="executionName" />
+ <option name="externalProjectPath" value="$PROJECT_DIR$" />
+ <option name="externalSystemIdString" value="GRADLE" />
+ <option name="scriptParameters" value="" />
+ <option name="taskDescriptions">
+ <list />
+ </option>
+ <option name="taskNames">
+ <list>
+ <option value="check" />
+ </list>
+ </option>
+ <option name="vmOptions" value="" />
+ </ExternalSystemSettings>
+ <GradleScriptDebugEnabled>true</GradleScriptDebugEnabled>
+ <method v="2" />
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/anastasis-ui/src/main/res/layout/fragment_intro.xml
b/anastasis-ui/src/main/res/layout/fragment_intro.xml
index 262287b..32b5b33 100644
--- a/anastasis-ui/src/main/res/layout/fragment_intro.xml
+++ b/anastasis-ui/src/main/res/layout/fragment_intro.xml
@@ -24,7 +24,6 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="16dp"
- android:tint="@color/green"
app:layout_constraintBottom_toTopOf="@+id/textView"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
@@ -33,7 +32,8 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
app:layout_constraintVertical_chainStyle="spread"
- app:srcCompat="@drawable/ic_baseline_cloud_circle" />
+ app:srcCompat="@drawable/ic_baseline_cloud_circle"
+ app:tint="@color/green" />
<TextView
android:id="@+id/textView"
diff --git a/build.gradle b/build.gradle
index 7c9e378..2bd92ab 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,7 +2,9 @@ buildscript {
ext.kotlin_version = '1.4.0'
ext.ktor_version = "1.4.0"
ext.nav_version = "2.3.0"
+ ext.material_version = "1.2.0"
ext.lifecycle_version = "2.2.0"
+ ext.constraintlayout_version = "2.0.1"
// check https://android-rebuilds.beuc.net/ for availability of free build
tools
ext.build_tools_version = "29.0.2"
repositories {
diff --git a/cashier/build.gradle b/cashier/build.gradle
index 4defd7a..604a508 100644
--- a/cashier/build.gradle
+++ b/cashier/build.gradle
@@ -62,9 +62,9 @@ android {
dependencies {
implementation project(":taler-kotlin-android")
- implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
+ implementation
"androidx.constraintlayout:constraintlayout:$constraintlayout_version"
implementation 'androidx.security:security-crypto:1.0.0-rc03'
- implementation 'com.google.android.material:material:1.2.0'
+ implementation "com.google.android.material:material:$material_version"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
@@ -75,6 +75,6 @@ dependencies {
testImplementation 'junit:junit:4.13'
- androidTestImplementation 'androidx.test.ext:junit:1.1.1'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.2'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
diff --git a/merchant-terminal/build.gradle b/merchant-terminal/build.gradle
index 1bdc138..8c94fa1 100644
--- a/merchant-terminal/build.gradle
+++ b/merchant-terminal/build.gradle
@@ -59,8 +59,8 @@ android {
dependencies {
implementation project(":merchant-lib")
- implementation 'com.google.android.material:material:1.1.0'
- implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ implementation "com.google.android.material:material:$material_version"
+ implementation
"androidx.constraintlayout:constraintlayout:$constraintlayout_version"
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.recyclerview:recyclerview-selection:1.1.0-rc01"
@@ -70,6 +70,6 @@ dependencies {
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
- testImplementation 'androidx.test.ext:junit:1.1.1'
+ testImplementation 'androidx.test.ext:junit:1.1.2'
testImplementation 'org.robolectric:robolectric:4.3.1'
}
diff --git a/wallet/build.gradle b/wallet/build.gradle
index 70b9648..5d02bca 100644
--- a/wallet/build.gradle
+++ b/wallet/build.gradle
@@ -105,8 +105,8 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation 'androidx.preference:preference:1.1.1'
- implementation 'com.google.android.material:material:1.2.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.0.0'
+ implementation "com.google.android.material:material:$material_version"
+ implementation
"androidx.constraintlayout:constraintlayout:$constraintlayout_version"
// Lists and Selection
implementation "androidx.recyclerview:recyclerview:1.1.0"
@@ -133,8 +133,8 @@ dependencies {
testImplementation 'junit:junit:4.13'
testImplementation 'org.json:json:20200518'
- androidTestImplementation 'androidx.test:runner:1.2.0'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+ androidTestImplementation 'androidx.test:runner:1.3.0'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
def walletLibraryDir = "src/main/assets"
diff --git a/wallet/src/main/java/net/taler/wallet/backend/WalletBackendApi.kt
b/wallet/src/main/java/net/taler/wallet/backend/WalletBackendApi.kt
index c6261bf..a72df9c 100644
--- a/wallet/src/main/java/net/taler/wallet/backend/WalletBackendApi.kt
+++ b/wallet/src/main/java/net/taler/wallet/backend/WalletBackendApi.kt
@@ -158,12 +158,19 @@ class WalletBackendApi(
}
sendRequest(operation, args?.invoke(JSONObject())) { isError,
message ->
val response = if (isError) {
- val error =
json.decodeFromString(WalletErrorInfo.serializer(), message.toString())
+ val error =
+ json.decodeFromString(WalletErrorInfo.serializer(),
message.toString())
WalletResponse.Error(error)
} else {
- @Suppress("UNCHECKED_CAST") // if serializer is null, T
must be Unit
- val t: T = serializer?.let {
json.decodeFromString(serializer, message.toString()) } ?: Unit as T
- WalletResponse.Success(t)
+ try {
+ val t: T = serializer?.let {
+ json.decodeFromString(serializer,
message.toString())
+ } ?: Unit as T
+ WalletResponse.Success(t)
+ } catch (e: Exception) {
+ val info = WalletErrorInfo(0, "", e.toString(), null)
+ WalletResponse.Error(info)
+ }
}
cont.resume(response)
}
diff --git
a/wallet/src/test/java/net/taler/wallet/payment/PaymentResponsesTest.kt
b/wallet/src/test/java/net/taler/wallet/payment/PaymentResponsesTest.kt
index 15702c6..fbdc07d 100644
--- a/wallet/src/test/java/net/taler/wallet/payment/PaymentResponsesTest.kt
+++ b/wallet/src/test/java/net/taler/wallet/payment/PaymentResponsesTest.kt
@@ -57,7 +57,6 @@ class PaymentResponsesTest {
"max_wire_fee": "CHF:0.1",
"max_fee": "CHF:0.1",
"wire_fee_amortization": 10,
- "merchant_base_url":
"https:\/\/backend.chf.taler.net\/instances\/department\/",
"merchant": {
"name": "BFH Department Technik und Informatik",
"instance": "department"
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.