Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0b95e1e authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6686801 from 076c246c to rvc-qpr1-release

Change-Id: I327b35284e65a53b9ae4c668efec376a7bbede10
parents 8b1b4b68 076c246c
Loading
Loading
Loading
Loading
+81 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package android.hardware.fingerprint;
import static android.Manifest.permission.INTERACT_ACROSS_USERS;
import static android.Manifest.permission.INTERACT_ACROSS_USERS;
import static android.Manifest.permission.MANAGE_FINGERPRINT;
import static android.Manifest.permission.MANAGE_FINGERPRINT;
import static android.Manifest.permission.USE_BIOMETRIC;
import static android.Manifest.permission.USE_BIOMETRIC;
import static android.Manifest.permission.USE_BIOMETRIC_INTERNAL;
import static android.Manifest.permission.USE_FINGERPRINT;
import static android.Manifest.permission.USE_FINGERPRINT;


import android.annotation.NonNull;
import android.annotation.NonNull;
@@ -75,11 +76,13 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
    private static final int MSG_ERROR = 104;
    private static final int MSG_ERROR = 104;
    private static final int MSG_REMOVED = 105;
    private static final int MSG_REMOVED = 105;
    private static final int MSG_ENUMERATED = 106;
    private static final int MSG_ENUMERATED = 106;
    private static final int MSG_FINGERPRINT_DETECTED = 107;


    private IFingerprintService mService;
    private IFingerprintService mService;
    private Context mContext;
    private Context mContext;
    private IBinder mToken = new Binder();
    private IBinder mToken = new Binder();
    private AuthenticationCallback mAuthenticationCallback;
    private AuthenticationCallback mAuthenticationCallback;
    private FingerprintDetectionCallback mFingerprintDetectionCallback;
    private EnrollmentCallback mEnrollmentCallback;
    private EnrollmentCallback mEnrollmentCallback;
    private RemovalCallback mRemovalCallback;
    private RemovalCallback mRemovalCallback;
    private EnumerateCallback mEnumerateCallback;
    private EnumerateCallback mEnumerateCallback;
@@ -107,6 +110,13 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        }
        }
    }
    }


    private class OnFingerprintDetectionCancelListener implements OnCancelListener {
        @Override
        public void onCancel() {
            cancelFingerprintDetect();
        }
    }

    /**
    /**
     * A wrapper class for the crypto objects supported by FingerprintManager. Currently the
     * A wrapper class for the crypto objects supported by FingerprintManager. Currently the
     * framework supports {@link Signature}, {@link Cipher} and {@link Mac} objects.
     * framework supports {@link Signature}, {@link Cipher} and {@link Mac} objects.
@@ -271,6 +281,18 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        public void onAuthenticationAcquired(int acquireInfo) {}
        public void onAuthenticationAcquired(int acquireInfo) {}
    };
    };


    /**
     * Callback structure provided for {@link #detectFingerprint(CancellationSignal,
     * FingerprintDetectionCallback, int)}.
     * @hide
     */
    public interface FingerprintDetectionCallback {
        /**
         * Invoked when a fingerprint has been detected.
         */
        void onFingerprintDetected(int userId, boolean isStrongBiometric);
    }

    /**
    /**
     * Callback structure provided to {@link FingerprintManager#enroll(byte[], CancellationSignal,
     * Callback structure provided to {@link FingerprintManager#enroll(byte[], CancellationSignal,
     * int, int, EnrollmentCallback)} must provide an implementation of this for listening to
     * int, int, EnrollmentCallback)} must provide an implementation of this for listening to
@@ -453,6 +475,35 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        }
        }
    }
    }


    /**
     * Uses the fingerprint hardware to detect for the presence of a finger, without giving details
     * about accept/reject/lockout.
     * @hide
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    public void detectFingerprint(@NonNull CancellationSignal cancel,
            @NonNull FingerprintDetectionCallback callback, int userId) {
        if (mService == null) {
            return;
        }

        if (cancel.isCanceled()) {
            Slog.w(TAG, "Detection already cancelled");
            return;
        } else {
            cancel.setOnCancelListener(new OnFingerprintDetectionCancelListener());
        }

        mFingerprintDetectionCallback = callback;

        try {
            mService.detectFingerprint(mToken, userId, mServiceReceiver,
                    mContext.getOpPackageName());
        } catch (RemoteException e) {
            Slog.w(TAG, "Remote exception when requesting finger detect", e);
        }
    }

    /**
    /**
     * Request fingerprint enrollment. This call warms up the fingerprint hardware
     * Request fingerprint enrollment. This call warms up the fingerprint hardware
     * and starts scanning for fingerprints. Progress will be indicated by callbacks to the
     * and starts scanning for fingerprints. Progress will be indicated by callbacks to the
@@ -797,6 +848,10 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
                    sendEnumeratedResult((Long) msg.obj /* deviceId */, msg.arg1 /* fingerId */,
                    sendEnumeratedResult((Long) msg.obj /* deviceId */, msg.arg1 /* fingerId */,
                            msg.arg2 /* groupId */);
                            msg.arg2 /* groupId */);
                    break;
                    break;
                case MSG_FINGERPRINT_DETECTED:
                    sendFingerprintDetected(msg.arg1 /* userId */,
                            (boolean) msg.obj /* isStrongBiometric */);
                    break;
            }
            }
        }
        }
    };
    };
