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

Commit 2e62846d authored by Evan Charlton's avatar Evan Charlton
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 f33065db
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -91,8 +91,6 @@ 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;
@@ -934,7 +932,8 @@ 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));