NTP-50492 | Shiv natani | db and table clear on logout and silent notification (#15596)
Co-authored-by: Prakhar Saxena <prakhar.saxena@navi.com>
This commit is contained in:
@@ -50,6 +50,7 @@ import com.navi.common.utils.getSessionId
|
||||
import com.navi.common.utils.log
|
||||
import com.navi.common.utils.updateSessionId
|
||||
import com.navi.pay.common.setup.NaviPayManager
|
||||
import com.navi.payment.nativepayment.db.manager.PaymentDbManagerEntryPoint
|
||||
import com.navi.payment.razorpay.RazorpayHelper
|
||||
import com.naviapp.BuildConfig
|
||||
import com.naviapp.adverse.AdverseDependencyProvider
|
||||
@@ -59,6 +60,7 @@ import com.naviapp.app.initializers.ApplicationComponent.applicationScope
|
||||
import com.naviapp.common.helper.UpiSdkHelperImpl
|
||||
import com.naviapp.common.navigator.NaviDeepLinkNavigator
|
||||
import com.naviapp.utils.getVersionCode
|
||||
import dagger.hilt.android.EntryPointAccessors
|
||||
import io.branch.referral.Branch
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
@@ -184,6 +186,13 @@ object NaviSDKHelper {
|
||||
NaviApplication.instance.naviBbpsManager.get().onLogout()
|
||||
NaviApplication.instance.notificationManager.get().logout()
|
||||
NaviApplication.instance.mmLibManager.get().clearMoneyManagerData()
|
||||
|
||||
val paymentDbManager =
|
||||
EntryPointAccessors.fromApplication(
|
||||
context = context,
|
||||
PaymentDbManagerEntryPoint::class.java,
|
||||
)
|
||||
paymentDbManager.getPaymentDbManager().onAppLogout()
|
||||
}
|
||||
|
||||
fun setLocation(latitude: Double, longitude: Double) {
|
||||
|
||||
@@ -18,6 +18,8 @@ import com.navi.common.model.ModuleNameV2
|
||||
import com.navi.common.utils.log
|
||||
import com.navi.pay.db.cleaner.NaviPayModuleDatabaseCleaner
|
||||
import com.navi.pay.db.cleaner.NaviPayModuleTableCleaner
|
||||
import com.navi.payment.nativepayment.db.cleaner.NaviPaymentModuleDatabaseCleaner
|
||||
import com.navi.payment.nativepayment.db.cleaner.NaviPaymentModuleTableCleaner
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -32,6 +34,8 @@ constructor(
|
||||
private val bbpsModuleTableCleaner: BbpsModuleTableCleaner,
|
||||
private val naviPayModuleDatabaseCleaner: NaviPayModuleDatabaseCleaner,
|
||||
private val naviPayModuleTableCleaner: NaviPayModuleTableCleaner,
|
||||
private val naviPaymentModuleDatabaseCleaner: NaviPaymentModuleDatabaseCleaner,
|
||||
private val naviPaymentModuleTableCleaner: NaviPaymentModuleTableCleaner,
|
||||
) : ModuleDatabaseCleanerExecutor {
|
||||
private val exceptionHandler = CoroutineExceptionHandler { _, exception -> exception.log() }
|
||||
private val coroutineScope: CoroutineScope =
|
||||
@@ -77,6 +81,7 @@ constructor(
|
||||
return when (moduleName) {
|
||||
ModuleNameV2.BBPS.name -> bbpsModuleDatabaseCleaner
|
||||
ModuleNameV2.NAVIPAY.name -> naviPayModuleDatabaseCleaner
|
||||
ModuleNameV2.PG.name -> naviPaymentModuleDatabaseCleaner
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
@@ -85,6 +90,7 @@ constructor(
|
||||
return when (moduleName) {
|
||||
ModuleNameV2.BBPS.name -> bbpsModuleTableCleaner
|
||||
ModuleNameV2.NAVIPAY.name -> naviPayModuleTableCleaner
|
||||
ModuleNameV2.PG.name -> naviPaymentModuleTableCleaner
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright © 2025 by Navi Technologies Limited
|
||||
* * All rights reserved. Strictly confidential
|
||||
*
|
||||
*/
|
||||
|
||||
package com.navi.payment.nativepayment.db.cleaner
|
||||
|
||||
import com.navi.common.dbcleaner.NaviModuleDatabaseCleaner
|
||||
import com.navi.common.utils.log
|
||||
import com.navi.payment.nativepayment.db.NaviPaymentAppDatabase
|
||||
import com.navi.payment.nativepayment.db.NaviPaymentAppDatabase.Companion.NAVI_PAYMENT_DATABASE_NAME
|
||||
import javax.inject.Inject
|
||||
|
||||
class NaviPaymentModuleDatabaseCleaner
|
||||
@Inject
|
||||
constructor(private val naviPaymentAppDatabase: NaviPaymentAppDatabase) :
|
||||
NaviModuleDatabaseCleaner {
|
||||
override suspend fun cleanDatabase(dbName: String) {
|
||||
when (dbName) {
|
||||
NAVI_PAYMENT_DATABASE_NAME -> {
|
||||
runWithCatching { naviPaymentAppDatabase.clearAllTables() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun runWithCatching(block: suspend () -> Unit) {
|
||||
runCatching { block() }.onFailure { it.log() }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright © 2025 by Navi Technologies Limited
|
||||
* * All rights reserved. Strictly confidential
|
||||
*
|
||||
*/
|
||||
|
||||
package com.navi.payment.nativepayment.db.cleaner
|
||||
|
||||
import com.navi.common.dbcleaner.NaviModuleTableCleaner
|
||||
import com.navi.common.utils.log
|
||||
import com.navi.payment.nativepayment.db.NaviPaymentAppDatabase
|
||||
import javax.inject.Inject
|
||||
|
||||
class NaviPaymentModuleTableCleaner
|
||||
@Inject
|
||||
constructor(private val naviPaymentAppDatabase: NaviPaymentAppDatabase) : NaviModuleTableCleaner {
|
||||
override suspend fun cleanTable(tableName: String) {
|
||||
when (tableName) {
|
||||
NaviPaymentAppDatabase.TRANSACTION_STATUS_REQUEST_TABLE -> {
|
||||
runWithCatching { naviPaymentAppDatabase.transactionStatusRequestDao().deleteAll() }
|
||||
}
|
||||
NaviPaymentAppDatabase.BANKS_TABLE -> {
|
||||
runWithCatching { naviPaymentAppDatabase.bankListDao().deleteAll() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun cleanTableRows(tableName: String, keys: List<String>, columnName: String) {
|
||||
// Will be implemented in future, if required
|
||||
}
|
||||
|
||||
private suspend fun runWithCatching(block: suspend () -> Unit) {
|
||||
runCatching { block() }.onFailure { it.log() }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright © 2025 by Navi Technologies Limited
|
||||
* * All rights reserved. Strictly confidential
|
||||
*
|
||||
*/
|
||||
|
||||
package com.navi.payment.nativepayment.db.manager
|
||||
|
||||
import com.navi.common.resourcemanager.manager.ResourceManager.exceptionHandler
|
||||
import com.navi.payment.nativepayment.db.NaviPaymentAppDatabase
|
||||
import dagger.hilt.EntryPoint
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@EntryPoint
|
||||
@InstallIn(SingletonComponent::class)
|
||||
interface PaymentDbManagerEntryPoint {
|
||||
fun getPaymentDbManager(): PaymentDbManager
|
||||
}
|
||||
|
||||
@Singleton
|
||||
class PaymentDbManager
|
||||
@Inject
|
||||
constructor(private val naviPaymentAppDatabase: NaviPaymentAppDatabase) {
|
||||
fun onAppLogout() {
|
||||
CoroutineScope(Dispatchers.IO + exceptionHandler).launch {
|
||||
naviPaymentAppDatabase.clearAllTables()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user