NTP-78114 | Added device list check for touch disable (#16846)

This commit is contained in:
Sanjay P
2025-07-04 18:28:14 +05:30
committed by GitHub
parent 9cbf2bc34a
commit 288dc076ad
2 changed files with 19 additions and 1 deletions

View File

@@ -9,6 +9,8 @@ package com.naviapp.home.usecase
import android.content.Context
import com.navi.common.firebaseremoteconfig.FirebaseRemoteConfigHelper
import com.navi.common.firebaseremoteconfig.FirebaseRemoteConfigHelper.TOUCH_DISABLED_DEVICE_LIST
import com.navi.common.utils.getDeviceModelName
import com.navi.common.utils.getTotalRamMemory
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
@@ -32,6 +34,8 @@ constructor(@ApplicationContext private val context: Context) {
*/
val deviceRamGb: Double by lazy { getTotalRamMemory(context)?.toDoubleOrNull() ?: 0.0 }
val deviceModel: String? by lazy { getDeviceModelName() }
/** Flag indicating if the device has lower RAM than the threshold defined in remote config. */
private val isRamBelowThreshold by lazy {
val maxRamThreshold =
@@ -62,9 +66,22 @@ constructor(@ApplicationContext private val context: Context) {
isDelayedRenderingFeatureEnabled && isRamBelowThreshold
}
/** Device list from Firebase Remote Config stored as JSON array. */
private val touchDisabledDeviceList: List<String> by lazy {
val devices = FirebaseRemoteConfigHelper.getString(TOUCH_DISABLED_DEVICE_LIST, "")
devices.split(",").map { it.trim() }.filter { it.isNotEmpty() }
}
/** Flag indicating if current device model is in the Firebase device list. */
private val isCurrentDeviceInList: Boolean by lazy {
deviceModel?.let { model ->
touchDisabledDeviceList.any { it.equals(model, ignoreCase = true) }
} ?: false
}
/** Cached result for initial touch disabled decision. */
private val _isInitialTouchDisabled by lazy {
isTouchDisabledFeatureEnabled && isRamBelowThreshold
(isTouchDisabledFeatureEnabled && isRamBelowThreshold) || isCurrentDeviceInList
}
/**

View File

@@ -259,6 +259,7 @@ object FirebaseRemoteConfigHelper {
const val DISABLE_INITIAL_TOUCH_EVENT = "DISABLE_INITIAL_TOUCH_EVENT"
const val DISABLE_INITIAL_TOUCH_EVENT_MAX_RAM = "DISABLE_INITIAL_TOUCH_EVENT_MAX_RAM"
const val TOUCH_DISABLED_DEVICE_LIST = "TOUCH_DISABLED_DEVICE_LIST"
// Api Retry constants
const val RETRY_INTERCEPTOR_ENABLED = "RETRY_INTERCEPTOR_ENABLED"