From 46de1ed968244150fb69537b2b47dfc0db19453c Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 28 Sep 2020 04:45:56 -0700 Subject: [PATCH] Better handling of data encryption --- app/src/main/java/com/topjohnwu/magisk/core/Info.kt | 6 ++++-- .../com/topjohnwu/magisk/ui/install/InstallViewModel.kt | 2 +- app/src/main/res/layout/fragment_install_md2.xml | 2 +- app/src/main/res/layout/include_home_magisk.xml | 2 +- app/src/main/res/raw/manager.sh | 2 -- scripts/util_functions.sh | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/core/Info.kt b/app/src/main/java/com/topjohnwu/magisk/core/Info.kt index 9bc2913d1..1e1753c4a 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/Info.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/Info.kt @@ -11,6 +11,7 @@ import com.topjohnwu.superuser.ShellUtils.fastCmd import com.topjohnwu.superuser.internal.UiThreadHandler import java.io.FileInputStream import java.io.IOException +import java.util.* val isRunningAsStub get() = Info.stub != null @@ -27,13 +28,14 @@ object Info { var remote = UpdateInfo() // Device state + var crypto = "" @JvmStatic var isSAR = false @JvmStatic var isAB = false - @JvmStatic val isFBE get() = crypto == "file" + @JvmStatic val isFDE get() = crypto == "block" @JvmStatic var ramdisk = false @JvmStatic var hasGMS = true - @JvmStatic var crypto = "" @JvmStatic var isPixel = false + @JvmStatic val cryptoText get() = crypto.capitalize(Locale.US) val isConnected by lazy { ObservableBoolean(false).also { field -> diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt index 986fdc8e5..d33bf1baa 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt @@ -24,7 +24,7 @@ class InstallViewModel( ) : BaseViewModel(State.LOADED) { val isRooted = Shell.rootAccess() - val skipOptions = Info.ramdisk && Info.isFBE && Info.isSAR + val skipOptions = Info.ramdisk && !Info.isFDE && Info.isSAR @get:Bindable var step = if (skipOptions) 1 else 0 diff --git a/app/src/main/res/layout/fragment_install_md2.xml b/app/src/main/res/layout/fragment_install_md2.xml index 56216e9a7..74728c388 100644 --- a/app/src/main/res/layout/fragment_install_md2.xml +++ b/app/src/main/res/layout/fragment_install_md2.xml @@ -105,7 +105,7 @@ diff --git a/app/src/main/res/raw/manager.sh b/app/src/main/res/raw/manager.sh index ee2c33a0f..5372cc179 100644 --- a/app/src/main/res/raw/manager.sh +++ b/app/src/main/res/raw/manager.sh @@ -123,8 +123,6 @@ check_encryption() { if $ISENCRYPTED; then if [ $SDK_INT -lt 24 ]; then CRYPTOTYPE="block" - elif [ -d /data/unencrypted ]; then - CRYPTOTYPE="file" else # First see what the system tells us CRYPTOTYPE=$(getprop ro.crypto.type) diff --git a/scripts/util_functions.sh b/scripts/util_functions.sh index 0fb68492e..2491f3215 100644 --- a/scripts/util_functions.sh +++ b/scripts/util_functions.sh @@ -363,10 +363,10 @@ get_flags() { KEEPVERITY=false fi fi + ISENCRYPTED=false + grep ' /data ' /proc/mounts | grep -q 'dm-' && ISENCRYPTED=true + [ "$(getprop ro.crypto.state)" = "encrypted" ] && ISENCRYPTED=true if [ -z $KEEPFORCEENCRYPT ]; then - ISENCRYPTED=false - grep ' /data ' /proc/mounts | grep -q 'dm-' && ISENCRYPTED=true - [ -d /data/unencrypted ] && ISENCRYPTED=true # No data access means unable to decrypt in recovery if $ISENCRYPTED || ! $DATA; then KEEPFORCEENCRYPT=true