Skip to content

refactor: deprecate redundant non-null on user agent#432

Open
yhkee0404 wants to merge 1 commit into
kyujin-cho:mainfrom
yhkee0404:nullable-user-agent
Open

refactor: deprecate redundant non-null on user agent#432
yhkee0404 wants to merge 1 commit into
kyujin-cho:mainfrom
yhkee0404:nullable-user-agent

Conversation

@yhkee0404
Copy link
Copy Markdown
Contributor

@yhkee0404 yhkee0404 commented Dec 13, 2025

Extends #73 that fixes #70 where getStringValue would have thrown NullPointerException because its return type String did not allow null which config.getString(key) could indeed return.

private fun getStringValue(key: String): String {
val subscriptionId = this.subscriptionId
if (subscriptionId < 0) {
return ""
}
val iCclInstance = this.loadCachedInterface { carrierConfigLoader }
val config = iCclInstance.getConfigForSubId(subscriptionId, iCclInstance.defaultCarrierServicePackageName)
return config.getString(key)
}

val userAgentConfig: String
get() = this.getStringValue(KEY_IMS_USER_AGENT)

configuredUserAgent = moder.userAgentConfig

var configuredUserAgent by rememberSaveable { mutableStateOf("") }

That is why this null check has been added since #73:

configuredUserAgent = try {
moder.userAgentConfig
} catch (e: java.lang.NullPointerException) {
null
}

var configuredUserAgent: String? by rememberSaveable { mutableStateOf("") }

However, it has become deprecated since #387 because getStringValue has started to prevent the exception by returning String? instead of just String with its null return being typecast into an empty string.

fun getStringValue(key: String): String? {

val userAgentConfig: String
get() = this.getStringValue(KEY_IMS_USER_AGENT) ?: ""

In fact, we do not even need the typecast as well if we also make userAgentConfig nullable as it has been allowed since #73.

var configuredUserAgent: String? by rememberSaveable { mutableStateOf("") }

You can download and test the built apk here but need to uninstall the previous release if any: https://github.com/yhkee0404/pixel-volte-patch/releases/tag/1.3.1_PR_426_430_431_432

@yhkee0404 yhkee0404 marked this pull request as ready for review December 13, 2025 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App crashes on OnePlus 7 Pro with Android 12

1 participant