From 61de7a383e67619b1c5fab26f81aef451438c9b8 Mon Sep 17 00:00:00 2001 From: twyen Date: Fri, 30 Jun 2017 14:53:33 -0700 Subject: Move voicemail notification dismissing to VisualVoicemailCallLogFragment The original code is somehow triggering when the VVM tab is not selected. Bug: 62517716 Test: VisualVoicemailCallLogFragment is utterly untestable PiperOrigin-RevId: 160692310 Change-Id: Ia9da8e5aa7dd28f22c46d87dd25ebf6097918a9a --- .../dialer/app/calllog/CallLogFragment.java | 27 +--------------------- .../calllog/VisualVoicemailCallLogFragment.java | 10 ++++++-- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/java/com/android/dialer/app/calllog/CallLogFragment.java b/java/com/android/dialer/app/calllog/CallLogFragment.java index aa765d90e..369fbbc91 100644 --- a/java/com/android/dialer/app/calllog/CallLogFragment.java +++ b/java/com/android/dialer/app/calllog/CallLogFragment.java @@ -20,7 +20,6 @@ import static android.Manifest.permission.READ_CALL_LOG; import android.app.Activity; import android.app.Fragment; -import android.app.KeyguardManager; import android.content.ContentResolver; import android.content.Context; import android.content.pm.PackageManager; @@ -114,7 +113,6 @@ public class CallLogFragment extends Fragment private CallLogQueryHandler mCallLogQueryHandler; private boolean mScrollToTop; private EmptyContentView mEmptyListView; - private KeyguardManager mKeyguardManager; private ContactInfoCache mContactInfoCache; private final OnContactInfoChangedListener mOnContactInfoChangedListener = new OnContactInfoChangedListener() { @@ -219,7 +217,6 @@ public class CallLogFragment extends Fragment final Activity activity = getActivity(); final ContentResolver resolver = activity.getContentResolver(); mCallLogQueryHandler = new CallLogQueryHandler(activity, resolver, this, mLogLimit); - mKeyguardManager = (KeyguardManager) activity.getSystemService(Context.KEYGUARD_SERVICE); if (PermissionsUtil.hasCallLogReadPermissions(getContext())) { resolver.registerContentObserver(CallLog.CONTENT_URI, true, mCallLogObserver); @@ -432,8 +429,6 @@ public class CallLogFragment extends Fragment @Override public void onStop() { - updateOnTransition(); - super.onStop(); mAdapter.onStop(); mContactInfoCache.stop(); @@ -516,9 +511,7 @@ public class CallLogFragment extends Fragment super.setMenuVisibility(menuVisible); if (mMenuVisible != menuVisible) { mMenuVisible = menuVisible; - if (!menuVisible) { - updateOnTransition(); - } else if (isResumed()) { + if (menuVisible && isResumed()) { refreshData(); } } @@ -536,7 +529,6 @@ public class CallLogFragment extends Fragment fetchCalls(); mCallLogQueryHandler.fetchVoicemailStatus(); mCallLogQueryHandler.fetchMissedCallsUnreadCount(); - updateOnTransition(); mRefreshDataRequired = false; } else { // Refresh the display of the existing data to update the timestamp text descriptions. @@ -544,23 +536,6 @@ public class CallLogFragment extends Fragment } } - /** - * Updates the voicemail notification state. - * - *

TODO: Move to CallLogActivity - */ - private void updateOnTransition() { - // We don't want to update any call data when keyguard is on because the user has likely not - // seen the new calls yet. - // This might be called before onCreate() and thus we need to check null explicitly. - if (mKeyguardManager != null - && !mKeyguardManager.inKeyguardRestrictedInputMode() - && mCallTypeFilter == Calls.VOICEMAIL_TYPE) { - LogUtil.i("CallLogFragment.updateOnTransition", "clearing all new voicemails"); - CallLogNotificationsService.markAllNewVoicemailsAsOld(getActivity()); - } - } - @Override public void onEmptyViewActionButtonClicked() { final Activity activity = getActivity(); diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java index 893d6bed9..17018b38d 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailCallLogFragment.java @@ -16,6 +16,7 @@ package com.android.dialer.app.calllog; +import android.app.KeyguardManager; import android.content.Intent; import android.database.ContentObserver; import android.media.AudioManager; @@ -132,7 +133,7 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { @Override public void onVisible() { - LogUtil.enterBlock("VisualVoicemailCallLogFragment.onPageSelected"); + LogUtil.enterBlock("VisualVoicemailCallLogFragment.onVisible"); super.onVisible(); if (getActivity() != null) { Intent intent = new Intent(VoicemailContract.ACTION_SYNC_VOICEMAIL); @@ -145,10 +146,15 @@ public class VisualVoicemailCallLogFragment extends CallLogFragment { @Override public void onNotVisible() { - LogUtil.enterBlock("VisualVoicemailCallLogFragment.onPageUnselected"); + LogUtil.enterBlock("VisualVoicemailCallLogFragment.onNotVisible"); super.onNotVisible(); if (getActivity() != null) { getActivity().setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE); + // onNotVisible will be called in the lock screen when the call ends + if (!getActivity().getSystemService(KeyguardManager.class).inKeyguardRestrictedInputMode()) { + LogUtil.i("VisualVoicemailCallLogFragment.onNotVisible", "clearing all new voicemails"); + CallLogNotificationsService.markAllNewVoicemailsAsOld(getActivity()); + } } } } -- cgit v1.2.3 From ad26445126c237c226d0b65fc1dad1b5ca41ef77 Mon Sep 17 00:00:00 2001 From: erfanian Date: Fri, 30 Jun 2017 15:34:18 -0700 Subject: Fix concurrency issue in constructor. Before: sColors served as the branch to initialize all member variables. Subsequent calls to the constructor after sColors had been initialized, would result in the use of static members that were not yet initialized. Now: We guard each reference with an explicit null check during construct. Members that require synchronized initialization were put into a small synchronized method. This was chosen instead of AtomicReferences, and instead of double checked locking, because -- although verbose -- we can tolerate a small number of overwrites to each member variable (they are idempotent within the Application scope), thus avoiding the need for any one thread to wait/acquire a lock, as well as avoiding the need to import the Atomic library (which added no incremental benefit). It is assumed that the JVM will not garbage collect overwritten references to member variables that are still in use across instances of LetterTileDrawable. This shouldn't matter because the references are volatile, anyway. Initialization-on-demand was not available due to the use of non-static resources on construct. Bug: 63143138 Test: No. Old unit tests. PiperOrigin-RevId: 160696979 Change-Id: Ie17a29e48f91cb3df07d81d29b6428b70fb4408a --- .../common/lettertiles/LetterTileDrawable.java | 83 +++++++++++++++------- 1 file changed, 57 insertions(+), 26 deletions(-) diff --git a/java/com/android/contacts/common/lettertiles/LetterTileDrawable.java b/java/com/android/contacts/common/lettertiles/LetterTileDrawable.java index 5c401fe38..5b7dcbe84 100644 --- a/java/com/android/contacts/common/lettertiles/LetterTileDrawable.java +++ b/java/com/android/contacts/common/lettertiles/LetterTileDrawable.java @@ -87,23 +87,23 @@ public class LetterTileDrawable extends Drawable { /** Default icon scale for vector drawable. */ private static final float VECTOR_ICON_SCALE = 0.7f; - /** Reusable components to avoid new allocations */ - private static final Paint sPaint = new Paint(); + private static Paint sPaint; private static final Rect sRect = new Rect(); private static final char[] sFirstChar = new char[1]; - /** Letter tile */ - private static TypedArray sColors; - - private static int sSpamColor; - private static int sDefaultColor; - private static int sTileFontColor; - private static float sLetterToTileRatio; - private static Drawable sDefaultPersonAvatar; - private static Drawable sDefaultBusinessAvatar; - private static Drawable sDefaultVoicemailAvatar; - private static Drawable sDefaultSpamAvatar; - private static Drawable sDefaultConferenceAvatar; + + private static volatile Integer sSpamColor; + private static volatile Integer sDefaultColor; + private static volatile Integer sTileFontColor; + private static volatile Float sLetterToTileRatio; + + private static volatile TypedArray sColors; + + private static volatile Drawable sDefaultPersonAvatar; + private static volatile Drawable sDefaultBusinessAvatar; + private static volatile Drawable sDefaultVoicemailAvatar; + private static volatile Drawable sDefaultSpamAvatar; + private static volatile Drawable sDefaultConferenceAvatar; private final Paint mPaint; @ContactType private int mContactType = TYPE_DEFAULT; @@ -117,35 +117,66 @@ public class LetterTileDrawable extends Drawable { private String mDisplayName; public LetterTileDrawable(final Resources res) { - if (sColors == null) { - sColors = res.obtainTypedArray(R.array.letter_tile_colors); + // Guard static members with null checks to insulate against concurrent calls to the + // constructor. + if (sSpamColor == null) { sSpamColor = res.getColor(R.color.spam_contact_background); + } + if (sDefaultColor == null) { sDefaultColor = res.getColor(R.color.letter_tile_default_color); + } + if (sTileFontColor == null) { sTileFontColor = res.getColor(R.color.letter_tile_font_color); + } + if (sTileFontColor == null) { sLetterToTileRatio = res.getFraction(R.dimen.letter_to_tile_ratio, 1, 1); + } + + if (sColors == null) { + sColors = res.obtainTypedArray(R.array.letter_tile_colors); + } + if (sDefaultPersonAvatar == null) { sDefaultPersonAvatar = res.getDrawable(R.drawable.product_logo_avatar_anonymous_white_color_120, null); - Assert.isNotNull(sDefaultPersonAvatar, "sDefaultPersonAvatar is null"); + } + if (sDefaultBusinessAvatar == null) { sDefaultBusinessAvatar = res.getDrawable(R.drawable.quantum_ic_business_vd_theme_24, null); - Assert.isNotNull(sDefaultBusinessAvatar, "sDefaultBusinessAvatar is null"); + } + if (sDefaultVoicemailAvatar == null) { sDefaultVoicemailAvatar = res.getDrawable(R.drawable.quantum_ic_voicemail_vd_theme_24, null); - Assert.isNotNull(sDefaultVoicemailAvatar, "sDefaultVoicemailAvatar is null"); + } + if (sDefaultSpamAvatar == null) { sDefaultSpamAvatar = res.getDrawable(R.drawable.quantum_ic_report_vd_theme_24, null); - Assert.isNotNull(sDefaultSpamAvatar, "sDefaultSpamAvatar is null"); + } + if (sDefaultConferenceAvatar == null) { sDefaultConferenceAvatar = res.getDrawable(R.drawable.quantum_ic_group_vd_theme_24, null); - Assert.isNotNull(sDefaultConferenceAvatar, "sDefaultConferenceAvatar is null"); - - sPaint.setTypeface( - Typeface.create(res.getString(R.string.letter_tile_letter_font_family), Typeface.NORMAL)); - sPaint.setTextAlign(Align.CENTER); - sPaint.setAntiAlias(true); } + + // Calls in this method are potentially not idempotent, and need to be set after + // the member is initilaized. + this.initializeDefaultPaintOptions(res); + + // These values should be reset on every call to the constructor. mPaint = new Paint(); mPaint.setFilterBitmap(true); mPaint.setDither(true); + mColor = sDefaultColor; } + private static void initializeDefaultPaintOptions(final Resources res) { + if (sPaint == null) { + synchronized (LetterTileDrawable.class) { + sPaint = new Paint(); + sPaint.setTypeface( + Typeface.create( + res.getString(R.string.letter_tile_letter_font_family), Typeface.NORMAL)); + sPaint.setTextAlign(Align.CENTER); + sPaint.setAntiAlias(true); + } + } + } + private Rect getScaledBounds(float scale, float offset) { // The drawable should be drawn in the middle of the canvas without changing its width to // height ratio. -- cgit v1.2.3 From 115a7c9bffc79aff0e9d9215489f5b3f200c94b4 Mon Sep 17 00:00:00 2001 From: yueg Date: Fri, 30 Jun 2017 15:39:26 -0700 Subject: Fix 2 NPEs in CallLogAdapter. Test: cl/160695183 PiperOrigin-RevId: 160697524 Change-Id: I07127554a968d8dc36c02b522b7536438be7fb90 --- java/com/android/dialer/app/calllog/CallLogAdapter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java index c4156d5c6..4942184a2 100644 --- a/java/com/android/dialer/app/calllog/CallLogAdapter.java +++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java @@ -368,7 +368,9 @@ public class CallLogAdapter extends GroupingListAdapter } expandViewHolderActions(viewHolder); - if (viewHolder.videoCallButtonView.getVisibility() == View.VISIBLE + if (viewHolder.videoCallButtonView != null + && viewHolder.videoCallButtonView.getVisibility() == View.VISIBLE + && LightbringerComponent.get(mActivity).getLightbringer().getPackageName() != null && LightbringerComponent.get(mActivity) .getLightbringer() .getPackageName() -- cgit v1.2.3 From ce5ad9c817de101f5685d6f63e0a90a02ebc4b2b Mon Sep 17 00:00:00 2001 From: sail Date: Mon, 3 Jul 2017 10:28:43 -0700 Subject: Automated g4 rollback of changelist 160696979. *** Reason for rollback *** Causes crash on launch (b/63252565) *** Original change description *** Fix concurrency issue in constructor. Before: sColors served as the branch to initialize all member variables. Subsequent calls to the constructor after sColors had been initialized, would result in the use of static members that were not yet initialized. Now: We guard each reference with an explicit null check during construct. Members that require synchronized initialization were put into a small synchronized method. This was chosen instead of AtomicReferences, and instead of double check... *** Bug: 63143138 Test: N/A PiperOrigin-RevId: 160837963 Change-Id: I2586f7586c8f39182d64c3b28a59886c5ba94789 --- .../common/lettertiles/LetterTileDrawable.java | 83 +++++++--------------- 1 file changed, 26 insertions(+), 57 deletions(-) diff --git a/java/com/android/contacts/common/lettertiles/LetterTileDrawable.java b/java/com/android/contacts/common/lettertiles/LetterTileDrawable.java index 5b7dcbe84..5c401fe38 100644 --- a/java/com/android/contacts/common/lettertiles/LetterTileDrawable.java +++ b/java/com/android/contacts/common/lettertiles/LetterTileDrawable.java @@ -87,23 +87,23 @@ public class LetterTileDrawable extends Drawable { /** Default icon scale for vector drawable. */ private static final float VECTOR_ICON_SCALE = 0.7f; - private static Paint sPaint; + /** Reusable components to avoid new allocations */ + private static final Paint sPaint = new Paint(); private static final Rect sRect = new Rect(); private static final char[] sFirstChar = new char[1]; - - private static volatile Integer sSpamColor; - private static volatile Integer sDefaultColor; - private static volatile Integer sTileFontColor; - private static volatile Float sLetterToTileRatio; - - private static volatile TypedArray sColors; - - private static volatile Drawable sDefaultPersonAvatar; - private static volatile Drawable sDefaultBusinessAvatar; - private static volatile Drawable sDefaultVoicemailAvatar; - private static volatile Drawable sDefaultSpamAvatar; - private static volatile Drawable sDefaultConferenceAvatar; + /** Letter tile */ + private static TypedArray sColors; + + private static int sSpamColor; + private static int sDefaultColor; + private static int sTileFontColor; + private static float sLetterToTileRatio; + private static Drawable sDefaultPersonAvatar; + private static Drawable sDefaultBusinessAvatar; + private static Drawable sDefaultVoicemailAvatar; + private static Drawable sDefaultSpamAvatar; + private static Drawable sDefaultConferenceAvatar; private final Paint mPaint; @ContactType private int mContactType = TYPE_DEFAULT; @@ -117,66 +117,35 @@ public class LetterTileDrawable extends Drawable { private String mDisplayName; public LetterTileDrawable(final Resources res) { - // Guard static members with null checks to insulate against concurrent calls to the - // constructor. - if (sSpamColor == null) { + if (sColors == null) { + sColors = res.obtainTypedArray(R.array.letter_tile_colors); sSpamColor = res.getColor(R.color.spam_contact_background); - } - if (sDefaultColor == null) { sDefaultColor = res.getColor(R.color.letter_tile_default_color); - } - if (sTileFontColor == null) { sTileFontColor = res.getColor(R.color.letter_tile_font_color); - } - if (sTileFontColor == null) { sLetterToTileRatio = res.getFraction(R.dimen.letter_to_tile_ratio, 1, 1); - } - - if (sColors == null) { - sColors = res.obtainTypedArray(R.array.letter_tile_colors); - } - if (sDefaultPersonAvatar == null) { sDefaultPersonAvatar = res.getDrawable(R.drawable.product_logo_avatar_anonymous_white_color_120, null); - } - if (sDefaultBusinessAvatar == null) { + Assert.isNotNull(sDefaultPersonAvatar, "sDefaultPersonAvatar is null"); sDefaultBusinessAvatar = res.getDrawable(R.drawable.quantum_ic_business_vd_theme_24, null); - } - if (sDefaultVoicemailAvatar == null) { + Assert.isNotNull(sDefaultBusinessAvatar, "sDefaultBusinessAvatar is null"); sDefaultVoicemailAvatar = res.getDrawable(R.drawable.quantum_ic_voicemail_vd_theme_24, null); - } - if (sDefaultSpamAvatar == null) { + Assert.isNotNull(sDefaultVoicemailAvatar, "sDefaultVoicemailAvatar is null"); sDefaultSpamAvatar = res.getDrawable(R.drawable.quantum_ic_report_vd_theme_24, null); - } - if (sDefaultConferenceAvatar == null) { + Assert.isNotNull(sDefaultSpamAvatar, "sDefaultSpamAvatar is null"); sDefaultConferenceAvatar = res.getDrawable(R.drawable.quantum_ic_group_vd_theme_24, null); - } - - // Calls in this method are potentially not idempotent, and need to be set after - // the member is initilaized. - this.initializeDefaultPaintOptions(res); + Assert.isNotNull(sDefaultConferenceAvatar, "sDefaultConferenceAvatar is null"); - // These values should be reset on every call to the constructor. + sPaint.setTypeface( + Typeface.create(res.getString(R.string.letter_tile_letter_font_family), Typeface.NORMAL)); + sPaint.setTextAlign(Align.CENTER); + sPaint.setAntiAlias(true); + } mPaint = new Paint(); mPaint.setFilterBitmap(true); mPaint.setDither(true); - mColor = sDefaultColor; } - private static void initializeDefaultPaintOptions(final Resources res) { - if (sPaint == null) { - synchronized (LetterTileDrawable.class) { - sPaint = new Paint(); - sPaint.setTypeface( - Typeface.create( - res.getString(R.string.letter_tile_letter_font_family), Typeface.NORMAL)); - sPaint.setTextAlign(Align.CENTER); - sPaint.setAntiAlias(true); - } - } - } - private Rect getScaledBounds(float scale, float offset) { // The drawable should be drawn in the middle of the canvas without changing its width to // height ratio. -- cgit v1.2.3 From 1803be7a4f88ebf05dddc99fcce6781f7ee937f9 Mon Sep 17 00:00:00 2001 From: wangqi Date: Wed, 5 Jul 2017 12:03:29 -0700 Subject: Fix NPE crash when haning up conference call. The reason of disconnect cause could be null. This is regression caused by cl/160563754 Bug: 63156395,63302714 Test: manual PiperOrigin-RevId: 160987545 Change-Id: I3fd726947601f55d5dc917b11626b64bfc9d0135 --- java/com/android/incallui/disconnectdialog/EnableWifiCallingPrompt.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/com/android/incallui/disconnectdialog/EnableWifiCallingPrompt.java b/java/com/android/incallui/disconnectdialog/EnableWifiCallingPrompt.java index da0c9d6be..a0ca8cd04 100644 --- a/java/com/android/incallui/disconnectdialog/EnableWifiCallingPrompt.java +++ b/java/com/android/incallui/disconnectdialog/EnableWifiCallingPrompt.java @@ -41,7 +41,7 @@ public class EnableWifiCallingPrompt implements DisconnectDialog { @Override public boolean shouldShow(DisconnectCause disconnectCause) { String reason = disconnectCause.getReason(); - if (reason.startsWith(REASON_WIFI_ON_BUT_WFC_OFF)) { + if (reason != null && reason.startsWith(REASON_WIFI_ON_BUT_WFC_OFF)) { LogUtil.i( "EnableWifiCallingPrompt.shouldShowPrompt", "showing prompt for disconnect cause: %s", -- cgit v1.2.3 From 3128dea03a0e3981511dfed6f3ef555f0b574725 Mon Sep 17 00:00:00 2001 From: twyen Date: Wed, 5 Jul 2017 17:54:33 -0700 Subject: Use NOTIFICATION_INCOMING_CALL_QUIET when the in call UI is visible There's a bug in O notification framework that the HUN(heads up notification) will always show when a notification with fullScreenIntent is updated. Previously NOTIFICATION_INCOMING_CALL_QUIET is only used when the call is already active when the new incoming call is received. NOTIFICATION_INCOMING_CALL_QUIET will post the notification to the ongoing call channel instead of the incoming call, which in theory will have lower importance and the HUN will not show. In this CL, all incoming call notification will become "quiet" if the InCallUi is visible. Bug: 62458080 Test: StatusBarNotiferTest.java PiperOrigin-RevId: 161029526 Change-Id: I671105ecfc102beb43e52cf4d91d55a66d31cd0e --- java/com/android/incallui/StatusBarNotifier.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/java/com/android/incallui/StatusBarNotifier.java b/java/com/android/incallui/StatusBarNotifier.java index 458df5149..53017a10e 100644 --- a/java/com/android/incallui/StatusBarNotifier.java +++ b/java/com/android/incallui/StatusBarNotifier.java @@ -66,6 +66,7 @@ import com.android.contacts.common.preference.ContactsPreferences; import com.android.contacts.common.util.BitmapUtil; import com.android.contacts.common.util.ContactDisplayUtils; import com.android.dialer.common.LogUtil; +import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.enrichedcall.EnrichedCallManager; import com.android.dialer.enrichedcall.Session; import com.android.dialer.multimedia.MultimediaData; @@ -308,11 +309,19 @@ public class StatusBarNotifier if (callState == DialerCall.State.INCOMING || callState == DialerCall.State.CALL_WAITING || isVideoUpgradeRequest) { - boolean alreadyActive = - callList.getActiveOrBackgroundCall() != null - && InCallPresenter.getInstance().isShowingInCallUi(); - notificationType = - alreadyActive ? NOTIFICATION_INCOMING_CALL_QUIET : NOTIFICATION_INCOMING_CALL; + if (ConfigProviderBindings.get(mContext) + .getBoolean("quiet_incoming_call_if_ui_showing", true)) { + notificationType = + InCallPresenter.getInstance().isShowingInCallUi() + ? NOTIFICATION_INCOMING_CALL_QUIET + : NOTIFICATION_INCOMING_CALL; + } else { + boolean alreadyActive = + callList.getActiveOrBackgroundCall() != null + && InCallPresenter.getInstance().isShowingInCallUi(); + notificationType = + alreadyActive ? NOTIFICATION_INCOMING_CALL_QUIET : NOTIFICATION_INCOMING_CALL; + } } else { notificationType = NOTIFICATION_IN_CALL; } -- cgit v1.2.3 From 061b6eb8dac57aa9d28dfdd1f8853879a2274b17 Mon Sep 17 00:00:00 2001 From: sail Date: Wed, 5 Jul 2017 18:01:29 -0700 Subject: Update REASON_IMS_ACCESS_BLOCKED definition to match framework change. This is changed in ag/2484808 to be defined by a constant telecom string. It will be available to public in O MR. We have to hard code it until then. (This is a take over of cl/161020406 from wangqi@) Test: VideoCallNotAvailablePromptTest PiperOrigin-RevId: 161030078 Change-Id: I0e1d8d98cb1f64b035d9063b28f8ba039c7378e4 --- .../android/contacts/common/compat/telecom/TelecomManagerCompat.java | 5 +++++ .../incallui/disconnectdialog/VideoCallNotAvailablePrompt.java | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/java/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java b/java/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java index e6f424788..172fb11e3 100644 --- a/java/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java +++ b/java/com/android/contacts/common/compat/telecom/TelecomManagerCompat.java @@ -35,6 +35,11 @@ public class TelecomManagerCompat { public static final String EXTRA_HANDOVER_VIDEO_STATE = "android.telecom.extra.HANDOVER_VIDEO_STATE"; + // This is a hidden constant in android.telecom.DisconnectCause. Telecom sets this as a disconnect + // reason if it wants us to prompt the user that the video call is not available. + // TODO(wangqi): Reference it to constant in android.telecom.DisconnectCause. + public static final String REASON_IMS_ACCESS_BLOCKED = "REASON_IMS_ACCESS_BLOCKED"; + /** * Returns the current SIM call manager. Apps must be prepared for this method to return null, * indicating that there currently exists no registered SIM call manager. diff --git a/java/com/android/incallui/disconnectdialog/VideoCallNotAvailablePrompt.java b/java/com/android/incallui/disconnectdialog/VideoCallNotAvailablePrompt.java index 34db976b2..526d45ed7 100644 --- a/java/com/android/incallui/disconnectdialog/VideoCallNotAvailablePrompt.java +++ b/java/com/android/incallui/disconnectdialog/VideoCallNotAvailablePrompt.java @@ -24,6 +24,7 @@ import android.support.annotation.NonNull; import android.telecom.DisconnectCause; import android.telecom.PhoneAccountHandle; import android.util.Pair; +import com.android.contacts.common.compat.telecom.TelecomManagerCompat; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallIntentBuilder; import com.android.dialer.common.LogUtil; @@ -33,12 +34,10 @@ import com.android.incallui.call.DialerCall; /** Prompt user to make voice call if video call is not currently available. */ public class VideoCallNotAvailablePrompt implements DisconnectDialog { - private static final String REASON_IMS_ACCESS_BLOCKED = "IMS_ACCESS_BLOCKED"; - @Override public boolean shouldShow(DisconnectCause disconnectCause) { if (disconnectCause.getCode() == DisconnectCause.ERROR - && REASON_IMS_ACCESS_BLOCKED.equals(disconnectCause.getReason())) { + && TelecomManagerCompat.REASON_IMS_ACCESS_BLOCKED.equals(disconnectCause.getReason())) { LogUtil.i( "VideoCallNotAvailablePrompt.shouldShowPrompt", "showing prompt for disconnect cause: %s", -- cgit v1.2.3