diff --git a/README.md b/README.md index eccd7ce7e..9ac04dfa2 100644 --- a/README.md +++ b/README.md @@ -38,3 +38,6 @@ Aurora Android native libraries only support `armeabi-v7a`, `arm64-v8a` and `x86 Tari native wallet library version to be used by Aurora is specified by the `ext.libwalletVersion` in the `build.gradle` file in the project root directory. Aurora build script automatically fetches the native libraries of this version into the `libwallet` folder in the root directory during the build process. Any library files you place in this folder will be deleted and replaced by this automatic download process. If you want to disable the automatic download and use the native libraries of your choice, please comment out the line `preBuild.dependsOn("downloadLibwallet")` in the file `app/build.gradle`. + +### For updating openssl +https://github.com/217heidai/openssl_for_android/releases \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 9e31865e8..fcc0e5b97 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -264,7 +264,7 @@ dependencies { implementation "com.github.adorsys:secure-storage-android:0.0.2" // Tor control - implementation "info.guardianproject:tor-android:0.4.7.14" + implementation "info.guardianproject:tor-android:0.4.8.7" implementation "info.guardianproject:jtorctl:0.4.5.7" // used to read log files @@ -288,7 +288,7 @@ dependencies { implementation('com.google.api-client:google-api-client-android:2.2.0') { exclude group: "org.apache.httpcomponents" } - implementation('com.google.apis:google-api-services-drive:v3-rev20221023-2.0.0') { + implementation('com.google.apis:google-api-services-drive:v3-rev20230822-2.0.0') { exclude group: "org.apache.httpcomponents" } // sentry - crash analytics @@ -323,9 +323,9 @@ dependencies { // debugImplementation because LeakCanary should only run in debug builds. debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12' - implementation 'com.github.vestrel00:contacts-android:0.2.4' + implementation 'com.github.vestrel00:contacts-android:0.3.1' - implementation "com.github.weliem:blessed-android:2.4.2" + implementation "com.github.weliem:blessed-android:2.5.0" // test testImplementation "junit:junit:4.13.2" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b0b91b874..37bf3b763 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -51,6 +51,7 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="false" + android:taskAffinity="" android:theme="@style/AppTheme.Light" tools:replace="android:supportsRtl,android:allowBackup"> @@ -85,6 +86,7 @@ android:name=".ui.fragment.splash.SplashActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:exported="true" + android:launchMode="singleInstance" android:screenOrientation="portrait" android:theme="@style/AppTheme.Splash" android:windowSoftInputMode="stateAlwaysHidden"> @@ -98,12 +100,14 @@ @@ -111,7 +115,7 @@ android:name=".ui.fragment.home.HomeActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:exported="true" - android:launchMode="singleTask" + android:launchMode="singleInstance" android:screenOrientation="portrait" android:theme="@style/AppTheme.Light" android:windowSoftInputMode="stateAlwaysHidden|adjustResize"> @@ -176,7 +180,7 @@ android:name="com.dropbox.core.android.AuthActivity" android:configChanges="orientation|keyboard" android:exported="true" - android:launchMode="singleTask" + android:launchMode="singleInstance" android:screenOrientation="portrait"> @@ -191,12 +195,14 @@ android:name="com.tari.android.wallet.ui.fragment.qr.QRScannerActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:exported="false" + android:launchMode="singleInstance" android:theme="@style/AppTheme.Light" android:windowSoftInputMode="stateAlwaysHidden" /> @@ -204,7 +210,7 @@ android:name="com.tari.android.wallet.ui.fragment.settings.logs.activity.DebugActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:exported="false" - android:launchMode="singleTask" + android:launchMode="singleInstance" android:parentActivityName=".ui.fragment.home.HomeActivity" android:screenOrientation="portrait" android:theme="@style/AppTheme.Light" @@ -213,7 +219,7 @@ android:name="com.tari.android.wallet.ui.fragment.restore.activity.WalletRestoreActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:exported="false" - android:launchMode="singleTask" + android:launchMode="singleInstance" android:parentActivityName=".ui.fragment.onboarding.activity.OnboardingFlowActivity" android:screenOrientation="portrait" android:theme="@style/AppTheme.Light" diff --git a/app/src/main/java/com/tari/android/wallet/application/baseNodes/BaseNodes.kt b/app/src/main/java/com/tari/android/wallet/application/baseNodes/BaseNodes.kt index f935931a1..67e8ac370 100644 --- a/app/src/main/java/com/tari/android/wallet/application/baseNodes/BaseNodes.kt +++ b/app/src/main/java/com/tari/android/wallet/application/baseNodes/BaseNodes.kt @@ -69,10 +69,7 @@ class BaseNodes( private fun findAndAddBaseNode(fileContent: String, regex: String): Sequence { return Regex(regex).findAll(fileContent).map { matchResult -> val tripleString = matchResult.value.split("::") - if (tripleString.size ==2) { - 1 - } - Logger.t(this::class.simpleName).e("baseNodeList0: $tripleString, baseNodeList1: ${tripleString[1]}, baseNodeList2: ${tripleString[2]}") + Logger.t(this::class.simpleName).i("baseNodeList0: $tripleString, baseNodeList1: ${tripleString[1]}, baseNodeList2: ${tripleString[2]}") BaseNodeDto(tripleString[0], tripleString[1], tripleString[2]) } } @@ -98,21 +95,21 @@ class BaseNodes( fun startSync() { try { - Logger.t(this::class.simpleName).e("startSync") + Logger.t(this::class.simpleName).i("startSync") //essential for wallet creation flow val baseNode = baseNodeSharedRepository.currentBaseNode ?: return serviceConnection.currentState.service ?: return if (EventBus.walletState.publishSubject.value != WalletState.Running) return - Logger.t(this::class.simpleName).e("startSync:publicKeyHex: ${baseNode.publicKeyHex}") - Logger.t(this::class.simpleName).e("startSync:address: ${baseNode.address}") - Logger.t(this::class.simpleName).e("startSync:address: ${Gson().toJson(baseNodeSharedRepository.userBaseNodes)}") + Logger.t(this::class.simpleName).i("startSync:publicKeyHex: ${baseNode.publicKeyHex}") + Logger.t(this::class.simpleName).i("startSync:address: ${baseNode.address}") + Logger.t(this::class.simpleName).i("startSync:address: ${Gson().toJson(baseNodeSharedRepository.userBaseNodes)}") val baseNodeKeyFFI = FFIPublicKey(HexString(baseNode.publicKeyHex)) FFIWallet.instance?.addBaseNodePeer(baseNodeKeyFFI, baseNode.address) baseNodeKeyFFI.destroy() walletService.getWithError { error, wallet -> wallet.startBaseNodeSync(error) } } catch (e: Throwable) { - Logger.t(this::class.simpleName).e("startSync") + Logger.t(this::class.simpleName).i("startSync") setNextBaseNode() startSync() } diff --git a/app/src/main/java/com/tari/android/wallet/application/deeplinks/DeepLink.kt b/app/src/main/java/com/tari/android/wallet/application/deeplinks/DeepLink.kt index cfb87dca7..df785c986 100644 --- a/app/src/main/java/com/tari/android/wallet/application/deeplinks/DeepLink.kt +++ b/app/src/main/java/com/tari/android/wallet/application/deeplinks/DeepLink.kt @@ -35,7 +35,7 @@ package com.tari.android.wallet.application.deeplinks import com.tari.android.wallet.data.sharedPrefs.tor.TorBridgeConfiguration import com.tari.android.wallet.model.MicroTari import com.tari.android.wallet.model.TariWalletAddress -import java.math.BigInteger +import com.tari.android.wallet.util.parseToBigInteger /** * Parses a deep link and contains the structured deep link details. @@ -98,7 +98,7 @@ sealed class DeepLink { constructor(params: Map) : this( params[tariAddressKey].orEmpty(), - params[amountKey]?.let { if (it.isEmpty()) null else MicroTari(BigInteger(it)) }, + params[amountKey]?.let { if (it.isEmpty()) null else MicroTari(it.parseToBigInteger()) }, params[noteKey].orEmpty() ) diff --git a/app/src/main/java/com/tari/android/wallet/application/deeplinks/DeeplinkFormatter.kt b/app/src/main/java/com/tari/android/wallet/application/deeplinks/DeeplinkFormatter.kt index 4084e5666..f73e8b20f 100644 --- a/app/src/main/java/com/tari/android/wallet/application/deeplinks/DeeplinkFormatter.kt +++ b/app/src/main/java/com/tari/android/wallet/application/deeplinks/DeeplinkFormatter.kt @@ -16,7 +16,7 @@ class DeeplinkFormatter @Inject constructor(private val networkRepository: Netwo return DeepLink.TorBridges(torBridges) } - val uri = Uri.parse(URLDecoder.decode(deepLink, "UTF-8")) + val uri = runCatching { Uri.parse(URLDecoder.decode(deepLink, "UTF-8")) }.getOrNull() ?: return null if (!uri.authority.equals(networkRepository.currentNetwork!!.network.uriComponent)) { return null diff --git a/app/src/main/java/com/tari/android/wallet/data/sharedPrefs/delegates/SharedPrefGsonDelegate.kt b/app/src/main/java/com/tari/android/wallet/data/sharedPrefs/delegates/SharedPrefGsonDelegate.kt index 2ddf8d70e..bd2449b4b 100644 --- a/app/src/main/java/com/tari/android/wallet/data/sharedPrefs/delegates/SharedPrefGsonDelegate.kt +++ b/app/src/main/java/com/tari/android/wallet/data/sharedPrefs/delegates/SharedPrefGsonDelegate.kt @@ -29,7 +29,7 @@ class SharedPrefGsonDelegate( try { gson.fromJson(savedValue, type) as T } catch (e: Throwable) { - logger.e(e.toString()) + logger.i(e.toString()) defValue } } else { diff --git a/app/src/main/java/com/tari/android/wallet/ffi/FFICommsConfig.kt b/app/src/main/java/com/tari/android/wallet/ffi/FFICommsConfig.kt index 39ba4c71f..cb09bc72d 100644 --- a/app/src/main/java/com/tari/android/wallet/ffi/FFICommsConfig.kt +++ b/app/src/main/java/com/tari/android/wallet/ffi/FFICommsConfig.kt @@ -79,7 +79,7 @@ class FFICommsConfig() : FFIBase() { } else { messageBuilder.append("Permission problem.") } - logger.e(Throwable(), messageBuilder.toString()) + logger.i(messageBuilder.toString()) throw FFIException(message = messageBuilder.toString()) } } diff --git a/app/src/main/java/com/tari/android/wallet/infrastructure/backup/BackupFileProcessor.kt b/app/src/main/java/com/tari/android/wallet/infrastructure/backup/BackupFileProcessor.kt index 5935e15ba..d01b76871 100644 --- a/app/src/main/java/com/tari/android/wallet/infrastructure/backup/BackupFileProcessor.kt +++ b/app/src/main/java/com/tari/android/wallet/infrastructure/backup/BackupFileProcessor.kt @@ -150,7 +150,7 @@ class BackupFileProcessor @Inject constructor( try { File(walletConfig.getWalletTempDirPath()).listFiles()?.forEach { it.delete() } } catch (e: Exception) { - Logger.e(e, "Ignorable backup error while clearing temporary and old files.") + Logger.i(e.toString() + "Ignorable backup error while clearing temporary and old files.") } } } diff --git a/app/src/main/java/com/tari/android/wallet/infrastructure/backup/local/LocalBackupStorage.kt b/app/src/main/java/com/tari/android/wallet/infrastructure/backup/local/LocalBackupStorage.kt index e13c6903f..e894b6ea2 100644 --- a/app/src/main/java/com/tari/android/wallet/infrastructure/backup/local/LocalBackupStorage.kt +++ b/app/src/main/java/com/tari/android/wallet/infrastructure/backup/local/LocalBackupStorage.kt @@ -124,7 +124,7 @@ class LocalBackupStorage @Inject constructor( } } } catch (e: Exception) { - logger.e(e, "Ignorable backup error while clearing temporary and old files.") + logger.i(e.toString() + "Ignorable backup error while clearing temporary and old files.") } return@withContext backupDate } diff --git a/app/src/main/java/com/tari/android/wallet/infrastructure/security/biometric/SingleSuccessOrErrorAdapterDecorator.kt b/app/src/main/java/com/tari/android/wallet/infrastructure/security/biometric/SingleSuccessOrErrorAdapterDecorator.kt index 28bdb4dcb..a432da869 100644 --- a/app/src/main/java/com/tari/android/wallet/infrastructure/security/biometric/SingleSuccessOrErrorAdapterDecorator.kt +++ b/app/src/main/java/com/tari/android/wallet/infrastructure/security/biometric/SingleSuccessOrErrorAdapterDecorator.kt @@ -10,8 +10,13 @@ class SingleSuccessOrErrorAdapterDecorator(private val decorated: BiometricPromp override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) { if (!isResumed.get()) { - decorated.onAuthenticationSucceeded(result) - isResumed.set(true) + if (result.cryptoObject?.cipher == null) { + decorated.onAuthenticationSucceeded(result) + isResumed.set(true) + } else { + decorated.onAuthenticationError(BiometricPrompt.ERROR_CANCELED, "Crypto object is not null") + isResumed.set(true) + } } } diff --git a/app/src/main/java/com/tari/android/wallet/service/BootDeviceReceiver.kt b/app/src/main/java/com/tari/android/wallet/service/BootDeviceReceiver.kt index 54954e33d..db29dd00c 100644 --- a/app/src/main/java/com/tari/android/wallet/service/BootDeviceReceiver.kt +++ b/app/src/main/java/com/tari/android/wallet/service/BootDeviceReceiver.kt @@ -35,13 +35,13 @@ package com.tari.android.wallet.service import android.content.BroadcastReceiver import android.content.Context import android.content.Intent +import android.os.Build import com.orhanobut.logger.Logger import com.tari.android.wallet.data.WalletConfig import com.tari.android.wallet.data.sharedPrefs.network.NetworkRepositoryImpl import com.tari.android.wallet.data.sharedPrefs.tariSettings.TariSettingsSharedRepository import com.tari.android.wallet.di.ApplicationModule import com.tari.android.wallet.service.service.WalletServiceLauncher -import com.tari.android.wallet.ui.common.domain.ResourceManager /** * This receiver is responsible for starting the service after boot finish. @@ -55,6 +55,9 @@ class BootDeviceReceiver : BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent?) { if (context == null || intent == null) return + // not allowed action starts from android 12 dio to new restriction + // https://developer.android.com/guide/components/foreground-services#background-start-restriction-exemptions + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) return logger.i("Boot device broadcast received") if (Intent.ACTION_BOOT_COMPLETED == intent.action) { val sharedPreferences = context.getSharedPreferences(ApplicationModule.sharedPrefsFileName, Context.MODE_PRIVATE) diff --git a/app/src/main/java/com/tari/android/wallet/service/service/FFIWalletListenerImpl.kt b/app/src/main/java/com/tari/android/wallet/service/service/FFIWalletListenerImpl.kt index 341784eca..f9c62bfe7 100644 --- a/app/src/main/java/com/tari/android/wallet/service/service/FFIWalletListenerImpl.kt +++ b/app/src/main/java/com/tari/android/wallet/service/service/FFIWalletListenerImpl.kt @@ -314,7 +314,7 @@ class FFIWalletListenerImpl( baseNodeValidationStatusMap[type] = Pair(currentStatus.first, isSuccess) checkBaseNodeSyncCompletion() } catch (e: Throwable) { - logger.e(e.toString()) + logger.i(e.toString()) } } diff --git a/app/src/main/java/com/tari/android/wallet/service/service/ServiceLifecycleCallbacks.kt b/app/src/main/java/com/tari/android/wallet/service/service/ServiceLifecycleCallbacks.kt index 43fb84741..89fc523d0 100644 --- a/app/src/main/java/com/tari/android/wallet/service/service/ServiceLifecycleCallbacks.kt +++ b/app/src/main/java/com/tari/android/wallet/service/service/ServiceLifecycleCallbacks.kt @@ -44,7 +44,7 @@ class ServiceLifecycleCallbacks(private val wallet: FFIWallet): DefaultLifecycle try { wallet.setPowerModeNormal() } catch (e: FFIException) { - logger.e(e, "Switching to normal power mode failed") + logger.i(e.toString() + "Switching to normal power mode failed") } } @@ -53,7 +53,7 @@ class ServiceLifecycleCallbacks(private val wallet: FFIWallet): DefaultLifecycle try { wallet.setPowerModeLow() } catch (e: FFIException) { - logger.e(e, "Switching to low power mode failed") + logger.i(e.toString() + "Switching to low power mode failed") } } } \ No newline at end of file diff --git a/app/src/main/java/com/tari/android/wallet/service/service/TariWalletServiceStubImpl.kt b/app/src/main/java/com/tari/android/wallet/service/service/TariWalletServiceStubImpl.kt index 435498209..328a725ed 100644 --- a/app/src/main/java/com/tari/android/wallet/service/service/TariWalletServiceStubImpl.kt +++ b/app/src/main/java/com/tari/android/wallet/service/service/TariWalletServiceStubImpl.kt @@ -160,7 +160,7 @@ class TariWalletServiceStubImpl( } ?: false override fun startBaseNodeSync(error: WalletError): Boolean = runMapping(error, { - logger.e(it, "Base node sync failed") + logger.i(it.toString() + "Base node sync failed") baseNodeSharedPrefsRepository.baseNodeLastSyncResult = false walletServiceListener.baseNodeValidationStatusMap.clear() EventBus.baseNodeSyncState.post(BaseNodeSyncState.Failed) diff --git a/app/src/main/java/com/tari/android/wallet/service/service/WalletService.kt b/app/src/main/java/com/tari/android/wallet/service/service/WalletService.kt index 3bc66c61a..b11911582 100644 --- a/app/src/main/java/com/tari/android/wallet/service/service/WalletService.kt +++ b/app/src/main/java/com/tari/android/wallet/service/service/WalletService.kt @@ -203,14 +203,14 @@ class WalletService : Service() { .repeat() .subscribeOn(Schedulers.io()) .observeOn(Schedulers.io()) - .doOnError { logger.i("error during sheduled expiration check $it") } + .doOnError { logger.i("error during scheduled expiration check $it") } .subscribe { try { logger.i("scheduled expiration check") cancelExpiredPendingInboundTxs() cancelExpiredPendingOutboundTxs() } catch (e: Exception) { - logger.e("error during sheduled expiration check $e") + logger.i("error during scheduled expiration check $e") } } } diff --git a/app/src/main/java/com/tari/android/wallet/tor/NativeLoader.kt b/app/src/main/java/com/tari/android/wallet/tor/NativeLoader.kt index 31b47f479..d5f1ae73c 100644 --- a/app/src/main/java/com/tari/android/wallet/tor/NativeLoader.kt +++ b/app/src/main/java/com/tari/android/wallet/tor/NativeLoader.kt @@ -48,13 +48,13 @@ object NativeLoader { return true } catch (e: Exception) { - logger.e(e, "Load from zip") + logger.i(e.toString() + "Load from zip") } finally { if (stream != null) { try { stream.close() } catch (e: Exception) { - logger.e(e, "Closing stream") + logger.i(e.toString() + "Closing stream") } } @@ -62,7 +62,7 @@ object NativeLoader { try { zipFile.close() } catch (e: Exception) { - logger.e(e, "closing zip file") + logger.i(e.toString() + "closing zip file") } } } diff --git a/app/src/main/java/com/tari/android/wallet/ui/common/CommonActivity.kt b/app/src/main/java/com/tari/android/wallet/ui/common/CommonActivity.kt index 6be51da48..ef287ddfd 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/common/CommonActivity.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/common/CommonActivity.kt @@ -176,10 +176,10 @@ abstract class CommonActivity : App } fun popUpTo(tag: String) { - viewModel.logger.e("popUpTo $tag") - viewModel.logger.e("popUpTo:last ${supportFragmentManager.fragments.last().tag}") - viewModel.logger.e("popUpTo:all ${supportFragmentManager.fragments.map { it.tag }.joinToString(", ")}") - viewModel.logger.e("popUpTo:all ${supportFragmentManager.fragments.map { it::class.java }.joinToString(", ")}") + viewModel.logger.i("popUpTo $tag") + viewModel.logger.i("popUpTo:last ${supportFragmentManager.fragments.last().tag}") + viewModel.logger.i("popUpTo:all ${supportFragmentManager.fragments.map { it.tag }.joinToString(", ")}") + viewModel.logger.i("popUpTo:all ${supportFragmentManager.fragments.map { it::class.java }.joinToString(", ")}") while (supportFragmentManager.fragments.last()::class.java.simpleName != tag && supportFragmentManager.backStackEntryCount > 0) { supportFragmentManager.popBackStackImmediate() } diff --git a/app/src/main/java/com/tari/android/wallet/ui/common/CommonViewModel.kt b/app/src/main/java/com/tari/android/wallet/ui/common/CommonViewModel.kt index 04c547af9..c0a20135d 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/common/CommonViewModel.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/common/CommonViewModel.kt @@ -143,13 +143,13 @@ open class CommonViewModel : ViewModel() { fun doOnConnected(action: (walletService: TariWalletService) -> Unit) { serviceConnection.connection.filter { it.status == ServiceConnectionStatus.CONNECTED }.take(1) - .doOnError { logger.e(it, it.toString()) } + .doOnError { logger.i(it.toString()) } .subscribe { action(it.service!!) } .addTo(compositeDisposable) } fun doOnConnectedToWallet(action: (walletService: FFIWallet) -> Unit) { - EventBus.walletState.publishSubject.filter { it == WalletState.Running }.take(1).doOnError { Logger.e(it.toString()) } + EventBus.walletState.publishSubject.filter { it == WalletState.Running }.take(1).doOnError { Logger.i(it.toString()) } .subscribe { action(FFIWallet.instance!!) } .addTo(compositeDisposable) } diff --git a/app/src/main/java/com/tari/android/wallet/ui/common/gyphy/repository/GiphyRESTRetrofitRepository.kt b/app/src/main/java/com/tari/android/wallet/ui/common/gyphy/repository/GiphyRESTRetrofitRepository.kt index 3786d2323..4eb576b15 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/common/gyphy/repository/GiphyRESTRetrofitRepository.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/common/gyphy/repository/GiphyRESTRetrofitRepository.kt @@ -20,7 +20,7 @@ class GiphyRESTRetrofitRepository(private val gateway: GiphyRESTGateway) : GIFRe body.data.map { GIFItem(it.id, Uri.parse(it.embedUrl), Uri.parse(it.images.fixedWidth.url)) } else { val exception = GIFSearchException(body?.meta?.message ?: response.message() ?: response.errorBody()?.string()) - logger.e(exception, "Get all was failed") + logger.i(exception.toString() + "Get all was failed") throw exception } } @@ -33,9 +33,9 @@ class GiphyRESTRetrofitRepository(private val gateway: GiphyRESTGateway) : GIFRe body.data.let { GIFItem(it.id, Uri.parse(it.embedUrl), Uri.parse(it.images.fixedWidth.url)) } else { val exception = GIFSearchException(body?.meta?.message ?: response.message() ?: response.errorBody()?.string()) - logger.e(exception.message.orEmpty()) - logger.e(exception.stackTraceToString()) - logger.e(exception, "Get by id was failed") + logger.i(exception.message.orEmpty()) + logger.i(exception.stackTraceToString()) + logger.i(exception. toString() + "Get by id was failed") throw exception } } diff --git a/app/src/main/java/com/tari/android/wallet/ui/extension/ParcelableExtensions.kt b/app/src/main/java/com/tari/android/wallet/ui/extension/ParcelableExtensions.kt index 7dd0923c4..efb35e5d2 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/extension/ParcelableExtensions.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/extension/ParcelableExtensions.kt @@ -49,6 +49,11 @@ inline fun Intent.parcelable(key: String): T? = when { else -> @Suppress("DEPRECATION") getParcelableExtra(key) as? T } +inline fun Intent.serializable(key: String): T? = when { + SDK_INT >= 33 -> getSerializableExtra(key, T::class.java) + else -> @Suppress("DEPRECATION") getSerializableExtra(key) as? T +} + inline fun Bundle.parcelable(key: String): T? = when { SDK_INT >= 33 -> getParcelable(key, T::class.java) else -> @Suppress("DEPRECATION") getParcelable(key) as? T diff --git a/app/src/main/java/com/tari/android/wallet/ui/fragment/auth/AuthActivity.kt b/app/src/main/java/com/tari/android/wallet/ui/fragment/auth/AuthActivity.kt index ce38714f7..29d470b15 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/fragment/auth/AuthActivity.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/fragment/auth/AuthActivity.kt @@ -44,8 +44,6 @@ import com.tari.android.wallet.R.string.auth_device_lock_code_prompt import com.tari.android.wallet.R.string.auth_not_available_or_canceled_desc import com.tari.android.wallet.R.string.auth_not_available_or_canceled_title import com.tari.android.wallet.R.string.auth_title -import com.tari.android.wallet.R.string.exit -import com.tari.android.wallet.R.string.proceed import com.tari.android.wallet.data.sharedPrefs.security.LoginAttemptDto import com.tari.android.wallet.databinding.ActivityAuthBinding import com.tari.android.wallet.extension.observe @@ -101,21 +99,18 @@ class AuthActivity : CommonActivity() { private fun doAuth() { showBiometricAuth() - // check whether there's at least screen lock - if (viewModel.authService.isDeviceSecured) { - lifecycleScope.launch { - try { - setupPinCodeFragment() - } catch (e: BiometricAuthenticationException) { - viewModel.logger.e(e, "Authentication has failed") - } + lifecycleScope.launch { + try { + setupPinCodeFragment() + } catch (e: BiometricAuthenticationException) { + viewModel.logger.i(e.message + "Authentication has failed") } - } else { - displayAuthNotAvailableDialog() } } fun showBiometricAuth() { + if (!viewModel.authService.isBiometricAuthAvailable) return + if (viewModel.authService.isDeviceSecured) { lifecycleScope.launch { try { @@ -131,7 +126,7 @@ class AuthActivity : CommonActivity() { proceedLogin() } } catch (e: BiometricAuthenticationException) { - viewModel.logger.e(e, "Authentication has failed") + viewModel.logger.i(e.toString() + "Authentication has failed") } } } else { @@ -146,14 +141,7 @@ class AuthActivity : CommonActivity() { val dialog = AlertDialog.Builder(this) .setMessage(getString(auth_not_available_or_canceled_desc)) .setCancelable(false) - .setPositiveButton(getString(proceed)) { dialog, _ -> - dialog.cancel() - // user has chosen to proceed without authentication - viewModel.securityPrefRepository.isAuthenticated = true - proceedLogin() - } - // negative button text and action - .setNegativeButton(getString(exit)) { _, _ -> finish() } + .setPositiveButton(getString(R.string.common_ok)) { dialog, _ -> dialog.cancel() } .create() dialog.setTitle(getString(auth_not_available_or_canceled_title)) dialog.show() diff --git a/app/src/main/java/com/tari/android/wallet/ui/fragment/auth/FeatureAuthFragment.kt b/app/src/main/java/com/tari/android/wallet/ui/fragment/auth/FeatureAuthFragment.kt index 560291199..b47ea7b74 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/fragment/auth/FeatureAuthFragment.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/fragment/auth/FeatureAuthFragment.kt @@ -45,8 +45,6 @@ import com.tari.android.wallet.R.string.auth_device_lock_code_prompt import com.tari.android.wallet.R.string.auth_not_available_or_canceled_desc import com.tari.android.wallet.R.string.auth_not_available_or_canceled_title import com.tari.android.wallet.R.string.auth_title -import com.tari.android.wallet.R.string.exit -import com.tari.android.wallet.R.string.proceed import com.tari.android.wallet.data.sharedPrefs.security.LoginAttemptDto import com.tari.android.wallet.databinding.FragmentFeatureAuthBinding import com.tari.android.wallet.extension.observe @@ -96,21 +94,18 @@ class FeatureAuthFragment : CommonFragment - dialog.cancel() - // user has chosen to proceed without authentication - viewModel.securityPrefRepository.isAuthenticated = true - authSuccessfully() - } - // negative button text and action - .setNegativeButton(getString(exit)) { _, _ -> viewModel.backPressed.postValue(Unit) } + .setPositiveButton(getString(R.string.common_ok)) { dialog, _ -> dialog.cancel() } .create() dialog.setTitle(getString(auth_not_available_or_canceled_title)) dialog.show() @@ -163,4 +151,4 @@ class FeatureAuthFragment : CommonFragment() { viewModel.shareViewModel.tariBluetoothClient.init(this) setContainerId(R.id.nav_container) - overridePendingTransition(0, 0) if (!securityPrefRepository.isAuthenticated) { val intent = Intent(this, SplashActivity::class.java) .apply { flags = Intent.FLAG_ACTIVITY_NEW_TASK } this.intent?.data?.let(intent::setData) - startActivity(intent) finish() + startActivity(intent) return } ui = ActivityHomeBinding.inflate(layoutInflater).also { setContentView(it.root) } @@ -381,6 +380,7 @@ class HomeActivity : CommonActivity() { } override fun onDestroy() { + viewModel.securityPrefRepository.isAuthenticated = false super.onDestroy() instance = WeakReference(null) viewModelStore.clear() diff --git a/app/src/main/java/com/tari/android/wallet/ui/fragment/home/navigation/TariNavigator.kt b/app/src/main/java/com/tari/android/wallet/ui/fragment/home/navigation/TariNavigator.kt index 9c265bf15..6f07a5f3d 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/fragment/home/navigation/TariNavigator.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/fragment/home/navigation/TariNavigator.kt @@ -29,6 +29,7 @@ import com.tari.android.wallet.ui.dialog.modular.modules.body.BodyModule import com.tari.android.wallet.ui.dialog.modular.modules.button.ButtonModule import com.tari.android.wallet.ui.dialog.modular.modules.button.ButtonStyle import com.tari.android.wallet.ui.dialog.modular.modules.head.HeadModule +import com.tari.android.wallet.ui.extension.serializable import com.tari.android.wallet.ui.extension.showInternetConnectionErrorDialog import com.tari.android.wallet.ui.extension.string import com.tari.android.wallet.ui.fragment.auth.FeatureAuthFragment @@ -339,7 +340,6 @@ class TariNavigator @Inject constructor(val prefs: SharedPrefsRepository, val ta private fun navigateBackFromTxSend(isYat: Boolean) { if (isYat) { activity.finish() - activity.overridePendingTransition(R.anim.fade_in, R.anim.fade_out) } else { val fragmentsCount = activity.supportFragmentManager.fragments.size - 5 for (i in 0 until fragmentsCount) { @@ -384,7 +384,7 @@ class TariNavigator @Inject constructor(val prefs: SharedPrefsRepository, val ta val innerAmount = (activity.intent.getDoubleExtra(PARAMETER_AMOUNT, Double.MIN_VALUE)) val tariAmount = amount ?: if (innerAmount != Double.MIN_VALUE) MicroTari(BigInteger.valueOf(innerAmount.toLong())) else null tariAmount?.let { putParcelable(PARAMETER_AMOUNT, it) } - activity.intent.getSerializableExtra(PARAMETER_CONTACT)?.let { putSerializable(PARAMETER_CONTACT, it) } + activity.intent.serializable(PARAMETER_CONTACT)?.let { putSerializable(PARAMETER_CONTACT, it) } } addFragment(AddAmountFragment(), bundle) diff --git a/app/src/main/java/com/tari/android/wallet/ui/fragment/onboarding/inroduction/IntroductionFragment.kt b/app/src/main/java/com/tari/android/wallet/ui/fragment/onboarding/inroduction/IntroductionFragment.kt index 5a289c608..0c9c846d1 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/fragment/onboarding/inroduction/IntroductionFragment.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/fragment/onboarding/inroduction/IntroductionFragment.kt @@ -131,7 +131,6 @@ class IntroductionFragment : CommonFragment(QR_DATA_SOURCE) viewModel.init(data ?: QrScannerSource.None) subscribeUI() @@ -128,7 +128,6 @@ class QRScannerActivity : CommonActivity> = _seedWords init { + _seedWords.value = listOf() doOnConnected { getSeedWords() } } diff --git a/app/src/main/java/com/tari/android/wallet/ui/fragment/settings/bugReporting/BugsReportingViewModel.kt b/app/src/main/java/com/tari/android/wallet/ui/fragment/settings/bugReporting/BugsReportingViewModel.kt index 8162b0bcb..b73f2420f 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/fragment/settings/bugReporting/BugsReportingViewModel.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/fragment/settings/bugReporting/BugsReportingViewModel.kt @@ -1,8 +1,15 @@ package com.tari.android.wallet.ui.fragment.settings.bugReporting import androidx.lifecycle.viewModelScope +import com.tari.android.wallet.R import com.tari.android.wallet.infrastructure.logging.BugReportingService import com.tari.android.wallet.ui.common.CommonViewModel +import com.tari.android.wallet.ui.dialog.modular.DialogArgs +import com.tari.android.wallet.ui.dialog.modular.ModularDialogArgs +import com.tari.android.wallet.ui.dialog.modular.modules.body.BodyModule +import com.tari.android.wallet.ui.dialog.modular.modules.button.ButtonModule +import com.tari.android.wallet.ui.dialog.modular.modules.button.ButtonStyle +import com.tari.android.wallet.ui.dialog.modular.modules.head.HeadModule import kotlinx.coroutines.launch import javax.inject.Inject @@ -16,8 +23,20 @@ class BugsReportingViewModel : CommonViewModel() { } fun send(name: String, email: String, bugDescription: String) = viewModelScope.launch { - bugReportingService.share(name, email, bugDescription) - backPressed.postValue(Unit) + try { + bugReportingService.share(name, email, bugDescription) + backPressed.postValue(Unit) + } catch (e: Exception) { + val args = ModularDialogArgs( + DialogArgs(), + listOf( + HeadModule(resourceManager.getString(R.string.common_error_title)), + BodyModule(resourceManager.getString(R.string.common_unknown_error)), + ButtonModule(resourceManager.getString(R.string.common_ok), ButtonStyle.Close) + ) + ) + modularDialog.postValue(args) + } } } diff --git a/app/src/main/java/com/tari/android/wallet/ui/fragment/settings/logs/logs/LogsViewModel.kt b/app/src/main/java/com/tari/android/wallet/ui/fragment/settings/logs/logs/LogsViewModel.kt index 3db4c9393..6f72217d0 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/fragment/settings/logs/logs/LogsViewModel.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/fragment/settings/logs/logs/LogsViewModel.kt @@ -53,7 +53,7 @@ class LogsViewModel : CommonViewModel() { backPressed.postValue(Unit) } modularDialog.postValue(errorArgs.getModular(resourceManager)) - logger.e(e, "Out of memory on reading big log file") + logger.i(e.message + "Out of memory on reading big log file") } } diff --git a/app/src/main/java/com/tari/android/wallet/ui/fragment/settings/userAutorization/BiometricAuthenticationViewModel.kt b/app/src/main/java/com/tari/android/wallet/ui/fragment/settings/userAutorization/BiometricAuthenticationViewModel.kt index cb1d7a340..a5f03b99e 100644 --- a/app/src/main/java/com/tari/android/wallet/ui/fragment/settings/userAutorization/BiometricAuthenticationViewModel.kt +++ b/app/src/main/java/com/tari/android/wallet/ui/fragment/settings/userAutorization/BiometricAuthenticationViewModel.kt @@ -47,7 +47,7 @@ class BiometricAuthenticationViewModel : CommonViewModel() { private fun handleError(e: Exception) { if (e is BiometricAuthenticationException) { if (e.code != BiometricPrompt.ERROR_USER_CANCELED && e.code != BiometricPrompt.ERROR_CANCELED) - logger.e(e, "Other biometric error. Code: ${e.code}") + logger.i(e.message + "Other biometric error. Code: ${e.code}") val args = AlertDialogArgs( resourceManager.getString(R.string.auth_failed_desc), resourceManager.getString(R.string.auth_failed_title), diff --git a/app/src/main/java/com/tari/android/wallet/util/BuildUtil.kt.orig b/app/src/main/java/com/tari/android/wallet/util/BuildUtil.kt.orig deleted file mode 100644 index a873fd5c1..000000000 --- a/app/src/main/java/com/tari/android/wallet/util/BuildUtil.kt.orig +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright 2020 The Tari Project - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.tari.android.wallet.util - -import com.tari.android.wallet.BuildConfig -import com.tari.android.wallet.model.TariWalletAddress - -object TariBuild { - - private val _mockedTurned = true - val MOCKED = _mockedTurned && BuildConfig.BUILD_TYPE == "debug" - - val mocked_emojiId = - "\uD83C\uDFB9\uD83C\uDFA4\uD83C\uDF20\uD83C\uDFAA\uD83D\uDC16\uD83C\uDF5A\uD83D\uDE08\uD83C\uDF73\uD83C\uDFED\uD83D\uDC2F\uD83D\uDC29\uD83D\uDC33\uD83D\uDC2D\uD83D\uDC35\uD83D\uDC11\uD83C\uDF4E\uD83D\uDE02\uD83C\uDFB3\uD83C\uDF34\uD83C\uDF6D\uD83D\uDC0D\uD83C\uDF1F\uD83D\uDCBC\uD83C\uDFB9\uD83D\uDC3A\uD83D\uDC79\uD83C\uDF77\uD83D\uDC3B\uD83D\uDEAB\uD83D\uDE92\uD83D\uDCB3\uD83C\uDFAE\uD83D\uDD2A" -<<<<<<< HEAD - val mocked_hex = "5A4A0A4F7427E33469858088838A721FE1560C316F09C55A8EA6388FFBF1C152DA" - - val mocked_zero_emojiId = (0..25).map { "\uD83C\uDF00" }.joinToString("") - val mocked_zero_hex = TariWalletAddress.zero66Hex - - val mocked_wallet_address - get() = TariWalletAddress(mocked_hex, mocked_emojiId) - - val moched_zero_contact - get() = TariWalletAddress(mocked_zero_hex, mocked_zero_emojiId) - - val isChat = false -======= - val moched_hex = "5A4A0A4F7427E33469858088838A721FE1560C316F09C55A8EA6388FFBF1C152DA" - - val mocked_wallet_address - get() = TariWalletAddress(moched_hex, mocked_emojiId) ->>>>>>> cb06ea1bc7c0b86add6505cb8e8235be91f6dd50 -} \ No newline at end of file diff --git a/app/src/main/java/com/tari/android/wallet/util/TariUtil.kt b/app/src/main/java/com/tari/android/wallet/util/TariUtil.kt new file mode 100644 index 000000000..a6ddc6379 --- /dev/null +++ b/app/src/main/java/com/tari/android/wallet/util/TariUtil.kt @@ -0,0 +1,5 @@ +package com.tari.android.wallet.util + +import java.math.BigInteger + +fun String?.parseToBigInteger(): BigInteger = runCatching { BigInteger(this) }.getOrNull() ?: BigInteger.ZERO \ No newline at end of file diff --git a/build.gradle b/build.gradle index 944b0cf26..21c410b1e 100644 --- a/build.gradle +++ b/build.gradle @@ -6,8 +6,8 @@ buildscript { ext.lifecycle_version = '2.6.2' // build & version - ext.buildNumber = 274 - ext.versionNumber = "0.24.0" + ext.buildNumber = 279 + ext.versionNumber = "0.24.1" // JNI libs ext.libwalletHostURL = "https://github.com/tari-project/tari/releases/download/" diff --git a/docs/tari.md b/docs/tari.md new file mode 100644 index 000000000..c13428dae --- /dev/null +++ b/docs/tari.md @@ -0,0 +1,101 @@ +# Build system +Expect standart android system we have script `downloadLibwallet` which downloading ffi side from github release page to local. It will appear in `libwallet` folder. It downloading `wallet.h` and `libminotari_wallet_ffi.a` for each architecture. +If you want to test some local build you should turn off this download and put files manually + +versionNumber is version of our app. It should be aligned with iOS version +buildNumber is build version, it should be incremented manually before the release +libwalletVersion is ffi version. It should be updated after ffi update and have release on tari github page + + + + + +# FFI integration +FFI written in Rust and built for android for diffrent architectures. We supported only arm64-v8a and x86_64 which is actual devices. Emulator has a diffrent and we stopped maintain it during 2023 year. +FFI lib files should be placed in right folder with rigth names. Now it's +libwallet/wallet.h +libwallet/arm64-v8a/libminotari_wallet_ffi.a +libwallet/x86_64/libminotari_wallet_ffi.a +Cmake files which build it very strict about it +Also for right functuoning it should contains +* `libcrypto.a` - ssl +* libsqlite3.a - sqlLite +* libssl.a - ssl +If you need to update it then ssl located here: +https://github.com/217heidai/openssl_for_android/releases + + + + + +# FFI Wrapper +We have 2 wrappers, in C++ and in kotlin +For C++ you should go to `\app\src\main\cpp` +It has CMake file which is responsible for C++ build. If you adding new cpp file you should include it to build list in this file +C++ files contains code for method injection from native code which descirbed in `wallet.h` +You should name methods like this +`Java_com_tari_android_wallet_ffi_FFIContacts_jniGetLength` +whele `Java_com_tari_android_wallet_ffi` is path, `FFIContacts` is kotlin wrapper file and `jniGetLength` experted method. +Inside methods you should use methods from `wallet.h` +jniCommon.cpp contains utils method for enligth work with C++ + +kotlin wrappers have `FFI` prefix. They should only contains logic related to wrapping entities and methods +`private external fun jniGetBalance(libError: FFIError): FFIPointer` +This is example of external method which connected to method in C++ wrapper +All FFI entities have pointer to C++ entity which is located in FFIBase + + + +# Wallet service + + + + + +# Yat integration +https://yat.fyi/ - sandbox +https://y.at/ - prod +https://github.com/yat-labs/yat-lib-android - yat lib +https://jitpack.io/#yat-labs/yat-lib-android - yat build +But last build was included manually because jitpack wont build for android 14. Needed to fix +In project for all interracition with Yat responsible `YatAdapter` +We have those features: +* Connecting existing Yat +* Showing connected Yat in wallet frament +* Searching wallet address by Yat via Yat lib + + + + +# BLE +Common: +Checking permissions for bluetooth_ and locations +Checking wheither bluetooth is turned on + +Then server: +* Searching for device with our service inside +* Needed RSSI < -55db, which is about 20cm +* Pair to this device +* Discovering our service in BLE protocol +* Searching for exact characteristics in that service. We have two for sharing and getting contact in BLE payment +* Then read or write by small chunks + +Then client: +* Creating service + both characteristics + callbacks +* Laucnching advetiser +* Waiting for connection + +For working with BLE we are using +https://github.com/weliem/blessed-android +It close to native but easier to use + + + + + +# Release policy + + + + +# Github policy \ No newline at end of file diff --git a/libwallet/arm64-v8a/libcrypto.a b/libwallet/arm64-v8a/libcrypto.a index 9d6a48dcd..f166c68d8 100644 Binary files a/libwallet/arm64-v8a/libcrypto.a and b/libwallet/arm64-v8a/libcrypto.a differ diff --git a/libwallet/arm64-v8a/libssl.a b/libwallet/arm64-v8a/libssl.a index 74b01c4d5..1a4291bfb 100644 Binary files a/libwallet/arm64-v8a/libssl.a and b/libwallet/arm64-v8a/libssl.a differ diff --git a/libwallet/x86_64/libcrypto.a b/libwallet/x86_64/libcrypto.a index 1dc98673a..cd01fb3ba 100644 Binary files a/libwallet/x86_64/libcrypto.a and b/libwallet/x86_64/libcrypto.a differ diff --git a/libwallet/x86_64/libssl.a b/libwallet/x86_64/libssl.a index a2c386266..61341fbd3 100644 Binary files a/libwallet/x86_64/libssl.a and b/libwallet/x86_64/libssl.a differ