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

Commit 75477d54 authored by Raman Tenneti's avatar Raman Tenneti Committed by Gerrit Code Review
Browse files

Merge "Revert submission"

parents e9c58020 a900038e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@
    <original-package android:name="com.android.alarmclock" />
    <original-package android:name="com.android.deskclock" />

    <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="29" />
    <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="25" />

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
+86 −180
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ package com.android.deskclock.alarms;

import android.annotation.TargetApi;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
@@ -47,47 +46,6 @@ import java.util.Objects;
final class AlarmNotifications {
    static final String EXTRA_NOTIFICATION_ID = "extra_notification_id";

    /**
     * Notification channel containing all low priority notifications.
     */
    private static final String ALARM_LOW_PRIORITY_NOTIFICATION_CHANNEL_ID =
            "alarmLowPriorityNotification";

    /**
     * Notification channel containing all high priority notifications.
     */
    private static final String ALARM_HIGH_PRIORITY_NOTIFICATION_CHANNEL_ID =
            "alarmHighPriorityNotification";

    /**
     * Notification channel containing all upcoming update notifications.
     */
    private static final String ALARM_UPDATE_UPCOMING_NOTIFICATION_CHANNEL_ID =
            "alarmUpdateUpcomingNotification";

    /**
     * Notification channel containing all missed update notifications.
     */
    private static final String ALARM_UPDATE_MISSED_NOTIFICATION_CHANNEL_ID =
            "alarmUpdateMissedNotification";

    /**
     * Notification channel containing all snooze notifications.
     */
    private static final String ALARM_SNOOZE_NOTIFICATION_CHANNEL_ID =
            "alarmSnoozeNotification";

    /**
     * Notification channel containing all missed notifications.
     */
    private static final String ALARM_MISSED_NOTIFICATION_CHANNEL_ID =
            "alarmMissedNotification";

    /**
     * Notification channel containing all alarm notifications.
     */
    private static final String ALARM_NOTIFICATION_CHANNEL_ID = "alarmNotification";

    /**
     * Formats times such that chronological order and lexicographical order agree.
     */
@@ -128,13 +86,11 @@ final class AlarmNotifications {
            AlarmInstance instance) {
        LogUtils.v("Displaying low priority notification for alarm instance: " + instance.mId);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(
                 context, ALARM_LOW_PRIORITY_NOTIFICATION_CHANNEL_ID)
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                .setShowWhen(false)
                .setContentTitle(context.getString(
                        R.string.alarm_alert_predismiss_title))
                        .setContentText(AlarmUtils.getAlarmText(
                                context, instance, true /* includeLabel */))
                .setContentText(AlarmUtils.getAlarmText(context, instance, true /* includeLabel */))
                .setColor(ContextCompat.getColor(context, R.color.default_background))
                .setSmallIcon(R.drawable.stat_notify_alarm)
                .setAutoCancel(false)
@@ -170,13 +126,6 @@ final class AlarmNotifications {
                viewAlarmIntent, PendingIntent.FLAG_UPDATE_CURRENT));

        NotificationManagerCompat nm = NotificationManagerCompat.from(context);
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            NotificationChannel channel = new NotificationChannel(
                    ALARM_LOW_PRIORITY_NOTIFICATION_CHANNEL_ID,
                    context.getString(R.string.default_label),
                    NotificationManagerCompat.IMPORTANCE_DEFAULT);
            nm.createNotificationChannel(channel);
        }
        final Notification notification = builder.build();
        nm.notify(id, notification);
        updateUpcomingAlarmGroupNotification(context, -1, notification);
@@ -186,13 +135,10 @@ final class AlarmNotifications {
            AlarmInstance instance) {
        LogUtils.v("Displaying high priority notification for alarm instance: " + instance.mId);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(
                context, ALARM_HIGH_PRIORITY_NOTIFICATION_CHANNEL_ID)
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                .setShowWhen(false)
                        .setContentTitle(context.getString(
                                R.string.alarm_alert_predismiss_title))
                        .setContentText(AlarmUtils.getAlarmText(
                                context, instance, true /* includeLabel */))
                .setContentTitle(context.getString(R.string.alarm_alert_predismiss_title))
                .setContentText(AlarmUtils.getAlarmText(context, instance, true /* includeLabel */))
                .setColor(ContextCompat.getColor(context, R.color.default_background))
                .setSmallIcon(R.drawable.stat_notify_alarm)
                .setAutoCancel(false)
@@ -221,13 +167,6 @@ final class AlarmNotifications {
                viewAlarmIntent, PendingIntent.FLAG_UPDATE_CURRENT));

        NotificationManagerCompat nm = NotificationManagerCompat.from(context);
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            NotificationChannel channel = new NotificationChannel(
                    ALARM_HIGH_PRIORITY_NOTIFICATION_CHANNEL_ID,
                    context.getString(R.string.default_label),
                    NotificationManagerCompat.IMPORTANCE_DEFAULT);
            nm.createNotificationChannel(channel);
        }
        final Notification notification = builder.build();
        nm.notify(id, notification);
        updateUpcomingAlarmGroupNotification(context, -1, notification);
