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

Commit 15a6ed45 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Ibeaa04b1,Id48d71d9 into main

* changes:
  Prevent NPE when retrieving sensor properties
  AI-generated suggestion for a Null Pointer Exception.
parents 658d789e 3ca5d34f
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.hardware.biometrics;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;

@@ -38,7 +39,11 @@ public class SensorPropertiesInternal implements Parcelable {
    public final boolean resetLockoutRequiresHardwareAuthToken;
    public final boolean resetLockoutRequiresChallenge;

    public static SensorPropertiesInternal from(@NonNull SensorPropertiesInternal prop) {
    @Nullable
    public static SensorPropertiesInternal from(@Nullable SensorPropertiesInternal prop) {
        if (prop == null) {
            return null;
        }
        return new SensorPropertiesInternal(prop.sensorId, prop.sensorStrength,
                prop.maxEnrollmentsPerUser, prop.componentInfo,
                prop.resetLockoutRequiresHardwareAuthToken, prop.resetLockoutRequiresChallenge);
+3 −1
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ import com.android.server.companion.virtual.VirtualDeviceManagerInternal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * System service that provides an interface for authenticating with biometrics and
@@ -268,7 +269,8 @@ public class AuthService extends SystemService {
            try {
                // Get the result from BiometricService, since it is the source of truth for all
                // biometric sensors.
                return mInjector.getBiometricService().getSensorProperties(opPackageName);
                return mInjector.getBiometricService().getSensorProperties(opPackageName)
                        .stream().filter(p -> p != null).collect(Collectors.toList());
            } finally {
                Binder.restoreCallingIdentity(identity);
            }
+9 −4
Original line number Diff line number Diff line
@@ -900,11 +900,16 @@ public class BiometricService extends SystemService {
            for (BiometricSensor sensor : mSensors) {
                // Explicitly re-create as the super class, since AIDL doesn't play nicely with
                // "List<? extends SensorPropertiesInternal> ...
                final SensorPropertiesInternal prop = SensorPropertiesInternal
                        .from(sensor.impl.getSensorProperties(opPackageName));
                SensorPropertiesInternal sensorProperties =
                        sensor.impl.getSensorProperties(opPackageName);
                if (sensorProperties != null) {
                    final SensorPropertiesInternal prop = SensorPropertiesInternal.from(
                            sensorProperties);
                    if (prop != null) {
                      sensors.add(prop);
                    }

                }
            }
            return sensors;
        }