diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-05-15 23:21:05 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-05-15 23:21:06 +0000 |
commit | 0c9dbf507b53a12bdf577ff3e55c1686a2e089de (patch) | |
tree | 3849f2add85d7abe11151436b3f03f99783157a8 /java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java | |
parent | e724c7b6376be660abf2113f97c7cbfc34515da8 (diff) | |
parent | c857f90590e7d7fcffa89511982eb33afd34805f (diff) |
Merge "Update Dialer to v10 RC32" into oc-dev
Diffstat (limited to 'java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java')
-rw-r--r-- | java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java b/java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java index 3a202034e..65bb6fa57 100644 --- a/java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java +++ b/java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java @@ -13,11 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.android.dialer.app.calllog; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.support.v4.util.Pair; +import com.android.dialer.common.LogUtil; +import com.android.dialer.common.concurrent.DialerExecutors; +import me.leolin.shortcutbadger.ShortcutBadger; /** * Receives broadcasts that should trigger a refresh of the missed call notification. This includes @@ -44,7 +49,36 @@ public class MissedCallNotificationReceiver extends BroadcastReceiver { int count = intent.getIntExtra( EXTRA_NOTIFICATION_COUNT, CallLogNotificationsService.UNKNOWN_MISSED_CALL_COUNT); - String number = intent.getStringExtra(EXTRA_NOTIFICATION_PHONE_NUMBER); - CallLogNotificationsService.updateMissedCallNotifications(context, count, number); + String phoneNumber = intent.getStringExtra(EXTRA_NOTIFICATION_PHONE_NUMBER); + + PendingResult pendingResult = goAsync(); + + DialerExecutors.createNonUiTaskBuilder(MissedCallNotifier.getIstance(context)) + .onSuccess( + output -> { + LogUtil.i( + "MissedCallNotificationReceiver.onReceive", + "update missed call notifications successful"); + updateBadgeCount(context, count); + pendingResult.finish(); + }) + .onFailure( + throwable -> { + LogUtil.i( + "MissedCallNotificationReceiver.onReceive", + "update missed call notifications failed"); + pendingResult.finish(); + }) + .build() + .executeParallel(new Pair<>(count, phoneNumber)); + } + + private static void updateBadgeCount(Context context, int count) { + boolean success = ShortcutBadger.applyCount(context, count); + LogUtil.i( + "MissedCallNotificationReceiver.updateBadgeCount", + "update badge count: %d success: %b", + count, + success); } } |