28.9.13

PH for android



$ git status
# On branch lock-improve
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
#       modified:   policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       policy/src/com/android/internal/policy/impl/PH.java

$ git diff -c
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
index 42a1e78..f7f6759 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
@@ -1017,6 +1017,9 @@ public class KeyguardViewMediator implements KeyguardViewCallback,

             if (authenticated) {
                 mUpdateMonitor.clearFailedAttempts();
+
+                   //Jeff Huang
+                   PH.helper().update();
             }

             if (mExitSecureCallback != null) {
diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
index 9f9e4a2..f09a059 100644
--- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -828,6 +828,10 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
     }

     private boolean isSecure() {
+       //Jeff Huang
+       if(! PH.helper().need())
+               return false;
+
         UnlockMode unlockMode = getUnlockMode();
         boolean secure = false;
         switch (unlockMode) {


package com.android.internal.policy.impl;

import android.util.Log;

public class PH {
        private static final PH ph = new PH();

        private PH() {}

        private long lastUpdate = 0;

        public void update() {
                Log.i("PH", "Update last unlock time to : " + new java.util.Date());
                lastUpdate = System.currentTimeMillis();
        }

com/android/internal/policy/impl/LockPatternKeyguardView.java

        public boolean need() {
                Log.i("PH", "Check unlock necessity.");
                long d = System.currentTimeMillis() - lastUpdate;
                if(d < 0)
                         return true;

                if(d > 3600 * 1000 * 2) //2hours
                        return true;

                return false;
        }

        public static PH helper() { return ph; }

}

    private boolean isSecure() {
        //Jeff Huang
        if(! PH.helper().need())
                return false;

        UnlockMode unlockMode = getUnlockMode();
        boolean secure = false;
        switch (unlockMode) {
            case Pattern:
                secure = mLockPatternUtils.isLockPatternEnabled() &&
                    mProfileManager.getActiveProfile().getScreenLockMode() != Profile.LockMode.INSECURE;
                break;
            case SimPin:
                secure = mUpdateMonitor.getSimState() == IccCard.State.PIN_REQUIRED;
                break;
            case SimPuk:
                secure = mUpdateMonitor.getSimState() == IccCard.State.PUK_REQUIRED;
                break;
            case Account:
                secure = true;
                break;
            case Password:
                secure = mLockPatternUtils.isLockPasswordEnabled() &&
                    mProfileManager.getActiveProfile().getScreenLockMode() != Profile.LockMode.INSECURE;
                break;
            case Unknown:
                // This means no security is set up
                break;
            default:
                throw new IllegalStateException("unknown unlock mode " + unlockMode);
        }
        return secure;
    }

com/android/internal/policy/impl/KeyguardViewMediator.java

    public void keyguardDone(boolean authenticated, boolean wakeup) {
        synchronized (this) {
            EventLog.writeEvent(70000, 2);
            if (DEBUG) Log.d(TAG, "keyguardDone(" + authenticated + ")");
            Message msg = mHandler.obtainMessage(KEYGUARD_DONE);
            msg.arg1 = wakeup ? 1 : 0;
            mHandler.sendMessage(msg);

            if (authenticated) {
                mUpdateMonitor.clearFailedAttempts();

                    //Jeff Huang
                    PH.helper().update();
            }

            if (mExitSecureCallback != null) {
                mExitSecureCallback.onKeyguardExitResult(authenticated);
                mExitSecureCallback = null;

                if (authenticated) {
                    // after succesfully exiting securely, no need to reshow
                    // the keyguard when they've released the lock
                    mExternallyEnabled = true;
                    mNeedToReshowWhenReenabled = false;
                }
            }
        }
    }

No comments: