Search in sources :

Example 1 with RequestThrottledException

use of com.android.internal.widget.LockPatternUtils.RequestThrottledException in project android_frameworks_base by ResurrectionRemix.

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;
}
Also used : AsyncTask(android.os.AsyncTask) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) RequestThrottledException(com.android.internal.widget.LockPatternUtils.RequestThrottledException)

Example 2 with RequestThrottledException

use of com.android.internal.widget.LockPatternUtils.RequestThrottledException in project android_frameworks_base by AOSPA.

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;
}
Also used : AsyncTask(android.os.AsyncTask) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) RequestThrottledException(com.android.internal.widget.LockPatternUtils.RequestThrottledException)

Example 3 with RequestThrottledException

use of com.android.internal.widget.LockPatternUtils.RequestThrottledException in project android_frameworks_base by AOSPA.

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;
}
Also used : AsyncTask(android.os.AsyncTask) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) RequestThrottledException(com.android.internal.widget.LockPatternUtils.RequestThrottledException)

Example 4 with RequestThrottledException

use of com.android.internal.widget.LockPatternUtils.RequestThrottledException in project platform_frameworks_base by android.

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;
}
Also used : AsyncTask(android.os.AsyncTask) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) RequestThrottledException(com.android.internal.widget.LockPatternUtils.RequestThrottledException)

Example 5 with RequestThrottledException

use of com.android.internal.widget.LockPatternUtils.RequestThrottledException in project android_frameworks_base by crdroidandroid.

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;
}
Also used : AsyncTask(android.os.AsyncTask) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) RequestThrottledException(com.android.internal.widget.LockPatternUtils.RequestThrottledException)

Aggregations

AsyncTask (android.os.AsyncTask)10 RequestThrottledException (com.android.internal.widget.LockPatternUtils.RequestThrottledException)10 ArrayList (java.util.ArrayList)10 List (java.util.List)10