NTP-78114 | Added device list check for touch disable (#16846)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user