Revert "Add primary switch for vibration settings screen"
This reverts commit fd54fc34c6
.
Reason for revert: b/215275738
Change-Id: I93612df6493a2a4184a98b3f049e23aa888095f2
This commit is contained in:
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.ContentObserver;
|
||||
@@ -38,23 +36,12 @@ import com.android.settingslib.core.AbstractPreferenceController;
|
||||
*/
|
||||
public abstract class VibrationPreferenceConfig {
|
||||
|
||||
/**
|
||||
* SettingsProvider key for the main "Vibration & haptics" toggle preference, that can disable
|
||||
* all device vibrations.
|
||||
*/
|
||||
public static final String MAIN_SWITCH_SETTING_KEY = Settings.System.VIBRATE_ON;
|
||||
|
||||
protected final ContentResolver mContentResolver;
|
||||
private final Vibrator mVibrator;
|
||||
private final String mSettingKey;
|
||||
private final int mDefaultIntensity;
|
||||
private final VibrationAttributes mVibrationAttributes;
|
||||
|
||||
/** Returns true if the user setting for enabling device vibrations is enabled. */
|
||||
public static boolean isMainVibrationSwitchEnabled(ContentResolver contentResolver) {
|
||||
return Settings.System.getInt(contentResolver, MAIN_SWITCH_SETTING_KEY, ON) == ON;
|
||||
}
|
||||
|
||||
public VibrationPreferenceConfig(Context context, String settingKey, int vibrationUsage) {
|
||||
mContentResolver = context.getContentResolver();
|
||||
mVibrator = context.getSystemService(Vibrator.class);
|
||||
@@ -65,16 +52,11 @@ public abstract class VibrationPreferenceConfig {
|
||||
.build();
|
||||
}
|
||||
|
||||
/** Returns the setting key for this setting preference. */
|
||||
/** Return the setting key for this setting preference. */
|
||||
public String getSettingKey() {
|
||||
return mSettingKey;
|
||||
}
|
||||
|
||||
/** Returns true if this setting preference is enabled for user update. */
|
||||
public boolean isPreferenceEnabled() {
|
||||
return isMainVibrationSwitchEnabled(mContentResolver);
|
||||
}
|
||||
|
||||
/** Returns the default intensity to be displayed when the setting value is not set. */
|
||||
public int getDefaultIntensity() {
|
||||
return mDefaultIntensity;
|
||||
@@ -98,9 +80,6 @@ public abstract class VibrationPreferenceConfig {
|
||||
|
||||
/** {@link ContentObserver} for a setting described by a {@link VibrationPreferenceConfig}. */
|
||||
public static final class SettingObserver extends ContentObserver {
|
||||
private static final Uri MAIN_SWITCH_SETTING_URI =
|
||||
Settings.System.getUriFor(MAIN_SWITCH_SETTING_KEY);
|
||||
|
||||
private final Uri mUri;
|
||||
private AbstractPreferenceController mPreferenceController;
|
||||
private Preference mPreference;
|
||||
@@ -113,11 +92,7 @@ public abstract class VibrationPreferenceConfig {
|
||||
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
if (mPreferenceController == null || mPreference == null) {
|
||||
// onDisplayPreference not triggered yet, nothing to update.
|
||||
return;
|
||||
}
|
||||
if (mUri.equals(uri) || MAIN_SWITCH_SETTING_URI.equals(uri)) {
|
||||
if (mUri.equals(uri) && mPreferenceController != null && mPreference != null) {
|
||||
mPreferenceController.updateState(mPreference);
|
||||
}
|
||||
}
|
||||
@@ -128,8 +103,6 @@ public abstract class VibrationPreferenceConfig {
|
||||
*/
|
||||
public void register(ContentResolver contentResolver) {
|
||||
contentResolver.registerContentObserver(mUri, /* notifyForDescendants= */ false, this);
|
||||
contentResolver.registerContentObserver(MAIN_SWITCH_SETTING_URI,
|
||||
/* notifyForDescendants= */ false, this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user