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

Commit 2ab85379 authored by Wenyi Wang's avatar Wenyi Wang
Browse files

Silence progress notifications

- First, we lower the importance of default channel.
- Then, we set setOnlyAlertOnce of progress notifications to true.
- Also, move the logic to create channel to the place where we construct
  progress notification for the first time only (instead of creating the
  channel every time when we construct a progress notification). This
  didn't lead to a bug but it should be good to change it.

Bug: 37217739

Test:
1. manually verified b/36530928 doesn't happen with this CL
2. manually verified no sound is heard when importing/exporting
   contacts, even if changing the importance of the default channel to
   make sound.

Change-Id: I9a6d1e2f6dae78ac518589cb07721b15a382445e
parent ec161129
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ public class ContactsNotificationChannelsUtil {
        final NotificationManager nm = context.getSystemService(NotificationManager.class);
        final NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL,
                context.getString(R.string.contacts_default_notification_channel),
                NotificationManager.IMPORTANCE_DEFAULT);
                NotificationManager.IMPORTANCE_LOW);
        nm.createNotificationChannel(channel);
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ public class NotificationImportExportListener implements VCardImportExportListen
            mHandler.obtainMessage(0, message).sendToTarget();
        }

        ContactsNotificationChannelsUtil.createDefaultChannel(mContext);
        final Notification notification = constructProgressNotification(mContext,
                VCardService.TYPE_IMPORT, message, message, jobId, displayName, -1, 0);
        mNotificationManager.notify(DEFAULT_NOTIFICATION_TAG, jobId, notification);
@@ -164,6 +165,7 @@ public class NotificationImportExportListener implements VCardImportExportListen
        final String message = mContext.getString(R.string.contacts_export_will_start_message);

        mHandler.obtainMessage(0, message).sendToTarget();
        ContactsNotificationChannelsUtil.createDefaultChannel(mContext);
        final Notification notification =
                NotificationImportExportListener.constructProgressNotification(mContext,
                        VCardService.TYPE_EXPORT, message, message, jobId, displayName, -1, 0);
@@ -220,10 +222,10 @@ public class NotificationImportExportListener implements VCardImportExportListen
                .appendQueryParameter(CancelActivity.TYPE, String.valueOf(type)).build();
        intent.setData(uri);

        ContactsNotificationChannelsUtil.createDefaultChannel(context);
        final NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
        builder.setOngoing(true)
                .setChannel(ContactsNotificationChannelsUtil.DEFAULT_CHANNEL)
                .setOnlyAlertOnce(true)
                .setProgress(totalCount, currentCount, totalCount == - 1)
                .setTicker(tickerText)
                .setContentTitle(description)