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

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

Merge "Clear calling identity before invoking contrast listeners" into main

parents 80e6ae72 bec93bc1
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -574,13 +574,30 @@ public class UiModeManager {

        @Override
        public void notifyContrastChanged(float contrast) {
            final Map<ContrastChangeListener, Executor> listeners;
            synchronized (mGlobalsLock) {
                // if value changed in the settings, update the cached value and notify listeners
                if (Math.abs(mContrast - contrast) < 1e-10) return;
                mContrast = contrast;

                if (!fixContrastAndForceInvertStateForMultiUser()) {
                    mContrastChangeListeners.forEach((listener, executor) -> executor.execute(
                            () -> listener.onContrastChanged(contrast)));
                    return;
                }
                listeners = new ArrayMap<>(mContrastChangeListeners);
            }

            listeners.forEach((listener, executor) -> {
                final long token = Binder.clearCallingIdentity();
                try {
                    executor.execute(() -> listener.onContrastChanged(contrast));
                } finally {
                    Binder.restoreCallingIdentity(token);
                }
            });


        }

        @Override