summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/app
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/dialer/app')
-rw-r--r--java/com/android/dialer/app/calllog/CallLogNotificationsService.java46
1 files changed, 36 insertions, 10 deletions
diff --git a/java/com/android/dialer/app/calllog/CallLogNotificationsService.java b/java/com/android/dialer/app/calllog/CallLogNotificationsService.java
index be1ebfb6d..84aedf880 100644
--- a/java/com/android/dialer/app/calllog/CallLogNotificationsService.java
+++ b/java/com/android/dialer/app/calllog/CallLogNotificationsService.java
@@ -24,7 +24,11 @@ import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
+import android.support.annotation.WorkerThread;
+import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
+import com.android.dialer.common.concurrent.DialerExecutor.Worker;
+import com.android.dialer.common.concurrent.DialerExecutorComponent;
import com.android.dialer.telecom.TelecomUtil;
import com.android.dialer.util.PermissionsUtil;
@@ -108,6 +112,15 @@ public class CallLogNotificationsService extends IntentService {
context.startService(serviceIntent);
}
+ public static void cancelAllMissedCalls(Context context) {
+ LogUtil.enterBlock("CallLogNotificationsService.cancelAllMissedCalls");
+ DialerExecutorComponent.get(context)
+ .dialerExecutorFactory()
+ .createNonUiTaskBuilder(new CancelAllMissedCallsWorker())
+ .build()
+ .executeSerial(context);
+ }
+
public static PendingIntent createMarkAllNewVoicemailsAsOldIntent(@NonNull Context context) {
Intent intent = new Intent(context, CallLogNotificationsService.class);
intent.setAction(CallLogNotificationsService.ACTION_MARK_ALL_NEW_VOICEMAILS_AS_OLD);
@@ -122,13 +135,6 @@ public class CallLogNotificationsService extends IntentService {
return PendingIntent.getService(context, 0, intent, 0);
}
- public static void cancelAllMissedCalls(@NonNull Context context) {
- LogUtil.enterBlock("CallLogNotificationsService.cancelAllMissedCalls");
- Intent serviceIntent = new Intent(context, CallLogNotificationsService.class);
- serviceIntent.setAction(ACTION_CANCEL_ALL_MISSED_CALLS);
- context.startService(serviceIntent);
- }
-
public static PendingIntent createCancelAllMissedCallsPendingIntent(@NonNull Context context) {
Intent intent = new Intent(context, CallLogNotificationsService.class);
intent.setAction(ACTION_CANCEL_ALL_MISSED_CALLS);
@@ -174,9 +180,7 @@ public class CallLogNotificationsService extends IntentService {
MissedCallNotifier.getIstance(this).insertPostCallNotification(phoneNumber, note);
break;
case ACTION_CANCEL_ALL_MISSED_CALLS:
- CallLogNotificationsQueryHelper.markAllMissedCallsInCallLogAsRead(this);
- MissedCallNotifier.cancelAllMissedCallNotifications(this);
- TelecomUtil.cancelMissedCallsNotification(this);
+ cancelAllMissedCalls(this);
break;
case ACTION_CANCEL_SINGLE_MISSED_CALL:
Uri callUri = intent.getData();
@@ -196,4 +200,26 @@ public class CallLogNotificationsService extends IntentService {
break;
}
}
+
+ @WorkerThread
+ private static void cancelAllMissedCallsBackground(Context context) {
+ LogUtil.enterBlock("CallLogNotificationsService.cancelAllMissedCallsBackground");
+ Assert.isWorkerThread();
+ CallLogNotificationsQueryHelper.markAllMissedCallsInCallLogAsRead(context);
+ MissedCallNotifier.cancelAllMissedCallNotifications(context);
+ TelecomUtil.cancelMissedCallsNotification(context);
+ }
+
+ /** Worker that cancels all missed call notifications and updates call log entries. */
+ private static class CancelAllMissedCallsWorker implements Worker<Context, Void> {
+
+ @Nullable
+ @Override
+ public Void doInBackground(@Nullable Context context) throws Throwable {
+ if (context != null) {
+ cancelAllMissedCallsBackground(context);
+ }
+ return null;
+ }
+ }
}