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

Commit f67a780c authored by Kevin Chyn's avatar Kevin Chyn Committed by Android (Google) Code Review
Browse files

Merge "[DO NOT MERGE] Add sysUiSessionId between BiometricService and AuthController" into rvc-dev

parents 54fda221 fa7069d8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ oneway interface IStatusBar
    // Used to show the authentication dialog (Biometrics, Device Credential)
    void showAuthenticationDialog(in Bundle bundle, IBiometricServiceReceiverInternal receiver,
            int biometricModality, boolean requireConfirmation, int userId, String opPackageName,
            long operationId);
            long operationId, int sysUiSessionId);
    // Used to notify the authentication dialog that a biometric has been authenticated
    void onBiometricAuthenticated();
    // Used to set a temporary message, e.g. fingerprint not recognized, finger moved too fast, etc
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ interface IStatusBarService
    // Used to show the authentication dialog (Biometrics, Device Credential)
    void showAuthenticationDialog(in Bundle bundle, IBiometricServiceReceiverInternal receiver,
            int biometricModality, boolean requireConfirmation, int userId, String opPackageName,
            long operationId);
            long operationId, int sysUiSessionId);
    // Used to notify the authentication dialog that a biometric has been authenticated
    void onBiometricAuthenticated();
    // Used to set a temporary message, e.g. fingerprint not recognized, finger moved too fast, etc
