Skip to content

Commit

Permalink
refactor se bypass detect
Browse files Browse the repository at this point in the history
  • Loading branch information
septs committed Mar 6, 2024
1 parent 9e45e97 commit fe3553f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
9 changes: 4 additions & 5 deletions app/src/main/java/app/septs/euiccprobe/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ class MainActivity : AppCompatActivity() {
appendLine()
appendLine("eUICC System Service: $state")
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val state = SystemService.getSEBypassState(applicationContext)
appendLine()
appendLine("Secure Elements: $state")
}
SystemService.getSystemFeatures(applicationContext).let {
appendLine()
appendLine("System Features:")
Expand Down Expand Up @@ -103,6 +98,10 @@ class MainActivity : AppCompatActivity() {
appendLine("Open Mobile API:")
appendLine("- Backend: ${result.backend}")
appendLine("- State: ${result.state}")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val state = OpenMobileAPI.getBypassState(applicationContext)
appendLine("- Bypass: $state")
}
if (result.state == OpenMobileAPI.State.Available) {
for (slot in result.slots) {
val state = if (slot.value) "Available" else "Unavailable"
Expand Down
25 changes: 25 additions & 0 deletions app/src/main/java/app/septs/euiccprobe/OpenMobileAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@ object OpenMobileAPI {
Available,
}


enum class SEBypass {
Unavailable,
CannotBeBypassed,
CanBeBypassed,
FullAccess,
}

@RequiresApi(Build.VERSION_CODES.P)
fun getBypassState(context: Context): SEBypass {
val pkgName = "com.android.se"
if (!SystemService.hasService(context, pkgName)) {
return SEBypass.Unavailable
}
if (SystemProperties.get("ro.debuggable")?.toInt() != 1) {
return SEBypass.CannotBeBypassed
}
val rule = SystemProperties.get("service.seek")
?: SystemProperties.get("persist.service.seek")
if (rule.orEmpty().contains("fullaccess")) {
return SEBypass.FullAccess
}
return SEBypass.CanBeBypassed
}

suspend fun getSlots(context: Context): Result {
val result = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
fromBuiltin(context)
Expand Down
24 changes: 0 additions & 24 deletions app/src/main/java/app/septs/euiccprobe/SystemService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,6 @@ object SystemService {
Disabled,
}

enum class SEBypass {
Unsupported,
CannotBeBypassed,
CanBeBypassed,
FullAccess,
}

@RequiresApi(Build.VERSION_CODES.P)
fun getSEBypassState(context: Context): SEBypass {
val pkgName = "com.android.se"
if (!hasService(context, pkgName)) {
return SEBypass.Unsupported
}
if (SystemProperties.get("ro.debuggable")?.toInt() != 1) {
return SEBypass.CannotBeBypassed
}
val rule = SystemProperties.get("service.seek")
?: SystemProperties.get("persist.service.seek")
if (rule.orEmpty().contains("fullaccess")) {
return SEBypass.FullAccess
}
return SEBypass.CanBeBypassed
}

fun getSystemFeatures(context: Context): Map<String, Boolean> {
val features = arrayOf(
"android.hardware.telephony",
Expand Down

0 comments on commit fe3553f

Please sign in to comment.