File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
app/src/main/java/com/klee/sapio/data Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -42,10 +42,15 @@ class DeviceConfiguration @Inject constructor(
4242 }
4343
4444 fun isRisky (): Int {
45- return if (RootBeer (mContext).isRooted) {
45+ return if (RootBeer (mContext).isRooted && ! isBootloaderLocked() ) {
4646 Label .RISKY
4747 } else {
4848 Label .SECURE
4949 }
5050 }
51+
52+ private fun isBootloaderLocked (): Boolean {
53+ val verifiedBootState = SystemPropertyReader ().read(" ro.boot.verifiedbootstate" )
54+ return verifiedBootState == " yellow" || verifiedBootState == " green"
55+ }
5156}
Original file line number Diff line number Diff line change 1+ package com.klee.sapio.data
2+
3+ import android.annotation.SuppressLint
4+ import android.util.Log
5+
6+ @SuppressLint(" PrivateApi" )
7+ class SystemPropertyReader {
8+
9+ private val getMethod by lazy {
10+ val clazz = Class .forName(" android.os.SystemProperties" )
11+ clazz.getMethod(" get" , String ::class .java, String ::class .java)
12+ }
13+
14+ fun read (propertyName : String ): String {
15+ return try {
16+ val value = getMethod.invoke(null , propertyName, " " ) as String
17+ value.trim()
18+ } catch (exception: ReflectiveOperationException ) {
19+ Log .w(TAG , " Unable to read property $propertyName " , exception)
20+ " "
21+ } catch (exception: IllegalArgumentException ) {
22+ Log .w(TAG , " Invalid arguments supplied for $propertyName " , exception)
23+ " "
24+ }
25+ }
26+
27+ private companion object {
28+ private const val TAG = " SystemPropertyReader"
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments