use of com.android.internal.widget.LockPatternUtils.RequestThrottledException in project platform_frameworks_base by android.
the class LockPatternChecker method checkPattern.
/**
* Checks a pattern asynchronously.
*
* @param utils The LockPatternUtils instance to use.
* @param pattern The pattern to check.
* @param userId The user to check against the pattern.
* @param callback The callback to be invoked with the check result.
*/
public static AsyncTask<?, ?, ?> checkPattern(final LockPatternUtils utils, final List<LockPatternView.Cell> pattern, final int userId, final OnCheckCallback callback) {
AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
private int mThrottleTimeout;
private List<LockPatternView.Cell> patternCopy;
@Override
protected void onPreExecute() {
// Make a copy of the pattern to prevent race conditions.
// No need to clone the individual cells because they are immutable.
patternCopy = new ArrayList(pattern);
}
@Override
protected Boolean doInBackground(Void... args) {
try {
return utils.checkPattern(patternCopy, userId, callback::onEarlyMatched);
} catch (RequestThrottledException ex) {
mThrottleTimeout = ex.getTimeoutMs();
return false;
}
}
@Override
protected void onPostExecute(Boolean result) {
callback.onChecked(result, mThrottleTimeout);
}
};
task.execute();
return task;
}
use of com.android.internal.widget.LockPatternUtils.RequestThrottledException in project android_frameworks_base by ResurrectionRemix.
the class LockPatternChecker method checkPattern.
/**
* Checks a pattern asynchronously.
*
* @param utils The LockPatternUtils instance to use.
* @param pattern The pattern to check.
* @param userId The user to check against the pattern.
* @param callback The callback to be invoked with the check result.
*/
public static AsyncTask<?, ?, ?> checkPattern(final LockPatternUtils utils, final List<LockPatternView.Cell> pattern, final int userId, final OnCheckCallback callback) {
AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
private int mThrottleTimeout;
private List<LockPatternView.Cell> patternCopy;
@Override
protected void onPreExecute() {
// Make a copy of the pattern to prevent race conditions.
// No need to clone the individual cells because they are immutable.
patternCopy = new ArrayList(pattern);
}
@Override
protected Boolean doInBackground(Void... args) {
try {
return utils.checkPattern(patternCopy, userId, callback::onEarlyMatched);
} catch (RequestThrottledException ex) {
mThrottleTimeout = ex.getTimeoutMs();
return false;
}
}
@Override
protected void onPostExecute(Boolean result) {
callback.onChecked(result, mThrottleTimeout);
}
};
task.execute();
return task;
}
use of com.android.internal.widget.LockPatternUtils.RequestThrottledException in project android_frameworks_base by DirtyUnicorns.
the class LockPatternChecker method verifyPattern.
/**
* Verify a pattern asynchronously.
*
* @param utils The LockPatternUtils instance to use.
* @param pattern The pattern to check.
* @param challenge The challenge to verify against the pattern.
* @param userId The user to check against the pattern.
* @param callback The callback to be invoked with the verification result.
*/
public static AsyncTask<?, ?, ?> verifyPattern(final LockPatternUtils utils, final List<LockPatternView.Cell> pattern, final long challenge, final int userId, final OnVerifyCallback callback) {
AsyncTask<Void, Void, byte[]> task = new AsyncTask<Void, Void, byte[]>() {
private int mThrottleTimeout;
private List<LockPatternView.Cell> patternCopy;
@Override
protected void onPreExecute() {
// Make a copy of the pattern to prevent race conditions.
// No need to clone the individual cells because they are immutable.
patternCopy = new ArrayList(pattern);
}
@Override
protected byte[] doInBackground(Void... args) {
try {
return utils.verifyPattern(patternCopy, challenge, userId);
} catch (RequestThrottledException ex) {
mThrottleTimeout = ex.getTimeoutMs();
return null;
}
}
@Override
protected void onPostExecute(byte[] result) {
callback.onVerified(result, mThrottleTimeout);
}
};
task.execute();
return task;
}
use of com.android.internal.widget.LockPatternUtils.RequestThrottledException in project android_frameworks_base by DirtyUnicorns.
the class LockPatternChecker method checkPattern.
/**
* Checks a pattern asynchronously.
*
* @param utils The LockPatternUtils instance to use.
* @param pattern The pattern to check.
* @param userId The user to check against the pattern.
* @param callback The callback to be invoked with the check result.
*/
public static AsyncTask<?, ?, ?> checkPattern(final LockPatternUtils utils, final List<LockPatternView.Cell> pattern, final int userId, final OnCheckCallback callback) {
AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
private int mThrottleTimeout;
private List<LockPatternView.Cell> patternCopy;
@Override
protected void onPreExecute() {
// Make a copy of the pattern to prevent race conditions.
// No need to clone the individual cells because they are immutable.
patternCopy = new ArrayList(pattern);
}
@Override
protected Boolean doInBackground(Void... args) {
try {
return utils.checkPattern(patternCopy, userId, callback::onEarlyMatched);
} catch (RequestThrottledException ex) {
mThrottleTimeout = ex.getTimeoutMs();
return false;
}
}
@Override
protected void onPostExecute(Boolean result) {
callback.onChecked(result, mThrottleTimeout);
}
};
task.execute();
return task;
}
use of com.android.internal.widget.LockPatternUtils.RequestThrottledException in project android_frameworks_base by crdroidandroid.
the class LockPatternChecker method verifyPattern.
/**
* Verify a pattern asynchronously.
*
* @param utils The LockPatternUtils instance to use.
* @param pattern The pattern to check.
* @param challenge The challenge to verify against the pattern.
* @param userId The user to check against the pattern.
* @param callback The callback to be invoked with the verification result.
*/
public static AsyncTask<?, ?, ?> verifyPattern(final LockPatternUtils utils, final List<LockPatternView.Cell> pattern, final long challenge, final int userId, final OnVerifyCallback callback) {
AsyncTask<Void, Void, byte[]> task = new AsyncTask<Void, Void, byte[]>() {
private int mThrottleTimeout;
private List<LockPatternView.Cell> patternCopy;
@Override
protected void onPreExecute() {
// Make a copy of the pattern to prevent race conditions.
// No need to clone the individual cells because they are immutable.
patternCopy = new ArrayList(pattern);
}
@Override
protected byte[] doInBackground(Void... args) {
try {
return utils.verifyPattern(patternCopy, challenge, userId);
} catch (RequestThrottledException ex) {
mThrottleTimeout = ex.getTimeoutMs();
return null;
}
}
@Override
protected void onPostExecute(byte[] result) {
callback.onVerified(result, mThrottleTimeout);
}
};
task.execute();
return task;
}
Aggregations