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
diff --git a/src/com/android/contacts/util/ContactsNotificationChannelsUtil.java b/src/com/android/contacts/util/ContactsNotificationChannelsUtil.java
index 3aa75c9..fec3bda 100644
--- a/src/com/android/contacts/util/ContactsNotificationChannelsUtil.java
+++ b/src/com/android/contacts/util/ContactsNotificationChannelsUtil.java
@@ -38,7 +38,7 @@
         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);
     }
 }
diff --git a/src/com/android/contacts/vcard/NotificationImportExportListener.java b/src/com/android/contacts/vcard/NotificationImportExportListener.java
index daac5cb..cec96d4 100644
--- a/src/com/android/contacts/vcard/NotificationImportExportListener.java
+++ b/src/com/android/contacts/vcard/NotificationImportExportListener.java
@@ -89,6 +89,7 @@
             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 @@
         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 @@
                 .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)