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

Commit c3de5db6 authored by Atneya Nair's avatar Atneya Nair
Browse files

Catch STHAL factory exceptions

The ST HAL factory may throw on back-to-back HAL process deaths.

Loop until the factory successfully creates.

Bug: 271058477
Test: AlwaysOnHotwordDetectorTest
Test: Successful attach on boot, audioserver death
Change-Id: Ifeb84d604cd0330cd0f9f2e11aa8cb6e14bc7b26
parent d2c2751b
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -168,9 +168,18 @@ class SoundTriggerModule implements IBinder.DeathRecipient, ISoundTriggerHal.Glo
     * Attached to the HAL service via factory.
     */
    private void attachToHal() {
        mHalService = null;
        while (mHalService == null) {
            try {
                mHalService = new SoundTriggerHalEnforcer(
                        new SoundTriggerHalWatchdog(
                            new SoundTriggerDuplicateModelHandler(mHalFactory.create())));
            } catch (RuntimeException e) {
                if (!(e.getCause() instanceof RemoteException)) {
                    throw e;
                }
            }
        }
        mHalService.linkToDeath(this);
        mHalService.registerCallback(this);
        mProperties = mHalService.getProperties();