Don't always announce accessibility events when resetting password

The code use to always announce for accessibility when resetting the
password field, which results in announcing "Four characters replaced
with zero characters."

The fix is to only announce this message when the user needs to try
again.

Fixes bug 24331841

Change-Id: Icc9450d37b9338a39709f50666829d4a007b2b65
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java
index af88239..59c01cf 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java
@@ -106,7 +106,7 @@
                     msg = R.string.kg_invalid_confirm_pin_hint;
                 }
             }
-            resetPasswordText(true);
+            resetPasswordText(true /* animate */, true /* announce */);
             if (msg != 0) {
                 mSecurityMessageDisplay.setMessage(msg, true);
             }
@@ -163,6 +163,7 @@
         return displayMessage;
     }
 
+    @Override
     public void resetState() {
         super.resetState();
         mStateMachine.reset();
@@ -242,6 +243,7 @@
                     Log.v(TAG, "supplyPukReportResult returned: " + result[0] + " " + result[1]);
                 }
                 post(new Runnable() {
+                    @Override
                     public void run() {
                         onSimLockChangedResponse(result[0], result[1]);
                     }
@@ -249,6 +251,7 @@
             } catch (RemoteException e) {
                 Log.e(TAG, "RemoteException for supplyPukReportResult:", e);
                 post(new Runnable() {
+                    @Override
                     public void run() {
                         onSimLockChangedResponse(PhoneConstants.PIN_GENERAL_FAILURE, -1);
                     }
@@ -316,13 +319,16 @@
 
         if (mCheckSimPukThread == null) {
             mCheckSimPukThread = new CheckSimPuk(mPukText, mPinText, mSubId) {
+                @Override
                 void onSimLockChangedResponse(final int result, final int attemptsRemaining) {
                     post(new Runnable() {
+                        @Override
                         public void run() {
                             if (mSimUnlockProgressDialog != null) {
                                 mSimUnlockProgressDialog.hide();
                             }
-                            resetPasswordText(true /* animate */);
+                            resetPasswordText(true /* animate */,
+                                    result != PhoneConstants.PIN_RESULT_SUCCESS /* announce */);
                             if (result == PhoneConstants.PIN_RESULT_SUCCESS) {
                                 KeyguardUpdateMonitor.getInstance(getContext())
                                         .reportSimUnlocked(mSubId);