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

Commit 9c5eb4b4 authored by d34d's avatar d34d Committed by Gerrit Code Review
Browse files

Keyguard: Don't show keyguard if CryptKeeper enabled

Some devices are exhibiting an issue where the keyguard will be
shown on top of the decrypt device screen when they have their
sim locked.  When this occurs, the user is not able to enter their
pin/password to decrypt the device even after the keyguard is
dismissed.

Change-Id: I7362b77a6ea2ec41c8835ae763ce427c12c02138
REF: CYNGNOS-299
(cherry picked from commit 345bb384)
parent b93e46d0
Loading
Loading
Loading
Loading
+25 −0
Original line number Original line Diff line number Diff line
@@ -29,10 +29,12 @@ import android.app.StatusBarManager;
import android.app.admin.DevicePolicyManager;
import android.app.admin.DevicePolicyManager;
import android.app.trust.TrustManager;
import android.app.trust.TrustManager;
import android.content.BroadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.content.pm.UserInfo;
import android.media.AudioManager;
import android.media.AudioManager;
import android.media.SoundPool;
import android.media.SoundPool;
@@ -143,6 +145,9 @@ public class KeyguardViewMediator extends SystemUI {
            "com.android.internal.action.KEYGUARD_SERVICE_STATE_CHANGED";
            "com.android.internal.action.KEYGUARD_SERVICE_STATE_CHANGED";
    private static final String KEYGUARD_SERVICE_EXTRA_ACTIVE = "active";
    private static final String KEYGUARD_SERVICE_EXTRA_ACTIVE = "active";


    private static final String SETTINGS_PACKAGE = "com.android.settings";
    private static final String CRYPT_KEEPER_ACTIVITY = SETTINGS_PACKAGE + ".CryptKeeper";

    // used for handler messages
    // used for handler messages
    private static final int SHOW = 2;
    private static final int SHOW = 2;
    private static final int HIDE = 3;
    private static final int HIDE = 3;
@@ -326,6 +331,8 @@ public class KeyguardViewMediator extends SystemUI {


    private final ArrayList<IKeyguardStateCallback> mKeyguardStateCallbacks = new ArrayList<>();
    private final ArrayList<IKeyguardStateCallback> mKeyguardStateCallbacks = new ArrayList<>();


    private int mCyrptKeeperEnabledState = -1;

    KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {
    KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {


        @Override
        @Override
@@ -800,6 +807,16 @@ public class KeyguardViewMediator extends SystemUI {
        return false;
        return false;
    }
    }


    private boolean isCryptKeeperEnabled() {
        if (mCyrptKeeperEnabledState == -1) {
            PackageManager pm = mContext.getPackageManager();
            mCyrptKeeperEnabledState = pm.getComponentEnabledSetting(
                    new ComponentName(SETTINGS_PACKAGE, CRYPT_KEEPER_ACTIVITY));
        }

        return mCyrptKeeperEnabledState != PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
    }

    public boolean isKeyguardBound() {
    public boolean isKeyguardBound() {
        return mKeyguardBound;
        return mKeyguardBound;
    }
    }
@@ -1049,6 +1066,14 @@ public class KeyguardViewMediator extends SystemUI {
            return;
            return;
        }
        }


        // Ugly hack to ensure keyguard is not shown on top of the CryptKeeper which prevents
        // a user from being able to decrypt their device.
        if (isCryptKeeperEnabled()) {
            if (DEBUG) Log.d(TAG, "doKeyguard: not showing because CryptKeeper is enabled");
            resetStateLocked();
            return;
        }

        // if the setup wizard hasn't run yet, don't show
        // if the setup wizard hasn't run yet, don't show
        final boolean requireSim = !SystemProperties.getBoolean("keyguard.no_require_sim",
        final boolean requireSim = !SystemProperties.getBoolean("keyguard.no_require_sim",
                false);
                false);