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

Commit 0e7f3b21 authored by Pascal Muetschard's avatar Pascal Muetschard
Browse files

Fix property change handler in InteractionJankMonitor.

The property change handler is provided with a property map that only
contains the properties that have changed, not all the properties in
our namespace. The old verison would reset properties back to their
default, whenever a property change event was received without the full
list of properties.

Test: manual
Change-Id: I37fa747c0873d332db84c777638203638c60c127
parent 6c29a6fb
Loading
Loading
Loading
Loading
+34 −18
Original line number Diff line number Diff line
@@ -837,25 +837,41 @@ public class InteractionJankMonitor {

    @WorkerThread
    private void updateProperties(DeviceConfig.Properties properties) {
        mSamplingInterval = properties.getInt(SETTINGS_SAMPLING_INTERVAL_KEY,
                DEFAULT_SAMPLING_INTERVAL);
        mTraceThresholdMissedFrames = properties.getInt(SETTINGS_THRESHOLD_MISSED_FRAMES_KEY,
                DEFAULT_TRACE_THRESHOLD_MISSED_FRAMES);
        mTraceThresholdFrameTimeMillis = properties.getInt(
                SETTINGS_THRESHOLD_FRAME_TIME_MILLIS_KEY,
                DEFAULT_TRACE_THRESHOLD_FRAME_TIME_MILLIS);
        for (String property : properties.getKeyset()) {
            switch (property) {
                case SETTINGS_SAMPLING_INTERVAL_KEY:
                    mSamplingInterval = properties.getInt(property, DEFAULT_SAMPLING_INTERVAL);
                    break;
                case SETTINGS_THRESHOLD_MISSED_FRAMES_KEY:
                    mTraceThresholdMissedFrames =
                            properties.getInt(property, DEFAULT_TRACE_THRESHOLD_MISSED_FRAMES);
                    break;
                case SETTINGS_THRESHOLD_FRAME_TIME_MILLIS_KEY:
                    mTraceThresholdFrameTimeMillis =
                            properties.getInt(property, DEFAULT_TRACE_THRESHOLD_FRAME_TIME_MILLIS);
                    break;
                case SETTINGS_ENABLED_KEY:
                    mEnabled = properties.getBoolean(property, DEFAULT_ENABLED);
                    break;
                case SETTINGS_DEBUG_OVERLAY_ENABLED_KEY:
                    // Never allow the debug overlay to be used on user builds
        boolean debugOverlayEnabled = Build.IS_DEBUGGABLE && properties.getBoolean(
                SETTINGS_DEBUG_OVERLAY_ENABLED_KEY,
                DEFAULT_DEBUG_OVERLAY_ENABLED);
                    boolean debugOverlayEnabled = Build.IS_DEBUGGABLE
                            && properties.getBoolean(property, DEFAULT_DEBUG_OVERLAY_ENABLED);
                    if (debugOverlayEnabled && mDebugOverlay == null) {
            mDebugOverlay = new InteractionMonitorDebugOverlay(mLock, mDebugBgColor, mDebugYOffset);
                        mDebugOverlay = new InteractionMonitorDebugOverlay(
                                mLock, mDebugBgColor, mDebugYOffset);
                    } else if (!debugOverlayEnabled && mDebugOverlay != null) {
                        mDebugOverlay.dispose();
                        mDebugOverlay = null;
                    }
        // The memory visibility is powered by the volatile field, mEnabled.
        mEnabled = properties.getBoolean(SETTINGS_ENABLED_KEY, DEFAULT_ENABLED);
                    break;
                default:
                    if (DEBUG) {
                        Log.d(TAG, "Got a change event for an unknown property: "
                                + property + " => " + properties.getString(property, ""));
                    }
            }
        }
    }

    @VisibleForTesting