Skip to content

Commit

Permalink
Base: add support for Build.VERSION.DEVICE_INITIAL_SDK_INT to profile…
Browse files Browse the repository at this point in the history
… manager
  • Loading branch information
mar-v-in committed Aug 11, 2023
1 parent d48238d commit 2d13959
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ object Build {

@JvmField
var SECURITY_PATCH: String? = null

@JvmField
var DEVICE_INITIAL_SDK_INT: Int = 0
}

fun generateWebViewUserAgentString(original: String): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ object ProfileManager {
return serial
}

@SuppressLint("BlockedPrivateApi")
private fun getRealData(): Map<String, String> = mutableMapOf(
"Build.BOARD" to android.os.Build.BOARD,
"Build.BOOTLOADER" to android.os.Build.BOOTLOADER,
Expand Down Expand Up @@ -235,6 +236,12 @@ object ProfileManager {
if (android.os.Build.VERSION.SDK_INT >= 23) {
put("Build.VERSION.SECURITY_PATCH", android.os.Build.VERSION.SECURITY_PATCH)
}
try {
val field = android.os.Build.VERSION::class.java.getDeclaredField("DEVICE_INITIAL_SDK_INT")
field.isAccessible = true
put("Build.VERSION.DEVICE_INITIAL_SDK_INT", field.getInt(null).toString())

This comment has been minimized.

Copy link
@ale5000-git

This comment has been minimized.

Copy link
@mar-v-in

mar-v-in Aug 13, 2023

Author Member

FIRST_SDK_INT is a Test-only API, that should not be used anywhere, not even in system code. DEVICE_INITIAL_SDK_INT is reachable for system apps.
That said, the code added here isn't used yet, I was only preparing for future compatibility.

} catch (ignored: Exception) {
}
}

private fun applyProfileData(profileData: Map<String, String>) {
Expand Down Expand Up @@ -267,6 +274,7 @@ object ProfileManager {
applyStringField("Build.VERSION.RELEASE") { Build.VERSION.RELEASE = it }
applyStringField("Build.VERSION.SDK") { Build.VERSION.SDK = it }
applyIntField("Build.VERSION.SDK_INT") { Build.VERSION.SDK_INT = it }
applyIntField("Build.VERSION.DEVICE_INITIAL_SDK_INT") { Build.VERSION.DEVICE_INITIAL_SDK_INT = it }
if (android.os.Build.VERSION.SDK_INT >= 21) {
Build.SUPPORTED_ABIS = profileData["Build.SUPPORTED_ABIS"]?.split(",")?.toTypedArray() ?: emptyArray()
} else {
Expand Down

0 comments on commit 2d13959

Please sign in to comment.