summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGianmarco Reverberi <gianmarco.reverberi@gmail.com>2015-11-08 22:02:10 +0100
committerSteve Kondik <shade@chemlab.org>2015-11-11 04:23:50 -0800
commita98ec263f508da2d8636b304e71b751834704100 (patch)
treef88868484cc443840722646864ce354f70d2188c
parent82f05fbb51021500f7c6c0b34c1ed0defb60d094 (diff)
downloadframeworks_base-a98ec263f508da2d8636b304e71b751834704100.zip
frameworks_base-a98ec263f508da2d8636b304e71b751834704100.tar.gz
frameworks_base-a98ec263f508da2d8636b304e71b751834704100.tar.bz2
SystemUI: fix notification on charger
Change-Id: I92382d556f6224f46beb211bfa0c4a22f2179683
-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) {