summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-03-03 23:08:07 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-03-03 23:08:07 +0000
commitcbace60335b2c241506a069731208f527ef35e9d (patch)
tree05a4a601c0d601393267a14c3cc7161e6ea6f2c9
parentb2c6b12cfbe3752cf14337d07ef3014abfabd2e3 (diff)
parent9ab3659d535b0674cc0c113071456c1000287fbc (diff)
downloadbase-cbace60335b2c241506a069731208f527ef35e9d.tar.gz
Merge "Created typed class for the pin result" am: 9ab3659d53
Change-Id: If62e7f5d44f38305f74318af610f5984324aa013
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java46
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java55
2 files changed, 56 insertions, 45 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
index 0ffe05de1357..8bfd5f327729 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java
@@ -16,6 +16,7 @@
package com.android.keyguard;
+import android.annotation.NonNull;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
@@ -26,6 +27,7 @@ import android.content.res.Configuration;
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;
@@ -37,7 +39,6 @@ import android.widget.ImageView;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.IccCardConstants.State;
-import com.android.internal.telephony.PhoneConstants;
import com.android.systemui.R;
/**
@@ -135,11 +136,11 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
// Sending empty PIN here to query the number of remaining PIN attempts
new CheckSimPin("", mSubId) {
- void onSimCheckResponse(final int result, final int attemptsRemaining) {
- Log.d(LOG_TAG, "onSimCheckResponse " + " dummy One result" + result +
- " attemptsRemaining=" + attemptsRemaining);
- if (attemptsRemaining >= 0) {
- mRemainingAttempts = attemptsRemaining;
+ void onSimCheckResponse(final PinResult result) {
+ Log.d(LOG_TAG, "onSimCheckResponse " + " dummy One result "
+ + result.toString());
+ if (result.getAttemptsRemaining() >= 0) {
+ mRemainingAttempts = result.getAttemptsRemaining();
setLockedSimMessage();
}
}
@@ -247,7 +248,7 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
mSubId = subId;
}
- abstract void onSimCheckResponse(final int result, final int attemptsRemaining);
+ abstract void onSimCheckResponse(@NonNull PinResult result);
@Override
public void run() {
@@ -257,23 +258,23 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
TelephonyManager telephonyManager =
((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE))
.createForSubscriptionId(mSubId);
- final int[] result = telephonyManager.supplyPinReportResult(mPin);
- if (result == null || result.length == 0) {
+ final PinResult result = telephonyManager.supplyPinReportPinResult(mPin);
+ if (result == null) {
Log.e(TAG, "Error result for supplyPinReportResult.");
post(new Runnable() {
@Override
public void run() {
- onSimCheckResponse(PhoneConstants.PIN_GENERAL_FAILURE, -1);
+ onSimCheckResponse(PinResult.getDefaultFailedResult());
}
});
} else {
if (DEBUG) {
- Log.v(TAG, "supplyPinReportResult returned: " + result[0] + " " + result[1]);
+ Log.v(TAG, "supplyPinReportResult returned: " + result.toString());
}
post(new Runnable() {
@Override
public void run() {
- onSimCheckResponse(result[0], result[1]);
+ onSimCheckResponse(result);
}
});
}
@@ -326,17 +327,18 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
if (mCheckSimPinThread == null) {
mCheckSimPinThread = new CheckSimPin(mPasswordEntry.getText(), mSubId) {
@Override
- void onSimCheckResponse(final int result, final int attemptsRemaining) {
+ void onSimCheckResponse(final PinResult result) {
post(new Runnable() {
@Override
public void run() {
- mRemainingAttempts = attemptsRemaining;
+ mRemainingAttempts = result.getAttemptsRemaining();
if (mSimUnlockProgressDialog != null) {
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) {
KeyguardUpdateMonitor.getInstance(getContext())
.reportSimUnlocked(mSubId);
mRemainingAttempts = -1;
@@ -346,14 +348,16 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
}
} else {
mShowDefaultMessage = false;
- if (result == PhoneConstants.PIN_PASSWORD_INCORRECT) {
- if (attemptsRemaining <= 2) {
+ if (result.getType() == PinResult.PIN_RESULT_TYPE_INCORRECT) {
+ if (result.getAttemptsRemaining() <= 2) {
// this is getting critical - show dialog
- getSimRemainingAttemptsDialog(attemptsRemaining).show();
+ getSimRemainingAttemptsDialog(
+ result.getAttemptsRemaining()).show();
} else {
// show message
mSecurityMessageDisplay.setMessage(
- getPinPasswordErrorMessage(attemptsRemaining, false));
+ getPinPasswordErrorMessage(
+ result.getAttemptsRemaining(), false));
}
} else {
// "PIN operation failed!" - no idea what this was and no way to
@@ -363,7 +367,7 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
}
if (DEBUG) Log.d(LOG_TAG, "verifyPasswordAndUnlock "
+ " CheckSimPin.onSimCheckResponse: " + result
- + " attemptsRemaining=" + attemptsRemaining);
+ + " attemptsRemaining=" + result.getAttemptsRemaining());
}
mCallback.userActivity();
mCheckSimPinThread = null;
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java
index abadcfd60a38..75cf691819c9 100644
--- 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;
@@ -36,7 +38,6 @@ import android.widget.ImageView;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.IccCardConstants.State;
-import com.android.internal.telephony.PhoneConstants;
import com.android.systemui.R;
@@ -187,13 +188,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();
@@ -307,7 +311,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() {
@@ -315,23 +319,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);
}
});
}
@@ -398,7 +402,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() {
@@ -406,29 +410,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) {
KeyguardUpdateMonitor.getInstance(getContext())
.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(
@@ -436,7 +443,7 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
}
if (DEBUG) Log.d(LOG_TAG, "verifyPasswordAndUnlock "
+ " UpdateSim.onSimCheckResponse: "
- + " attemptsRemaining=" + attemptsRemaining);
+ + " attemptsRemaining=" + result.getAttemptsRemaining());
mStateMachine.reset();
}
mCheckSimPukThread = null;