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

Commit a97412e4 authored by DvTonder's avatar DvTonder
Browse files

Framework: Restore Keyguard-obsolete to AOSP state

Some of the CM features code got merged into the obsolete keyguard
code, revert to pure AOSP state.

Change-Id: I6980f9254b49cf1208dd1536f625951d804445ae
parent 38328494
Loading
Loading
Loading
Loading
+11 −28
Original line number Diff line number Diff line
/*
 * Copyright (C) 2011 The Android Open Source Project
 * Copyright (C) 2012 The CyanogenMod Project (Weather, Calendar)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -17,17 +16,6 @@

package com.android.internal.policy.impl.keyguard_obsolete;

import android.content.ContentResolver;
import android.content.Context;
import android.provider.Settings;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.android.internal.R;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.widget.DigitalClock;
@@ -39,6 +27,17 @@ import java.util.Date;

import libcore.util.MutableInt;

import android.content.ContentResolver;
import android.content.Context;
import android.provider.Settings;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

/***
 * Manages a number of views inside of LockScreen layouts. See below for a list of widgets
 *
@@ -216,22 +215,6 @@ class KeyguardStatusViewManager implements OnClickListener {
        }
    }

    /**
     * Split the MultiSelectListPreference string based on a separator of ',' and
     * stripping off the start [ and the end ]
     * @param val
     * @return
     */
    private static String[] parseStoredValue(String val) {
        if (val == null || val.isEmpty())
            return null;
        else {
            // Strip off the start [ and the end ] before splitting
            val = val.substring(1, val.length() -1);
            return (val.split(","));
        }
    }

    private boolean inWidgetMode() {
        return mTransportView != null && mTransportView.getVisibility() == View.VISIBLE;
    }
+7 −44
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@ import com.android.internal.widget.LockPatternUtils;
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;
@@ -250,8 +248,6 @@ public class KeyguardViewMediator implements KeyguardViewCallback {
    private int mUnlockSoundId;
    private int mLockSoundStreamId;

    private ProfileManager mProfileManager;

    /**
     * The volume applied to the lock/unlock sounds.
     */
@@ -373,7 +369,6 @@ public class KeyguardViewMediator implements KeyguardViewCallback {
        mWakeAndHandOff.setReferenceCounted(false);

        mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(DELAYED_KEYGUARD_ACTION));
        mProfileManager = (ProfileManager) context.getSystemService(Context.PROFILE_SERVICE);

        mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

@@ -439,21 +434,11 @@ public class KeyguardViewMediator implements KeyguardViewCallback {
            mScreenOn = false;
            if (DEBUG) Log.d(TAG, "onScreenTurnedOff(" + why + ")");

            // Prepare for handling Lock/Slide lock delay and timeout
            boolean lockImmediately = false;
            final ContentResolver cr = mContext.getContentResolver();
            boolean separateSlideLockTimeoutEnabled = Settings.System.getInt(cr,
                    Settings.System.SCREEN_LOCK_SLIDE_DELAY_TOGGLE, 0) == 1;
            if (mLockPatternUtils.isSecure()) {
                // Lock immediately based on setting if secure (user has a pin/pattern/password)
                // This is retained as-is to ensue AOSP security integrity is maintained
                lockImmediately = mLockPatternUtils.getPowerButtonInstantlyLocks();
            } else {
                // Unless a separate slide lock timeout is enabled, this "locks" the device when
                // not secure to provide easy access to the camera while preventing unwanted input
                lockImmediately = separateSlideLockTimeoutEnabled ? false
                        : mLockPatternUtils.getPowerButtonInstantlyLocks();
            }
            // Lock immediately based on setting if secure (user has a pin/pattern/password).
            // This also "locks" the device when not secure to provide easy access to the
            // camera while preventing unwanted input.
            final boolean lockImmediately =
                mLockPatternUtils.getPowerButtonInstantlyLocks() || !mLockPatternUtils.isSecure();

            if (mExitSecureCallback != null) {
                if (DEBUG) Log.d(TAG, "pending exit secure callback cancelled");
@@ -472,6 +457,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback {
                // to enable it a little bit later (i.e, give the user a chance
                // to turn the screen back on within a certain window without
                // having to unlock the screen)
                final ContentResolver cr = mContext.getContentResolver();

                // From DisplaySettings
                long displayTimeout = Settings.System.getInt(cr, SCREEN_OFF_TIMEOUT,
@@ -482,33 +468,17 @@ public class KeyguardViewMediator implements KeyguardViewCallback {
                        Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT,
                        KEYGUARD_LOCK_AFTER_DELAY_DEFAULT);

                // From CyanogenMod specific Settings
                int slideLockTimeoutDelay = (why == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT ? Settings.System
                        .getInt(cr, Settings.System.SCREEN_LOCK_SLIDE_TIMEOUT_DELAY,
                                KEYGUARD_LOCK_AFTER_DELAY_DEFAULT) : Settings.System.getInt(cr,
                        Settings.System.SCREEN_LOCK_SLIDE_SCREENOFF_DELAY, 0));

                // From DevicePolicyAdmin
                final long policyTimeout = mLockPatternUtils.getDevicePolicyManager()
                        .getMaximumTimeToLock(null);

                if (DEBUG) Log.d(TAG, "Security lock screen timeout delay is " + lockAfterTimeout
                        + " ms; slide lock screen timeout delay is "
                        + slideLockTimeoutDelay
                        + " ms; Separate slide lock delay settings considered: "
                        + separateSlideLockTimeoutEnabled
                        + "; Policy timeout is "
                        + policyTimeout
                        + " ms");

                long timeout;
                if (policyTimeout > 0) {
                    // policy in effect. Make sure we don't go beyond policy limit.
                    displayTimeout = Math.max(displayTimeout, 0); // ignore negative values
                    timeout = Math.min(policyTimeout - displayTimeout, lockAfterTimeout);
                } else {
                    // Not sure lockAfterTimeout is needed any more but keeping it for AOSP compatibility
                    timeout = separateSlideLockTimeoutEnabled ? slideLockTimeoutDelay : lockAfterTimeout;
                    timeout = lockAfterTimeout;
                }

                if (timeout <= 0) {
@@ -738,13 +708,6 @@ public class KeyguardViewMediator implements KeyguardViewCallback {
            return;
        }

        // if the current profile has disabled us, don't show
        if (!lockedOrMissing
                && mProfileManager.getActiveProfile().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();
    }