Boot Sounds setting in OtherSoundSettings
Uses a persistent system property so it can be accessed by bootanim. BUG:30690353 Change-Id: Iffb7e140074b8bf4b0faabdecbbf163b14360655
This commit is contained in:
@@ -5998,6 +5998,9 @@
|
|||||||
<!-- Sound: Other sounds: Value for the emergency tone option with value 2: vibrate. [CHAR LIMIT=30] -->
|
<!-- Sound: Other sounds: Value for the emergency tone option with value 2: vibrate. [CHAR LIMIT=30] -->
|
||||||
<string name="emergency_tone_vibrate">Vibrate</string>
|
<string name="emergency_tone_vibrate">Vibrate</string>
|
||||||
|
|
||||||
|
<!-- Sound: Other sounds: Title for the option enabling boot sounds. [CHAR LIMIT=30] -->
|
||||||
|
<string name="boot_sounds_title">Power on sounds</string>
|
||||||
|
|
||||||
<!-- Sound: Title for the Do not Disturb option and associated settings page. [CHAR LIMIT=30] -->
|
<!-- Sound: Title for the Do not Disturb option and associated settings page. [CHAR LIMIT=30] -->
|
||||||
<string name="zen_mode_settings_title">Do not disturb</string>
|
<string name="zen_mode_settings_title">Do not disturb</string>
|
||||||
|
|
||||||
|
@@ -55,6 +55,11 @@
|
|||||||
android:title="@string/dock_audio_media_title"
|
android:title="@string/dock_audio_media_title"
|
||||||
android:summary="%s" />
|
android:summary="%s" />
|
||||||
|
|
||||||
|
<!-- Boot sounds -->
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="boot_sounds"
|
||||||
|
android:title="@string/boot_sounds_title" />
|
||||||
|
|
||||||
<!-- Emergency tone -->
|
<!-- Emergency tone -->
|
||||||
<DropDownPreference
|
<DropDownPreference
|
||||||
android:key="emergency_tone"
|
android:key="emergency_tone"
|
||||||
|
@@ -25,10 +25,13 @@ import android.net.Uri;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
import android.provider.Settings.Global;
|
import android.provider.Settings.Global;
|
||||||
import android.provider.Settings.System;
|
import android.provider.Settings.System;
|
||||||
|
import android.support.v14.preference.SwitchPreference;
|
||||||
|
import android.support.v7.preference.Preference;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
|
||||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||||
@@ -68,6 +71,10 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In
|
|||||||
private static final String KEY_DOCK_AUDIO_MEDIA = "dock_audio_media";
|
private static final String KEY_DOCK_AUDIO_MEDIA = "dock_audio_media";
|
||||||
private static final String KEY_EMERGENCY_TONE = "emergency_tone";
|
private static final String KEY_EMERGENCY_TONE = "emergency_tone";
|
||||||
|
|
||||||
|
// Boot Sounds needs to be a system property so it can be accessed during boot.
|
||||||
|
private static final String KEY_BOOT_SOUNDS = "boot_sounds";
|
||||||
|
private static final String PROPERTY_BOOT_SOUNDS = "persist.sys.bootanim.play_sound";
|
||||||
|
|
||||||
private static final SettingPref PREF_DIAL_PAD_TONES = new SettingPref(
|
private static final SettingPref PREF_DIAL_PAD_TONES = new SettingPref(
|
||||||
TYPE_SYSTEM, KEY_DIAL_PAD_TONES, System.DTMF_TONE_WHEN_DIALING, DEFAULT_ON) {
|
TYPE_SYSTEM, KEY_DIAL_PAD_TONES, System.DTMF_TONE_WHEN_DIALING, DEFAULT_ON) {
|
||||||
@Override
|
@Override
|
||||||
@@ -174,6 +181,8 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In
|
|||||||
PREF_EMERGENCY_TONE,
|
PREF_EMERGENCY_TONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private SwitchPreference mBootSounds;
|
||||||
|
|
||||||
private final SettingsObserver mSettingsObserver = new SettingsObserver();
|
private final SettingsObserver mSettingsObserver = new SettingsObserver();
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -199,6 +208,9 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In
|
|||||||
for (SettingPref pref : PREFS) {
|
for (SettingPref pref : PREFS) {
|
||||||
pref.init(this);
|
pref.init(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mBootSounds = (SwitchPreference) findPreference(KEY_BOOT_SOUNDS);
|
||||||
|
mBootSounds.setChecked(SystemProperties.getBoolean(PROPERTY_BOOT_SOUNDS, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -213,6 +225,16 @@ public class OtherSoundSettings extends SettingsPreferenceFragment implements In
|
|||||||
mSettingsObserver.register(false);
|
mSettingsObserver.register(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceTreeClick(Preference preference) {
|
||||||
|
if (preference == mBootSounds) {
|
||||||
|
SystemProperties.set(PROPERTY_BOOT_SOUNDS, mBootSounds.isChecked() ? "1" : "0");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return super.onPreferenceTreeClick(preference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean hasDockSettings(Context context) {
|
private static boolean hasDockSettings(Context context) {
|
||||||
return context.getResources().getBoolean(R.bool.has_dock_settings);
|
return context.getResources().getBoolean(R.bool.has_dock_settings);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user