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

Commit c8f4f70e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE crashes during UDFPS BiometricPrompt" into sc-dev

parents 42bac3b1 9e5e59b5
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2021 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.
  -->
<com.android.systemui.biometrics.UdfpsAnimationViewBp
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/udfps_animation_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</com.android.systemui.biometrics.UdfpsAnimationViewBp>
+12 −1
Original line number Diff line number Diff line
@@ -62,8 +62,11 @@ public abstract class UdfpsAnimationView extends FrameLayout implements DozeRece
    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();

        if (getUdfpsAnimation() != null) {
            getUdfpsAnimation().onDestroy();
        }
    }

    private int expansionToAlpha(float expansion) {
        // Fade to 0 opacity when reaching this expansion amount
@@ -78,11 +81,19 @@ public abstract class UdfpsAnimationView extends FrameLayout implements DozeRece
    }

    void onIlluminationStarting() {
        if (getUdfpsAnimation() == null) {
            return;
        }

        getUdfpsAnimation().setIlluminationShowing(true);
        postInvalidate();
    }

    void onIlluminationStopped() {
        if (getUdfpsAnimation() == null) {
            return;
        }

        getUdfpsAnimation().setIlluminationShowing(false);
        postInvalidate();
    }
+42 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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 com.android.systemui.biometrics;

import android.content.Context;
import android.util.AttributeSet;

import androidx.annotation.Nullable;

/**
 * Class that coordinates non-HBM animations during BiometricPrompt.
 *
 * Note that {@link AuthBiometricUdfpsView} also shows UDFPS animations. At some point we should
 * de-dupe this if necessary. This will probably happen once the top-level TODO in UdfpsController
 * is completed (inflate operation-specific views, instead of inflating generic udfps_view and
 * adding operation-specific animations to it).
 */
public class UdfpsAnimationViewBp extends UdfpsAnimationView {
    public UdfpsAnimationViewBp(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Nullable
    @Override
    protected UdfpsAnimation getUdfpsAnimation() {
        return null;
    }
}
+14 −8
Original line number Diff line number Diff line
@@ -361,23 +361,29 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
        switch (reason) {
            case IUdfpsOverlayController.REASON_ENROLL_FIND_SENSOR:
            case IUdfpsOverlayController.REASON_ENROLL_ENROLLING: {
                final UdfpsAnimationViewEnroll animation = (UdfpsAnimationViewEnroll)
                final UdfpsAnimationViewEnroll view = (UdfpsAnimationViewEnroll)
                        inflater.inflate(R.layout.udfps_animation_view_enroll, null, false);
                animation.setEnrollHelper(mEnrollHelper);
                return animation;
                view.setEnrollHelper(mEnrollHelper);
                return view;
            }

            case IUdfpsOverlayController.REASON_AUTH_BP: {
                final UdfpsAnimationViewBp view = (UdfpsAnimationViewBp)
                        inflater.inflate(R.layout.udfps_animation_view_bp, null, false);
                return view;
            }

            case IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD: {
                final UdfpsAnimationViewKeyguard animation = (UdfpsAnimationViewKeyguard)
                final UdfpsAnimationViewKeyguard view = (UdfpsAnimationViewKeyguard)
                        inflater.inflate(R.layout.udfps_animation_view_keyguard, null, false);
                animation.setStatusBarStateController(mStatusBarStateController);
                return animation;
                view.setStatusBarStateController(mStatusBarStateController);
                return view;
            }

            case IUdfpsOverlayController.REASON_AUTH_FPM_OTHER: {
                final UdfpsAnimationViewFpmOther animation = (UdfpsAnimationViewFpmOther)
                final UdfpsAnimationViewFpmOther view = (UdfpsAnimationViewFpmOther)
                        inflater.inflate(R.layout.udfps_animation_view_fpm_other, null, false);
                return animation;
                return view;
            }

            default: