diff options
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java')
-rwxr-xr-x | packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java index dc681157f534..10dcbd6f9182 100755 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java @@ -16,6 +16,7 @@ package com.android.keyguard; +import android.annotation.NonNull; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; @@ -25,6 +26,7 @@ import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Color; +import android.telephony.PinResult; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; @@ -34,7 +36,6 @@ import android.view.View; import android.view.WindowManager; import android.widget.ImageView; -import com.android.internal.telephony.PhoneConstants; import com.android.systemui.Dependency; import com.android.systemui.R; @@ -191,13 +192,16 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView { // Sending empty PUK here to query the number of remaining PIN attempts new CheckSimPuk("", "", mSubId) { - void onSimLockChangedResponse(final int result, final int attemptsRemaining) { - Log.d(LOG_TAG, "onSimCheckResponse " + " dummy One result" + result + - " attemptsRemaining=" + attemptsRemaining); - if (attemptsRemaining >= 0) { - mRemainingAttempts = attemptsRemaining; - mSecurityMessageDisplay.setMessage( - getPukPasswordErrorMessage(attemptsRemaining, true)); + void onSimLockChangedResponse(final PinResult result) { + if (result == null) Log.e(LOG_TAG, "onSimCheckResponse, pin result is NULL"); + else { + Log.d(LOG_TAG, "onSimCheckResponse " + " dummy One result " + + result.toString()); + if (result.getAttemptsRemaining() >= 0) { + mRemainingAttempts = result.getAttemptsRemaining(); + mSecurityMessageDisplay.setMessage( + getPukPasswordErrorMessage(result.getAttemptsRemaining(), true)); + } } } }.start(); @@ -311,7 +315,7 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView { mSubId = subId; } - abstract void onSimLockChangedResponse(final int result, final int attemptsRemaining); + abstract void onSimLockChangedResponse(@NonNull PinResult result); @Override public void run() { @@ -319,23 +323,23 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView { TelephonyManager telephonyManager = ((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE)) .createForSubscriptionId(mSubId); - final int[] result = telephonyManager.supplyPukReportResult(mPuk, mPin); - if (result == null || result.length == 0) { + final PinResult result = telephonyManager.supplyPukReportPinResult(mPuk, mPin); + if (result == null) { Log.e(TAG, "Error result for supplyPukReportResult."); post(new Runnable() { @Override public void run() { - onSimLockChangedResponse(PhoneConstants.PIN_GENERAL_FAILURE, -1); + onSimLockChangedResponse(PinResult.getDefaultFailedResult()); } }); } else { if (DEBUG) { - Log.v(TAG, "supplyPukReportResult returned: " + result[0] + " " + result[1]); + Log.v(TAG, "supplyPukReportResult returned: " + result.toString()); } post(new Runnable() { @Override public void run() { - onSimLockChangedResponse(result[0], result[1]); + onSimLockChangedResponse(result); } }); } @@ -402,7 +406,7 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView { if (mCheckSimPukThread == null) { mCheckSimPukThread = new CheckSimPuk(mPukText, mPinText, mSubId) { @Override - void onSimLockChangedResponse(final int result, final int attemptsRemaining) { + void onSimLockChangedResponse(final PinResult result) { post(new Runnable() { @Override public void run() { @@ -410,29 +414,32 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView { mSimUnlockProgressDialog.hide(); } resetPasswordText(true /* animate */, - result != PhoneConstants.PIN_RESULT_SUCCESS /* announce */); - if (result == PhoneConstants.PIN_RESULT_SUCCESS) { + /* announce */ + result.getType() != PinResult.PIN_RESULT_TYPE_SUCCESS); + if (result.getType() == PinResult.PIN_RESULT_TYPE_SUCCESS) { Dependency.get(KeyguardUpdateMonitor.class) .reportSimUnlocked(mSubId); mRemainingAttempts = -1; mShowDefaultMessage = true; if (mCallback != null) { - mCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser()); + mCallback.dismiss(true, + KeyguardUpdateMonitor.getCurrentUser()); } } else { mShowDefaultMessage = false; - if (result == PhoneConstants.PIN_PASSWORD_INCORRECT) { + if (result.getType() == PinResult.PIN_RESULT_TYPE_INCORRECT) { // show message mSecurityMessageDisplay.setMessage(getPukPasswordErrorMessage( - attemptsRemaining, false)); - if (attemptsRemaining <= 2) { + result.getAttemptsRemaining(), false)); + if (result.getAttemptsRemaining() <= 2) { // this is getting critical - show dialog - getPukRemainingAttemptsDialog(attemptsRemaining).show(); + getPukRemainingAttemptsDialog( + result.getAttemptsRemaining()).show(); } else { // show message mSecurityMessageDisplay.setMessage( getPukPasswordErrorMessage( - attemptsRemaining, false)); + result.getAttemptsRemaining(), false)); } } else { mSecurityMessageDisplay.setMessage(getContext().getString( @@ -440,7 +447,7 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView { } if (DEBUG) Log.d(LOG_TAG, "verifyPasswordAndUnlock " + " UpdateSim.onSimCheckResponse: " - + " attemptsRemaining=" + attemptsRemaining); + + " attemptsRemaining=" + result.getAttemptsRemaining()); mStateMachine.reset(); } mCheckSimPukThread = null; |