From e6a6356935c3a35d41133833e8a9cc2b7a108962 Mon Sep 17 00:00:00 2001 From: twyen Date: Tue, 10 Oct 2017 17:36:17 -0700 Subject: Remove voicemail count changed check for legacy notifications Previously before showing a voicemail notification dialer checks if the count has changed to avoid showing duplicated notifications. With the dismissed flag in place the count changed check is redundant, and it prevents the notification to reshow after reboot. Also updated the EXTRA_IS_REFRESH to use the O_MR public version. Bug: 66633426 Test: LegacyVoicemailNotificationReceiverTest PiperOrigin-RevId: 171760393 Change-Id: I508b8f42a44fd849ab7c8ca6fe9d4e7e8a38b1c7 --- .../LegacyVoicemailNotificationReceiver.java | 40 ++++++---------------- 1 file changed, 10 insertions(+), 30 deletions(-) (limited to 'java') diff --git a/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java b/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java index 74ddff245..efa34a071 100644 --- a/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java +++ b/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java @@ -22,6 +22,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Build; +import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import android.support.annotation.VisibleForTesting; import android.support.v4.os.BuildCompat; @@ -44,15 +45,10 @@ import com.android.voicemail.VoicemailComponent; @TargetApi(VERSION_CODES.O) public class LegacyVoicemailNotificationReceiver extends BroadcastReceiver { - private static final String LEGACY_VOICEMAIL_COUNT = "legacy_voicemail_count"; @VisibleForTesting static final String LEGACY_VOICEMAIL_DISMISSED = "legacy_voicemail_dismissed"; - /** - * Whether the notification is just a refresh or for a new voicemail. The phone should not play a - * ringtone or vibrate during a refresh if the notification is already showing. This is Hidden in - * O and public in O MR1. - */ - @VisibleForTesting static final String EXTRA_IS_REFRESH = "is_refresh"; + /** Hidden version of {@link TelephonyManager#EXTRA_IS_REFRESH} in OC */ + @VisibleForTesting static final String EXTRA_IS_REFRESH_LEGACY = "is_refresh"; @Override public void onReceive(Context context, Intent intent) { @@ -79,7 +75,13 @@ public class LegacyVoicemailNotificationReceiver extends BroadcastReceiver { PhoneAccountHandle phoneAccountHandle = Assert.isNotNull(intent.getParcelableExtra(TelephonyManager.EXTRA_PHONE_ACCOUNT_HANDLE)); int count = intent.getIntExtra(TelephonyManager.EXTRA_NOTIFICATION_COUNT, -1); - boolean isRefresh = intent.getBooleanExtra(EXTRA_IS_REFRESH, false); + + boolean isRefresh = + intent.getBooleanExtra( + VERSION.SDK_INT >= VERSION_CODES.O_MR1 + ? TelephonyManager.EXTRA_IS_REFRESH + : EXTRA_IS_REFRESH_LEGACY, + false); LogUtil.i("LegacyVoicemailNotificationReceiver.onReceive", "isRefresh: " + isRefresh); PerAccountSharedPreferences preferences = getSharedPreferences(context, phoneAccountHandle); if (isRefresh) { @@ -93,13 +95,6 @@ public class LegacyVoicemailNotificationReceiver extends BroadcastReceiver { setDismissed(context, phoneAccountHandle, false); } - if (!hasVoicemailCountChanged(preferences, count)) { - LogUtil.i( - "LegacyVoicemailNotificationReceiver.onReceive", - "voicemail count hasn't changed, ignoring"); - return; - } - if (count == -1) { // Carrier might not send voicemail count. Missing extra means there are unknown numbers of // voicemails (One or more). Treat it as 1 so the generic version will be shown. ("Voicemail" @@ -149,21 +144,6 @@ public class LegacyVoicemailNotificationReceiver extends BroadcastReceiver { .apply(); } - private static boolean hasVoicemailCountChanged( - PerAccountSharedPreferences preferences, int newCount) { - if (newCount == -1) { - // Carrier does not report voicemail count - return true; - } - - // Carriers may send multiple notifications for the same voicemail. - if (newCount != 0 && newCount == preferences.getInt(LEGACY_VOICEMAIL_COUNT, -1)) { - return false; - } - preferences.edit().putInt(LEGACY_VOICEMAIL_COUNT, newCount).apply(); - return true; - } - @VisibleForTesting static PerAccountSharedPreferences getSharedPreferences( Context context, PhoneAccountHandle phoneAccountHandle) { -- cgit v1.2.3 From d0f207f160a4abac488de29df82a842b6e3a353d Mon Sep 17 00:00:00 2001 From: erfanian Date: Wed, 11 Oct 2017 12:23:29 -0700 Subject: Fix incallui to use latest ux mocks for assisted dialing. * Remove old language icon from bottom row. Screenshot=In change as scuba test Bug: 64205446 Test: new unit tests PiperOrigin-RevId: 171858076 Change-Id: Idf781be193dae3593f778af1ac833f046abd87e3 --- .../dialer/assisteddialing/TransformationInfo.java | 15 ++++++++------- java/com/android/incallui/CallCardPresenter.java | 3 ++- java/com/android/incallui/call/DialerCall.java | 9 +++++++++ java/com/android/incallui/contactgrid/BottomRow.java | 9 ++------- .../android/incallui/contactgrid/ContactGridManager.java | 6 +----- java/com/android/incallui/contactgrid/TopRow.java | 9 +++++++++ .../res/layout/incall_contactgrid_bottom_row.xml | 4 ---- .../android/incallui/contactgrid/res/values/strings.xml | 3 +++ .../incallui/incall/protocol/PrimaryCallState.java | 9 +++++++-- 9 files changed, 41 insertions(+), 26 deletions(-) (limited to 'java') diff --git a/java/com/android/dialer/assisteddialing/TransformationInfo.java b/java/com/android/dialer/assisteddialing/TransformationInfo.java index 03e565c51..de8f27d01 100644 --- a/java/com/android/dialer/assisteddialing/TransformationInfo.java +++ b/java/com/android/dialer/assisteddialing/TransformationInfo.java @@ -57,19 +57,20 @@ public abstract class TransformationInfo { return new AutoValue_TransformationInfo.Builder(); } + /** A builder for TransformationInfo. */ @AutoValue.Builder - abstract static class Builder { - abstract Builder setOriginalNumber(String value); + public abstract static class Builder { + public abstract Builder setOriginalNumber(String value); - abstract Builder setTransformedNumber(String value); + public abstract Builder setTransformedNumber(String value); - abstract Builder setUserHomeCountryCode(String value); + public abstract Builder setUserHomeCountryCode(String value); - abstract Builder setUserRoamingCountryCode(String value); + public abstract Builder setUserRoamingCountryCode(String value); - abstract Builder setTransformedNumberCountryCallingCode(int value); + public abstract Builder setTransformedNumberCountryCallingCode(int value); - abstract TransformationInfo build(); + public abstract TransformationInfo build(); } public static TransformationInfo newInstanceFromBundle(@NonNull Bundle transformationInfoBundle) { diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java index d49d556a6..c9fc4a72c 100644 --- a/java/com/android/incallui/CallCardPresenter.java +++ b/java/com/android/incallui/CallCardPresenter.java @@ -484,7 +484,8 @@ public class CallCardPresenter supports2ndCallOnHold(), getSwapToSecondaryButtonState(), mPrimary.isAssistedDialed(), - null)); + null, + mPrimary.getAssistedDialingExtras())); InCallActivity activity = (InCallActivity) (mInCallScreen.getInCallScreenFragment().getActivity()); diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java index 2511bb8ca..621ad21f8 100644 --- a/java/com/android/incallui/call/DialerCall.java +++ b/java/com/android/incallui/call/DialerCall.java @@ -42,6 +42,7 @@ import android.telecom.VideoProfile; import android.text.TextUtils; import com.android.contacts.common.compat.CallCompat; import com.android.contacts.common.compat.telecom.TelecomManagerCompat; +import com.android.dialer.assisteddialing.TransformationInfo; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallIntentParser; import com.android.dialer.callintent.CallSpecificAppData; @@ -1036,6 +1037,14 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa return false; } + public TransformationInfo getAssistedDialingExtras() { + if (isAssistedDialed()) { + return TransformationInfo.newInstanceFromBundle( + getIntentExtras().getBundle(TelephonyManagerCompat.ASSISTED_DIALING_EXTRAS)); + } + return null; + } + public LatencyReport getLatencyReport() { return mLatencyReport; } diff --git a/java/com/android/incallui/contactgrid/BottomRow.java b/java/com/android/incallui/contactgrid/BottomRow.java index 91f08ef3e..a0d118552 100644 --- a/java/com/android/incallui/contactgrid/BottomRow.java +++ b/java/com/android/incallui/contactgrid/BottomRow.java @@ -49,7 +49,6 @@ public class BottomRow { public final boolean isForwardIconVisible; public final boolean isSpamIconVisible; public final boolean shouldPopulateAccessibilityEvent; - public final boolean isAssistedDialedVisisble; public Info( @Nullable CharSequence label, @@ -59,8 +58,7 @@ public class BottomRow { boolean isHdIconVisible, boolean isForwardIconVisible, boolean isSpamIconVisible, - boolean shouldPopulateAccessibilityEvent, - boolean isAssistedDialedVisisble) { + boolean shouldPopulateAccessibilityEvent) { this.label = label; this.isTimerVisible = isTimerVisible; this.isWorkIconVisible = isWorkIconVisible; @@ -69,7 +67,6 @@ public class BottomRow { this.isForwardIconVisible = isForwardIconVisible; this.isSpamIconVisible = isSpamIconVisible; this.shouldPopulateAccessibilityEvent = shouldPopulateAccessibilityEvent; - this.isAssistedDialedVisisble = isAssistedDialedVisisble; } } @@ -84,7 +81,6 @@ public class BottomRow { boolean isHdAttemptingIconVisible = state.isHdAttempting; boolean isSpamIconVisible = false; boolean shouldPopulateAccessibilityEvent = true; - boolean isAssistedDialedVisisble = state.isAssistedDialed; if (isIncoming(state) && primaryInfo.isSpam) { label = context.getString(R.string.contact_grid_incoming_suspected_spam); @@ -118,8 +114,7 @@ public class BottomRow { isHdIconVisible, isForwardIconVisible, isSpamIconVisible, - shouldPopulateAccessibilityEvent, - isAssistedDialedVisisble); + shouldPopulateAccessibilityEvent); } private static CharSequence getLabelForPhoneNumber(PrimaryInfo primaryInfo) { diff --git a/java/com/android/incallui/contactgrid/ContactGridManager.java b/java/com/android/incallui/contactgrid/ContactGridManager.java index c0ab9609f..8deee8263 100644 --- a/java/com/android/incallui/contactgrid/ContactGridManager.java +++ b/java/com/android/incallui/contactgrid/ContactGridManager.java @@ -61,7 +61,7 @@ public class ContactGridManager { @Nullable private ImageView avatarImageView; // Row 2: Mobile +1 (650) 253-0000 - // Row 2: [HD attempting icon]/[HD icon] [Assisted Dialing Icon] 00:15 + // Row 2: [HD attempting icon]/[HD icon] 00:15 // Row 2: Call ended // Row 2: Hanging up // Row 2: [Alert sign] Suspected spam caller @@ -69,7 +69,6 @@ public class ContactGridManager { private final ImageView workIconImageView; private final ImageView hdIconImageView; private final ImageView forwardIconImageView; - private final ImageView assistedDialingImageView; private final TextView forwardedNumberView; private final ImageView spamIconImageView; private final ViewAnimator bottomTextSwitcher; @@ -101,7 +100,6 @@ public class ContactGridManager { hdIconImageView = view.findViewById(R.id.contactgrid_hdIcon); forwardIconImageView = view.findViewById(R.id.contactgrid_forwardIcon); forwardedNumberView = view.findViewById(R.id.contactgrid_forwardNumber); - assistedDialingImageView = view.findViewById(R.id.contactgrid_assistedDialingIcon); spamIconImageView = view.findViewById(R.id.contactgrid_spamIcon); bottomTextSwitcher = view.findViewById(R.id.contactgrid_bottom_text_switcher); bottomTextView = view.findViewById(R.id.contactgrid_bottom_text); @@ -321,8 +319,6 @@ public class ContactGridManager { bottomTextView.setText(info.label); bottomTextView.setAllCaps(info.isSpamIconVisible); workIconImageView.setVisibility(info.isWorkIconVisible ? View.VISIBLE : View.GONE); - assistedDialingImageView.setVisibility( - info.isAssistedDialedVisisble ? View.VISIBLE : View.GONE); if (hdIconImageView.getVisibility() == View.GONE) { if (info.isHdAttemptingIconVisible) { hdIconImageView.setImageResource(R.drawable.asd_hd_icon); diff --git a/java/com/android/incallui/contactgrid/TopRow.java b/java/com/android/incallui/contactgrid/TopRow.java index 3593c991d..cfa7e1b86 100644 --- a/java/com/android/incallui/contactgrid/TopRow.java +++ b/java/com/android/incallui/contactgrid/TopRow.java @@ -173,6 +173,15 @@ public class TopRow { return context.getString(R.string.incall_video_call_requesting); } } + + if (state.isAssistedDialed) { + String countryCode = + String.valueOf(state.assistedDialingExtras.transformedNumberCountryCallingCode()); + return context.getString( + R.string.incall_connecting_assited_dialed, + countryCode, + state.assistedDialingExtras.userHomeCountryCode()); + } return context.getString(R.string.incall_connecting); } } diff --git a/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_bottom_row.xml b/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_bottom_row.xml index c545c25cd..ce355ea2d 100644 --- a/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_bottom_row.xml +++ b/java/com/android/incallui/contactgrid/res/layout/incall_contactgrid_bottom_row.xml @@ -30,10 +30,6 @@ android:id="@+id/contactgrid_hdIcon" style="@style/BottomRowIcon" android:visibility="gone"/> - Calling… + + Calling using +%1$s (%2$s)\u2026 + Transferring… diff --git a/java/com/android/incallui/incall/protocol/PrimaryCallState.java b/java/com/android/incallui/incall/protocol/PrimaryCallState.java index fe80276c9..4a50fbeaf 100644 --- a/java/com/android/incallui/incall/protocol/PrimaryCallState.java +++ b/java/com/android/incallui/incall/protocol/PrimaryCallState.java @@ -21,6 +21,7 @@ import android.support.annotation.IntDef; import android.support.annotation.Nullable; import android.telecom.DisconnectCause; import android.text.TextUtils; +import com.android.dialer.assisteddialing.TransformationInfo; import com.android.dialer.common.Assert; import com.android.incallui.call.DialerCall; import com.android.incallui.call.DialerCall.State; @@ -68,6 +69,7 @@ public class PrimaryCallState { public final @ButtonState int swapToSecondaryButtonState; public final boolean isAssistedDialed; @Nullable public final String customLabel; + @Nullable public final TransformationInfo assistedDialingExtras; // TODO: Convert to autovalue. b/34502119 public static PrimaryCallState createEmptyPrimaryCallState() { @@ -100,7 +102,8 @@ public class PrimaryCallState { true /* supportsCallOnHold */, ButtonState.NOT_SUPPORT /* swapToSecondaryButtonState */, false /* isAssistedDialed */, - customLabel); + customLabel, + null /* assistedDialingExtras */); } public PrimaryCallState( @@ -127,7 +130,8 @@ public class PrimaryCallState { boolean supportsCallOnHold, @ButtonState int swapToSecondaryButtonState, boolean isAssistedDialed, - @Nullable String customLabel) { + @Nullable String customLabel, + @Nullable TransformationInfo assistedDialingExtras) { this.state = state; this.isVideoCall = isVideoCall; this.sessionModificationState = sessionModificationState; @@ -155,6 +159,7 @@ public class PrimaryCallState { Assert.checkArgument(state == State.CALL_PENDING); } this.customLabel = customLabel; + this.assistedDialingExtras = assistedDialingExtras; } @Override -- cgit v1.2.3 From 2cec38000c225d15a7b895db28541f4be2f2df7b Mon Sep 17 00:00:00 2001 From: roldenburg Date: Wed, 11 Oct 2017 16:26:51 -0700 Subject: Fix for voice screen showing for a short time when making a video call Author: tomoyuki.nishikawa@sony.com This change was inspired by http://aosp/508735 Even though VideoProfile.isVideo(getVideoState() returns true when starting a video call, ImsVideoTech is not ready until call.getVideoCall() returns not null (see https://android.googlesource.com/platform/packages/apps/Dialer/+/master/java/com/android/incallui/videotech/ims/ImsVideoTech.java#66) During the time between VideoProfile.isVideo(getVideoState() being true but call.getVideoCall() returning null, we are incorrectly showing the phone call UI instead of the video call UI. To fix this, we need to trust the VideoProfile check in addition to the VideoTech check. We still need to check VideoTech for other video options aside from just IMS VT. Bug: 67712159 Test: manual PiperOrigin-RevId: 171892356 Change-Id: Ibe1f9de60aaa4adc971401bee0277961cfe037e4 --- java/com/android/incallui/call/DialerCall.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'java') diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java index 621ad21f8..6829203ff 100644 --- a/java/com/android/incallui/call/DialerCall.java +++ b/java/com/android/incallui/call/DialerCall.java @@ -857,7 +857,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa } public boolean isVideoCall() { - return getVideoTech().isTransmittingOrReceiving(); + return getVideoTech().isTransmittingOrReceiving() || VideoProfile.isVideo(getVideoState()); } public boolean hasReceivedVideoUpgradeRequest() { -- cgit v1.2.3 From 9982f0db5e9b74a66d22befa113073c9cfcd221e Mon Sep 17 00:00:00 2001 From: wangqi Date: Wed, 11 Oct 2017 17:46:07 -0700 Subject: Optimization for incoming call latency. There are many binder call triggered by IPC on main thread. This change will try to reduce them by caching thing that's bound to a call. It reduce total binder transaction from 1002 to 664 and saves ~11% latency of incoming call on locked screen. 1. Cache isVoiceMailNumber in DialerCall 2. Cache call capable accounts in DialerCall 3. Cache current country iso in DialerCall 4. Don't set orientation change if it's not changed. This change also add lots of trace info. It won't affect release build though since they are stripped out by proguard. Bug: 64542087 Test: manual PiperOrigin-RevId: 171901266 Change-Id: Iec48f030529aa59974212147276f6d0ae121872a --- java/com/android/dialer/location/GeoUtil.java | 6 ++- .../dialer/phonenumberutil/PhoneNumberHelper.java | 3 ++ java/com/android/incallui/CallButtonPresenter.java | 2 +- java/com/android/incallui/CallCardPresenter.java | 2 +- .../com/android/incallui/CallerInfoAsyncQuery.java | 4 ++ java/com/android/incallui/CallerInfoUtils.java | 22 +--------- java/com/android/incallui/ContactInfoCache.java | 4 ++ java/com/android/incallui/InCallActivity.java | 7 ++++ .../com/android/incallui/InCallActivityCommon.java | 5 +++ java/com/android/incallui/InCallPresenter.java | 5 ++- java/com/android/incallui/InCallServiceImpl.java | 2 + java/com/android/incallui/ProximitySensor.java | 3 ++ java/com/android/incallui/StatusBarNotifier.java | 24 ++++++++--- .../incallui/answer/impl/AnswerFragment.java | 10 +++++ .../impl/answermethod/FlingUpDownMethod.java | 9 +++++ .../answer/impl/classifier/FalsingManager.java | 7 ++++ .../AnswerProximitySensor.java | 11 +++++ java/com/android/incallui/call/CallList.java | 13 +++--- java/com/android/incallui/call/DialerCall.java | 47 +++++++++++++++++++--- .../incallui/spam/SpamCallListListener.java | 2 +- 20 files changed, 146 insertions(+), 42 deletions(-) (limited to 'java') diff --git a/java/com/android/dialer/location/GeoUtil.java b/java/com/android/dialer/location/GeoUtil.java index b39256d32..27fbf2315 100644 --- a/java/com/android/dialer/location/GeoUtil.java +++ b/java/com/android/dialer/location/GeoUtil.java @@ -17,6 +17,7 @@ package com.android.dialer.location; import android.content.Context; +import android.os.Trace; /** Static methods related to Geo. */ public class GeoUtil { @@ -24,6 +25,9 @@ public class GeoUtil { /** @return the ISO 3166-1 two letters country code of the country the user is in. */ public static String getCurrentCountryIso(Context context) { // The {@link CountryDetector} should never return null so this is safe to return as-is. - return CountryDetector.getInstance(context).getCurrentCountryIso(); + Trace.beginSection("GeoUtil.getCurrentCountryIso"); + String countryIso = CountryDetector.getInstance(context).getCurrentCountryIso(); + Trace.endSection(); + return countryIso; } } diff --git a/java/com/android/dialer/phonenumberutil/PhoneNumberHelper.java b/java/com/android/dialer/phonenumberutil/PhoneNumberHelper.java index b25e4d7fe..cc9b73081 100644 --- a/java/com/android/dialer/phonenumberutil/PhoneNumberHelper.java +++ b/java/com/android/dialer/phonenumberutil/PhoneNumberHelper.java @@ -17,6 +17,7 @@ package com.android.dialer.phonenumberutil; import android.content.Context; +import android.os.Trace; import android.provider.CallLog; import android.support.annotation.Nullable; import android.telecom.PhoneAccountHandle; @@ -113,6 +114,7 @@ public class PhoneNumberHelper { */ public static String getCurrentCountryIso( Context context, @Nullable PhoneAccountHandle phoneAccountHandle) { + Trace.beginSection("PhoneNumberHelper.getCurrentCountryIso"); // Without framework function calls, this seems to be the most accurate location service // we can rely on. String countryIso = @@ -125,6 +127,7 @@ public class PhoneNumberHelper { "No CountryDetector; falling back to countryIso based on locale: " + countryIso); } countryIso = countryIso.toUpperCase(); + Trace.endSection(); return countryIso; } diff --git a/java/com/android/incallui/CallButtonPresenter.java b/java/com/android/incallui/CallButtonPresenter.java index b3fb97fad..aa17dc4eb 100644 --- a/java/com/android/incallui/CallButtonPresenter.java +++ b/java/com/android/incallui/CallButtonPresenter.java @@ -118,7 +118,7 @@ public class CallButtonPresenter // OUTGOING. We may want to do that once we start showing "Voice mail" label on // the dialpad too.) if (oldState == InCallState.OUTGOING && mCall != null) { - if (CallerInfoUtils.isVoiceMailNumber(mContext, mCall) && getActivity() != null) { + if (mCall.isVoiceMailNumber() && getActivity() != null) { getActivity().showDialpadFragment(true /* show */, true /* animate */); } } diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java index c9fc4a72c..871243c7d 100644 --- a/java/com/android/incallui/CallCardPresenter.java +++ b/java/com/android/incallui/CallCardPresenter.java @@ -478,7 +478,7 @@ public class CallCardPresenter !TextUtils.isEmpty(mPrimary.getLastForwardedNumber()), shouldShowContactPhoto, mPrimary.getConnectTimeMillis(), - CallerInfoUtils.isVoiceMailNumber(mContext, mPrimary), + mPrimary.isVoiceMailNumber(), mPrimary.isRemotelyHeld(), isBusiness, supports2ndCallOnHold(), diff --git a/java/com/android/incallui/CallerInfoAsyncQuery.java b/java/com/android/incallui/CallerInfoAsyncQuery.java index 09752c71f..8fc9c4f14 100644 --- a/java/com/android/incallui/CallerInfoAsyncQuery.java +++ b/java/com/android/incallui/CallerInfoAsyncQuery.java @@ -29,6 +29,7 @@ import android.os.Build.VERSION_CODES; import android.os.Handler; import android.os.Looper; import android.os.Message; +import android.os.Trace; import android.provider.ContactsContract; import android.provider.ContactsContract.Directory; import android.support.annotation.MainThread; @@ -191,9 +192,11 @@ public class CallerInfoAsyncQuery { CallerInfo info, OnQueryCompleteListener listener, Object cookie) { + Trace.beginSection("CallerInfoAsyncQuery.startOtherDirectoriesQuery"); long[] directoryIds = StrictModeUtils.bypass(() -> getDirectoryIds(context)); int size = directoryIds.length; if (size == 0) { + Trace.endSection(); return false; } @@ -213,6 +216,7 @@ public class CallerInfoAsyncQuery { OnQueryCompleteListener intermediateListener = listenerFactory.newListener(directoryId); startQueryInternal(token, context, info, intermediateListener, cookie, uri); } + Trace.endSection(); return true; } diff --git a/java/com/android/incallui/CallerInfoUtils.java b/java/com/android/incallui/CallerInfoUtils.java index bf586f504..38043eda8 100644 --- a/java/com/android/incallui/CallerInfoUtils.java +++ b/java/com/android/incallui/CallerInfoUtils.java @@ -16,15 +16,10 @@ package com.android.incallui; -import android.Manifest.permission; import android.content.Context; import android.content.Loader; import android.content.Loader.OnLoadCompleteListener; -import android.content.pm.PackageManager; import android.net.Uri; -import android.support.annotation.NonNull; -import android.support.v4.content.ContextCompat; -import android.telecom.PhoneAccount; import android.telecom.TelecomManager; import android.text.TextUtils; import com.android.contacts.common.model.Contact; @@ -34,7 +29,6 @@ import com.android.dialer.phonenumbercache.CachedNumberLookupService; import com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo; import com.android.dialer.phonenumbercache.ContactInfo; import com.android.dialer.phonenumberutil.PhoneNumberHelper; -import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.util.PermissionsUtil; import com.android.incallui.call.DialerCall; import java.util.Arrays; @@ -112,7 +106,7 @@ public class CallerInfoUtils { // Because the InCallUI is immediately launched before the call is connected, occasionally // a voicemail call will be passed to InCallUI as a "voicemail:" URI without a number. // This call should still be handled as a voicemail call. - if (isVoiceMailNumber(context, call)) { + if (call.isVoiceMailNumber()) { info.markAsVoiceMail(context); } @@ -146,20 +140,6 @@ public class CallerInfoUtils { return cacheInfo; } - public static boolean isVoiceMailNumber(Context context, @NonNull DialerCall call) { - if (call.getHandle() != null - && PhoneAccount.SCHEME_VOICEMAIL.equals(call.getHandle().getScheme())) { - return true; - } - - if (ContextCompat.checkSelfPermission(context, permission.READ_PHONE_STATE) - != PackageManager.PERMISSION_GRANTED) { - return false; - } - - return TelecomUtil.isVoicemailNumber(context, call.getAccountHandle(), call.getNumber()); - } - /** * Handles certain "corner cases" for CNAP. When we receive weird phone numbers from the network * to indicate different number presentations, convert them to expected number and presentation diff --git a/java/com/android/incallui/ContactInfoCache.java b/java/com/android/incallui/ContactInfoCache.java index 2a9394526..2fb18b8d7 100644 --- a/java/com/android/incallui/ContactInfoCache.java +++ b/java/com/android/incallui/ContactInfoCache.java @@ -807,10 +807,12 @@ public class ContactInfoCache implements OnImageLoadCompleteListener { @Override public void onQueryComplete(int token, Object cookie, CallerInfo callerInfo) { + Trace.beginSection("ContactInfoCache.FindInfoCallback.onQueryComplete"); Assert.isMainThread(); DialerCallCookieWrapper cw = (DialerCallCookieWrapper) cookie; String callId = cw.callId; if (!isWaitingForThisQuery(cw.callId, mQueryToken.mQueryId)) { + Trace.endSection(); return; } ContactCacheEntry cacheEntry = mInfoMap.get(callId); @@ -818,6 +820,7 @@ public class ContactInfoCache implements OnImageLoadCompleteListener { if (cacheEntry == null) { Log.w(TAG, "Contact lookup done, but cache entry is not found."); clearCallbacks(callId); + Trace.endSection(); return; } // Before issuing a request for more data from other services, we only check that the @@ -842,6 +845,7 @@ public class ContactInfoCache implements OnImageLoadCompleteListener { } clearCallbacks(callId); } + Trace.endSection(); } } diff --git a/java/com/android/incallui/InCallActivity.java b/java/com/android/incallui/InCallActivity.java index 2ba4d98a1..2e3d721df 100644 --- a/java/com/android/incallui/InCallActivity.java +++ b/java/com/android/incallui/InCallActivity.java @@ -95,6 +95,7 @@ public class InCallActivity extends TransactionSafeFragmentActivity private boolean touchDownWhenPseudoScreenOff; private boolean isInShowMainInCallFragment; private boolean needDismissPendingDialogs; + private boolean allowOrientationChange; public InCallActivity() { common = new InCallActivityCommon(this); @@ -161,7 +162,9 @@ public class InCallActivity extends TransactionSafeFragmentActivity protected void onStart() { Trace.beginSection("InCallActivity.onStart"); LogUtil.i("InCallActivity.onStart", ""); + Trace.beginSection("call super"); super.onStart(); + Trace.endSection(); isVisible = true; showMainInCallFragment(); common.onStart(); @@ -514,6 +517,10 @@ public class InCallActivity extends TransactionSafeFragmentActivity } public void setAllowOrientationChange(boolean allowOrientationChange) { + if (this.allowOrientationChange == allowOrientationChange) { + return; + } + this.allowOrientationChange = allowOrientationChange; if (!allowOrientationChange) { setRequestedOrientation(InCallOrientationEventListener.ACTIVITY_PREFERENCE_DISALLOW_ROTATION); } else { diff --git a/java/com/android/incallui/InCallActivityCommon.java b/java/com/android/incallui/InCallActivityCommon.java index 9ccda3251..0a7c2689b 100644 --- a/java/com/android/incallui/InCallActivityCommon.java +++ b/java/com/android/incallui/InCallActivityCommon.java @@ -29,6 +29,7 @@ import android.content.Intent; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Bundle; +import android.os.Trace; import android.support.annotation.IntDef; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -257,6 +258,7 @@ public class InCallActivityCommon { } public void onStart() { + Trace.beginSection("InCallActivityCommon.onStart"); // setting activity should be last thing in setup process InCallPresenter.getInstance().setActivity(inCallActivity); enableInCallOrientationEventListener( @@ -267,9 +269,11 @@ public class InCallActivityCommon { if (!isRecreating) { InCallPresenter.getInstance().onUiShowing(true); } + Trace.endSection(); } public void onResume() { + Trace.beginSection("InCallActivityCommon.onResume"); if (InCallPresenter.getInstance().isReadyForTearDown()) { LogUtil.i( "InCallActivityCommon.onResume", @@ -309,6 +313,7 @@ public class InCallActivityCommon { CallList.getInstance() .onInCallUiShown( inCallActivity.getIntent().getBooleanExtra(INTENT_EXTRA_FOR_FULL_SCREEN, false)); + Trace.endSection(); } // onPause is guaranteed to be called when the InCallActivity goes diff --git a/java/com/android/incallui/InCallPresenter.java b/java/com/android/incallui/InCallPresenter.java index a0069a629..70fe88be8 100644 --- a/java/com/android/incallui/InCallPresenter.java +++ b/java/com/android/incallui/InCallPresenter.java @@ -444,6 +444,7 @@ public class InCallPresenter implements CallList.Listener { * activity is provided, it means that the activity was finished and we should attempt to cleanup. */ private void updateActivity(InCallActivity inCallActivity) { + Trace.beginSection("InCallPresenter.updateActivity"); boolean updateListeners = false; boolean doAttemptCleanup = false; @@ -475,6 +476,7 @@ public class InCallPresenter implements CallList.Listener { if (mInCallState == InCallState.NO_CALLS) { LogUtil.i("InCallPresenter.updateActivity", "UI Initialized, but no calls left. Shut down"); attemptFinishActivity(); + Trace.endSection(); return; } } else { @@ -510,6 +512,7 @@ public class InCallPresenter implements CallList.Listener { if (doAttemptCleanup) { attemptCleanup(); } + Trace.endSection(); } public void setManageConferenceActivity( @@ -842,7 +845,7 @@ public class InCallPresenter implements CallList.Listener { if (!mCallList.hasLiveCall() && !call.getLogState().isIncoming && !isSecretCode(call.getNumber()) - && !CallerInfoUtils.isVoiceMailNumber(mContext, call)) { + && !call.isVoiceMailNumber()) { PostCall.onCallDisconnected(mContext, call.getNumber(), call.getConnectTimeMillis()); } } diff --git a/java/com/android/incallui/InCallServiceImpl.java b/java/com/android/incallui/InCallServiceImpl.java index a08ee0aa5..8570c58c4 100644 --- a/java/com/android/incallui/InCallServiceImpl.java +++ b/java/com/android/incallui/InCallServiceImpl.java @@ -41,7 +41,9 @@ public class InCallServiceImpl extends InCallService { @Override public void onCallAudioStateChanged(CallAudioState audioState) { + Trace.beginSection("InCallServiceImpl.onCallAudioStateChanged"); AudioModeProvider.getInstance().onAudioStateChanged(audioState); + Trace.endSection(); } @Override diff --git a/java/com/android/incallui/ProximitySensor.java b/java/com/android/incallui/ProximitySensor.java index db538abdc..339a2e941 100644 --- a/java/com/android/incallui/ProximitySensor.java +++ b/java/com/android/incallui/ProximitySensor.java @@ -20,6 +20,7 @@ import android.content.Context; import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager.DisplayListener; import android.os.PowerManager; +import android.os.Trace; import android.support.annotation.NonNull; import android.telecom.CallAudioState; import android.view.Display; @@ -206,6 +207,7 @@ public class ProximitySensor * request for, or is in a video call; or the phone is horizontal while in a call. */ private synchronized void updateProximitySensorMode() { + Trace.beginSection("ProximitySensor.updateProximitySensorMode"); final int audioRoute = mAudioModeProvider.getAudioState().getRoute(); boolean screenOnImmediately = @@ -249,6 +251,7 @@ public class ProximitySensor // behavior in either case. turnOffProximitySensor(screenOnImmediately); } + Trace.endSection(); } /** diff --git a/java/com/android/incallui/StatusBarNotifier.java b/java/com/android/incallui/StatusBarNotifier.java index 7146c7235..e5908f12e 100644 --- a/java/com/android/incallui/StatusBarNotifier.java +++ b/java/com/android/incallui/StatusBarNotifier.java @@ -541,6 +541,18 @@ public class StatusBarNotifier || !Objects.equals(mRingtone, ringtone) || !Objects.equals(savedCallAudioState, callAudioState); + LogUtil.d( + "StatusBarNotifier.checkForChangeAndSaveData", + "data changed: icon: %b, content: %b, state: %b, largeIcon: %b, title: %b, ringtone: %b, " + + "audioState: %b, type: %b", + (mSavedIcon != icon), + !Objects.equals(mSavedContent, content), + (mCallState != state), + largeIconChanged, + contentTitleChanged, + !Objects.equals(mRingtone, ringtone), + !Objects.equals(savedCallAudioState, callAudioState), + mCurrentNotification != notificationType); // If we aren't showing a notification right now or the notification type is changing, // definitely do an update. if (mCurrentNotification != notificationType) { @@ -614,7 +626,7 @@ public class StatusBarNotifier @ContactType int contactType = LetterTileDrawable.getContactTypeFromPrimitives( - CallerInfoUtils.isVoiceMailNumber(context, call), + call.isVoiceMailNumber(), call.isSpam(), contactInfo.isBusiness, call.getNumberPresentation(), @@ -709,7 +721,7 @@ public class StatusBarNotifier resId = getECIncomingCallText(call.getEnrichedCallSession()); } else if (call.hasProperty(Details.PROPERTY_WIFI)) { resId = R.string.notification_incoming_call_wifi_template; - } else if (call.getAccountHandle() != null && hasMultiplePhoneAccounts()) { + } else if (call.getAccountHandle() != null && hasMultiplePhoneAccounts(call)) { return getMultiSimIncomingText(call); } else if (call.isVideoCall()) { resId = R.string.notification_incoming_video_call; @@ -1043,9 +1055,11 @@ public class StatusBarNotifier mStatusBarCallListener = listener; } - @SuppressWarnings("MissingPermission") - private boolean hasMultiplePhoneAccounts() { - return mContext.getSystemService(TelecomManager.class).getCallCapablePhoneAccounts().size() > 1; + private boolean hasMultiplePhoneAccounts(DialerCall call) { + if (call.getCallCapableAccounts() == null) { + return false; + } + return call.getCallCapableAccounts().size() > 1; } @Override diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java index 3476557ba..f0b0c0fde 100644 --- a/java/com/android/incallui/answer/impl/AnswerFragment.java +++ b/java/com/android/incallui/answer/impl/AnswerFragment.java @@ -744,6 +744,7 @@ public class AnswerFragment extends Fragment @Override public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) { + Trace.beginSection("AnswerFragment.onViewCreated"); super.onViewCreated(view, savedInstanceState); createInCallScreenDelegate(); updateUI(); @@ -751,18 +752,22 @@ public class AnswerFragment extends Fragment if (savedInstanceState == null || !savedInstanceState.getBoolean(STATE_HAS_ANIMATED_ENTRY)) { ViewUtil.doOnGlobalLayout(view, this::animateEntry); } + Trace.endSection(); } @Override public void onResume() { + Trace.beginSection("AnswerFragment.onResume"); super.onResume(); LogUtil.i("AnswerFragment.onResume", null); restoreSwipeHintTexts(); inCallScreenDelegate.onInCallScreenResumed(); + Trace.endSection(); } @Override public void onStart() { + Trace.beginSection("AnswerFragment.onStart"); super.onStart(); LogUtil.i("AnswerFragment.onStart", null); @@ -770,10 +775,12 @@ public class AnswerFragment extends Fragment if (answerVideoCallScreen != null) { answerVideoCallScreen.onVideoScreenStart(); } + Trace.endSection(); } @Override public void onStop() { + Trace.beginSection("AnswerFragment.onStop"); super.onStop(); LogUtil.i("AnswerFragment.onStop", null); @@ -781,13 +788,16 @@ public class AnswerFragment extends Fragment if (answerVideoCallScreen != null) { answerVideoCallScreen.onVideoScreenStop(); } + Trace.endSection(); } @Override public void onPause() { + Trace.beginSection("AnswerFragment.onPause"); super.onPause(); LogUtil.i("AnswerFragment.onPause", null); inCallScreenDelegate.onInCallScreenPaused(); + Trace.endSection(); } @Override diff --git a/java/com/android/incallui/answer/impl/answermethod/FlingUpDownMethod.java b/java/com/android/incallui/answer/impl/answermethod/FlingUpDownMethod.java index 5c1ee47e6..ea5956c8c 100644 --- a/java/com/android/incallui/answer/impl/answermethod/FlingUpDownMethod.java +++ b/java/com/android/incallui/answer/impl/answermethod/FlingUpDownMethod.java @@ -28,6 +28,7 @@ import android.content.res.ColorStateList; import android.graphics.PorterDuff.Mode; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.os.Trace; import android.support.annotation.ColorInt; import android.support.annotation.FloatRange; import android.support.annotation.IntDef; @@ -157,6 +158,7 @@ public class FlingUpDownMethod extends AnswerMethod implements OnProgressChanged @Override public void onStart() { + Trace.beginSection("FlingUpDownMethod.onStart"); super.onStart(); falsingManager.onScreenOn(); if (getView() != null) { @@ -170,22 +172,26 @@ public class FlingUpDownMethod extends AnswerMethod implements OnProgressChanged startSwipeToAnswerEntryAnimation(); } } + Trace.endSection(); } @Override public void onStop() { + Trace.beginSection("FlingUpDownMethod.onStop"); endAnimation(); falsingManager.onScreenOff(); if (getActivity().isFinishing()) { setAnimationState(AnimationState.COMPLETED); } super.onStop(); + Trace.endSection(); } @Nullable @Override public View onCreateView( LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) { + Trace.beginSection("FlingUpDownMethod.onCreateView"); View view = layoutInflater.inflate(R.layout.swipe_up_down_method, viewGroup, false); contactPuckContainer = view.findViewById(R.id.incoming_call_puck_container); @@ -242,6 +248,7 @@ public class FlingUpDownMethod extends AnswerMethod implements OnProgressChanged (ViewGroup) view.findViewById(R.id.hint_container), contactPuckContainer, swipeToAnswerText); + Trace.endSection(); return view; } @@ -400,6 +407,7 @@ public class FlingUpDownMethod extends AnswerMethod implements OnProgressChanged } private void updateSwipeTextAndPuckForTouch() { + Trace.beginSection("FlingUpDownMethod.updateSwipeTextAndPuckForTouch"); // Clamp progress value between -1 and 1. final float clampedProgress = MathUtil.clamp(swipeProgress, -1 /* min */, 1 /* max */); final float positiveAdjustedProgress = Math.abs(clampedProgress); @@ -473,6 +481,7 @@ public class FlingUpDownMethod extends AnswerMethod implements OnProgressChanged } getParent().onAnswerProgressUpdate(clampedProgress); + Trace.endSection(); } private void startSwipeToAnswerSwipeAnimation() { diff --git a/java/com/android/incallui/answer/impl/classifier/FalsingManager.java b/java/com/android/incallui/answer/impl/classifier/FalsingManager.java index fdcc0a3f9..9cdd888d1 100644 --- a/java/com/android/incallui/answer/impl/classifier/FalsingManager.java +++ b/java/com/android/incallui/answer/impl/classifier/FalsingManager.java @@ -22,6 +22,7 @@ import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.PowerManager; +import android.os.Trace; import android.view.MotionEvent; import android.view.accessibility.AccessibilityManager; @@ -130,11 +131,17 @@ public class FalsingManager implements SensorEventListener { } private void registerSensors(int[] sensors) { + Trace.beginSection("FalsingManager.registerSensors"); for (int sensorType : sensors) { + Trace.beginSection("get sensor " + sensorType); Sensor s = mSensorManager.getDefaultSensor(sensorType); + Trace.endSection(); if (s != null) { + Trace.beginSection("register"); mSensorManager.registerListener(this, s, SensorManager.SENSOR_DELAY_GAME); + Trace.endSection(); } } + Trace.endSection(); } } diff --git a/java/com/android/incallui/answerproximitysensor/AnswerProximitySensor.java b/java/com/android/incallui/answerproximitysensor/AnswerProximitySensor.java index 16fad8b17..113144b7f 100644 --- a/java/com/android/incallui/answerproximitysensor/AnswerProximitySensor.java +++ b/java/com/android/incallui/answerproximitysensor/AnswerProximitySensor.java @@ -19,6 +19,7 @@ package com.android.incallui.answerproximitysensor; import android.content.Context; import android.hardware.display.DisplayManager; import android.os.PowerManager; +import android.os.Trace; import android.view.Display; import com.android.dialer.common.LogUtil; import com.android.dialer.configprovider.ConfigProviderBindings; @@ -43,16 +44,19 @@ public class AnswerProximitySensor private final AnswerProximityWakeLock answerProximityWakeLock; public static boolean shouldUse(Context context, DialerCall call) { + Trace.beginSection("AnswerProximitySensor.shouldUse"); // Don't use the AnswerProximitySensor for call waiting and other states. Those states are // handled by the general ProximitySensor code. if (call.getState() != State.INCOMING) { LogUtil.i("AnswerProximitySensor.shouldUse", "call state is not incoming"); + Trace.endSection(); return false; } if (!ConfigProviderBindings.get(context) .getBoolean(CONFIG_ANSWER_PROXIMITY_SENSOR_ENABLED, true)) { LogUtil.i("AnswerProximitySensor.shouldUse", "disabled by config"); + Trace.endSection(); return false; } @@ -60,19 +64,23 @@ public class AnswerProximitySensor .getSystemService(PowerManager.class) .isWakeLockLevelSupported(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK)) { LogUtil.i("AnswerProximitySensor.shouldUse", "wake lock level not supported"); + Trace.endSection(); return false; } if (isDefaultDisplayOn(context)) { LogUtil.i("AnswerProximitySensor.shouldUse", "display is already on"); + Trace.endSection(); return false; } + Trace.endSection(); return true; } public AnswerProximitySensor( Context context, DialerCall call, PseudoScreenState pseudoScreenState) { + Trace.beginSection("AnswerProximitySensor Constructor"); this.call = call; LogUtil.i("AnswerProximitySensor.constructor", "acquiring lock"); @@ -90,11 +98,14 @@ public class AnswerProximitySensor answerProximityWakeLock.acquire(); call.addListener(this); + Trace.endSection(); } private void cleanup() { + Trace.beginSection("AnswerProximitySensor.Cleanup"); call.removeListener(this); releaseProximityWakeLock(); + Trace.endSection(); } private void releaseProximityWakeLock() { diff --git a/java/com/android/incallui/call/CallList.java b/java/com/android/incallui/call/CallList.java index 8d6620628..7c35e4b92 100644 --- a/java/com/android/incallui/call/CallList.java +++ b/java/com/android/incallui/call/CallList.java @@ -34,7 +34,6 @@ import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.enrichedcall.EnrichedCallComponent; import com.android.dialer.enrichedcall.EnrichedCallManager; -import com.android.dialer.location.GeoUtil; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.shortcuts.ShortcutUsageReporter; @@ -139,7 +138,7 @@ public class CallList implements DialerCallDelegate { Spam.get(context) .checkSpamStatus( number, - null, + call.getCountryIso(), new SpamBindings.Listener() { @Override public void onComplete(boolean isSpam) { @@ -196,7 +195,7 @@ public class CallList implements DialerCallDelegate { } }, call.getNumber(), - GeoUtil.getCurrentCountryIso(context)); + call.getCountryIso()); Trace.endSection(); if (call.getState() == DialerCall.State.INCOMING @@ -257,7 +256,7 @@ public class CallList implements DialerCallDelegate { Spam.get(context) .checkUserMarkedNonSpamStatus( number, - null, + call.getCountryIso(), new SpamBindings.Listener() { @Override public void onComplete(boolean isInUserWhiteList) { @@ -268,7 +267,7 @@ public class CallList implements DialerCallDelegate { Spam.get(context) .checkGlobalSpamListStatus( number, - null, + call.getCountryIso(), new SpamBindings.Listener() { @Override public void onComplete(boolean isInGlobalSpamList) { @@ -279,7 +278,7 @@ public class CallList implements DialerCallDelegate { Spam.get(context) .checkUserMarkedSpamStatus( number, - null, + call.getCountryIso(), new SpamBindings.Listener() { @Override public void onComplete(boolean isInUserSpamList) { @@ -626,9 +625,11 @@ public class CallList implements DialerCallDelegate { * listeners to call back to determine what changed. */ private void notifyGenericListeners() { + Trace.beginSection("CallList.notifyGenericListeners"); for (Listener listener : mListeners) { listener.onCallListChange(this); } + Trace.endSection(); } private void notifyListenersOfDisconnect(DialerCall call) { diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java index 6829203ff..47a4a70f5 100644 --- a/java/com/android/incallui/call/DialerCall.java +++ b/java/com/android/incallui/call/DialerCall.java @@ -16,6 +16,7 @@ package com.android.incallui.call; +import android.Manifest.permission; import android.content.Context; import android.hardware.camera2.CameraCharacteristics; import android.net.Uri; @@ -58,11 +59,14 @@ import com.android.dialer.enrichedcall.EnrichedCallManager.Filter; import com.android.dialer.enrichedcall.EnrichedCallManager.StateChangedListener; import com.android.dialer.enrichedcall.Session; import com.android.dialer.lightbringer.LightbringerComponent; +import com.android.dialer.location.GeoUtil; import com.android.dialer.logging.ContactLookupResult; import com.android.dialer.logging.ContactLookupResult.Type; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; +import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.theme.R; +import com.android.dialer.util.PermissionsUtil; import com.android.incallui.audiomode.AudioModeProvider; import com.android.incallui.latencyreport.LatencyReport; import com.android.incallui.util.TelecomCallUtil; @@ -158,6 +162,9 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa private com.android.dialer.logging.VideoTech.Type selectedAvailableVideoTechType = com.android.dialer.logging.VideoTech.Type.NONE; + private boolean isVoicemailNumber; + private List callCapableAccounts; + private String countryIso; public static String getNumberFromHandle(Uri handle) { return handle == null ? "" : handle.getSchemeSpecificPart(); @@ -450,6 +457,30 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa return mLogState.conferencedCalls != 0; } + public boolean isVoiceMailNumber() { + return isVoicemailNumber; + } + + public List getCallCapableAccounts() { + return callCapableAccounts; + } + + public String getCountryIso() { + return countryIso; + } + + private void updateIsVoiceMailNumber() { + if (getHandle() != null && PhoneAccount.SCHEME_VOICEMAIL.equals(getHandle().getScheme())) { + isVoicemailNumber = true; + } + + if (!PermissionsUtil.hasPermission(mContext, permission.READ_PHONE_STATE)) { + isVoicemailNumber = false; + } + + isVoicemailNumber = TelecomUtil.isVoicemailNumber(mContext, getAccountHandle(), getNumber()); + } + private void update() { Trace.beginSection("DialerCall.update"); int oldState = getState(); @@ -475,6 +506,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa Trace.endSection(); } + @SuppressWarnings("MissingPermission") private void updateFromTelecomCall() { Trace.beginSection("DialerCall.updateFromTelecomCall"); LogUtil.v("DialerCall.updateFromTelecomCall", mTelecomCall.toString()); @@ -510,6 +542,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa updateEmergencyCallState(); } + TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class); // If the phone account handle of the call is set, cache capability bit indicating whether // the phone account supports call subjects. PhoneAccountHandle newPhoneAccountHandle = mTelecomCall.getDetails().getAccountHandle(); @@ -517,14 +550,18 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa mPhoneAccountHandle = newPhoneAccountHandle; if (mPhoneAccountHandle != null) { - PhoneAccount phoneAccount = - mContext.getSystemService(TelecomManager.class).getPhoneAccount(mPhoneAccountHandle); + PhoneAccount phoneAccount = telecomManager.getPhoneAccount(mPhoneAccountHandle); if (phoneAccount != null) { mIsCallSubjectSupported = phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_CALL_SUBJECT); } } } + if (PermissionsUtil.hasPermission(mContext, permission.READ_PHONE_STATE)) { + updateIsVoiceMailNumber(); + callCapableAccounts = telecomManager.getCallCapablePhoneAccounts(); + countryIso = GeoUtil.getCurrentCountryIso(mContext); + } Trace.endSection(); } @@ -1148,9 +1185,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa if (callProviderLabel == null) { PhoneAccount account = getPhoneAccount(); if (account != null && !TextUtils.isEmpty(account.getLabel())) { - List accounts = - mContext.getSystemService(TelecomManager.class).getCallCapablePhoneAccounts(); - if (accounts != null && accounts.size() > 1) { + if (callCapableAccounts != null && callCapableAccounts.size() > 1) { callProviderLabel = account.getLabel().toString(); } } @@ -1220,9 +1255,11 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa @Override public void onSessionModificationStateChanged() { + Trace.beginSection("DialerCall.onSessionModificationStateChanged"); for (DialerCallListener listener : mListeners) { listener.onDialerCallSessionModificationStateChange(); } + Trace.endSection(); } @Override diff --git a/java/com/android/incallui/spam/SpamCallListListener.java b/java/com/android/incallui/spam/SpamCallListListener.java index 6b2bdcef6..cf545c071 100644 --- a/java/com/android/incallui/spam/SpamCallListListener.java +++ b/java/com/android/incallui/spam/SpamCallListListener.java @@ -150,7 +150,7 @@ public class SpamCallListListener implements CallList.Listener { } NumberInCallHistoryWorker historyTask = - new NumberInCallHistoryWorker(context, number, GeoUtil.getCurrentCountryIso(context)); + new NumberInCallHistoryWorker(context, number, call.getCountryIso()); dialerExecutorFactory .createNonUiTaskBuilder(historyTask) .onSuccess((result) -> call.setCallHistoryStatus(result)) -- cgit v1.2.3 From ac7ab398262a92c33735fe0d93b029bf8aba548f Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Thu, 12 Oct 2017 00:50:28 -0700 Subject: Updated animation to enter and exit search ui. video: https://drive.google.com/open?id=0B2Hce9qilHmvZkREWm1BMURJNjQ Bug: 67635181 Test: n/a PiperOrigin-RevId: 171928416 Change-Id: Id0ef91647ec15ea970a691b1ae896010a12e6bb8 --- java/com/android/dialer/app/res/layout/search_edittext.xml | 1 + java/com/android/dialer/app/widget/SearchEditTextLayout.java | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'java') diff --git a/java/com/android/dialer/app/res/layout/search_edittext.xml b/java/com/android/dialer/app/res/layout/search_edittext.xml index 63786dfb0..5fc492d29 100644 --- a/java/com/android/dialer/app/res/layout/search_edittext.xml +++ b/java/com/android/dialer/app/res/layout/search_edittext.xml @@ -39,6 +39,7 @@ android:layout_width="@dimen/search_box_icon_size" android:layout_height="@dimen/search_box_icon_size" android:layout_marginStart="8dp" + android:layout_centerVertical="true" android:importantForAccessibility="no" android:scaleType="center" android:src="@drawable/quantum_ic_search_vd_theme_24" diff --git a/java/com/android/dialer/app/widget/SearchEditTextLayout.java b/java/com/android/dialer/app/widget/SearchEditTextLayout.java index 95bd12aa1..9da0e245f 100644 --- a/java/com/android/dialer/app/widget/SearchEditTextLayout.java +++ b/java/com/android/dialer/app/widget/SearchEditTextLayout.java @@ -274,7 +274,6 @@ public class SearchEditTextLayout extends FrameLayout { mCollapsedSearchBox.setVisibility(collapsedViewVisibility); mVoiceSearchButtonView.setVisibility(collapsedViewVisibility); mOverflowButtonView.setVisibility(collapsedViewVisibility); - mBackButtonView.setVisibility(expandedViewVisibility); // TODO: Prevents keyboard from jumping up in landscape mode after exiting the // SearchFragment when the query string is empty. More elegant fix? //mExpandedSearchBox.setVisibility(expandedViewVisibility); -- cgit v1.2.3 From a8371d31fb26cdc689ea03cfc4843d69702dc9dc Mon Sep 17 00:00:00 2001 From: twyen Date: Thu, 12 Oct 2017 13:58:08 -0700 Subject: Use TelephonyManagerCompat for IS_REFRESH Bug: 66633426 Test: LegacyVoicemailNotificationReceiverTest PiperOrigin-RevId: 172007744 Change-Id: Ic67566c22659b51d605c92d2673f9baddaee531f --- .../app/voicemail/LegacyVoicemailNotificationReceiver.java | 12 ++---------- .../dialer/compat/telephony/TelephonyManagerCompat.java | 3 +++ 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'java') diff --git a/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java b/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java index efa34a071..0a6f2c156 100644 --- a/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java +++ b/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java @@ -22,7 +22,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Build; -import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import android.support.annotation.VisibleForTesting; import android.support.v4.os.BuildCompat; @@ -33,6 +32,7 @@ import com.android.dialer.app.calllog.LegacyVoicemailNotifier; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.PerAccountSharedPreferences; +import com.android.dialer.compat.telephony.TelephonyManagerCompat; import com.android.dialer.util.DialerUtils; import com.android.voicemail.VoicemailClient; import com.android.voicemail.VoicemailComponent; @@ -47,9 +47,6 @@ public class LegacyVoicemailNotificationReceiver extends BroadcastReceiver { @VisibleForTesting static final String LEGACY_VOICEMAIL_DISMISSED = "legacy_voicemail_dismissed"; - /** Hidden version of {@link TelephonyManager#EXTRA_IS_REFRESH} in OC */ - @VisibleForTesting static final String EXTRA_IS_REFRESH_LEGACY = "is_refresh"; - @Override public void onReceive(Context context, Intent intent) { @@ -76,12 +73,7 @@ public class LegacyVoicemailNotificationReceiver extends BroadcastReceiver { Assert.isNotNull(intent.getParcelableExtra(TelephonyManager.EXTRA_PHONE_ACCOUNT_HANDLE)); int count = intent.getIntExtra(TelephonyManager.EXTRA_NOTIFICATION_COUNT, -1); - boolean isRefresh = - intent.getBooleanExtra( - VERSION.SDK_INT >= VERSION_CODES.O_MR1 - ? TelephonyManager.EXTRA_IS_REFRESH - : EXTRA_IS_REFRESH_LEGACY, - false); + boolean isRefresh = intent.getBooleanExtra(TelephonyManagerCompat.EXTRA_IS_REFRESH, false); LogUtil.i("LegacyVoicemailNotificationReceiver.onReceive", "isRefresh: " + isRefresh); PerAccountSharedPreferences preferences = getSharedPreferences(context, phoneAccountHandle); if (isRefresh) { diff --git a/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java b/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java index 61c44b9f4..fbc789900 100644 --- a/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java +++ b/java/com/android/dialer/compat/telephony/TelephonyManagerCompat.java @@ -73,6 +73,9 @@ public class TelephonyManagerCompat { public static final String ASSISTED_DIALING_EXTRAS = "android.telecom.extra.ASSISTED_DIALING_EXTRAS"; + public static final String EXTRA_IS_REFRESH = + BuildCompat.isAtLeastOMR1() ? "android.telephony.extra.IS_REFRESH" : "is_refresh"; + /** * Returns the number of phones available. Returns 1 for Single standby mode (Single SIM * functionality) Returns 2 for Dual standby mode.(Dual SIM functionality) -- cgit v1.2.3 From 392f8cd64936a626cc035ac9bb0302094d8dd957 Mon Sep 17 00:00:00 2001 From: twyen Date: Thu, 12 Oct 2017 13:58:30 -0700 Subject: Handle invalid PhoneAccountHandle component name in MissedCallNotifier Bug: 66946794 Test: MissedCallNotifierTest PiperOrigin-RevId: 172007792 Change-Id: I14a2c0b6a5ad5a5b8acd449214c91bff68282b6a --- java/com/android/dialer/app/calllog/MissedCallNotifier.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'java') diff --git a/java/com/android/dialer/app/calllog/MissedCallNotifier.java b/java/com/android/dialer/app/calllog/MissedCallNotifier.java index 8a986dc41..f50751e2b 100644 --- a/java/com/android/dialer/app/calllog/MissedCallNotifier.java +++ b/java/com/android/dialer/app/calllog/MissedCallNotifier.java @@ -260,9 +260,11 @@ public class MissedCallNotifier implements Worker, Void> { if (call.accountComponentName == null || call.accountId == null) { continue; } - PhoneAccountHandle phoneAccountHandle = - new PhoneAccountHandle( - ComponentName.unflattenFromString(call.accountComponentName), call.accountId); + ComponentName componentName = ComponentName.unflattenFromString(call.accountComponentName); + if (componentName == null) { + continue; + } + PhoneAccountHandle phoneAccountHandle = new PhoneAccountHandle(componentName, call.accountId); PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle); if (phoneAccount == null) { continue; -- cgit v1.2.3