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

Commit 5fda2d4d authored by DvTonder's avatar DvTonder
Browse files

Framework: Forward port the ability to enable/disable keyguard with Profiles

This commit adds a few missing pieces needed to support the bypassing of the
keyguard via a profile

Change-Id: I557b80e6de62687b05c434a31083c331127a0398
parent 58e2ba85
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import android.app.Activity;
import android.app.ActivityManagerNative;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.Profile;
import android.app.ProfileManager;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
@@ -243,6 +245,8 @@ public class KeyguardViewMediator {
    private int mUnlockSoundId;
    private int mLockSoundStreamId;

    private ProfileManager mProfileManager;

    /**
     * The volume applied to the lock/unlock sounds.
     */
@@ -494,6 +498,8 @@ public class KeyguardViewMediator {
        mKeyguardViewManager = new KeyguardViewManager(context, wm, mViewMediatorCallback,
                mLockPatternUtils);

        mProfileManager = (ProfileManager) context.getSystemService(Context.PROFILE_SERVICE);

        mUserPresentIntent = new Intent(Intent.ACTION_USER_PRESENT);
        mUserPresentIntent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING
                | Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
@@ -887,6 +893,16 @@ public class KeyguardViewMediator {
            return;
        }

        // if the current profile has disabled us, don't show
        Profile profile = mProfileManager.getActiveProfile();
        if (profile != null) {
            if (!lockedOrMissing
                    && profile.getScreenLockMode() == Profile.LockMode.DISABLE) {
                if (DEBUG) Log.d(TAG, "doKeyguard: not showing because of profile override");
                return;
            }
        }

        if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen");
        showLocked(options);
    }