@@ -891,6 +946,14 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        }
        }
    }
    }


    private void sendFingerprintDetected(int userId, boolean isStrongBiometric) {
        if (mFingerprintDetectionCallback == null) {
            Slog.e(TAG, "sendFingerprintDetected, callback null");
            return;
        }
        mFingerprintDetectionCallback.onFingerprintDetected(userId, isStrongBiometric);
    }

    /**
    /**
     * @hide
     * @hide
     */
     */
@@ -927,6 +990,18 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        }
        }
    }
    }


    private void cancelFingerprintDetect() {
        if (mService == null) {
            return;
        }

        try {
            mService.cancelFingerprintDetect(mToken, mContext.getOpPackageName());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
    /**
     * @hide
     * @hide
     */
     */
@@ -1032,6 +1107,12 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
                    fp).sendToTarget();
                    fp).sendToTarget();
        }
        }


        @Override
        public void onFingerprintDetected(long deviceId, int userId, boolean isStrongBiometric) {
            mHandler.obtainMessage(MSG_FINGERPRINT_DETECTED, userId, 0, isStrongBiometric)
                    .sendToTarget();
        }

        @Override // binder call
        @Override // binder call
        public void onAuthenticationFailed(long deviceId) {
        public void onAuthenticationFailed(long deviceId) {
            mHandler.obtainMessage(MSG_AUTHENTICATION_FAILED).sendToTarget();
            mHandler.obtainMessage(MSG_AUTHENTICATION_FAILED).sendToTarget();
+8 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,11 @@ interface IFingerprintService {
    void authenticate(IBinder token, long sessionId, int userId,
    void authenticate(IBinder token, long sessionId, int userId,
            IFingerprintServiceReceiver receiver, int flags, String opPackageName);
            IFingerprintServiceReceiver receiver, int flags, String opPackageName);


    // Uses the fingerprint hardware to detect for the presence of a finger, without giving details
    // about accept/reject/lockout.
    void detectFingerprint(IBinder token, int userId, IFingerprintServiceReceiver receiver,
            String opPackageName);

    // This method prepares the service to start authenticating, but doesn't start authentication.
    // This method prepares the service to start authenticating, but doesn't start authentication.
    // This is protected by the MANAGE_BIOMETRIC signatuer permission. This method should only be
    // This is protected by the MANAGE_BIOMETRIC signatuer permission. This method should only be
    // called from BiometricService. The additional uid, pid, userId arguments should be determined
    // called from BiometricService. The additional uid, pid, userId arguments should be determined
@@ -48,6 +53,9 @@ interface IFingerprintService {
    // Cancel authentication for the given sessionId
    // Cancel authentication for the given sessionId
    void cancelAuthentication(IBinder token, String opPackageName);
    void cancelAuthentication(IBinder token, String opPackageName);


    // Cancel finger detection
    void cancelFingerprintDetect(IBinder token, String opPackageName);

    // Same as above, except this is protected by the MANAGE_BIOMETRIC signature permission. Takes
    // Same as above, except this is protected by the MANAGE_BIOMETRIC signature permission. Takes
    // an additional uid, pid, userid.
    // an additional uid, pid, userid.
    void cancelAuthenticationFromService(IBinder token, String opPackageName,
    void cancelAuthenticationFromService(IBinder token, String opPackageName,
+1 −0
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@ oneway interface IFingerprintServiceReceiver {
    void onAcquired(long deviceId, int acquiredInfo, int vendorCode);
    void onAcquired(long deviceId, int acquiredInfo, int vendorCode);
    void onAuthenticationSucceeded(long deviceId, in Fingerprint fp, int userId,
    void onAuthenticationSucceeded(long deviceId, in Fingerprint fp, int userId,
            boolean isStrongBiometric);
            boolean isStrongBiometric);
    void onFingerprintDetected(long deviceId, int userId, boolean isStrongBiometric);
    void onAuthenticationFailed(long deviceId);
    void onAuthenticationFailed(long deviceId);
    void onError(long deviceId, int error, int vendorCode);
    void onError(long deviceId, int error, int vendorCode);
    void onRemoved(long deviceId, int fingerId, int groupId, int remaining);
    void onRemoved(long deviceId, int fingerId, int groupId, int remaining);
+92 −5
Original line number Original line Diff line number Diff line
@@ -395,6 +395,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    private static final int EMS = LINES;
    private static final int EMS = LINES;
    private static final int PIXELS = 2;
    private static final int PIXELS = 2;
    // Maximum text length for single line input.
    private static final int MAX_LENGTH_FOR_SINGLE_LINE_EDIT_TEXT = 5000;
    private InputFilter.LengthFilter mSingleLineLengthFilter = null;
    private static final RectF TEMP_RECTF = new RectF();
    private static final RectF TEMP_RECTF = new RectF();
    /** @hide */
    /** @hide */
@@ -1589,7 +1593,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        // Same as setSingleLine(), but make sure the transformation method and the maximum number
        // Same as setSingleLine(), but make sure the transformation method and the maximum number
        // of lines of height are unchanged for multi-line TextViews.
        // of lines of height are unchanged for multi-line TextViews.
        setInputTypeSingleLine(singleLine);
        setInputTypeSingleLine(singleLine);
        applySingleLine(singleLine, singleLine, singleLine);
        applySingleLine(singleLine, singleLine, singleLine,
                // Does not apply automated max length filter since length filter will be resolved
                // later in this function.
                false
        );
        if (singleLine && getKeyListener() == null && ellipsize == ELLIPSIZE_NOT_SET) {
        if (singleLine && getKeyListener() == null && ellipsize == ELLIPSIZE_NOT_SET) {
            ellipsize = ELLIPSIZE_END;
            ellipsize = ELLIPSIZE_END;
@@ -1633,7 +1641,16 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            setTransformationMethod(PasswordTransformationMethod.getInstance());
            setTransformationMethod(PasswordTransformationMethod.getInstance());
        }
        }
        if (maxlength >= 0) {
        // For addressing b/145128646
        // For the performance reason, we limit characters for single line text field.
        if (bufferType == BufferType.EDITABLE && singleLine && maxlength == -1) {
            mSingleLineLengthFilter = new InputFilter.LengthFilter(
                MAX_LENGTH_FOR_SINGLE_LINE_EDIT_TEXT);
        }
        if (mSingleLineLengthFilter != null) {
            setFilters(new InputFilter[] { mSingleLineLengthFilter });
        } else if (maxlength >= 0) {
            setFilters(new InputFilter[] { new InputFilter.LengthFilter(maxlength) });
            setFilters(new InputFilter[] { new InputFilter.LengthFilter(maxlength) });
        } else {
        } else {
            setFilters(NO_FILTERS);
            setFilters(NO_FILTERS);
@@ -6590,7 +6607,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        if (mSingleLine != singleLine || forceUpdate) {
        if (mSingleLine != singleLine || forceUpdate) {
            // Change single line mode, but only change the transformation if
            // Change single line mode, but only change the transformation if
            // we are not in password mode.
            // we are not in password mode.
            applySingleLine(singleLine, !isPassword, true);
            applySingleLine(singleLine, !isPassword, true, true);
        }
        }
        if (!isSuggestionsEnabled()) {
        if (!isSuggestionsEnabled()) {
@@ -10229,6 +10246,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     * Note that the default conditions are not necessarily those that were in effect prior this
     * Note that the default conditions are not necessarily those that were in effect prior this
     * method, and you may want to reset these properties to your custom values.
     * method, and you may want to reset these properties to your custom values.
     *
     *
     * Note that due to performance reasons, by setting single line for the EditText, the maximum
     * text length is set to 5000 if no other character limitation are applied.
     *
     * @attr ref android.R.styleable#TextView_singleLine
     * @attr ref android.R.styleable#TextView_singleLine
     */
     */
    @android.view.RemotableViewMethod
    @android.view.RemotableViewMethod
@@ -10236,7 +10256,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        // Could be used, but may break backward compatibility.
        // Could be used, but may break backward compatibility.
        // if (mSingleLine == singleLine) return;
        // if (mSingleLine == singleLine) return;
        setInputTypeSingleLine(singleLine);
        setInputTypeSingleLine(singleLine);
        applySingleLine(singleLine, true, true);
        applySingleLine(singleLine, true, true, true);
    }
    }
    /**
    /**
@@ -10256,14 +10276,40 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    }
    }
    private void applySingleLine(boolean singleLine, boolean applyTransformation,
    private void applySingleLine(boolean singleLine, boolean applyTransformation,
            boolean changeMaxLines) {
            boolean changeMaxLines, boolean changeMaxLength) {
        mSingleLine = singleLine;
        mSingleLine = singleLine;
        if (singleLine) {
        if (singleLine) {
            setLines(1);
            setLines(1);
            setHorizontallyScrolling(true);
            setHorizontallyScrolling(true);
            if (applyTransformation) {
            if (applyTransformation) {
                setTransformationMethod(SingleLineTransformationMethod.getInstance());
                setTransformationMethod(SingleLineTransformationMethod.getInstance());
            }
            }
            if (!changeMaxLength) return;
            // Single line length filter is only applicable editable text.
            if (mBufferType != BufferType.EDITABLE) return;
            final InputFilter[] prevFilters = getFilters();
            for (InputFilter filter: getFilters()) {
                // We don't add LengthFilter if already there.
                if (filter instanceof InputFilter.LengthFilter) return;
            }
            if (mSingleLineLengthFilter == null) {
                mSingleLineLengthFilter = new InputFilter.LengthFilter(
                    MAX_LENGTH_FOR_SINGLE_LINE_EDIT_TEXT);
            }
            final InputFilter[] newFilters = new InputFilter[prevFilters.length + 1];
            System.arraycopy(prevFilters, 0, newFilters, 0, prevFilters.length);
            newFilters[prevFilters.length] = mSingleLineLengthFilter;
            setFilters(newFilters);
            // Since filter doesn't apply to existing text, trigger filter by setting text.
            setText(getText());
        } else {
        } else {
            if (changeMaxLines) {
            if (changeMaxLines) {
                setMaxLines(Integer.MAX_VALUE);
                setMaxLines(Integer.MAX_VALUE);
@@ -10272,6 +10318,47 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            if (applyTransformation) {
            if (applyTransformation) {
                setTransformationMethod(null);
                setTransformationMethod(null);
            }
            }
            if (!changeMaxLength) return;
            // Single line length filter is only applicable editable text.
            if (mBufferType != BufferType.EDITABLE) return;
            final InputFilter[] prevFilters = getFilters();
            if (prevFilters.length == 0) return;
            // Short Circuit: if mSingleLineLengthFilter is not allocated, nobody sets automated
            // single line char limit filter.
            if (mSingleLineLengthFilter == null) return;
            // If we need to remove mSingleLineLengthFilter, we need to allocate another array.
            // Since filter list is expected to be small and want to avoid unnecessary array
            // allocation, check if there is mSingleLengthFilter first.
            int targetIndex = -1;
            for (int i = 0; i < prevFilters.length; ++i) {
                if (prevFilters[i] == mSingleLineLengthFilter) {
                    targetIndex = i;
                    break;
                }
            }
            if (targetIndex == -1) return;  // not found. Do nothing.
            if (prevFilters.length == 1) {
                setFilters(NO_FILTERS);
                return;
            }
            // Create new array which doesn't include mSingleLengthFilter.
            final InputFilter[] newFilters = new InputFilter[prevFilters.length - 1];
            System.arraycopy(prevFilters, 0, newFilters, 0, targetIndex);
            System.arraycopy(
                    prevFilters,
                    targetIndex + 1,
                    newFilters,
                    targetIndex,
                    prevFilters.length - targetIndex - 1);
            setFilters(newFilters);
            mSingleLineLengthFilter = null;
        }
        }
    }
    }
+6 −1
Original line number Original line Diff line number Diff line
@@ -1259,7 +1259,12 @@
        <!-- Can be combined with <var>text</var> and its variations to
        <!-- Can be combined with <var>text</var> and its variations to
             allow multiple lines of text in the field.  If this flag is not set,
             allow multiple lines of text in the field.  If this flag is not set,
             the text field will be constrained to a single line.  Corresponds to
             the text field will be constrained to a single line.  Corresponds to
             {@link android.text.InputType#TYPE_TEXT_FLAG_MULTI_LINE}. -->
             {@link android.text.InputType#TYPE_TEXT_FLAG_MULTI_LINE}.

             Note: If this flag is not set and the text field doesn't have max length limit, the
             framework automatically set maximum length of the characters to 5000 for the
             performance reasons.
             -->
        <flag name="textMultiLine" value="0x00020001" />
        <flag name="textMultiLine" value="0x00020001" />
        <!-- Can be combined with <var>text</var> and its variations to
        <!-- Can be combined with <var>text</var> and its variations to
             indicate that though the regular text view should not be multiple
             indicate that though the regular text view should not be multiple
Loading