summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/enrichedcall
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2017-09-27 17:11:33 -0700
committerEric Erfanian <erfanian@google.com>2017-09-28 08:36:37 -0700
commit96aea2a8f42bfc55dd2b08c51698efb0d0559109 (patch)
treeeb2b91eaa8fafe6041c27dae82a68888ba771a93 /java/com/android/dialer/enrichedcall
parentf455e6a70d225a28fff2b1922b0e1f4123d94a55 (diff)
Use goAsync() and dialer executor to insert post call notifications
Previously post call notifications are inserted by launching CallLogNotificationService. This usually works because the call has just broght dialer to the foreground and there are some grace period before the app is consider background again. However if the post call message comes later background check will crash the app. This CL made the broadcast receiver async and complete the insertion in a worker since it wouldn't take more than a few seconds. Bug: 66444859 Test: unit tests PiperOrigin-RevId: 170275928 Change-Id: I0ff396b51a173f2e4bab0bca6b6e5c5b56ab62da
Diffstat (limited to 'java/com/android/dialer/enrichedcall')
-rw-r--r--java/com/android/dialer/enrichedcall/EnrichedCallManager.java10
-rw-r--r--java/com/android/dialer/enrichedcall/stub/EnrichedCallManagerStub.java8
2 files changed, 16 insertions, 2 deletions
diff --git a/java/com/android/dialer/enrichedcall/EnrichedCallManager.java b/java/com/android/dialer/enrichedcall/EnrichedCallManager.java
index 0606a00e5..9f68978b5 100644
--- a/java/com/android/dialer/enrichedcall/EnrichedCallManager.java
+++ b/java/com/android/dialer/enrichedcall/EnrichedCallManager.java
@@ -16,6 +16,7 @@
package com.android.dialer.enrichedcall;
+import android.content.BroadcastReceiver.PendingResult;
import android.support.annotation.MainThread;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -269,10 +270,17 @@ public interface EnrichedCallManager {
/**
* Called when post call data arrives for the given session.
*
+ * @param pendingResult PendingResult form a broadcast receiver. The broadcast might be received
+ * when dialer is not in the foreground, and can not start {@link
+ * com.android.dialer.app.calllog.CallLogNotificationsService} to handle the event. The
+ * pendingResult allows dialer to hold on to resources when the event is handled in a
+ * background thread. TODO(b/67015768): migrate CallLogNotificationsService to a
+ * JobIntentService so it can be used in the background.
* @throws IllegalStateException if there's no session for the given id
*/
@MainThread
- void onIncomingPostCallData(long sessionId, @NonNull MultimediaData multimediaData);
+ void onIncomingPostCallData(
+ @NonNull PendingResult pendingResult, long sessionId, @NonNull MultimediaData multimediaData);
/**
* Registers the given {@link VideoShareListener}.
diff --git a/java/com/android/dialer/enrichedcall/stub/EnrichedCallManagerStub.java b/java/com/android/dialer/enrichedcall/stub/EnrichedCallManagerStub.java
index 87d99def8..55bc0dbb7 100644
--- a/java/com/android/dialer/enrichedcall/stub/EnrichedCallManagerStub.java
+++ b/java/com/android/dialer/enrichedcall/stub/EnrichedCallManagerStub.java
@@ -16,6 +16,7 @@
package com.android.dialer.enrichedcall.stub;
+import android.content.BroadcastReceiver.PendingResult;
import android.support.annotation.MainThread;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -150,7 +151,12 @@ public final class EnrichedCallManagerStub implements EnrichedCallManager {
public void onIncomingCallComposerData(long sessionId, @NonNull MultimediaData multimediaData) {}
@Override
- public void onIncomingPostCallData(long sessionId, @NonNull MultimediaData multimediaData) {}
+ public void onIncomingPostCallData(
+ @NonNull PendingResult pendingResult,
+ long sessionId,
+ @NonNull MultimediaData multimediaData) {
+ pendingResult.finish();
+ }
@Override
public void registerVideoShareListener(@NonNull VideoShareListener listener) {}