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

Commit 8d2fd576 authored by Ilya Matyukhin's avatar Ilya Matyukhin
Browse files

Remove retry in Fingerprint21 getService

The retry was preventing the system from booting on devices that
were failing to load the fingerprint HAL.

Instead of retrying immediately, the system will try to retrieve the HAL
again only when it's needed. On a misconfigured or bad device where the
HAL cannot be retrieved, the system will simply log an error and move
on.

The retry was originally introduced to fix the unreliable isUdfps check.
Sometimes the HAL wouldn't be loaded early enough, and that would cause
the system to think that the sensor is not a UDFPS, as a side effect.

The check is fixed in this change by relying on the presence of a UDFPS
config in config.xml.

Bug: 178053992
Bug: 179465449
Test: the absence/presence of UDFPS is detected correctly
Test: the system boots with manually deleted HAL binary
Change-Id: I5d3b81e26f6ed421d32691c6cab55ef90f4b5ec8
parent ca389a64
Loading
Loading
Loading
Loading
+8 −16
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import android.util.proto.ProtoOutputStream;

import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.FrameworkStatsLog;
import com.android.server.biometrics.SensorServiceStateProto;
import com.android.server.biometrics.SensorStateProto;
@@ -113,7 +114,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
    @NonNull private final HalResultController mHalResultController;
    @Nullable private IUdfpsOverlayController mUdfpsOverlayController;
    private int mCurrentUserId = UserHandle.USER_NULL;
    private boolean mIsUdfps = false;
    private final boolean mIsUdfps;
    private final int mSensorId;

    private final class BiometricTaskStackListener extends TaskStackListener {
@@ -335,19 +336,10 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
            Slog.e(TAG, "Unable to register user switch observer");
        }

        final IBiometricsFingerprint daemon = getDaemon();
        mIsUdfps = false;
        android.hardware.biometrics.fingerprint.V2_3.IBiometricsFingerprint extension =
                android.hardware.biometrics.fingerprint.V2_3.IBiometricsFingerprint.castFrom(
                        daemon);
        if (extension != null) {
            try {
                mIsUdfps = extension.isUdfps(sensorId);
            } catch (RemoteException e) {
                Slog.e(TAG, "Remote exception while quering udfps", e);
                mIsUdfps = false;
            }
        }
        // TODO(b/179175438): Remove this code block after transition to AIDL.
        // The existence of config_udfps_sensor_props indicates that the sensor is UDFPS.
        mIsUdfps = !ArrayUtils.isEmpty(
                mContext.getResources().getIntArray(R.array.config_udfps_sensor_props));

        final @FingerprintSensorProperties.SensorType int sensorType =
                mIsUdfps ? FingerprintSensorProperties.TYPE_UDFPS_OPTICAL
@@ -415,7 +407,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
        Slog.d(TAG, "Daemon was null, reconnecting, current operation: "
                + mScheduler.getCurrentClient());
        try {
            mDaemon = IBiometricsFingerprint.getService(true /* retry */);
            mDaemon = IBiometricsFingerprint.getService();
        } catch (java.util.NoSuchElementException e) {
            // Service doesn't exist or cannot be opened.
            Slog.w(TAG, "NoSuchElementException", e);