NTP-65561 | Sohan | Added device ram as an input parameter to Home pa… (#16248)

This commit is contained in:
Sohan Reddy Atukula
2025-05-22 15:28:56 +05:30
committed by GitHub
parent 36d65c9c61
commit 8aec31dd47
2 changed files with 19 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ import com.navi.common.network.models.ErrorMessage
import com.navi.common.network.models.GenericErrorResponse import com.navi.common.network.models.GenericErrorResponse
import com.navi.common.network.models.RepoResult import com.navi.common.network.models.RepoResult
import com.navi.common.network.models.isSuccessWithData import com.navi.common.network.models.isSuccessWithData
import com.navi.common.utils.getDeviceModelName
import com.naviapp.BuildConfig import com.naviapp.BuildConfig
import com.naviapp.app.NaviApplication import com.naviapp.app.NaviApplication
import com.naviapp.home.respository.HomeRepository import com.naviapp.home.respository.HomeRepository
@@ -39,6 +40,7 @@ constructor(
screenHash: String? = null, screenHash: String? = null,
naeScreenName: String, naeScreenName: String,
shouldShowNae: Boolean, shouldShowNae: Boolean,
totalRam: Double,
noInternetCallback: () -> Unit, noInternetCallback: () -> Unit,
onFailure: onFailure:
suspend (apiErrorMessage: ErrorMessage?, errors: List<GenericErrorResponse>?) -> Unit, suspend (apiErrorMessage: ErrorMessage?, errors: List<GenericErrorResponse>?) -> Unit,
@@ -82,7 +84,7 @@ constructor(
AlchemistScreenRequest( AlchemistScreenRequest(
screenName = HOME_SCREEN_IN_CAPS, screenName = HOME_SCREEN_IN_CAPS,
screenHash = screenHashForApi, screenHash = screenHashForApi,
inputMap = queryMap, inputMap = buildQueryMap(queryMap = queryMap, totalRam = totalRam),
), ),
naeScreenName = naeScreenName, naeScreenName = naeScreenName,
) )
@@ -144,8 +146,20 @@ constructor(
return NaviCacheAltSourceEntity(isSuccess = false) return NaviCacheAltSourceEntity(isSuccess = false)
} }
private fun buildQueryMap(
queryMap: HashMap<String, String>,
totalRam: Double,
): HashMap<String, String> {
queryMap[DEVICE_RAM_GB] = totalRam.toString()
val deviceName = getDeviceModelName()
queryMap[DEVICE_NAME] = deviceName.toString()
return queryMap
}
companion object { companion object {
const val SCREEN_STRUCTURE_AND_META_DATA_NULL = const val SCREEN_STRUCTURE_AND_META_DATA_NULL =
"Both screen structure and meta data is null" "Both screen structure and meta data is null"
const val DEVICE_RAM_GB = "deviceRamGb"
const val DEVICE_NAME = "deviceName"
} }
} }

View File

@@ -65,6 +65,7 @@ import com.naviapp.utils.Constants.HomePageConstants.FETCH_HOME_ITEMS_TIMEOUT
import com.naviapp.utils.SelectiveRefreshHandler import com.naviapp.utils.SelectiveRefreshHandler
import dagger.Lazy import dagger.Lazy
import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject import javax.inject.Inject
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
@@ -94,6 +95,7 @@ constructor(
val sectionVisibilityTracker: HomePageSectionImpressionTracker, val sectionVisibilityTracker: HomePageSectionImpressionTracker,
val postRenderTaskExecutor: PostRenderTaskExecutor, val postRenderTaskExecutor: PostRenderTaskExecutor,
private val homeContentProcessingUseCase: HomeContentProcessingUseCase, private val homeContentProcessingUseCase: HomeContentProcessingUseCase,
@ApplicationContext val context: Context,
) : ) :
BaseMviViewModel<HpStates, HpEvents, HpEffects>( BaseMviViewModel<HpStates, HpEvents, HpEffects>(
initialState = HpStates(), initialState = HpStates(),
@@ -105,6 +107,7 @@ constructor(
private var analyticsStartTs = System.currentTimeMillis() private var analyticsStartTs = System.currentTimeMillis()
private var isHomeUIRenderedEventLogged = false private var isHomeUIRenderedEventLogged = false
var isErrorNaeTriggered = false var isErrorNaeTriggered = false
private val totalRamMemory = getTotalRamMemory(context = context)?.toDoubleOrNull() ?: 100.0
// Internet Connectivity // Internet Connectivity
private val _internetConnectivity = MutableSharedFlow<ConnectivityObserver.Status>() private val _internetConnectivity = MutableSharedFlow<ConnectivityObserver.Status>()
@@ -201,6 +204,7 @@ constructor(
screenHash = screenHash, screenHash = screenHash,
shouldShowNae = shouldShowNae.orFalse(), shouldShowNae = shouldShowNae.orFalse(),
naeScreenName = naeScreenName, naeScreenName = naeScreenName,
totalRam = totalRamMemory,
onFailure = { errorMessage, errors -> onFailure = { errorMessage, errors ->
setEffect { HpEffects.OnApiFailure(errorMessage, errors) } setEffect { HpEffects.OnApiFailure(errorMessage, errors) }
}, },