Better handling of data encryption

This commit is contained in:
topjohnwu 2020-09-28 04:45:56 -07:00
parent 9bebe07d5a
commit 46de1ed968
6 changed files with 10 additions and 10 deletions

View File

@ -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 ->

View File

@ -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

View File

@ -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}"

View File

@ -208,7 +208,7 @@
<TextView
style="@style/W.Home.ItemContent.Right"
android:text="@{Info.crypto}"
android:text="@{Info.cryptoText}"
tools:text="N/A" />
</LinearLayout>

View File

@ -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)

View File

@ -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