From 9a6afa3ae2bfc0074f7f64a7ec3238c26e913c3c Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Thu, 3 Aug 2017 11:34:42 -0700 Subject: Update oc-dr1-dev to v11.1 RC06 This moves the branch forward from v11 RC17. This release contains fixes for the following bugs: Bug: 63584851 63803282 63917358 64099380 64101648 64105912 64119808 64122858 64125770 64300111 Test: TH, on device Merged-In: I858e3665253139b8aab4e4c063bfc4c419f33cc9 Merged-In: Ifc146f2fec24fd2f8a51cd32feb3699bb1c07136 Change-Id: I48296c56fb1d275a06b7c314f5380266c1195ef2 --- .../contacts/common/list/PhoneNumberListAdapter.java | 7 +++++-- .../app/calllog/CallLogListItemViewHolder.java | 20 ++++++-------------- java/com/android/dialer/app/list/ListsFragment.java | 4 +--- .../app/voicemail/VoicemailPlaybackPresenter.java | 6 ++++++ .../calldetails/CallDetailsHeaderViewHolder.java | 5 ++++- .../android/dialer/lightbringer/Lightbringer.java | 2 ++ .../dialer/lightbringer/stub/LightbringerStub.java | 5 +++++ .../VisualVoicemailEnabledChecker.java | 4 +--- .../voicemailstatus/VoicemailStatusHelper.java | 20 ++++++++++++-------- java/com/android/incallui/InCallPresenter.java | 13 +++++++++++-- java/com/android/incallui/VideoCallPresenter.java | 2 +- .../incallui/contactgrid/ContactGridManager.java | 15 ++++++++++----- 12 files changed, 64 insertions(+), 39 deletions(-) diff --git a/java/com/android/contacts/common/list/PhoneNumberListAdapter.java b/java/com/android/contacts/common/list/PhoneNumberListAdapter.java index d1118c3c7..ae15eb232 100644 --- a/java/com/android/contacts/common/list/PhoneNumberListAdapter.java +++ b/java/com/android/contacts/common/list/PhoneNumberListAdapter.java @@ -27,6 +27,7 @@ import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.CommonDataKinds.SipAddress; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Directory; +import android.support.annotation.VisibleForTesting; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; @@ -357,7 +358,8 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { bindPhoneNumber(view, cursor, directory.isDisplayNumber(), position); } - protected void bindPhoneNumber( + @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED) + public void bindPhoneNumber( ContactListItemView view, Cursor cursor, boolean displayNumber, int position) { CharSequence label = null; if (displayNumber && !cursor.isNull(PhoneQuery.PHONE_TYPE)) { @@ -397,7 +399,8 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { } } - if (LightbringerComponent.get(mContext).getLightbringer().isReachable(mContext, number)) { + if (action == ContactListItemView.NONE + && LightbringerComponent.get(mContext).getLightbringer().isReachable(mContext, number)) { action = ContactListItemView.LIGHTBRINGER; } diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java index 884d07d50..a4a2ba2ff 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java @@ -551,12 +551,15 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder private void bindActionButtons() { boolean canPlaceCallToNumber = PhoneNumberHelper.canPlaceCallsTo(number, numberPresentation); + // Hide the call buttons by default. We then set it to be visible when appropriate below. + // This saves us having to remember to set it to GONE in multiple places. + callButtonView.setVisibility(View.GONE); + videoCallButtonView.setVisibility(View.GONE); + if (isFullyUndialableVoicemail()) { // Sometimes the voicemail server will report the message is from some non phone number // source. If the number does not contains any dialable digit treat it as it is from a unknown // number, remove all action buttons but still show the voicemail playback layout. - callButtonView.setVisibility(View.GONE); - videoCallButtonView.setVisibility(View.GONE); detailsButtonView.setVisibility(View.GONE); createNewContactButtonView.setVisibility(View.GONE); addToExistingContactButtonView.setVisibility(View.GONE); @@ -582,11 +585,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } if (canPlaceCallToNumber) { - // Set up the call button but hide it by default (the primary action is to call so it is - // redundant). We then set it to be visible when appropriate below. This saves us having to - // remember to set it to GONE in multiple places. callButtonView.setTag(IntentProvider.getReturnCallIntentProvider(number)); - callButtonView.setVisibility(View.GONE); } if (!TextUtils.isEmpty(voicemailUri) && canPlaceCallToNumber) { @@ -616,8 +615,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } else if (lightbringerReady) { videoCallButtonView.setTag(IntentProvider.getLightbringerIntentProvider(number)); videoCallButtonView.setVisibility(View.VISIBLE); - } else { - videoCallButtonView.setVisibility(View.GONE); } // For voicemail calls, show the voicemail playback layout; hide otherwise. @@ -944,12 +941,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder String accountLabel = mCallLogCache.getAccountLabel(accountHandle); if (!TextUtils.isEmpty(accountLabel)) { SimDetails.Builder simDetails = SimDetails.newBuilder().setNetwork(accountLabel); - int color = mCallLogCache.getAccountColor(accountHandle); - if (color == PhoneAccount.NO_HIGHLIGHT_COLOR) { - simDetails.setColor(R.color.secondary_text_color); - } else { - simDetails.setColor(color); - } + simDetails.setColor(mCallLogCache.getAccountColor(accountHandle)); contact.setSimDetails(simDetails.build()); } return contact.build(); diff --git a/java/com/android/dialer/app/list/ListsFragment.java b/java/com/android/dialer/app/list/ListsFragment.java index 3f03db1e8..dbb6c8b5c 100644 --- a/java/com/android/dialer/app/list/ListsFragment.java +++ b/java/com/android/dialer/app/list/ListsFragment.java @@ -75,7 +75,6 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis private SharedPreferences mPrefs; private boolean mHasFetchedVoicemailStatus; private boolean mShowVoicemailTabAfterVoicemailStatusIsFetched; - private VoicemailStatusHelper mVoicemailStatusHelper; private final ArrayList mOnPageChangeListeners = new ArrayList<>(); /** The position of the currently selected tab. */ private int mTabIndex = TAB_INDEX_SPEED_DIAL; @@ -99,7 +98,6 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis LogUtil.d("ListsFragment.onCreate", null); Trace.beginSection(TAG + " onCreate"); super.onCreate(savedInstanceState); - mVoicemailStatusHelper = new VoicemailStatusHelper(); mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); Trace.endSection(); } @@ -294,7 +292,7 @@ public class ListsFragment extends Fragment implements OnPageChangeListener, Lis // Update hasActiveVoicemailProvider, which controls the number of tabs displayed. boolean hasActiveVoicemailProvider = - mVoicemailStatusHelper.getNumberActivityVoicemailSources(statusCursor) > 0; + VoicemailStatusHelper.getNumberActivityVoicemailSources(statusCursor) > 0; if (hasActiveVoicemailProvider != mAdapter.hasActiveVoicemailProvider()) { mAdapter.setHasActiveVoicemailProvider(hasActiveVoicemailProvider); mAdapter.notifyDataSetChanged(); diff --git a/java/com/android/dialer/app/voicemail/VoicemailPlaybackPresenter.java b/java/com/android/dialer/app/voicemail/VoicemailPlaybackPresenter.java index 5c9bc01c2..6d5015a22 100644 --- a/java/com/android/dialer/app/voicemail/VoicemailPlaybackPresenter.java +++ b/java/com/android/dialer/app/voicemail/VoicemailPlaybackPresenter.java @@ -57,6 +57,7 @@ import com.android.dialer.constants.Constants; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.phonenumbercache.CallLogQuery; +import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.util.PermissionsUtil; import com.google.common.io.ByteStreams; import java.io.File; @@ -515,6 +516,11 @@ public class VoicemailPlaybackPresenter mView.disableUiElements(); mIsPrepared = false; + if (mContext != null && TelecomUtil.isInCall(mContext)) { + handleError(new IllegalStateException("Cannot play voicemail when call is in progress")); + return; + } + try { mMediaPlayer = new MediaPlayer(); mMediaPlayer.setOnPreparedListener(this); diff --git a/java/com/android/dialer/calldetails/CallDetailsHeaderViewHolder.java b/java/com/android/dialer/calldetails/CallDetailsHeaderViewHolder.java index 3df3c3aac..ea12c4f95 100644 --- a/java/com/android/dialer/calldetails/CallDetailsHeaderViewHolder.java +++ b/java/com/android/dialer/calldetails/CallDetailsHeaderViewHolder.java @@ -19,6 +19,7 @@ package com.android.dialer.calldetails; import android.content.Context; import android.net.Uri; import android.support.v7.widget.RecyclerView; +import android.telecom.PhoneAccount; import android.text.TextUtils; import android.view.View; import android.view.View.OnClickListener; @@ -93,7 +94,9 @@ public class CallDetailsHeaderViewHolder extends RecyclerView.ViewHolder if (!TextUtils.isEmpty(contact.getSimDetails().getNetwork())) { networkView.setVisibility(View.VISIBLE); networkView.setText(contact.getSimDetails().getNetwork()); - networkView.setTextColor(context.getResources().getColor(contact.getSimDetails().getColor())); + if (contact.getSimDetails().getColor() != PhoneAccount.NO_HIGHLIGHT_COLOR) { + networkView.setTextColor(contact.getSimDetails().getColor()); + } } if (TextUtils.isEmpty(contact.getNumber())) { diff --git a/java/com/android/dialer/lightbringer/Lightbringer.java b/java/com/android/dialer/lightbringer/Lightbringer.java index 669e571a0..8bfa7736a 100644 --- a/java/com/android/dialer/lightbringer/Lightbringer.java +++ b/java/com/android/dialer/lightbringer/Lightbringer.java @@ -27,6 +27,8 @@ import android.telecom.PhoneAccountHandle; public interface Lightbringer { + boolean isEnabled(); + @MainThread boolean isReachable(@NonNull Context context, @Nullable String number); diff --git a/java/com/android/dialer/lightbringer/stub/LightbringerStub.java b/java/com/android/dialer/lightbringer/stub/LightbringerStub.java index 1cb3c1ff0..e691b96f0 100644 --- a/java/com/android/dialer/lightbringer/stub/LightbringerStub.java +++ b/java/com/android/dialer/lightbringer/stub/LightbringerStub.java @@ -34,6 +34,11 @@ public class LightbringerStub implements Lightbringer { @Inject public LightbringerStub() {} + @Override + public boolean isEnabled() { + return false; + } + @MainThread @Override public boolean isReachable(@NonNull Context context, @Nullable String number) { diff --git a/java/com/android/dialer/voicemailstatus/VisualVoicemailEnabledChecker.java b/java/com/android/dialer/voicemailstatus/VisualVoicemailEnabledChecker.java index a1fc29edf..3f519ad82 100644 --- a/java/com/android/dialer/voicemailstatus/VisualVoicemailEnabledChecker.java +++ b/java/com/android/dialer/voicemailstatus/VisualVoicemailEnabledChecker.java @@ -45,7 +45,6 @@ public class VisualVoicemailEnabledChecker implements CallLogQueryHandler.Listen private SharedPreferences mPrefs; private boolean mHasActiveVoicemailProvider; private CallLogQueryHandler mCallLogQueryHandler; - private VoicemailStatusHelper mVoicemailStatusHelper; private Context mContext; private Callback mCallback; @@ -53,7 +52,6 @@ public class VisualVoicemailEnabledChecker implements CallLogQueryHandler.Listen mContext = context; mCallback = callback; mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext); - mVoicemailStatusHelper = new VoicemailStatusHelper(); mHasActiveVoicemailProvider = mPrefs.getBoolean(PREF_KEY_HAS_ACTIVE_VOICEMAIL_PROVIDER, false); } @@ -77,7 +75,7 @@ public class VisualVoicemailEnabledChecker implements CallLogQueryHandler.Listen @Override public void onVoicemailStatusFetched(Cursor statusCursor) { boolean hasActiveVoicemailProvider = - mVoicemailStatusHelper.getNumberActivityVoicemailSources(statusCursor) > 0; + VoicemailStatusHelper.getNumberActivityVoicemailSources(statusCursor) > 0; if (hasActiveVoicemailProvider != mHasActiveVoicemailProvider) { mHasActiveVoicemailProvider = hasActiveVoicemailProvider; mPrefs diff --git a/java/com/android/dialer/voicemailstatus/VoicemailStatusHelper.java b/java/com/android/dialer/voicemailstatus/VoicemailStatusHelper.java index 9df45c211..313fc1be1 100644 --- a/java/com/android/dialer/voicemailstatus/VoicemailStatusHelper.java +++ b/java/com/android/dialer/voicemailstatus/VoicemailStatusHelper.java @@ -21,15 +21,17 @@ import android.provider.VoicemailContract.Status; import com.android.dialer.database.VoicemailStatusQuery; /** - * Interface used by the call log UI to determine what user message, if any, related to voicemail + * Utility used by the call log UI to determine what user message, if any, related to voicemail * source status needs to be shown. The messages are returned in the order of importance. * - *

The implementation of this interface interacts with the voicemail content provider to fetch - * statuses of all the registered voicemail sources and determines if any status message needs to be - * shown. The user of this interface must observe/listen to provider changes and invoke this class - * to check if any message needs to be shown. + *

This class interacts with the voicemail content provider to fetch statuses of all the + * registered voicemail sources and determines if any status message needs to be shown. The user of + * this class must observe/listen to provider changes and invoke this class to check if any message + * needs to be shown. */ -public class VoicemailStatusHelper { +public final class VoicemailStatusHelper { + + private VoicemailStatusHelper() {} /** * Returns the number of active voicemail sources installed. @@ -39,7 +41,7 @@ public class VoicemailStatusHelper { * @param cursor The caller is responsible for the life cycle of the cursor and resetting the * position */ - public int getNumberActivityVoicemailSources(Cursor cursor) { + public static int getNumberActivityVoicemailSources(Cursor cursor) { int count = 0; if (!cursor.moveToFirst()) { return 0; @@ -60,8 +62,10 @@ public class VoicemailStatusHelper { * activation is attempted, it will transition into CONFIGURING then into OK or other error state, * NOT_CONFIGURED is never set through an error. */ - private boolean isVoicemailSourceActive(Cursor cursor) { + private static boolean isVoicemailSourceActive(Cursor cursor) { return cursor.getString(VoicemailStatusQuery.SOURCE_PACKAGE_INDEX) != null + // getInt() returns 0 when null + && !cursor.isNull(VoicemailStatusQuery.CONFIGURATION_STATE_INDEX) && cursor.getInt(VoicemailStatusQuery.CONFIGURATION_STATE_INDEX) != Status.CONFIGURATION_STATE_NOT_CONFIGURED; } diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java index 1528e7dcf..563468e84 100644 --- a/java/com/android/incallui/InCallPresenter.java +++ b/java/com/android/incallui/InCallPresenter.java @@ -189,6 +189,8 @@ public class InCallPresenter implements CallList.Listener { /** Determines if the InCall UI is in fullscreen mode or not. */ private boolean mIsFullScreen = false; + private boolean mScreenTimeoutEnabled = true; + private PhoneStateListener mPhoneStateListener = new PhoneStateListener() { @Override @@ -395,6 +397,7 @@ public class InCallPresenter implements CallList.Listener { } private void attemptFinishActivity() { + mScreenTimeoutEnabled = true; final boolean doFinish = (mInCallActivity != null && isActivityStarted()); LogUtil.i("InCallPresenter.attemptFinishActivity", "Hide in call UI: " + doFinish); if (doFinish) { @@ -1064,6 +1067,7 @@ public class InCallPresenter implements CallList.Listener { // TODO - b/36649622: Investigate this redundant call mStatusBarNotifier.updateNotification(mCallList); } + applyScreenTimeout(); } /*package*/ @@ -1577,13 +1581,18 @@ public class InCallPresenter implements CallList.Listener { public void enableScreenTimeout(boolean enable) { LogUtil.v("InCallPresenter.enableScreenTimeout", "enableScreenTimeout: value=" + enable); + mScreenTimeoutEnabled = enable; + applyScreenTimeout(); + } + + private void applyScreenTimeout() { if (mInCallActivity == null) { - LogUtil.e("InCallPresenter.enableScreenTimeout", "InCallActivity is null."); + LogUtil.e("InCallPresenter.applyScreenTimeout", "InCallActivity is null."); return; } final Window window = mInCallActivity.getWindow(); - if (enable) { + if (mScreenTimeoutEnabled) { window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } else { window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); diff --git a/java/com/android/incallui/VideoCallPresenter.java b/java/com/android/incallui/VideoCallPresenter.java index a10602227..5b4178d45 100644 --- a/java/com/android/incallui/VideoCallPresenter.java +++ b/java/com/android/incallui/VideoCallPresenter.java @@ -867,7 +867,7 @@ public class VideoCallPresenter false /* isRemotelyHeld */); enableCamera(mVideoCall, false); InCallPresenter.getInstance().setFullScreen(false); - + InCallPresenter.getInstance().enableScreenTimeout(false); mIsVideoMode = false; } diff --git a/java/com/android/incallui/contactgrid/ContactGridManager.java b/java/com/android/incallui/contactgrid/ContactGridManager.java index 502cc52b8..708bfab4e 100644 --- a/java/com/android/incallui/contactgrid/ContactGridManager.java +++ b/java/com/android/incallui/contactgrid/ContactGridManager.java @@ -32,6 +32,7 @@ import android.widget.ViewAnimator; import com.android.contacts.common.compat.PhoneNumberUtilsCompat; import com.android.contacts.common.lettertiles.LetterTileDrawable; import com.android.dialer.common.Assert; +import com.android.dialer.common.LogUtil; import com.android.dialer.util.DrawableConverter; import com.android.incallui.incall.protocol.ContactPhotoType; import com.android.incallui.incall.protocol.PrimaryCallState; @@ -347,12 +348,16 @@ public class ContactGridManager { } if (info.isTimerVisible) { + bottomTextSwitcher.setDisplayedChild(1); + bottomTimerView.setBase( + primaryCallState.connectTimeMillis + - System.currentTimeMillis() + + SystemClock.elapsedRealtime()); if (!isTimerStarted) { - bottomTextSwitcher.setDisplayedChild(1); - bottomTimerView.setBase( - primaryCallState.connectTimeMillis - - System.currentTimeMillis() - + SystemClock.elapsedRealtime()); + LogUtil.i( + "ContactGridManager.updateBottomRow", + "starting timer with base: %d", + bottomTimerView.getBase()); bottomTimerView.start(); isTimerStarted = true; } -- cgit v1.2.3