@@ -293,13 +232,6 @@ final class AlarmNotifications {
        }

        final NotificationManagerCompat nm = NotificationManagerCompat.from(context);
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            NotificationChannel channel = new NotificationChannel(
                    ALARM_UPDATE_UPCOMING_NOTIFICATION_CHANNEL_ID,
                    context.getString(R.string.default_label),
                    NotificationManagerCompat.IMPORTANCE_DEFAULT);
            nm.createNotificationChannel(channel);
        }

        final Notification firstUpcoming = getFirstActiveNotification(context, UPCOMING_GROUP_KEY,
                canceledNotificationId, postedNotification);
@@ -311,8 +243,7 @@ final class AlarmNotifications {
        Notification summary = getActiveGroupSummaryNotification(context, UPCOMING_GROUP_KEY);
        if (summary == null
                || !Objects.equals(summary.contentIntent, firstUpcoming.contentIntent)) {
            summary = new NotificationCompat.Builder(
                    context, ALARM_UPDATE_UPCOMING_NOTIFICATION_CHANNEL_ID)
            summary = new NotificationCompat.Builder(context)
                    .setShowWhen(false)
                    .setContentIntent(firstUpcoming.contentIntent)
                    .setColor(ContextCompat.getColor(context, R.color.default_background))
@@ -335,12 +266,6 @@ final class AlarmNotifications {
        }

        final NotificationManagerCompat nm = NotificationManagerCompat.from(context);
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            NotificationChannel channel = new NotificationChannel(
                    ALARM_UPDATE_MISSED_NOTIFICATION_CHANNEL_ID,
                    context.getString(R.string.default_label),
                    NotificationManagerCompat.IMPORTANCE_DEFAULT);
        }

        final Notification firstMissed = getFirstActiveNotification(context, MISSED_GROUP_KEY,
                canceledNotificationId, postedNotification);
@@ -352,8 +277,7 @@ final class AlarmNotifications {
        Notification summary = getActiveGroupSummaryNotification(context, MISSED_GROUP_KEY);
        if (summary == null
                || !Objects.equals(summary.contentIntent, firstMissed.contentIntent)) {
            summary = new NotificationCompat.Builder(
                    context, ALARM_UPDATE_MISSED_NOTIFICATION_CHANNEL_ID)
            summary = new NotificationCompat.Builder(context)
                    .setShowWhen(false)
                    .setContentIntent(firstMissed.contentIntent)
                    .setColor(ContextCompat.getColor(context, R.color.default_background))
@@ -373,8 +297,7 @@ final class AlarmNotifications {
            AlarmInstance instance) {
        LogUtils.v("Displaying snoozed notification for alarm instance: " + instance.mId);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(
                context, ALARM_SNOOZE_NOTIFICATION_CHANNEL_ID)
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                .setShowWhen(false)
                .setContentTitle(instance.getLabelOrDefault(context))
                .setContentText(context.getString(R.string.alarm_alert_snooze_until,
@@ -407,13 +330,6 @@ final class AlarmNotifications {
                viewAlarmIntent, PendingIntent.FLAG_UPDATE_CURRENT));

        NotificationManagerCompat nm = NotificationManagerCompat.from(context);
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            NotificationChannel channel = new NotificationChannel(
                    ALARM_SNOOZE_NOTIFICATION_CHANNEL_ID,
                    context.getString(R.string.default_label),
                    NotificationManagerCompat.IMPORTANCE_DEFAULT);
            nm.createNotificationChannel(channel);
        }
        final Notification notification = builder.build();
        nm.notify(id, notification);
        updateUpcomingAlarmGroupNotification(context, -1, notification);
@@ -425,8 +341,7 @@ final class AlarmNotifications {

        String label = instance.mLabel;
        String alarmTime = AlarmUtils.getFormattedTime(context, instance.getAlarmTime());
        NotificationCompat.Builder builder = new NotificationCompat.Builder(
                context, ALARM_MISSED_NOTIFICATION_CHANNEL_ID)
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                .setShowWhen(false)
                .setContentTitle(context.getString(R.string.alarm_missed_title))
                .setContentText(instance.mLabel.isEmpty() ? alarmTime :
@@ -460,13 +375,6 @@ final class AlarmNotifications {
                showAndDismiss, PendingIntent.FLAG_UPDATE_CURRENT));

        NotificationManagerCompat nm = NotificationManagerCompat.from(context);
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            NotificationChannel channel = new NotificationChannel(
                    ALARM_MISSED_NOTIFICATION_CHANNEL_ID,
                    context.getString(R.string.default_label),
                    NotificationManagerCompat.IMPORTANCE_DEFAULT);
            nm.createNotificationChannel(channel);
        }
        final Notification notification = builder.build();
        nm.notify(id, notification);
        updateMissedAlarmGroupNotification(context, -1, notification);
@@ -476,11 +384,9 @@ final class AlarmNotifications {
        LogUtils.v("Displaying alarm notification for alarm instance: " + instance.mId);

        Resources resources = service.getResources();
        NotificationCompat.Builder notification = new NotificationCompat.Builder(
                service, ALARM_NOTIFICATION_CHANNEL_ID)
        NotificationCompat.Builder notification = new NotificationCompat.Builder(service)
                .setContentTitle(instance.getLabelOrDefault(service))
                        .setContentText(AlarmUtils.getFormattedTime(
                                service, instance.getAlarmTime()))
                .setContentText(AlarmUtils.getFormattedTime(service, instance.getAlarmTime()))
                .setColor(ContextCompat.getColor(service, R.color.default_background))
                .setSmallIcon(R.drawable.stat_notify_alarm)
                .setOngoing(true)
+1 −16
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.deskclock.data;

import android.app.Notification;
import android.app.NotificationChannel;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -26,8 +25,6 @@ import android.content.SharedPreferences;
import androidx.annotation.VisibleForTesting;
import androidx.core.app.NotificationManagerCompat;

import com.android.deskclock.R;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -37,11 +34,6 @@ import java.util.List;
 */
final class StopwatchModel {

    /**
     * Notification channel containing all stopwatch notifications.
     */
    static final String STOPWATCH_NOTIFICATION_CHANNEL_ID = "StopwatchNotification";

    private final Context mContext;

    private final SharedPreferences mPrefs;
@@ -74,13 +66,6 @@ final class StopwatchModel {
        mPrefs = prefs;
        mNotificationModel = notificationModel;
        mNotificationManager = NotificationManagerCompat.from(context);
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            NotificationChannel channel = new NotificationChannel(
                    STOPWATCH_NOTIFICATION_CHANNEL_ID,
                    context.getString(R.string.default_label),
                    NotificationManagerCompat.IMPORTANCE_DEFAULT);
            mNotificationManager.createNotificationChannel(channel);
        }

        // Update stopwatch notification when locale changes.
        final IntentFilter localeBroadcastFilter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED);
+10 −11
Original line number Diff line number Diff line
@@ -127,8 +127,7 @@ class StopwatchNotificationBuilder {
            content.setViewVisibility(R.id.state, VISIBLE);
        }

        final Builder notification = new NotificationCompat.Builder(
                context, StopwatchModel.STOPWATCH_NOTIFICATION_CHANNEL_ID)
        final Builder notification = new NotificationCompat.Builder(context)
                .setLocalOnly(true)
                .setOngoing(running)
                .setCustomContentView(content)
+0 −13
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.deskclock.data;
import android.annotation.SuppressLint;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
@@ -57,11 +56,6 @@ import static com.android.deskclock.data.Timer.State.RESET;
 */
final class TimerModel {

    /**
     * Notification channel containing all TimerModel notifications.
     */
    static final String TIMER_MODEL_NOTIFICATION_CHANNEL_ID = "TimerModelNotification";

    /**
     * Running timers less than this threshold are left running/expired; greater than this
     * threshold are considered missed.
@@ -142,13 +136,6 @@ final class TimerModel {
        mRingtoneModel = ringtoneModel;
        mNotificationModel = notificationModel;
        mNotificationManager = NotificationManagerCompat.from(context);
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            NotificationChannel channel = new NotificationChannel(
                    TIMER_MODEL_NOTIFICATION_CHANNEL_ID,
                    context.getString(R.string.default_label),
                    NotificationManagerCompat.IMPORTANCE_DEFAULT);
            mNotificationManager.createNotificationChannel(channel);
        }

        mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);

Loading