+5 −3
Original line number Diff line number Diff line
@@ -432,7 +432,7 @@ public abstract class AuthBiometricView extends LinearLayout {
        Utils.notifyAccessibilityContentChanged(mAccessibilityManager, this);
    }

    public void updateState(@BiometricState int newState) {
    void updateState(@BiometricState int newState) {
        Log.v(TAG, "newState: " + newState);

        switch (newState) {
@@ -453,8 +453,10 @@ public abstract class AuthBiometricView extends LinearLayout {
                }
                announceForAccessibility(getResources()
                        .getString(R.string.biometric_dialog_authenticated));
                mHandler.postDelayed(() -> mCallback.onAction(Callback.ACTION_AUTHENTICATED),
                        getDelayAfterAuthenticatedDurationMs());
                mHandler.postDelayed(() -> {
                    Log.d(TAG, "Sending ACTION_AUTHENTICATED");
                    mCallback.onAction(Callback.ACTION_AUTHENTICATED);
                }, getDelayAfterAuthenticatedDurationMs());
                break;

            case STATE_PENDING_CONFIRMATION:
+20 −6
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ public class AuthContainerView extends LinearLayout
        int mModalityMask;
        boolean mSkipIntro;
        long mOperationId;
        int mSysUiSessionId;
    }

    public static class Builder {
@@ -158,6 +159,11 @@ public class AuthContainerView extends LinearLayout
            return this;
        }

        public Builder setSysUiSessionId(int sysUiSessionId) {
            mConfig.mSysUiSessionId = sysUiSessionId;
            return this;
        }

        public AuthContainerView build(int modalityMask) {
            mConfig.mModalityMask = modalityMask;
            return new AuthContainerView(mConfig, new Injector());
@@ -203,6 +209,9 @@ public class AuthContainerView extends LinearLayout
    final class BiometricCallback implements AuthBiometricView.Callback {
        @Override
        public void onAction(int action) {
            Log.d(TAG, "onAction: " + action
                    + ", sysUiSessionId: " + mConfig.mSysUiSessionId
                    + ", state: " + mContainerState);
            switch (action) {
                case AuthBiometricView.Callback.ACTION_AUTHENTICATED:
                    animateAway(AuthDialogCallback.DISMISSED_BIOMETRIC_AUTHENTICATED);
@@ -461,13 +470,13 @@ public class AuthContainerView extends LinearLayout
        if (animate) {
            animateAway(false /* sendReason */, 0 /* reason */);
        } else {
            removeWindowIfAttached();
            removeWindowIfAttached(false /* sendReason */);
        }
    }

    @Override
    public void dismissFromSystemServer() {
        removeWindowIfAttached();
        removeWindowIfAttached(true /* sendReason */);
    }

    @Override
@@ -540,7 +549,7 @@ public class AuthContainerView extends LinearLayout

        final Runnable endActionRunnable = () -> {
            setVisibility(View.INVISIBLE);
            removeWindowIfAttached();
            removeWindowIfAttached(true /* sendReason */);
        };

        postOnAnimation(() -> {
@@ -575,19 +584,24 @@ public class AuthContainerView extends LinearLayout
    }

    private void sendPendingCallbackIfNotNull() {
        Log.d(TAG, "pendingCallback: " + mPendingCallbackReason);
        Log.d(TAG, "pendingCallback: " + mPendingCallbackReason
                + " sysUISessionId: " + mConfig.mSysUiSessionId);
        if (mPendingCallbackReason != null) {
            mConfig.mCallback.onDismissed(mPendingCallbackReason, mCredentialAttestation);
            mPendingCallbackReason = null;
        }
    }

    private void removeWindowIfAttached() {
    private void removeWindowIfAttached(boolean sendReason) {
        if (sendReason) {
            sendPendingCallbackIfNotNull();
        }

        if (mContainerState == STATE_GONE) {
            Log.w(TAG, "Container already STATE_GONE, mSysUiSessionId: " + mConfig.mSysUiSessionId);
            return;
        }
        Log.d(TAG, "Removing container, mSysUiSessionId: " + mConfig.mSysUiSessionId);
        mContainerState = STATE_GONE;
        mWindowManager.removeView(this);
    }
+12 −5
Original line number Diff line number Diff line
@@ -276,14 +276,15 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
    @Override
    public void showAuthenticationDialog(Bundle bundle, IBiometricServiceReceiverInternal receiver,
            int biometricModality, boolean requireConfirmation, int userId, String opPackageName,
            long operationId) {
            long operationId, int sysUiSessionId) {
        final int authenticators = Utils.getAuthenticators(bundle);

        if (DEBUG) {
            Log.d(TAG, "showAuthenticationDialog, authenticators: " + authenticators
                    + ", biometricModality: " + biometricModality
                    + ", requireConfirmation: " + requireConfirmation
                    + ", operationId: " + operationId);
                    + ", operationId: " + operationId
                    + ", sysUiSessionId: " + sysUiSessionId);
        }
        SomeArgs args = SomeArgs.obtain();
        args.arg1 = bundle;
@@ -293,6 +294,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        args.argi2 = userId;
        args.arg4 = opPackageName;
        args.arg5 = operationId;
        args.argi3 = sysUiSessionId;

        boolean skipAnimation = false;
        if (mCurrentDialog != null) {
@@ -382,6 +384,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        final int userId = args.argi2;
        final String opPackageName = (String) args.arg4;
        final long operationId = (long) args.arg5;
        final int sysUiSessionId = args.argi3;

        // Create a new dialog but do not replace the current one yet.
        final AuthDialog newDialog = buildDialog(
@@ -391,7 +394,8 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
                type,
                opPackageName,
                skipAnimation,
                operationId);
                operationId,
                sysUiSessionId);

        if (newDialog == null) {
            Log.e(TAG, "Unsupported type: " + type);
@@ -403,7 +407,8 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
                    + " savedState: " + savedState
                    + " mCurrentDialog: " + mCurrentDialog
                    + " newDialog: " + newDialog
                    + " type: " + type);
                    + " type: " + type
                    + " sysUiSessionId: " + sysUiSessionId);
        }

        if (mCurrentDialog != null) {
@@ -458,7 +463,8 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
    }

    protected AuthDialog buildDialog(Bundle biometricPromptBundle, boolean requireConfirmation,
            int userId, int type, String opPackageName, boolean skipIntro, long operationId) {
            int userId, int type, String opPackageName, boolean skipIntro, long operationId,
            int sysUiSessionId) {
        return new AuthContainerView.Builder(mContext)
                .setCallback(this)
                .setBiometricPromptBundle(biometricPromptBundle)
@@ -467,6 +473,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
                .setOpPackageName(opPackageName)
                .setSkipIntro(skipIntro)
                .setOperationId(operationId)
                .setSysUiSessionId(sysUiSessionId)
                .build(type);
    }
}
Loading