summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/power/PowerUI.java')
-rw-r--r--packages/SystemUI/src/com/android/systemui/power/PowerUI.java27
1 files changed, 11 insertions, 16 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
index 5913bb7..4c1a16c 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
@@ -24,12 +24,15 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
+import android.media.Ringtone;
+import android.media.RingtoneManager;
import android.net.Uri;
import android.os.BatteryManager;
import android.os.Handler;
import android.os.PowerManager;
import android.os.SystemClock;
import android.os.UserHandle;
+import android.os.Vibrator;
import android.provider.Settings;
import android.util.Log;
import android.util.Slog;
@@ -249,27 +252,19 @@ public class PowerUI extends SystemUI {
final String soundPath =
Settings.Global.getString(cr, Settings.Global.POWER_NOTIFICATIONS_RINGTONE);
- NotificationManager notificationManager =
- (NotificationManager)mContext.getSystemService(Context.NOTIFICATION_SERVICE);
- if (notificationManager == null) {
- return;
- }
-
- Notification powerNotify=new Notification();
- powerNotify.defaults = Notification.DEFAULT_ALL;
if (soundPath != null) {
- powerNotify.sound = Uri.parse(soundPath);
- if (powerNotify.sound != null) {
- // DEFAULT_SOUND overrides so flip off
- powerNotify.defaults &= ~Notification.DEFAULT_SOUND;
+ Ringtone powerRingtone = RingtoneManager.getRingtone(mContext, Uri.parse(soundPath));
+ if (powerRingtone != null) {
+ powerRingtone.play();
}
}
if (Settings.Global.getInt(cr,
- Settings.Global.POWER_NOTIFICATIONS_VIBRATE, 0) == 0) {
- powerNotify.defaults &= ~Notification.DEFAULT_VIBRATE;
+ Settings.Global.POWER_NOTIFICATIONS_VIBRATE, 0) == 1) {
+ Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
+ if (vibrator != null) {
+ vibrator.vibrate(250);
+ }
}
-
- notificationManager.notify(0, powerNotify);
}
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {