Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d33079d5 authored by Amir Samuelov's avatar Amir Samuelov Committed by Gerrit - the friendly Code Review server
Browse files

packages: settings: CryptKeeper: Disable FDE if PFE activated

Don't allow Full-Disk-Encryption (FDE) after Per-File-Encryption (PFE)

Change-Id: I5ed46d4362f6536a6cf526aa5bf4bac4610c47b6
parent 7286f3fc
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.content.IntentFilter;
import android.content.res.Resources;
import android.os.BatteryManager;
import android.os.Bundle;
import android.os.SystemProperties;
import android.os.storage.StorageManager;
import android.preference.Preference;
import android.text.TextUtils;
@@ -61,14 +62,15 @@ public class CryptKeeperSettings extends Fragment {
                final int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
                final int invalidCharger = intent.getIntExtra(
                    BatteryManager.EXTRA_INVALID_CHARGER, 0);

                final String pfeState = SystemProperties.get("vold.pfe");
                final boolean pfeActivated = "activated".equals(pfeState);
                final boolean levelOk = level >= MIN_BATTERY_LEVEL;
                final boolean pluggedOk =
                    ((plugged & BatteryManager.BATTERY_PLUGGED_ANY) != 0) &&
                     invalidCharger == 0;

                // Update UI elements based on power/battery status
                mInitiateButton.setEnabled(levelOk && pluggedOk);
                mInitiateButton.setEnabled(levelOk && pluggedOk && !pfeActivated);
                mPowerWarning.setVisibility(pluggedOk ? View.GONE : View.VISIBLE );
                mBatteryWarning.setVisibility(levelOk ? View.GONE : View.VISIBLE);
            }