Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 883e5da3 authored by Evan Charlton's avatar Evan Charlton Committed by Steve Kondik
Browse files

Correctly get the current time for quiet hours.

Can't cache the Calendar.getInstance() return value; the time won't
automatically update.

Change-Id: I774d6fdc153bc6a13459a18c56b4d9e3ec2a09ae
parent 344d5c04
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -99,8 +99,6 @@ public class NotificationManagerService extends INotificationManager.Stub

    private static final int DEFAULT_STREAM_TYPE = AudioManager.STREAM_NOTIFICATION;

    private static final Calendar CALENDAR = Calendar.getInstance();

    final Context mContext;
    final IActivityManager mAm;
    final IBinder mForegroundToken = new Binder();
@@ -1005,7 +1003,8 @@ public class NotificationManagerService extends INotificationManager.Stub
    private boolean inQuietHours() {
        if (mQuietHoursEnabled && (mQuietHoursStart != mQuietHoursEnd)) {
            // Get the date in "quiet hours" format.
            int minutes = CALENDAR.get(Calendar.HOUR_OF_DAY) * 60 + CALENDAR.get(Calendar.MINUTE);
            Calendar calendar = Calendar.getInstance();
            int minutes = calendar.get(Calendar.HOUR_OF_DAY) * 60 + calendar.get(Calendar.MINUTE);
            if (mQuietHoursEnd < mQuietHoursStart) {
                // Starts at night, ends in the morning.
                return (minutes > mQuietHoursStart) || (minutes < mQuietHoursEnd);