Commit 46de1ed9 authored by topjohnwu's avatar topjohnwu

Better handling of data encryption

parent 9bebe07d
......@@ -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 ->
......
......@@ -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
......
......@@ -105,7 +105,7 @@
<CheckBox
style="@style/WidgetFoundation.Checkbox"
gone="@{Info.isFBE}"
goneUnless="@{Info.isFDE}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="@={Config.keepEnc}"
......
......@@ -208,7 +208,7 @@
<TextView
style="@style/W.Home.ItemContent.Right"
android:text="@{Info.crypto}"
android:text="@{Info.cryptoText}"
tools:text="N/A" />
</LinearLayout>
......
......@@ -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)
......
......@@ -363,10 +363,10 @@ get_flags() {
KEEPVERITY=false
fi
fi
if [ -z $KEEPFORCEENCRYPT ]; then
ISENCRYPTED=false
grep ' /data ' /proc/mounts | grep -q 'dm-' && ISENCRYPTED=true
[ -d /data/unencrypted ] && ISENCRYPTED=true
[ "$(getprop ro.crypto.state)" = "encrypted" ] && ISENCRYPTED=true
if [ -z $KEEPFORCEENCRYPT ]; then
# No data access means unable to decrypt in recovery
if $ISENCRYPTED || ! $DATA; then
KEEPFORCEENCRYPT=true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment