Merge "Created typed class pin result in keyguard"
This commit is contained in:
@@ -8951,6 +8951,19 @@ package android.telephony {
|
||||
field @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final int LISTEN_VOICE_ACTIVATION_STATE = 131072; // 0x20000
|
||||
}
|
||||
|
||||
public final class PinResult implements android.os.Parcelable {
|
||||
ctor public PinResult(int, int);
|
||||
method public int describeContents();
|
||||
method public int getAttemptsRemaining();
|
||||
method @NonNull public static android.telephony.PinResult getDefaultFailedResult();
|
||||
method public int getType();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.PinResult> CREATOR;
|
||||
field public static final int PIN_RESULT_TYPE_FAILURE = 2; // 0x2
|
||||
field public static final int PIN_RESULT_TYPE_INCORRECT = 1; // 0x1
|
||||
field public static final int PIN_RESULT_TYPE_SUCCESS = 0; // 0x0
|
||||
}
|
||||
|
||||
public final class PreciseCallState implements android.os.Parcelable {
|
||||
ctor public PreciseCallState(int, int, int, int, int);
|
||||
method public int describeContents();
|
||||
@@ -9431,9 +9444,11 @@ package android.telephony {
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setVoiceActivationState(int);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void shutdownAllRadios();
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean supplyPin(String);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int[] supplyPinReportResult(String);
|
||||
method @Nullable @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public android.telephony.PinResult supplyPinReportPinResult(@NonNull String);
|
||||
method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int[] supplyPinReportResult(String);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean supplyPuk(String, String);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int[] supplyPukReportResult(String, String);
|
||||
method @Nullable @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public android.telephony.PinResult supplyPukReportPinResult(@NonNull String, @NonNull String);
|
||||
method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int[] supplyPukReportResult(String, String);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean switchSlots(int[]);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void toggleRadioOnOff();
|
||||
method public void updateServiceLocation();
|
||||
|
||||
173
telephony/java/android/telephony/PinResult.java
Normal file
173
telephony/java/android/telephony/PinResult.java
Normal file
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.telephony;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.android.internal.telephony.PhoneConstants;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Holds the result from a pin attempt.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public final class PinResult implements Parcelable {
|
||||
/** @hide */
|
||||
@IntDef({
|
||||
PIN_RESULT_TYPE_SUCCESS,
|
||||
PIN_RESULT_TYPE_INCORRECT,
|
||||
PIN_RESULT_TYPE_FAILURE,
|
||||
})
|
||||
public @interface PinResultType {}
|
||||
|
||||
/**
|
||||
* Indicates that the pin attempt was a success.
|
||||
*/
|
||||
public static final int PIN_RESULT_TYPE_SUCCESS = PhoneConstants.PIN_RESULT_SUCCESS;
|
||||
|
||||
/**
|
||||
* Indicates that the pin attempt was incorrect.
|
||||
*/
|
||||
public static final int PIN_RESULT_TYPE_INCORRECT = PhoneConstants.PIN_PASSWORD_INCORRECT;
|
||||
|
||||
/**
|
||||
* Indicates that the pin attempt was a failure.
|
||||
*/
|
||||
public static final int PIN_RESULT_TYPE_FAILURE = PhoneConstants.PIN_GENERAL_FAILURE;
|
||||
|
||||
private static final PinResult sFailedResult =
|
||||
new PinResult(PinResult.PIN_RESULT_TYPE_FAILURE, -1);
|
||||
|
||||
private final @PinResultType int mType;
|
||||
|
||||
private final int mAttemptsRemaining;
|
||||
|
||||
/**
|
||||
* Returns either success, incorrect or failure.
|
||||
*
|
||||
* @see: #PIN_RESULT_TYPE_SUCCESS
|
||||
* @see: #PIN_RESULT_TYPE_INCORRECT
|
||||
* @see: #PIN_RESULT_TYPE_FAILURE
|
||||
* @return The result type of the pin attempt.
|
||||
*/
|
||||
public @PinResultType int getType() {
|
||||
return mType;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of pin attempts remaining.
|
||||
*
|
||||
* @return Number of attempts remaining.
|
||||
*/
|
||||
public int getAttemptsRemaining() {
|
||||
return mAttemptsRemaining;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static PinResult getDefaultFailedResult() {
|
||||
return sFailedResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* PinResult constructor
|
||||
*
|
||||
* @param type The type of pin result.
|
||||
* @see: #PIN_RESULT_TYPE_SUCCESS
|
||||
* @see: #PIN_RESULT_TYPE_INCORRECT
|
||||
* @see: #PIN_RESULT_TYPE_FAILURE
|
||||
* @param attemptsRemaining Number of pin attempts remaining.
|
||||
*/
|
||||
public PinResult(@PinResultType int type, int attemptsRemaining) {
|
||||
mType = type;
|
||||
mAttemptsRemaining = attemptsRemaining;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a PinResult object from the given parcel.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
private PinResult(Parcel in) {
|
||||
mType = in.readInt();
|
||||
mAttemptsRemaining = in.readInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* String representation of the Pin Result.
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "type: " + getType() + ", attempts remaining: " + getAttemptsRemaining();
|
||||
}
|
||||
|
||||
/**
|
||||
* Required to be Parcelable
|
||||
*/
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Required to be Parcelable
|
||||
*/
|
||||
@Override
|
||||
public void writeToParcel(@NonNull Parcel out, int flags) {
|
||||
out.writeInt(mType);
|
||||
out.writeInt(mAttemptsRemaining);
|
||||
}
|
||||
|
||||
/** Required to be Parcelable */
|
||||
public static final @NonNull Parcelable.Creator<PinResult> CREATOR = new Creator<PinResult>() {
|
||||
public PinResult createFromParcel(Parcel in) {
|
||||
return new PinResult(in);
|
||||
}
|
||||
public PinResult[] newArray(int size) {
|
||||
return new PinResult[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mAttemptsRemaining, mType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
PinResult other = (PinResult) obj;
|
||||
return (mType == other.mType
|
||||
&& mAttemptsRemaining == other.mAttemptsRemaining);
|
||||
}
|
||||
}
|
||||
@@ -8645,9 +8645,13 @@ public class TelephonyManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
/**
|
||||
* @deprecated use {@link #supplyPinReportPinResult(String pin)} instead.
|
||||
*
|
||||
* @hide */
|
||||
@SystemApi
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
@Deprecated
|
||||
public int[] supplyPinReportResult(String pin) {
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
@@ -8659,9 +8663,13 @@ public class TelephonyManager {
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
/**
|
||||
* @deprecated use {@link #supplyPukReportPinResult(String puk, String pin)} instead.
|
||||
*
|
||||
* @hide */
|
||||
@SystemApi
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
@Deprecated
|
||||
public int[] supplyPukReportResult(String puk, String pin) {
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
@@ -8673,6 +8681,55 @@ public class TelephonyManager {
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Used when the user attempts to enter their pin.
|
||||
*
|
||||
* @param pin The user entered pin.
|
||||
* @return The result of the pin.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@Nullable
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
public PinResult supplyPinReportPinResult(@NonNull String pin) {
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
if (telephony != null) {
|
||||
int[] result = telephony.supplyPinReportResultForSubscriber(getSubId(), pin);
|
||||
return new PinResult(result[0], result[1]);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelephony#supplyPinReportResultForSubscriber", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used when the user attempts to enter the puk or their pin.
|
||||
*
|
||||
* @param puk The product unblocking key.
|
||||
* @param pin The user entered pin.
|
||||
* @return The result of the pin.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@Nullable
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
public PinResult supplyPukReportPinResult(@NonNull String puk, @NonNull String pin) {
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
if (telephony != null) {
|
||||
int[] result = telephony.supplyPukReportResultForSubscriber(getSubId(), puk, pin);
|
||||
return new PinResult(result[0], result[1]);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelephony#]", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to notify callers of
|
||||
* {@link TelephonyManager#sendUssdRequest(String, UssdResponseCallback, Handler)} when the
|
||||
|
||||
Reference in New Issue
Block a user