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

Commit df512171 authored by Alexey Kuzmin's avatar Alexey Kuzmin Committed by android-build-merger
Browse files

Move vibration preview invokation to the correct place

am: f8eb8c3c

Change-Id: I252301516d7be6b5026e4fba5b5e9144889f6b1f
parents b979a38c f8eb8c3c
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -128,6 +128,20 @@ public abstract class VibrationPreferenceFragment extends RadioButtonPickerFragm
                    Settings.System.putInt(getContext().getContentResolver(),
                            vibrationEnabledSetting, vibrationEnabled ? 1 : 0);
                }

                int previousIntensity = Settings.System.getInt(getContext().getContentResolver(),
                        getVibrationIntensitySetting(), 0);
                if (vibrationEnabled && previousIntensity == candidate.getIntensity()) {
                    // We can't play preview effect here for all cases because that causes a data
                    // race (VibratorService may access intensity settings before these settings
                    // are updated). But we can't just play it in intensity settings update
                    // observer, because the intensity settings are not changed if we turn the
                    // vibration off, then on.
                    //
                    // In this case we sould play the preview here.
                    // To be refactored in b/132952771
                    playVibrationPreview();
                }
            }
        }
        // There are two conditions that need to change the intensity.
@@ -137,15 +151,6 @@ public abstract class VibrationPreferenceFragment extends RadioButtonPickerFragm
            // Update vibration intensity setting
            Settings.System.putInt(getContext().getContentResolver(),
                    getVibrationIntensitySetting(), candidate.getIntensity());
        } else {
            // We can't play preview effect here for all cases because that causes a data race
            // (VibratorService may access intensity settings before these settings are updated).
            // But we can't just play it in intensity settings update observer, because the
            // intensity settings are not changed if we turn the vibration off, then on.
            //
            // In this case we sould play the preview here.
            // To be refactored in b/132952771
            playVibrationPreview();
        }
    }