Add Sandbox Routing Key (#8498)
This commit is contained in:
@@ -34,7 +34,8 @@ class NaviConfigurationActivity : ComponentActivity() {
|
||||
onVersionCodeChange = { BaseUtils.saveUpdatedVersionCodeAndRestart(it, this) },
|
||||
onBaseUrlChanged = { BaseUtils.saveUpdatedBaseUrlAndRestart(it, this) },
|
||||
onBackButtonClick = { finish() },
|
||||
onEnterApJourneyClicked = ::onEnterApJourneyClicked
|
||||
onEnterApJourneyClicked = ::onEnterApJourneyClicked,
|
||||
onRoutingKeyChange = { BaseUtils.saveRoutingKeyAndRestart(it, this) }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -58,22 +59,19 @@ class NaviConfigurationActivity : ComponentActivity() {
|
||||
}
|
||||
|
||||
private fun onEnterApJourneyClicked(applicationType: String?) {
|
||||
DeepLinkManager.getDeepLinkListener()?.navigateTo(
|
||||
activity = this@NaviConfigurationActivity,
|
||||
ctaData = CtaData(
|
||||
url = "applicationPlatform/launch",
|
||||
parameters = listOf(
|
||||
LineItem(
|
||||
"applicantType",
|
||||
"CUSTOMER"
|
||||
DeepLinkManager.getDeepLinkListener()
|
||||
?.navigateTo(
|
||||
activity = this@NaviConfigurationActivity,
|
||||
ctaData =
|
||||
CtaData(
|
||||
url = "applicationPlatform/launch",
|
||||
parameters =
|
||||
listOf(
|
||||
LineItem(key = "applicantType", value = "CUSTOMER"),
|
||||
LineItem(key = "applicationType", value = applicationType)
|
||||
)
|
||||
),
|
||||
LineItem(
|
||||
"applicationType",
|
||||
applicationType
|
||||
)
|
||||
)
|
||||
),
|
||||
finish = true
|
||||
)
|
||||
finish = true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,11 +33,13 @@ fun NaviConfigurationScreen(
|
||||
onVersionCodeChange: (versionCode: String) -> Unit,
|
||||
onBaseUrlChanged: (baseUrl: String) -> Unit,
|
||||
onBackButtonClick: () -> Unit,
|
||||
onEnterApJourneyClicked : (applicationType : String?)-> Unit
|
||||
onEnterApJourneyClicked: (applicationType: String?) -> Unit,
|
||||
onRoutingKeyChange: (routingKey: String) -> Unit
|
||||
) {
|
||||
var versionCode by remember { mutableStateOf(TextFieldValue(EMPTY)) }
|
||||
var baseUrl by remember { mutableStateOf(TextFieldValue(EMPTY)) }
|
||||
var applicationType by remember { mutableStateOf(TextFieldValue(EMPTY)) }
|
||||
var routingKey by remember { mutableStateOf(TextFieldValue(EMPTY)) }
|
||||
|
||||
Column {
|
||||
NaviTopNavigationBar(onBackButtonClick = onBackButtonClick)
|
||||
@@ -90,6 +92,16 @@ fun NaviConfigurationScreen(
|
||||
onButtonClick = { onEnterApJourneyClicked(applicationType.text) },
|
||||
)
|
||||
|
||||
NaviTextFieldWithTitleAndButton(
|
||||
titleText = "Sandbox Routing Key",
|
||||
placeholderText = "Enter sandbox routing key",
|
||||
keyboardType = KeyboardType.Uri,
|
||||
inputText = routingKey,
|
||||
onTextValueChanged = { routingKey = it },
|
||||
buttonText = "Update",
|
||||
onButtonClick = { onRoutingKeyChange(routingKey.text) },
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
}
|
||||
}
|
||||
@@ -106,6 +118,7 @@ private fun NaviConfigurationScreenPreview() {
|
||||
onVersionCodeChange = {},
|
||||
onBaseUrlChanged = {},
|
||||
onBackButtonClick = {},
|
||||
onEnterApJourneyClicked = {}
|
||||
onEnterApJourneyClicked = {},
|
||||
onRoutingKeyChange = {}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ object CommonPrefConstants {
|
||||
const val IS_MOCK_LOCATION = "IS_MOCK_LOCATION"
|
||||
const val IS_LOCATION_DATA_POST = "IS_LOCATION_DATA_POST"
|
||||
const val LOCATION_UPDATE_ENABLED = "LOCATION_UPDATE_ENABLED"
|
||||
const val CURRENT_FONT = "CURRENT_FONT"
|
||||
const val UPDATED_BASE_URL = "updatedBaseUrl"
|
||||
const val UPDATED_VERSION_CODE = "updatedVersionCode"
|
||||
const val ROUTING_KEY = "routing_key"
|
||||
const val APP_BASE_URL = "appBaseUrl"
|
||||
const val PULSE_BASE_URL = "pulseBaseUrl"
|
||||
const val UPDATED_PULSE_BASE_URL = "updatedPulseBaseUrl"
|
||||
|
||||
@@ -18,6 +18,7 @@ import android.os.Build
|
||||
import android.provider.Settings
|
||||
import com.navi.base.sharedpref.CommonPrefConstants
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.ALFRED_DIALOG_SCREENSHOT
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.ROUTING_KEY
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.UPDATED_BASE_URL
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.UPDATED_PULSE_BASE_URL
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.UPDATED_VERSION_CODE
|
||||
@@ -111,11 +112,9 @@ object BaseUtils {
|
||||
value
|
||||
)
|
||||
}
|
||||
|
||||
fun setBaseUrl(baseUrl: String) {
|
||||
PreferenceManager.setStringPreferenceApp(
|
||||
key = UPDATED_BASE_URL,
|
||||
baseUrl
|
||||
)
|
||||
PreferenceManager.setStringPreferenceApp(key = UPDATED_BASE_URL, baseUrl)
|
||||
}
|
||||
|
||||
fun getPhoneNumberWithCountryCode(): String? {
|
||||
@@ -413,7 +412,7 @@ object BaseUtils {
|
||||
}
|
||||
}
|
||||
|
||||
fun checkDiffAndSaveDataInSharedPreference(
|
||||
private fun checkDiffAndSaveDataInSharedPreference(
|
||||
sharedPrefKey: String,
|
||||
updatedValue: String?
|
||||
): Boolean {
|
||||
@@ -506,6 +505,21 @@ object BaseUtils {
|
||||
}
|
||||
}
|
||||
|
||||
fun saveRoutingKeyAndRestart(updatedRoutingKey: String?, context: Context?) {
|
||||
if (
|
||||
checkDiffAndSaveDataInSharedPreference(
|
||||
sharedPrefKey = ROUTING_KEY,
|
||||
updatedValue = updatedRoutingKey
|
||||
)
|
||||
) {
|
||||
triggerAppRestart(context = context)
|
||||
}
|
||||
}
|
||||
|
||||
fun getRoutingKey(): String? {
|
||||
return PreferenceManager.getStringPreferenceApp(ROUTING_KEY)
|
||||
}
|
||||
|
||||
fun getDebugVersionCode(): String? =
|
||||
PreferenceManager.getStringPreferenceApp(key = UPDATED_VERSION_CODE)
|
||||
|
||||
@@ -532,10 +546,10 @@ object BaseUtils {
|
||||
val packageManager = context.packageManager
|
||||
val requestedUpiAppPackageNames = mutableListOf<String>()
|
||||
packageManager?.let {
|
||||
val allUpiAppsPackageNames = packageManager.queryIntentActivities(
|
||||
upiIntent,
|
||||
PackageManager.GET_META_DATA
|
||||
).mapNotNull { it.activityInfo?.packageName }
|
||||
val allUpiAppsPackageNames =
|
||||
packageManager
|
||||
.queryIntentActivities(upiIntent, PackageManager.GET_META_DATA)
|
||||
.mapNotNull { it.activityInfo?.packageName }
|
||||
|
||||
allUpiAppsPackageNames.forEach { packageName ->
|
||||
if (exceptionUpiApps.contains(packageName).not()) {
|
||||
@@ -545,5 +559,4 @@ object BaseUtils {
|
||||
}
|
||||
return requestedUpiAppPackageNames.isNotEmpty()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.os.Build
|
||||
import com.navi.alfred.AlfredManager
|
||||
import com.navi.analytics.utils.NaviAnalyticsHelper
|
||||
import com.navi.base.security.interceptor.EncryptionHashInterceptor
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.ROUTING_KEY
|
||||
import com.navi.base.utils.BaseUtils
|
||||
import com.navi.base.utils.isDataNeedsToUpdate
|
||||
import com.navi.common.model.NetworkInfo
|
||||
@@ -35,15 +36,16 @@ abstract class BaseHttpClient(
|
||||
private val networkInfo: NetworkInfo,
|
||||
private val context: Context,
|
||||
private val shouldAddHeaders: Boolean = true,
|
||||
private val shouldAddAuthenticator : Boolean = true
|
||||
private val shouldAddAuthenticator: Boolean = true
|
||||
) {
|
||||
|
||||
companion object{
|
||||
companion object {
|
||||
const val HEADER_SESSION_TOKEN = "X-Session-Token"
|
||||
const val X_TARGET = "X-Target"
|
||||
const val APPREQUESTID = "appRequestId"
|
||||
const val CF_RAY = "CF_RAY"
|
||||
}
|
||||
|
||||
val baseHttpClientBuilder: OkHttpClient.Builder
|
||||
get() {
|
||||
val okHttpClientBuilder = OkHttpClient.Builder()
|
||||
@@ -62,9 +64,7 @@ abstract class BaseHttpClient(
|
||||
addInterceptor(GzipInterceptor())
|
||||
|
||||
getChildInterceptors()?.let { interceptors ->
|
||||
interceptors.forEach { interceptor ->
|
||||
addInterceptor(interceptor)
|
||||
}
|
||||
interceptors.forEach { interceptor -> addInterceptor(interceptor) }
|
||||
}
|
||||
|
||||
addInterceptor(MetricInterceptor())
|
||||
@@ -89,6 +89,7 @@ abstract class BaseHttpClient(
|
||||
addUnsafeNonAscii("defaultLocale", BaseUtils.getDefaultLocale())
|
||||
add("deviceId", BaseUtils.getDeviceId(context))
|
||||
add(APPREQUESTID, UUID.randomUUID().toString())
|
||||
BaseUtils.getRoutingKey()?.let { add(ROUTING_KEY, it) }
|
||||
BaseUtils.getSessionToken()?.let { add(HEADER_SESSION_TOKEN, it) }
|
||||
try {
|
||||
add("X-Click-Stream-Data", NaviAnalyticsHelper.getClickStreamData())
|
||||
@@ -96,17 +97,15 @@ abstract class BaseHttpClient(
|
||||
Timber.e(e)
|
||||
}
|
||||
networkInfo.moduleName?.name?.let { moduleName ->
|
||||
add(
|
||||
X_TARGET,
|
||||
moduleName
|
||||
)
|
||||
add(X_TARGET, moduleName)
|
||||
}
|
||||
// TODO should removed. GI Backend can use X-Target
|
||||
add("source", "APK")
|
||||
}
|
||||
}
|
||||
request = request.newBuilder().headers(builder.build()).build()
|
||||
if (isDataNeedsToUpdate(
|
||||
if (
|
||||
isDataNeedsToUpdate(
|
||||
request.method,
|
||||
request.url.toString(),
|
||||
networkInfo.moduleName?.name.orEmpty(),
|
||||
@@ -115,29 +114,32 @@ abstract class BaseHttpClient(
|
||||
) {
|
||||
TemporaryStorageHelper.updateScreenDataStatus()
|
||||
}
|
||||
val response: Response = try {
|
||||
chain.proceed(request).newBuilder().build()
|
||||
} catch (e: IOException) {
|
||||
val errorMessage = handleException(e)
|
||||
logIOException(e, errorMessage, request)
|
||||
// A mocked response in case of n/w exception
|
||||
val errorStatusCode: Int = errorMessage.statusCode ?: ApiConstants.API_CODE_ERROR
|
||||
Response.Builder()
|
||||
.request(request)
|
||||
.protocol(Protocol.HTTP_2)
|
||||
.code(errorStatusCode)
|
||||
.message(e.message.orEmpty())
|
||||
.body(ResponseBody.create("application/json".toMediaTypeOrNull(), "{}"))
|
||||
.addHeader("content-type", "application/json")
|
||||
.build()
|
||||
}
|
||||
val response: Response =
|
||||
try {
|
||||
chain.proceed(request).newBuilder().build()
|
||||
} catch (e: IOException) {
|
||||
val errorMessage = handleException(e)
|
||||
logIOException(e, errorMessage, request)
|
||||
// A mocked response in case of n/w exception
|
||||
val errorStatusCode: Int =
|
||||
errorMessage.statusCode ?: ApiConstants.API_CODE_ERROR
|
||||
Response.Builder()
|
||||
.request(request)
|
||||
.protocol(Protocol.HTTP_2)
|
||||
.code(errorStatusCode)
|
||||
.message(e.message.orEmpty())
|
||||
.body(ResponseBody.create("application/json".toMediaTypeOrNull(), "{}"))
|
||||
.addHeader("content-type", "application/json")
|
||||
.build()
|
||||
}
|
||||
val endTime = System.currentTimeMillis()
|
||||
val byteSent = request.body?.contentLength() ?: 0L
|
||||
val byteReceived = try {
|
||||
response.peekBody(Long.MAX_VALUE).bytes().size.toLong()
|
||||
} catch (e: Exception) {
|
||||
0L
|
||||
}
|
||||
val byteReceived =
|
||||
try {
|
||||
response.peekBody(Long.MAX_VALUE).bytes().size.toLong()
|
||||
} catch (e: Exception) {
|
||||
0L
|
||||
}
|
||||
AlfredManager.saveApiLog(
|
||||
byteReceived = byteReceived,
|
||||
byteSent = byteSent,
|
||||
|
||||
Reference in New Issue
Block a user