Create channel if channel is not available
Bug: 36530928
Test: follow steps to repro in http://b/36530928#comment2
and make sure no crash is seen when importing from SIM or Vcard.
Also hard code to stop listening for ACTION_BOOT_COMPLETED and
make sure channel is created before setting channel;
Change-Id: Ib061e299082670c24a0e248da5a61285cd944ea6
diff --git a/src/com/android/contacts/SimImportService.java b/src/com/android/contacts/SimImportService.java
index 4d4f551..60de982 100644
--- a/src/com/android/contacts/SimImportService.java
+++ b/src/com/android/contacts/SimImportService.java
@@ -153,6 +153,7 @@
@Override
public int onStartCommand(Intent intent, int flags, final int startId) {
+ ContactsNotificationChannelsUtil.createDefaultChannel(this);
final ImportTask task = createTaskForIntent(intent, startId);
if (task == null) {
new StopTask(this, startId).executeOnExecutor(mExecutor);
diff --git a/src/com/android/contacts/vcard/NotificationImportExportListener.java b/src/com/android/contacts/vcard/NotificationImportExportListener.java
index f4d682c..daac5cb 100644
--- a/src/com/android/contacts/vcard/NotificationImportExportListener.java
+++ b/src/com/android/contacts/vcard/NotificationImportExportListener.java
@@ -220,6 +220,7 @@
.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)
@@ -247,6 +248,7 @@
*/
/* package */ static Notification constructCancelNotification(
Context context, String description) {
+ ContactsNotificationChannelsUtil.createDefaultChannel(context);
return new NotificationCompat.Builder(context)
.setChannel(ContactsNotificationChannelsUtil.DEFAULT_CHANNEL)
.setAutoCancel(true)
@@ -278,6 +280,7 @@
*/
/* package */ static Notification constructFinishNotificationWithFlags(
Context context, String title, String description, Intent intent, int flags) {
+ ContactsNotificationChannelsUtil.createDefaultChannel(context);
return new NotificationCompat.Builder(context)
.setChannel(ContactsNotificationChannelsUtil.DEFAULT_CHANNEL)
.setAutoCancel(true)
@@ -302,6 +305,7 @@
*/
/* package */ static Notification constructImportFailureNotification(
Context context, String reason) {
+ ContactsNotificationChannelsUtil.createDefaultChannel(context);
return new NotificationCompat.Builder(context)
.setChannel(ContactsNotificationChannelsUtil.DEFAULT_CHANNEL)
.setAutoCancel(true)