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

Commit 9541c14a authored by Beverly's avatar Beverly
Browse files

Update screen decor overlays when face auth sensor changes

The face auth sensor location may not be available when
ScreenDecorations initially adds the overlay. If the location
is available later, then the face scanning overlay should be
added.

Test: Reboot device and observe face scanning animation can
be seen when face auth runs (without requiring config change).
Flag: NONE
Test: atest ScreenDecorationsTest
Fixes: 333088555

Change-Id: Id27ddece6b8ebc71ef7ba0e035cff869d91f7b56
parent 5a0f5ab3
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -401,8 +401,6 @@ public class ScreenDecorations implements
        mExecutor = mThreadFactory.buildDelayableExecutorOnHandler(mHandler);
        mExecutor.execute(this::startOnScreenDecorationsThread);
        mDotViewController.setUiExecutor(mExecutor);
        mJavaAdapter.alwaysCollectFlow(mFacePropertyRepository.getSensorLocation(),
                this::onFaceSensorLocationChanged);
        mCommandRegistry.registerCommand(ScreenDecorCommand.SCREEN_DECOR_CMD_NAME,
                () -> new ScreenDecorCommand(mScreenDecorCommandCallback));
    }
@@ -579,6 +577,8 @@ public class ScreenDecorations implements
        };
        mDisplayTracker.addDisplayChangeCallback(mDisplayListener, new HandlerExecutor(mHandler));
        updateConfiguration();
        mJavaAdapter.alwaysCollectFlow(mFacePropertyRepository.getSensorLocation(),
                this::onFaceSensorLocationChanged);
        Trace.endSection();
    }

@@ -1320,10 +1320,18 @@ public class ScreenDecorations implements
    @VisibleForTesting
    void onFaceSensorLocationChanged(Point location) {
        mLogger.onSensorLocationChanged();

        if (mExecutor != null) {
            mExecutor.execute(
                    () -> updateOverlayProviderViews(
                            new Integer[]{mFaceScanningViewId}));
                    () -> {
                        if (getOverlayView(mFaceScanningViewId) == null) {
                            // face sensor location was just initialized
                            setupDecorations();
                        } else {
                            updateOverlayProviderViews(new Integer[]{mFaceScanningViewId});
                        }
                    }
            );
        }
    }

+22 −0
Original line number Diff line number Diff line
@@ -1273,6 +1273,28 @@ public class ScreenDecorationsTest extends SysuiTestCase {
                any());
    }

    @Test
    public void delayedFaceSensorLocationChangesAddsFaceScanningOverlay() {
        setupResources(0 /* radius */, 0 /* radiusTop */, 0 /* radiusBottom */,
                null /* roundedTopDrawable */, null /* roundedBottomDrawable */,
                0 /* roundedPadding */, true /* privacyDot */, false /* faceScanning */);
        mScreenDecorations.start();
        verifyFaceScanningViewExists(false); // face scanning view not added yet

        // WHEN the sensor location is updated
        mFaceScanningProviders = new ArrayList<>();
        mFaceScanningProviders.add(mFaceScanningDecorProvider);
        when(mFaceScanningProviderFactory.getProviders()).thenReturn(mFaceScanningProviders);
        when(mFaceScanningProviderFactory.getHasProviders()).thenReturn(true);
        final Point location = new Point();
        mFakeFacePropertyRepository.setSensorLocation(location);
        mScreenDecorations.onFaceSensorLocationChanged(location);
        mExecutor.runAllReady();

        // THEN the face scanning view is added
        verifyFaceScanningViewExists(true);
    }

    @Test
    public void testPrivacyDotShowingListenerWorkWellWithNullParameter() {
        mPrivacyDotShowingListener.onPrivacyDotShown(null);