From 10b34a5ebf12e97ecba0caf3c8e30b476b038a96 Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Thu, 4 May 2017 08:23:17 -0700 Subject: Update Dialer to V10 RC16 This release was created following the instructions at: go/dialer-aosp-release Subsequent dialer releases will follow as O bugs are fixed, until we reach our final RC. Version: 10 Candidate: RC16 Branch: dialer-android_release_branch/153304843.1 dialer-android/dialer-android_20170416.00/dialer-android_20170416.00_RC16 This release contains the following bug fixes since RC00: Bug: 37324705 35304403 36067503 35304446 33203808 37280992 37346084 35766990 37481880 37424493 36470282 37347691 37519015 37168472 35805360 37545472 27704934 36515614 35766990 37577470 34739750 35801628 36788693 35264204 36708536 37628370 36904650 37314436 37642171 37530847 37637799 37666625 37548549 37648036 37636412 37323529 37630507 35919141 37198343 37548572 36178218 37640315 37663896 37720467 37275944 37710497 31634477 37744796 37348506 37744796 37568534 37672424 34872683 34873026 37681461 34873295 37748373 37526812 37618638 37663896 37536088 37727455 37165687 36651204 36900708 37323529 36902926 37256480 37328353 37432034 37436952 34093562 37720889 37321935 37780300 37781115 37755902 36588206 34258266 37290464 37698062 37618638 37473004 37432034 37918676 37870494 37722091 Test: make, on device Change-Id: I99e1a484ccd578c1f8a13e7a6a4b4952f0791297 --- .../app/calllog/BlockReportSpamListener.java | 5 ++- .../android/dialer/app/calllog/CallLogAdapter.java | 29 +++++++++++---- .../dialer/app/calllog/CallLogAsyncTaskUtil.java | 16 +++++--- .../dialer/app/calllog/CallLogFragment.java | 5 +-- .../app/calllog/CallLogListItemViewHolder.java | 43 ++++++++++++++++++---- .../calllog/CallLogNotificationsQueryHelper.java | 2 +- .../app/calllog/DefaultVoicemailNotifier.java | 23 +++++++++--- .../calllog/VisualVoicemailCallLogFragment.java | 19 +++------- 8 files changed, 97 insertions(+), 45 deletions(-) (limited to 'java/com/android/dialer/app/calllog') diff --git a/java/com/android/dialer/app/calllog/BlockReportSpamListener.java b/java/com/android/dialer/app/calllog/BlockReportSpamListener.java index 740d6b361..28082df2b 100644 --- a/java/com/android/dialer/app/calllog/BlockReportSpamListener.java +++ b/java/com/android/dialer/app/calllog/BlockReportSpamListener.java @@ -20,6 +20,7 @@ import android.app.FragmentManager; import android.content.ContentValues; import android.content.Context; import android.net.Uri; +import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import com.android.dialer.blocking.BlockReportSpamDialogs; import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler; @@ -55,7 +56,7 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic final String number, final String countryIso, final int callType, - final ContactSource.Type contactSourceType) { + @NonNull final ContactSource.Type contactSourceType) { BlockReportSpamDialogs.BlockReportSpamDialogFragment.newInstance( displayNumber, Spam.get(mContext).isDialogReportSpamCheckedByDefault(), @@ -99,7 +100,7 @@ public class BlockReportSpamListener implements CallLogListItemViewHolder.OnClic final String number, final String countryIso, final int callType, - final ContactSource.Type contactSourceType) { + @NonNull final ContactSource.Type contactSourceType) { BlockReportSpamDialogs.BlockDialogFragment.newInstance( displayNumber, Spam.get(mContext).isSpamEnabled(), diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java index d4872d5b3..b433e6529 100644 --- a/java/com/android/dialer/app/calllog/CallLogAdapter.java +++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java @@ -77,6 +77,7 @@ import com.android.dialer.enrichedcall.historyquery.proto.HistoryResult; import com.android.dialer.lightbringer.Lightbringer; import com.android.dialer.lightbringer.LightbringerComponent; import com.android.dialer.lightbringer.LightbringerListener; +import com.android.dialer.logging.ContactSource; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.phonenumbercache.CallLogQuery; @@ -177,13 +178,14 @@ public class CallLogAdapter extends GroupingListAdapter } }; + // Todo (uabdullah): Use plurals http://b/37751831 private void showDeleteSelectedItemsDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); Assert.checkArgument(selectedItems.size() > 0); String voicemailString = selectedItems.size() == 1 ? mActivity.getResources().getString(R.string.voicemailMultiSelectVoicemail) - : mActivity.getResources().getString(R.string.voicemailMultiSelectVoicemail); + : mActivity.getResources().getString(R.string.voicemailMultiSelectVoicemails); String deleteVoicemailTitle = mActivity .getResources() @@ -228,14 +230,15 @@ public class CallLogAdapter extends GroupingListAdapter if (ConfigProviderBindings.get(v.getContext()) .getBoolean("enable_call_log_multiselect", true) && mVoicemailPlaybackPresenter != null) { - if (v.getId() == R.id.primary_action_view) { + if (v.getId() == R.id.primary_action_view || v.getId() == R.id.quick_contact_photo) { if (mActionMode == null) { mActionMode = v.startActionMode(mActionModeCallback); } CallLogListItemViewHolder viewHolder = (CallLogListItemViewHolder) v.getTag(); viewHolder.quickContactView.setVisibility(View.GONE); viewHolder.checkBoxView.setVisibility(View.VISIBLE); - return false; + mExpandCollapseListener.onClick(v); + return true; } } return true; @@ -522,6 +525,7 @@ public class CallLogAdapter extends GroupingListAdapter viewHolder.callLogEntryView.setTag(viewHolder); viewHolder.primaryActionView.setTag(viewHolder); + viewHolder.quickContactView.setTag(viewHolder); return viewHolder; } @@ -630,7 +634,7 @@ public class CallLogAdapter extends GroupingListAdapter @Override protected Boolean doInBackground(Void... params) { views.blockId = - mFilteredNumberAsyncQueryHandler.getBlockedIdSynchronousForCalllogOnly( + mFilteredNumberAsyncQueryHandler.getBlockedIdSynchronous( views.number, views.countryIso); details.isBlocked = views.blockId != null; if (isCancelled()) { @@ -872,14 +876,25 @@ public class CallLogAdapter extends GroupingListAdapter } views.info = info; - views.numberType = - (String) - Phone.getTypeLabel(mActivity.getResources(), details.numberType, details.numberLabel); + views.numberType = getNumberType(mActivity.getResources(), details); mCallLogListItemHelper.updatePhoneCallDetails(details); return true; } + private static String getNumberType(Resources res, PhoneCallDetails details) { + // Label doesn't make much sense if the information is coming from CNAP or Cequint Caller ID. + if (details.sourceType == ContactSource.Type.SOURCE_TYPE_CNAP + || details.sourceType == ContactSource.Type.SOURCE_TYPE_CEQUINT_CALLER_ID) { + return ""; + } + // Returns empty label instead of "custom" if the custom label is empty. + if (details.numberType == Phone.TYPE_CUSTOM && TextUtils.isEmpty(details.numberLabel)) { + return ""; + } + return (String) Phone.getTypeLabel(res, details.numberType, details.numberLabel); + } + /** * Render item view given position. This is running on UI thread so DO NOT put any expensive * operation into it. diff --git a/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java b/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java index 2aedb6f17..a58357448 100644 --- a/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java +++ b/java/com/android/dialer/app/calllog/CallLogAsyncTaskUtil.java @@ -83,12 +83,7 @@ public class CallLogAsyncTaskUtil { new AsyncTask() { @Override public Void doInBackground(Void... params) { - ContentValues values = new ContentValues(); - values.put(Voicemails.DELETED, "1"); - context.getContentResolver().update(voicemailUri, values, null, null); - // TODO(b/35440541): check which source package is changed. Don't need - // to upload changes on foreign voicemails, they will get a PROVIDER_CHANGED - uploadVoicemailLocalChangesToServer(context); + deleteVoicemailSynchronous(context, voicemailUri); return null; } @@ -101,6 +96,15 @@ public class CallLogAsyncTaskUtil { }); } + public static void deleteVoicemailSynchronous(Context context, Uri voicemailUri) { + ContentValues values = new ContentValues(); + values.put(Voicemails.DELETED, "1"); + context.getContentResolver().update(voicemailUri, values, null, null); + // TODO(b/35440541): check which source package is changed. Don't need + // to upload changes on foreign voicemails, they will get a PROVIDER_CHANGED + uploadVoicemailLocalChangesToServer(context); + } + public static void markCallAsRead(@NonNull final Context context, @NonNull final long[] callIds) { if (!PermissionsUtil.hasPhonePermissions(context)) { return; diff --git a/java/com/android/dialer/app/calllog/CallLogFragment.java b/java/com/android/dialer/app/calllog/CallLogFragment.java index fcc34ebef..874aeeac8 100644 --- a/java/com/android/dialer/app/calllog/CallLogFragment.java +++ b/java/com/android/dialer/app/calllog/CallLogFragment.java @@ -41,7 +41,6 @@ import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import com.android.contacts.common.GeoUtil; import com.android.dialer.app.Bindings; import com.android.dialer.app.R; import com.android.dialer.app.calllog.calllogcache.CallLogCache; @@ -56,6 +55,7 @@ import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.database.CallLogQueryHandler; +import com.android.dialer.location.GeoUtil; import com.android.dialer.phonenumbercache.ContactInfoHelper; import com.android.dialer.util.PermissionsUtil; @@ -376,6 +376,7 @@ public class CallLogFragment extends Fragment super.onStop(); mAdapter.onStop(); + mContactInfoCache.stop(); } @Override @@ -398,8 +399,6 @@ public class CallLogFragment extends Fragment outState.putBoolean(KEY_HAS_READ_CALL_LOG_PERMISSION, mHasReadCallLogPermission); outState.putBoolean(KEY_REFRESH_DATA_REQUIRED, mRefreshDataRequired); - mContactInfoCache.stop(); - mAdapter.onSaveInstanceState(outState); } diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java index b57f9b04a..278caba92 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java @@ -17,6 +17,7 @@ package com.android.dialer.app.calllog; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.res.Resources; @@ -26,6 +27,7 @@ import android.provider.CallLog; import android.provider.CallLog.Calls; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import android.support.v7.widget.CardView; import android.support.v7.widget.RecyclerView; @@ -43,6 +45,7 @@ import android.widget.ImageButton; import android.widget.ImageView; import android.widget.QuickContactBadge; import android.widget.TextView; +import android.widget.Toast; import com.android.contacts.common.ClipboardUtils; import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.common.compat.PhoneNumberUtilsCompat; @@ -182,7 +185,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder * The name or number associated with the call. Cached here for use when setting content * descriptions on buttons in the actions ViewStub when it is inflated. */ - public CharSequence nameOrNumber; + @Nullable public CharSequence nameOrNumber; /** * The call type or Location associated with the call. Cached here for use when setting text for a * voicemail log's call button @@ -257,6 +260,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder primaryActionView.setOnClickListener(mExpandCollapseListener); if (mVoicemailPlaybackPresenter != null) { primaryActionView.setOnLongClickListener(longPressListener); + quickContactView.setOnLongClickListener(longPressListener); } else { primaryActionView.setOnCreateContextMenuListener(this); } @@ -788,17 +792,38 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder mVoicemailPlaybackPresenter.shareVoicemail(); } else { logCallLogAction(view.getId()); + final IntentProvider intentProvider = (IntentProvider) view.getTag(); - if (intentProvider != null) { - final Intent intent = intentProvider.getIntent(mContext); - // See IntentProvider.getCallDetailIntentProvider() for why this may be null. - if (intent != null) { - DialerUtils.startActivityWithErrorToast(mContext, intent); - } + if (intentProvider == null) { + return; + } + + final Intent intent = intentProvider.getIntent(mContext); + // See IntentProvider.getCallDetailIntentProvider() for why this may be null. + if (intent == null) { + return; + } + + // We check to see if we are starting a Lightbringer intent. The reason is Lightbringer + // intents need to be started using startActivityForResult instead of the usual startActivity + String packageName = intent.getPackage(); + if (packageName != null && packageName.equals(getLightbringer().getPackageName(mContext))) { + startLightbringerActivity(intent); + } else { + DialerUtils.startActivityWithErrorToast(mContext, intent); } } } + private void startLightbringerActivity(Intent intent) { + try { + Activity activity = (Activity) mContext; + activity.startActivityForResult(intent, DialtactsActivity.ACTIVITY_REQUEST_CODE_LIGHTBRINGER); + } catch (ActivityNotFoundException e) { + Toast.makeText(mContext, R.string.activity_not_available, Toast.LENGTH_SHORT).show(); + } + } + private CallComposerContact buildContact() { CallComposerContact.Builder contact = CallComposerContact.newBuilder(); contact.setPhotoId(info.photoId); @@ -808,7 +833,9 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder if (info.lookupUri != null) { contact.setContactUri(info.lookupUri.toString()); } - contact.setNameOrNumber((String) nameOrNumber); + if (nameOrNumber != null) { + contact.setNameOrNumber((String) nameOrNumber); + } contact.setContactType(getContactType()); contact.setNumber(number); /* second line of contact view. */ diff --git a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java index 79a32afe3..4127d1f0b 100644 --- a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java +++ b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java @@ -32,10 +32,10 @@ import android.support.annotation.WorkerThread; import android.support.v4.os.UserManagerCompat; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; -import com.android.contacts.common.GeoUtil; import com.android.dialer.app.R; import com.android.dialer.calllogutils.PhoneNumberDisplayUtil; import com.android.dialer.common.LogUtil; +import com.android.dialer.location.GeoUtil; import com.android.dialer.notification.GroupedNotificationUtil; import com.android.dialer.phonenumbercache.ContactInfo; import com.android.dialer.phonenumbercache.ContactInfoHelper; diff --git a/java/com/android/dialer/app/calllog/DefaultVoicemailNotifier.java b/java/com/android/dialer/app/calllog/DefaultVoicemailNotifier.java index 0007d1863..d67f12266 100644 --- a/java/com/android/dialer/app/calllog/DefaultVoicemailNotifier.java +++ b/java/com/android/dialer/app/calllog/DefaultVoicemailNotifier.java @@ -31,6 +31,7 @@ import android.os.PersistableBundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; +import android.support.annotation.WorkerThread; import android.support.v4.os.BuildCompat; import android.support.v4.util.Pair; import android.telecom.PhoneAccount; @@ -48,6 +49,7 @@ import com.android.dialer.app.R; import com.android.dialer.app.calllog.CallLogNotificationsQueryHelper.NewCall; import com.android.dialer.app.contactinfo.ContactPhotoLoader; import com.android.dialer.app.list.DialtactsPagerAdapter; +import com.android.dialer.blocking.FilteredNumberAsyncQueryHandler; import com.android.dialer.blocking.FilteredNumbersUtil; import com.android.dialer.calllogutils.PhoneAccountUtils; import com.android.dialer.common.Assert; @@ -76,17 +78,24 @@ public class DefaultVoicemailNotifier { private final Context context; private final CallLogNotificationsQueryHelper queryHelper; + private final FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler; @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) - DefaultVoicemailNotifier(Context context, CallLogNotificationsQueryHelper queryHelper) { + DefaultVoicemailNotifier( + Context context, + CallLogNotificationsQueryHelper queryHelper, + FilteredNumberAsyncQueryHandler filteredNumberAsyncQueryHandler) { this.context = context; this.queryHelper = queryHelper; + this.filteredNumberAsyncQueryHandler = filteredNumberAsyncQueryHandler; } /** Returns an instance of {@link DefaultVoicemailNotifier}. */ public static DefaultVoicemailNotifier getInstance(Context context) { return new DefaultVoicemailNotifier( - context, CallLogNotificationsQueryHelper.getInstance(context)); + context, + CallLogNotificationsQueryHelper.getInstance(context), + new FilteredNumberAsyncQueryHandler(context)); } /** @@ -97,7 +106,9 @@ public class DefaultVoicemailNotifier { * *

It is not safe to call this method from the main thread. */ + @WorkerThread public void updateNotification() { + Assert.isWorkerThread(); // Lookup the list of new voicemails to include in the notification. final List newCalls = queryHelper.getNewVoicemails(); @@ -121,13 +132,15 @@ public class DefaultVoicemailNotifier { NewCall newCall = itr.next(); // Skip notifying for numbers which are blocked. - if (FilteredNumbersUtil.shouldBlockVoicemail( - context, newCall.number, newCall.countryIso, newCall.dateMs)) { + if (!FilteredNumbersUtil.hasRecentEmergencyCall(context) + && filteredNumberAsyncQueryHandler.getBlockedIdSynchronous( + newCall.number, newCall.countryIso) + != null) { itr.remove(); if (newCall.voicemailUri != null) { // Delete the voicemail. - context.getContentResolver().delete(newCall.voicemailUri, null, null); + CallLogAsyncTaskUtil.deleteVoicemailSynchronous(context, newCall.voicemailUri); } continue; } diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java index 7c25e7d39..1440218fb 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java @@ -45,16 +45,6 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { super(CallLog.Calls.VOICEMAIL_TYPE); } - @Override - public void onCreate(Bundle state) { - super.onCreate(state); - mVoicemailPlaybackPresenter = VoicemailPlaybackPresenter.getInstance(getActivity(), state); - getActivity() - .getContentResolver() - .registerContentObserver( - VoicemailContract.Status.CONTENT_URI, true, mVoicemailStatusObserver); - } - @Override protected VoicemailPlaybackPresenter getVoicemailPlaybackPresenter() { return mVoicemailPlaybackPresenter; @@ -62,6 +52,12 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { @Override public void onActivityCreated(Bundle savedInstanceState) { + mVoicemailPlaybackPresenter = + VoicemailPlaybackPresenter.getInstance(getActivity(), savedInstanceState); + getActivity() + .getContentResolver() + .registerContentObserver( + VoicemailContract.Status.CONTENT_URI, true, mVoicemailStatusObserver); super.onActivityCreated(savedInstanceState); mVoicemailErrorManager = new VoicemailErrorManager(getContext(), getAdapter().getAlertManager(), mModalAlertManager); @@ -132,9 +128,6 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { public void onNotVisible() { LogUtil.enterBlock("VisualVoicemailCallLogFragment.onPageUnselected"); super.onNotVisible(); - if (getAdapter() != null && getAdapter().mActionMode != null) { - getAdapter().mActionMode.finish(); - } if (getActivity() != null) { getActivity().setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE); } -- cgit v1.2.3