diff options
author | Eric Erfanian <erfanian@google.com> | 2017-07-25 16:01:40 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-07-25 16:01:40 +0000 |
commit | 55e2443f1aa9619a3330d2d7496ea5272e5266d9 (patch) | |
tree | 2cf71fd57558abf1368001dab759b97dabc0b0b7 /java/com/android/dialer/app/calllog | |
parent | 32dcb9243cd556b6c7b476c33cef027413377c2a (diff) | |
parent | b950d5f7e9711362f175ff2262d055449b139325 (diff) |
Merge changes I9b4919e9,I15419178,Ib0f46aed,If592be8c
* changes:
Fix Lightbringer call upgrading when Dialer was not in memory before the call
Handle null host for secret code
Dont start a service to cancel missed call notifications, use DialerExecutor instead
Fix NPE when user click on call log.
Diffstat (limited to 'java/com/android/dialer/app/calllog')
-rw-r--r-- | java/com/android/dialer/app/calllog/CallLogAdapter.java | 30 | ||||
-rw-r--r-- | java/com/android/dialer/app/calllog/CallLogNotificationsService.java | 46 |
2 files changed, 56 insertions, 20 deletions
diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java index e3509a964..0e8112caa 100644 --- a/java/com/android/dialer/app/calllog/CallLogAdapter.java +++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java @@ -368,20 +368,30 @@ public class CallLogAdapter extends GroupingListAdapter } expandViewHolderActions(viewHolder); - if (viewHolder.videoCallButtonView != null - && viewHolder.videoCallButtonView.getVisibility() == View.VISIBLE - && LightbringerComponent.get(mActivity).getLightbringer().getPackageName() != null - && LightbringerComponent.get(mActivity) - .getLightbringer() - .getPackageName() - .equals( - ((IntentProvider) viewHolder.videoCallButtonView.getTag()) - .getIntent(mActivity) - .getPackage())) { + if (isLightbringerCallButtonVisible(viewHolder.videoCallButtonView)) { CallIntentBuilder.increaseLightbringerCallButtonAppearInExpandedCallLogItemCount(); } } } + + private boolean isLightbringerCallButtonVisible(View videoCallButtonView) { + if (videoCallButtonView == null) { + return false; + } + if (videoCallButtonView.getVisibility() != View.VISIBLE) { + return false; + } + IntentProvider intentProvider = (IntentProvider) videoCallButtonView.getTag(); + if (intentProvider == null) { + return false; + } + String packageName = + LightbringerComponent.get(mActivity).getLightbringer().getPackageName(); + if (packageName == null) { + return false; + } + return packageName.equals(intentProvider.getIntent(mActivity).getPackage()); + } }; private void checkMarkCallLogEntry(CallLogListItemViewHolder viewHolder) { 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; + } + } } |