New user interface sound effects:
- Low battery. (http://b/2320026)
- Dock/undock events.
- Keyguard lock/unlock events.
New system settings have been created to turn these on/off
and to specify the relevant sound files.
[Production notes: The provided low battery sound and dock
sounds were synthesized; the lock screen sounds are
processed samples of a ballpoint pen click mechanism.]
Bug: 2320026
Change-Id: I374285b0f94f59c7555bb8816580f5a8c802e90d
diff --git a/services/java/com/android/server/status/StatusBarPolicy.java b/services/java/com/android/server/status/StatusBarPolicy.java
index 20209e4..d13f9d3 100644
--- a/services/java/com/android/server/status/StatusBarPolicy.java
+++ b/services/java/com/android/server/status/StatusBarPolicy.java
@@ -22,6 +22,7 @@
import android.bluetooth.BluetoothHeadset;
import android.bluetooth.BluetoothPbap;
import android.content.BroadcastReceiver;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -30,7 +31,10 @@
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
+import android.media.Ringtone;
+import android.media.RingtoneManager;
import android.net.NetworkInfo;
+import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.Binder;
import android.os.Handler;
@@ -109,6 +113,7 @@
private int mBatteryViewSequence;
private boolean mBatteryShowLowOnEndCall = false;
private static final boolean SHOW_LOW_BATTERY_WARNING = true;
+ private static final boolean SHOW_BATTERY_WARNINGS_IN_CALL = true;
// phone
private TelephonyManager mPhone;
@@ -686,7 +691,7 @@
+ " mBatteryShowLowOnEndCall=" + mBatteryShowLowOnEndCall);
}
- if (mPhoneState == TelephonyManager.CALL_STATE_IDLE) {
+ if (SHOW_BATTERY_WARNINGS_IN_CALL || mPhoneState == TelephonyManager.CALL_STATE_IDLE) {
showLowBatteryWarning();
} else {
mBatteryShowLowOnEndCall = true;
@@ -810,6 +815,21 @@
d.show();
mLowBatteryDialog = d;
}
+
+ final ContentResolver cr = mContext.getContentResolver();
+ if (Settings.System.getInt(cr,
+ Settings.System.POWER_SOUNDS_ENABLED, 1) == 1)
+ {
+ final String soundPath = Settings.System.getString(cr,
+ Settings.System.LOW_BATTERY_SOUND);
+ if (soundPath != null) {
+ final Uri soundUri = Uri.parse("file://" + soundPath);
+ if (soundUri != null) {
+ final Ringtone sfx = RingtoneManager.getRingtone(mContext, soundUri);
+ if (sfx != null) sfx.play();
+ }
+ }
+ }
}
private final void updateCallState(int state) {