diff options
-rw-r--r-- | wallet/build.gradle | 10 | ||||
-rw-r--r-- | wallet/proguard-rules.pro | 9 | ||||
-rw-r--r-- | wallet/src/main/AndroidManifest.xml | 2 | ||||
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/backend/TalerWalletCore.kt | 61 | ||||
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/backend/WalletBackendService.kt | 31 | ||||
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt | 2 |
6 files changed, 16 insertions, 99 deletions
diff --git a/wallet/build.gradle b/wallet/build.gradle index 22fc0c8..075cdc7 100644 --- a/wallet/build.gradle +++ b/wallet/build.gradle @@ -23,8 +23,7 @@ plugins { id "de.undercouch.download" version "5.3.0" } -def walletCoreVersion = "v0.9.1" -def walletCoreSha256 = "99fd96fb897c6954710728820369949090bff84d06728f04b29c6cb067c8f9d4" +def qtart_version = "0.9.2-dev.1" static def versionCodeEpoch() { return (new Date().getTime() / 1000).toInteger() @@ -48,9 +47,8 @@ android { minSdkVersion 24 targetSdkVersion 33 versionCode 21 - versionName walletCoreVersion + versionName qtart_version testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - buildConfigField "String", "WALLET_CORE_VERSION", "\"$walletCoreVersion\"" } buildTypes { release { @@ -116,6 +114,7 @@ android { dependencies { implementation project(":taler-kotlin-android") + implementation "net.taler:qtart:$qtart_version@aar" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" @@ -166,9 +165,6 @@ dependencies { testImplementation 'org.json:json:20220320' } -// FIXME: add download and verify tasks for .so files -// (They should go on src/main/jniLibs/${ANDROID_ABI}/libtalerwalletcore.so) - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { kotlinOptions { freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" diff --git a/wallet/proguard-rules.pro b/wallet/proguard-rules.pro index 733d3ea..9eda10b 100644 --- a/wallet/proguard-rules.pro +++ b/wallet/proguard-rules.pro @@ -21,12 +21,3 @@ #-renamesourcefileattribute SourceFile #noinspection ShrinkerUnresolvedReference --keep class net.taler.wallet.** {*;} --keep interface net.taler.wallet.** {*;} - --dontwarn java.awt.* --keep class com.sun.jna.* {*;} --keepclassmembers class * extends com.sun.jna.* {public*;} --keep,includedescriptorclasses class * { - native <methods>; -}
\ No newline at end of file diff --git a/wallet/src/main/AndroidManifest.xml b/wallet/src/main/AndroidManifest.xml index 6498714..0b0a5b6 100644 --- a/wallet/src/main/AndroidManifest.xml +++ b/wallet/src/main/AndroidManifest.xml @@ -24,9 +24,7 @@ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" /> - <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.NFC" /> - <uses-permission android:name="android.permission.INTERNET" /> <uses-feature android:name="android.hardware.telephony" diff --git a/wallet/src/main/java/net/taler/wallet/backend/TalerWalletCore.kt b/wallet/src/main/java/net/taler/wallet/backend/TalerWalletCore.kt deleted file mode 100644 index 65ad58b..0000000 --- a/wallet/src/main/java/net/taler/wallet/backend/TalerWalletCore.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of GNU Taler - * (C) 2023 Taler Systems S.A. - * - * GNU Taler is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 3, or (at your option) any later version. - * - * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -/* - * This file is part of GNU Taler - * (C) 2023 Taler Systems S.A. - * - * GNU Taler is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 3, or (at your option) any later version. - * - * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -package net.taler.wallet.backend - -import com.sun.jna.Callback -import com.sun.jna.Library -import com.sun.jna.Native -import com.sun.jna.Pointer - -interface TalerWalletCore: Library { - companion object { - val INSTANCE: TalerWalletCore by lazy { - Native.load("talerwalletcore", TalerWalletCore::class.java) - } - } - - interface TALER_WALLET_MessageHandlerFn: Callback { - fun invoke(handler_p: Pointer, message: String) - } - - interface TALER_LogFn: Callback { - fun invoke(cls: Pointer, stream: Int, msg: String) - } - - fun TALER_WALLET_create(): Pointer - fun TALER_WALLET_set_message_handler(twi: Pointer, handler_f: TALER_WALLET_MessageHandlerFn, handler_p: Pointer) - fun TALER_WALLET_send_request(twi: Pointer, request: String): Int - fun TALER_WALLET_run(twi: Pointer): Int - fun TALER_WALLET_join(twi: Pointer) - fun TALER_start_redirect_std(logfn: TALER_LogFn, cls: Pointer) -}
\ No newline at end of file diff --git a/wallet/src/main/java/net/taler/wallet/backend/WalletBackendService.kt b/wallet/src/main/java/net/taler/wallet/backend/WalletBackendService.kt index 7b93a21..a14fbf9 100644 --- a/wallet/src/main/java/net/taler/wallet/backend/WalletBackendService.kt +++ b/wallet/src/main/java/net/taler/wallet/backend/WalletBackendService.kt @@ -25,7 +25,7 @@ import android.os.Message import android.os.Messenger import android.os.RemoteException import android.util.Log -import com.sun.jna.Pointer +import net.taler.qtart.TalerWalletCore import net.taler.wallet.HostCardEmulatorService import org.json.JSONObject import java.lang.ref.WeakReference @@ -45,8 +45,7 @@ class WalletBackendService : Service() { */ private val messenger: Messenger = Messenger(IncomingHandler(this)) - private lateinit var walletCore: TalerWalletCore - private lateinit var instance: Pointer + private val walletCore = TalerWalletCore() private var initialized = false @@ -59,19 +58,13 @@ class WalletBackendService : Service() { override fun onCreate() { Log.i(TAG, "onCreate in wallet backend service") - walletCore = TalerWalletCore.INSTANCE - instance = walletCore.TALER_WALLET_create() - walletCore.TALER_WALLET_set_message_handler(instance, object: TalerWalletCore.TALER_WALLET_MessageHandlerFn { - override fun invoke(handler_p: Pointer, message: String) { - this@WalletBackendService.handleAkonoMessage(message) - } - }, instance) - walletCore.TALER_start_redirect_std(object: TalerWalletCore.TALER_LogFn { - override fun invoke(cls: Pointer, stream: Int, msg: String) { - Log.d(TAG, "wallet log: $msg") - } - }, instance) - walletCore.TALER_WALLET_run(instance) + walletCore.setMessageHandler { + this@WalletBackendService.handleAkonoMessage(it) + } + walletCore.setStdoutHandler { + Log.d(TAG, "wallet log: $it") + } + walletCore.run() sendInitMessage() // runIntegrationTest() super.onCreate() @@ -84,7 +77,7 @@ class WalletBackendService : Service() { msg.put("args", args) args.put("persistentStoragePath", "${application.filesDir}/$WALLET_DB") Log.d(TAG, "init message: ${msg.toString(2)}") - walletCore.TALER_WALLET_send_request(instance, msg.toString()) + walletCore.sendRequest(msg.toString()) } /** @@ -102,7 +95,7 @@ class WalletBackendService : Service() { args.put("merchantBaseUrl", "https://backend.demo.taler.net/") args.put("merchantAuthToken", "secret-token:sandbox") Log.d(TAG, "integration test message: ${msg.toString(2)}") - walletCore.TALER_WALLET_send_request(instance, msg.toString()) + walletCore.sendRequest(msg.toString()) } /** @@ -142,7 +135,7 @@ class WalletBackendService : Service() { request.put("operation", operation) request.put("id", serviceRequestID) request.put("args", argsObj) - svc.walletCore.TALER_WALLET_send_request(svc.instance, request.toString(2)) + svc.walletCore.sendRequest(request.toString()) Log.i( TAG, "mapping service request ID $serviceRequestID to client request ID $clientRequestID" diff --git a/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt b/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt index 8bb0a4a..11c252b 100644 --- a/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt @@ -28,10 +28,10 @@ import com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_SHORT import com.google.android.material.snackbar.Snackbar import net.taler.common.showError import net.taler.common.toRelativeTime +import net.taler.qtart.BuildConfig.WALLET_CORE_VERSION import net.taler.wallet.BuildConfig.FLAVOR import net.taler.wallet.BuildConfig.VERSION_CODE import net.taler.wallet.BuildConfig.VERSION_NAME -import net.taler.wallet.BuildConfig.WALLET_CORE_VERSION import net.taler.wallet.MainViewModel import net.taler.wallet.R import net.taler.wallet.withdraw.WithdrawTestStatus |