summaryrefslogtreecommitdiff
path: root/java/com/android
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2017-10-17 18:13:45 -0700
committerEric Erfanian <erfanian@google.com>2017-10-17 20:12:41 -0700
commit639943a7668ad4229942e1207128045d49e9ed02 (patch)
treedd54827288a08600f58ac0aed849e179fcddd8df /java/com/android
parent78cc8ca990f3ce43252c038ad55420bebaeb4180 (diff)
Support bulk inserted voicemails.
Bulk insert is implemented in ag/3073902 When more than one voicemail is inserted into the VoicemailProvider, the URI type is Voicemails.DIR_TYPE instead of ITEM_TYPE. This CL adds support to the new type. Previously when multiple voicemails are being notified, each one of them will generate a ringtone because the notifiction is set to alert children. In this CL, the summary will have alert instead, and will only alert when new voicemails are received. Bug: 21281858 Test: VisualVoicemailNotifierTest PiperOrigin-RevId: 172546076 Change-Id: I4df6098fc3a793139e3d4e77fe1339efdc001944
Diffstat (limited to 'java/com/android')
-rw-r--r--java/com/android/dialer/app/AndroidManifest.xml5
-rw-r--r--java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java18
-rw-r--r--java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java5
-rw-r--r--java/com/android/dialer/simulator/impl/SimulatorNotifications.java15
4 files changed, 34 insertions, 9 deletions
diff --git a/java/com/android/dialer/app/AndroidManifest.xml b/java/com/android/dialer/app/AndroidManifest.xml
index 2ef5dad14..ad771496d 100644
--- a/java/com/android/dialer/app/AndroidManifest.xml
+++ b/java/com/android/dialer/app/AndroidManifest.xml
@@ -86,6 +86,11 @@
android:mimeType="vnd.android.cursor.item/voicemail"
android:scheme="content"
/>
+ <data
+ android:host="com.android.voicemail"
+ android:mimeType="vnd.android.cursor.dir/voicemails"
+ android:scheme="content"
+ />
</intent-filter>
<intent-filter android:priority="100">
<action android:name="android.intent.action.BOOT_COMPLETED"/>
diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java
index 2fd9a2161..4fc956fa8 100644
--- a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java
+++ b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java
@@ -64,11 +64,16 @@ final class VisualVoicemailNotifier {
*/
private static final String GROUP_KEY = "VisualVoicemailGroup";
+ /**
+ * @param shouldAlert whether ringtone or vibration should be made when the notification is posted
+ * or updated. Should only be true when there is a real new voicemail.
+ */
public static void showNotifications(
@NonNull Context context,
@NonNull List<NewCall> newCalls,
@NonNull Map<String, ContactInfo> contactInfos,
- @Nullable String callers) {
+ @Nullable String callers,
+ boolean shouldAlert) {
LogUtil.enterBlock("VisualVoicemailNotifier.showNotifications");
PendingIntent deleteIntent =
CallLogNotificationsService.createMarkAllNewVoicemailsAsOldIntent(context);
@@ -86,7 +91,15 @@ final class VisualVoicemailNotifier {
.setContentIntent(newVoicemailIntent(context, null));
if (VERSION.SDK_INT >= VERSION_CODES.O) {
- groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN);
+ if (shouldAlert) {
+ groupSummary.setOnlyAlertOnce(false);
+ // Group summary will alert when posted/updated
+ groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_ALL);
+ } else {
+ // Only children will alert. but since all children are set to "only alert summary" it is
+ // effectively silenced.
+ groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN);
+ }
PhoneAccountHandle handle = getAccountForCall(context, newCalls.get(0));
groupSummary.setChannelId(NotificationChannelManager.getVoicemailChannelId(context, handle));
}
@@ -203,6 +216,7 @@ final class VisualVoicemailNotifier {
if (VERSION.SDK_INT >= VERSION_CODES.O) {
builder.setChannelId(NotificationChannelManager.getVoicemailChannelId(context, handle));
+ builder.setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY);
}
ContactPhotoLoader loader = new ContactPhotoLoader(context, contactInfo);
diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java b/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java
index e30623bb2..77b4c1113 100644
--- a/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java
+++ b/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java
@@ -67,7 +67,7 @@ class VisualVoicemailUpdateTask implements Worker<VisualVoicemailUpdateTask.Inpu
// Query failed, just return
return;
}
-
+ boolean shouldAlert = !voicemailsToNotify.isEmpty();
voicemailsToNotify.addAll(getAndUpdateVoicemailsWithExistingNotification(context, queryHelper));
voicemailsToNotify = filterBlockedNumbers(context, queryHandler, voicemailsToNotify);
if (voicemailsToNotify.isEmpty()) {
@@ -100,7 +100,8 @@ class VisualVoicemailUpdateTask implements Worker<VisualVoicemailUpdateTask.Inpu
}
}
}
- VisualVoicemailNotifier.showNotifications(context, voicemailsToNotify, contactInfos, callers);
+ VisualVoicemailNotifier.showNotifications(
+ context, voicemailsToNotify, contactInfos, callers, shouldAlert);
// Set trigger to update notifications when database changes.
VoicemailNotificationJobService.scheduleJob(context);
diff --git a/java/com/android/dialer/simulator/impl/SimulatorNotifications.java b/java/com/android/dialer/simulator/impl/SimulatorNotifications.java
index 3f402d317..4ed7c9b8f 100644
--- a/java/com/android/dialer/simulator/impl/SimulatorNotifications.java
+++ b/java/com/android/dialer/simulator/impl/SimulatorNotifications.java
@@ -16,12 +16,15 @@
package com.android.dialer.simulator.impl;
+import android.content.ContentValues;
import android.content.Context;
import android.provider.VoicemailContract.Voicemails;
import android.support.annotation.NonNull;
import android.view.ActionProvider;
import com.android.dialer.common.LogUtil;
import com.android.dialer.databasepopulator.VoicemailPopulator;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.TimeUnit;
/** Implements the simulator submenu. */
@@ -45,6 +48,7 @@ final class SimulatorNotifications {
private static void addVoicemailNotifications(@NonNull Context context) {
LogUtil.enterBlock("SimulatorNotifications.addVoicemailNotifications");
+ List<ContentValues> voicemails = new ArrayList<>();
for (int i = NOTIFICATION_COUNT; i > 0; i--) {
VoicemailPopulator.Voicemail voicemail =
VoicemailPopulator.Voicemail.builder()
@@ -54,11 +58,12 @@ final class SimulatorNotifications {
.setIsRead(false)
.setTimeMillis(System.currentTimeMillis() - TimeUnit.HOURS.toMillis(i))
.build();
- context
- .getContentResolver()
- .insert(
- Voicemails.buildSourceUri(context.getPackageName()),
- voicemail.getAsContentValues(context));
+ voicemails.add(voicemail.getAsContentValues(context));
}
+ context
+ .getContentResolver()
+ .bulkInsert(
+ Voicemails.buildSourceUri(context.getPackageName()),
+ voicemails.toArray(new ContentValues[voicemails.size()]));
}
}