From 96aea2a8f42bfc55dd2b08c51698efb0d0559109 Mon Sep 17 00:00:00 2001 From: twyen Date: Wed, 27 Sep 2017 17:11:33 -0700 Subject: 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 --- java/com/android/dialer/enrichedcall/EnrichedCallManager.java | 10 +++++++++- .../dialer/enrichedcall/stub/EnrichedCallManagerStub.java | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'java/com/android/dialer/enrichedcall') 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) {} -- cgit v1.2.3