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

Commit 13c7b270 authored by Curtis Belmonte's avatar Curtis Belmonte
Browse files

Fix possible NPE in fingerprint service provider

Test: atest FingerprintManagerTest

Bug: 179073068
Change-Id: If624d54834c443b727e574333a4bd116f11a297c
parent 69237805
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -67,7 +67,13 @@ public interface ServiceProvider {
    @NonNull
    List<FingerprintSensorPropertiesInternal> getSensorProperties();

    @NonNull
    /**
     * Returns the internal properties of the specified sensor, if owned by this provider.
     *
     * @param sensorId The ID of a fingerprint sensor, or -1 for any sensor.
     * @return An object representing the internal properties of the specified sensor.
     */
    @Nullable
    FingerprintSensorPropertiesInternal getSensorProperties(int sensorId);

    void scheduleResetLockout(int sensorId, int userId, @Nullable byte[] hardwareAuthToken);
+11 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.biometrics.sensors.fingerprint.aidl;

import static android.hardware.fingerprint.FingerprintManager.SENSOR_ID_ANY;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
@@ -240,10 +242,17 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
        return props;
    }

    @NonNull
    @Nullable
    @Override
    public FingerprintSensorPropertiesInternal getSensorProperties(int sensorId) {
        return mSensors.get(sensorId).getSensorProperties();
        if (mSensors.size() == 0) {
            return null;
        } else if (sensorId == SENSOR_ID_ANY) {
            return mSensors.valueAt(0).getSensorProperties();
        } else {
            final Sensor sensor = mSensors.get(sensorId);
            return sensor != null ? sensor.getSensorProperties() : null;
        }
    }

    private void scheduleLoadAuthenticatorIds(int sensorId) {
+1 −1
Original line number Diff line number Diff line
@@ -515,7 +515,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
        return properties;
    }

    @NonNull
    @Nullable
    @Override
    public FingerprintSensorPropertiesInternal getSensorProperties(int sensorId) {
        return mSensorProperties;