Correct the state when prevent ringing page is launched.

When prevent ringing page is opened, the switch gets checked and is set
to vibrate in default. Make it set to a correct state based on the value
stored in Settings.Secure.VOLUME_HUSH_GESTURE.

Fixes: 129728579
Test: robotests
Change-Id: I1063db9fe79800eb2e400810e2414ee650076ea0
This commit is contained in:
Yi-Ling Chuang
2019-04-10 17:28:36 +08:00
parent dc4f7ce282
commit 17afd6633a
2 changed files with 74 additions and 7 deletions

View File

@@ -102,8 +102,15 @@ public class PreventRingingSwitchPreferenceController extends AbstractPreference
@Override
public void onSwitchChanged(Switch switchView, boolean isChecked) {
final int preventRingingSetting = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.VOLUME_HUSH_GESTURE, Settings.Secure.VOLUME_HUSH_VIBRATE);
final int newRingingSetting = preventRingingSetting == Settings.Secure.VOLUME_HUSH_OFF
? Settings.Secure.VOLUME_HUSH_VIBRATE
: preventRingingSetting;
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.VOLUME_HUSH_GESTURE, isChecked ? Settings.Secure.VOLUME_HUSH_VIBRATE
Settings.Secure.VOLUME_HUSH_GESTURE, isChecked
? newRingingSetting
: Settings.Secure.VOLUME_HUSH_OFF);
}