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

Commit ab589363 authored by Wilson Wu's avatar Wilson Wu Committed by Android (Google) Code Review
Browse files

Merge "Fix keyboard vibration settings delay" into main

parents 05174229 f2174611
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;

import android.app.settings.SettingsEnums;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
import android.net.Uri;
@@ -159,8 +160,11 @@ public class KeyboardVibrationTogglePreferenceController extends TogglePreferenc
    }

    private boolean updateKeyboardVibrationSetting(boolean enable) {
        final boolean success = Settings.System.putInt(mContext.getContentResolver(),
        final ContentResolver contentResolver = mContext.getContentResolver();
        final boolean success = Settings.System.putInt(contentResolver,
                KEYBOARD_VIBRATION_ENABLED, enable ? ON : OFF);
        contentResolver.notifyChange(Settings.System.getUriFor(KEYBOARD_VIBRATION_ENABLED),
                null /* observer */, ContentResolver.NOTIFY_NO_DELAY);
        if (!success) {
            Log.w(TAG, "Update settings database error!");
        }
+5 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.when;
import static org.mockito.Mockito.verify;

import android.app.settings.SettingsEnums;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.os.vibrator.Flags;
@@ -60,6 +61,9 @@ public class KeyboardVibrationTogglePreferenceControllerTest {
    @Mock
    private PreferenceScreen mPreferenceScreen;

    @Mock
    private ContentResolver mContentResolver;

    private Context mContext;
    private Resources mResources;
    private KeyboardVibrationTogglePreferenceController mController;
@@ -72,6 +76,7 @@ public class KeyboardVibrationTogglePreferenceControllerTest {
        mContext = spy(ApplicationProvider.getApplicationContext());
        mResources = spy(mContext.getResources());
        when(mContext.getResources()).thenReturn(mResources);
        when(mContext.getContentResolver()).thenReturn(mContentResolver);
        mFeatureFactory = FakeFeatureFactory.setupForTest();
        mController = new KeyboardVibrationTogglePreferenceController(mContext, "preferenceKey");
        mPreference = new SwitchPreference(mContext);