Fix 4942542, 4590542: Password unlock fixes

Fixes issue where hint text was inappropriately shown on password unlock screen.
This was caused by TextView.setKeyListener() clearing the inputType flags.  The
workaround is to change the order of these calls.  TextView.setKeyListener()
should probably not be clearing existing inputType flags.

Fixes wake issue caused by IME events not poking the wakelock.  It now correctly pokes
the wakelock whenever the password text field changes.

Change-Id: I746b21117492c4a176f6627e7d33150e6104495e
diff --git a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
index f862d01..75e799c 100644
--- a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
@@ -29,7 +29,9 @@
 import android.os.SystemClock;
 import android.security.KeyStore;
 import android.telephony.TelephonyManager;
+import android.text.Editable;
 import android.text.InputType;
+import android.text.TextWatcher;
 import android.text.method.DigitsKeyListener;
 import android.text.method.TextKeyListener;
 import android.util.Log;
@@ -120,15 +122,6 @@
             }
         });
 
-        // We don't currently use the IME for PIN mode, but this will make it work if we ever do...
-        if (!mIsAlpha) {
-            mPasswordEntry.setInputType(InputType.TYPE_CLASS_NUMBER
-                    | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
-        } else {
-            mPasswordEntry.setInputType(InputType.TYPE_CLASS_TEXT
-                    | InputType.TYPE_TEXT_VARIATION_PASSWORD);
-        }
-
         mEmergencyCallButton = (Button) findViewById(R.id.emergencyCallButton);
         mEmergencyCallButton.setOnClickListener(this);
         mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton);
@@ -151,14 +144,17 @@
 
         mPasswordEntry.requestFocus();
 
-        // This allows keyboards with overlapping qwerty/numeric keys to choose just the
-        // numeric keys.
+        // This allows keyboards with overlapping qwerty/numeric keys to choose just numeric keys.
         if (mIsAlpha) {
             mPasswordEntry.setKeyListener(TextKeyListener.getInstance());
+            mPasswordEntry.setInputType(InputType.TYPE_CLASS_TEXT
+                    | InputType.TYPE_TEXT_VARIATION_PASSWORD);
             // mStatusView.setHelpMessage(R.string.keyguard_password_enter_password_code,
             //      StatusView.LOCK_ICON);
         } else {
             mPasswordEntry.setKeyListener(DigitsKeyListener.getInstance());
+            mPasswordEntry.setInputType(InputType.TYPE_CLASS_NUMBER
+                    | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
             //mStatusView.setHelpMessage(R.string.keyguard_password_enter_pin_code,
             //      StatusView.LOCK_ICON);
         }
@@ -179,6 +175,19 @@
         //mUpdateMonitor.registerSimStateCallback(this);
 
         resetStatusInfo();
+
+        // Poke the wakelock any time the text is modified
+        mPasswordEntry.addTextChangedListener(new TextWatcher() {
+            public void onTextChanged(CharSequence s, int start, int before, int count) {
+            }
+
+            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+            }
+
+            public void afterTextChanged(Editable s) {
+                mCallback.pokeWakelock();
+            }
+        });
     }
 
     @Override