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

Commit 788d6659 authored by Ilya Matyukhin's avatar Ilya Matyukhin
Browse files

Return immediately from isHardwareDetected

If the service is not available at the time of the call, do not call
ServiceManager.waitForDeclaredService(halFqn) as this call will wait
indefinitely for the HAL to start if the HAL is declared.

This is important because isHardwareDetected is used in SystemUI
(Keyguard) to determine whether certain UI elements should be available.
If the HAL crashes and cannot restart, this can cause a SystemUI ANR.

Bug: 189275305
Test: on device with a declared HAL that never registers itself.
Change-Id: Ia768bf5b1bc124fd789cbe8e5fe523e1fa2becca
parent 6fda8023
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -160,6 +160,13 @@ public class FaceProvider implements IBinder.DeathRecipient, ServiceProvider {
        return "FaceProvider/" + mHalInstanceName;
    }

    boolean hasHalInstance() {
        if (mTestHalEnabled) {
            return true;
        }
        return ServiceManager.checkService(IFace.DESCRIPTOR + "/" + mHalInstanceName) != null;
    }

    @Nullable
    @VisibleForTesting
    synchronized IFace getHalInstance() {
@@ -291,7 +298,7 @@ public class FaceProvider implements IBinder.DeathRecipient, ServiceProvider {

    @Override
    public boolean isHardwareDetected(int sensorId) {
        return getHalInstance() != null;
        return hasHalInstance();
    }

    @Override
+9 −1
Original line number Diff line number Diff line
@@ -172,6 +172,14 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
        return "FingerprintProvider/" + mHalInstanceName;
    }

    boolean hasHalInstance() {
        if (mTestHalEnabled) {
            return true;
        }
        return (ServiceManager.checkService(IFingerprint.DESCRIPTOR + "/" + mHalInstanceName)
                != null);
    }

    @Nullable
    @VisibleForTesting
    synchronized IFingerprint getHalInstance() {
@@ -454,7 +462,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi

    @Override
    public boolean isHardwareDetected(int sensorId) {
        return getHalInstance() != null;
        return hasHalInstance();
    }

    @Override