Permalink
Browse files

SystemUI: fix notification on charger

Change-Id: I92382d556f6224f46beb211bfa0c4a22f2179683
  • Loading branch information...
gianmarcorev authored and xlxfoxxlx committed Nov 8, 2015
1 parent 4abad7f commit 7d2f3560f7b6b4957145382761821e65607e828c
Showing with 11 additions and 16 deletions.
  1. +11 −16 packages/SystemUI/src/com/android/systemui/power/PowerUI.java
@@ -25,13 +25,16 @@
import android.content.IntentFilter;
import android.content.res.Resources;
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.HardwarePropertiesManager;
import android.os.PowerManager;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.Vibrator;
import android.provider.Settings;
import android.text.format.DateUtils;
import android.util.Log;
@@ -356,27 +359,19 @@ void playPowerNotificationSound() {
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) {

0 comments on commit 7d2f356

Please sign in to comment.