diff --git a/app/src/main/java/com/topjohnwu/magisk/Config.kt b/app/src/main/java/com/topjohnwu/magisk/Config.kt index 09c28fb45..27dce273d 100644 --- a/app/src/main/java/com/topjohnwu/magisk/Config.kt +++ b/app/src/main/java/com/topjohnwu/magisk/Config.kt @@ -121,6 +121,7 @@ object Config : PreferenceModel, DBConfig { var suReAuth by preference(Key.SU_REAUTH, false) var checkUpdate by preference(Key.CHECK_UPDATES, true) var magiskHide by preference(Key.MAGISKHIDE, true) + @JvmStatic var coreOnly by preference(Key.COREONLY, false) var showSystemApp by preference(Key.SHOW_SYSTEM_APP, false) diff --git a/app/src/main/java/com/topjohnwu/magisk/extensions/XAndroid.kt b/app/src/main/java/com/topjohnwu/magisk/extensions/XAndroid.kt index f166574b9..066f1835b 100644 --- a/app/src/main/java/com/topjohnwu/magisk/extensions/XAndroid.kt +++ b/app/src/main/java/com/topjohnwu/magisk/extensions/XAndroid.kt @@ -24,8 +24,10 @@ import com.topjohnwu.magisk.utils.DynamicClassLoader import com.topjohnwu.magisk.utils.FileProvider import com.topjohnwu.magisk.utils.Utils import com.topjohnwu.magisk.utils.currentLocale +import com.topjohnwu.superuser.ShellUtils import java.io.File import java.io.FileNotFoundException +import java.text.SimpleDateFormat import java.util.* val packageName: String get() = get().packageName @@ -280,4 +282,33 @@ fun Context.unwrap(): Context { fun Context.hasPermissions(vararg permissions: String) = permissions.all { ContextCompat.checkSelfPermission(this, it) == PERMISSION_GRANTED -} \ No newline at end of file +} + +private val securityLevelFormatter get() = SimpleDateFormat("yyyy-MM-dd", currentLocale) + +/** Friendly reminder to seek newer roms or install oem updates. */ +val isDeviceSecure: Boolean + get() { + val latestPermittedTime = Calendar.getInstance().apply { + time = securityLevelDate + add(Calendar.MONTH, 2) + }.time.time + return now in 0..latestPermittedTime + } +val securityLevelDate get() = securityLevelFormatter.parseOrNull(securityLevel) ?: Date(0) +val securityLevel + get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + Build.VERSION.SECURITY_PATCH + } else { + null + } ?: "1970-01-01" //never + +val isSAR + get() = ShellUtils + .fastCmd("grep_prop ro.build.system_root_image") + .let { it.isNotEmpty() && it.toBoolean() } + +val isAB + get() = ShellUtils + .fastCmd("grep_prop ro.build.ab_update") + .let { it.isNotEmpty() && it.toBoolean() } \ No newline at end of file diff --git a/app/src/main/java/com/topjohnwu/magisk/extensions/XJava.kt b/app/src/main/java/com/topjohnwu/magisk/extensions/XJava.kt index 1f8c7c007..51c55c048 100644 --- a/app/src/main/java/com/topjohnwu/magisk/extensions/XJava.kt +++ b/app/src/main/java/com/topjohnwu/magisk/extensions/XJava.kt @@ -3,9 +3,11 @@ package com.topjohnwu.magisk.extensions import android.net.Uri import android.os.Build import androidx.core.net.toFile +import timber.log.Timber import java.io.File import java.io.InputStream import java.io.OutputStream +import java.text.SimpleDateFormat import java.util.* import java.util.zip.ZipEntry import java.util.zip.ZipInputStream @@ -100,4 +102,7 @@ fun Locale.toLangTag(): String { tag.append('-').append(variant) return tag.toString() } -} \ No newline at end of file +} + +fun SimpleDateFormat.parseOrNull(date: String) = + runCatching { parse(date) }.onFailure { Timber.e(it) }.getOrNull() \ No newline at end of file diff --git a/app/src/main/java/com/topjohnwu/magisk/extensions/XSU.kt b/app/src/main/java/com/topjohnwu/magisk/extensions/XSU.kt index d60e9227a..1e5aef1d9 100644 --- a/app/src/main/java/com/topjohnwu/magisk/extensions/XSU.kt +++ b/app/src/main/java/com/topjohnwu/magisk/extensions/XSU.kt @@ -11,4 +11,6 @@ fun reboot(reason: String = if (Info.recovery) "recovery" else "") { } fun File.suOutputStream() = SuFileOutputStream(this) -fun File.suInputStream() = SuFileInputStream(this) \ No newline at end of file +fun File.suInputStream() = SuFileInputStream(this) + +val hasRoot get() = Shell.rootAccess() \ No newline at end of file diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt index 1105ff2ea..37cec4cb0 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt @@ -62,6 +62,7 @@ class HomeViewModel( val stateMagiskExpanded = KObservableField(false) val stateManagerExpanded = KObservableField(false) + val stateDeviceExpanded = KObservableField(false) val stateHideManagerName = R.string.manager.res().let { if (!statePackageOriginal) { diff --git a/app/src/main/res/drawable/ic_device.xml b/app/src/main/res/drawable/ic_device.xml new file mode 100644 index 000000000..5b90a6084 --- /dev/null +++ b/app/src/main/res/drawable/ic_device.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home_md2.xml b/app/src/main/res/layout/fragment_home_md2.xml index cfa5bb1af..2f45f806c 100644 --- a/app/src/main/res/layout/fragment_home_md2.xml +++ b/app/src/main/res/layout/fragment_home_md2.xml @@ -5,14 +5,22 @@ + + + + + + + + @@ -31,13 +39,204 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:clipToPadding="false" - android:orientation="vertical"> + android:orientation="vertical" + android:paddingTop="@dimen/l1"> + android:clipToPadding="false"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + app:layout_constraintTop_toBottomOf="@+id/home_device_wrapper" + app:layout_constraintWidth_max="200dp"> + + + + app:layout_constraintTop_toBottomOf="@+id/home_device_wrapper" + app:layout_constraintWidth_max="200dp"> + + Magisk System + Yes + No + No connection available Home @@ -28,6 +31,14 @@ Source XDA + Security + System + A/B + SAR + + Secure + Outdated + Version Code Mode