From 8fbecce1ed1cfab8061acb7b8d22fd0feeaba452 Mon Sep 17 00:00:00 2001 From: linyuh Date: Mon, 18 Dec 2017 13:53:09 -0800 Subject: Allow orientation change when receiving video upgrade request in the in-call UI. Bug: 67764843 Test: Manual PiperOrigin-RevId: 179463451 Change-Id: Iee1999c673a0b6f67d8e538745c23e75865a5262 --- java/com/android/incallui/InCallActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/com/android/incallui/InCallActivity.java b/java/com/android/incallui/InCallActivity.java index c4c365afa..f09f0d944 100644 --- a/java/com/android/incallui/InCallActivity.java +++ b/java/com/android/incallui/InCallActivity.java @@ -1295,7 +1295,7 @@ public class InCallActivity extends TransactionSafeFragmentActivity return new ShouldShowUiResult(true, call); } - if (call.hasSentVideoUpgradeRequest()) { + if (call.hasSentVideoUpgradeRequest() || call.hasReceivedVideoUpgradeRequest()) { LogUtil.i("InCallActivity.getShouldShowVideoUi", "upgrading to video"); return new ShouldShowUiResult(true, call); } -- cgit v1.2.3 From bfba4389c53b4b887b93db8ef0313d1609fec033 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Mon, 18 Dec 2017 14:29:54 -0800 Subject: Added tests for SmartDialNameMatcher. Bug: 30215380 Test: this cl PiperOrigin-RevId: 179468203 Change-Id: I2996a15135cde48094cb8f430b2fd6d7eeee6ec7 --- .../dialer/smartdial/SmartDialNameMatcher.java | 76 +++++++++------------- 1 file changed, 30 insertions(+), 46 deletions(-) diff --git a/java/com/android/dialer/smartdial/SmartDialNameMatcher.java b/java/com/android/dialer/smartdial/SmartDialNameMatcher.java index a1580a0ce..a9256ec3f 100644 --- a/java/com/android/dialer/smartdial/SmartDialNameMatcher.java +++ b/java/com/android/dialer/smartdial/SmartDialNameMatcher.java @@ -17,7 +17,6 @@ package com.android.dialer.smartdial; import android.support.annotation.Nullable; -import android.support.annotation.VisibleForTesting; import android.text.TextUtils; import com.android.dialer.smartdial.SmartDialPrefix.PhoneNumberTokens; import java.util.ArrayList; @@ -42,17 +41,10 @@ public class SmartDialNameMatcher { private final ArrayList mMatchPositions = new ArrayList<>(); private final SmartDialMap mMap; private String mQuery; - private String mNameMatchMask = ""; - private String mPhoneNumberMatchMask = ""; // Controls whether to treat an empty query as a match (with anything). private boolean mShouldMatchEmptyQuery = false; - @VisibleForTesting - public SmartDialNameMatcher(String query) { - this(query, LATIN_SMART_DIAL_MAP); - } - public SmartDialNameMatcher(String query, SmartDialMap map) { mQuery = query; mMap = map; @@ -116,38 +108,31 @@ public class SmartDialNameMatcher { * * @param phoneNumber - Raw phone number * @param query - Normalized query (only contains numbers from 0-9) - * @param useNanp - Overwriting nanp setting boolean, used for testing. * @return {@literal null} if the number and the query don't match, a valid SmartDialMatchPosition * with the matching positions otherwise */ - @VisibleForTesting @Nullable - public SmartDialMatchPosition matchesNumber(String phoneNumber, String query, boolean useNanp) { + public SmartDialMatchPosition matchesNumber(String phoneNumber, String query) { if (TextUtils.isEmpty(phoneNumber)) { return mShouldMatchEmptyQuery ? new SmartDialMatchPosition(0, 0) : null; } StringBuilder builder = new StringBuilder(); constructEmptyMask(builder, phoneNumber.length()); - mPhoneNumberMatchMask = builder.toString(); // Try matching the number as is SmartDialMatchPosition matchPos = matchesNumberWithOffset(phoneNumber, query, 0); if (matchPos == null) { - final PhoneNumberTokens phoneNumberTokens = SmartDialPrefix.parsePhoneNumber(phoneNumber); + PhoneNumberTokens phoneNumberTokens = SmartDialPrefix.parsePhoneNumber(phoneNumber); - if (phoneNumberTokens == null) { - return matchPos; - } if (phoneNumberTokens.countryCodeOffset != 0) { matchPos = matchesNumberWithOffset(phoneNumber, query, phoneNumberTokens.countryCodeOffset); } - if (matchPos == null && phoneNumberTokens.nanpCodeOffset != 0 && useNanp) { + if (matchPos == null && phoneNumberTokens.nanpCodeOffset != 0) { matchPos = matchesNumberWithOffset(phoneNumber, query, phoneNumberTokens.nanpCodeOffset); } } if (matchPos != null) { replaceBitInMask(builder, matchPos); - mPhoneNumberMatchMask = builder.toString(); } return matchPos; } @@ -161,20 +146,7 @@ public class SmartDialNameMatcher { * with the matching positions otherwise */ public SmartDialMatchPosition matchesNumber(String phoneNumber) { - return matchesNumber(phoneNumber, mQuery, true); - } - - /** - * Matches a phone number against a query, taking care of formatting characters and also taking - * into account country code prefixes and special NANP number treatment. - * - * @param phoneNumber - Raw phone number - * @param query - Normalized query (only contains numbers from 0-9) - * @return {@literal null} if the number and the query don't match, a valid SmartDialMatchPosition - * with the matching positions otherwise - */ - public SmartDialMatchPosition matchesNumber(String phoneNumber, String query) { - return matchesNumber(phoneNumber, query, true); + return matchesNumber(phoneNumber, mQuery); } /** @@ -252,12 +224,10 @@ public class SmartDialNameMatcher { * contained in query. If the function returns true, matchList will contain an ArrayList of * match positions (multiple matches correspond to initial matches). */ - @VisibleForTesting - boolean matchesCombination( + private boolean matchesCombination( String displayName, String query, ArrayList matchList) { StringBuilder builder = new StringBuilder(); constructEmptyMask(builder, displayName.length()); - mNameMatchMask = builder.toString(); final int nameLength = displayName.length(); final int queryLength = query.length(); @@ -338,7 +308,6 @@ public class SmartDialNameMatcher { for (SmartDialMatchPosition match : matchList) { replaceBitInMask(builder, match); } - mNameMatchMask = builder.toString(); return true; } else if (ALLOW_INITIAL_MATCH && queryStart < INITIAL_LENGTH_LIMIT) { // we matched the first character. @@ -395,12 +364,35 @@ public class SmartDialNameMatcher { for (SmartDialMatchPosition match : matchList) { replaceBitInMask(builder, match); } - mNameMatchMask = builder.toString(); return true; } return false; } + /** + * This function iterates through each token in the display name, trying to match the query to the + * numeric equivalent of the token. + * + *

A token is defined as a range in the display name delimited by characters that have no latin + * alphabet equivalents (e.g. spaces - ' ', periods - ',', underscores - '_' or chinese characters + * - '王'). Transliteration from non-latin characters to latin character will be done on a best + * effort basis - e.g. 'Ü' - 'u'. + * + *

For example, the display name "Phillips Thomas Jr" contains three tokens: "phillips", + * "thomas", and "jr". + * + *

A match must begin at the start of a token. For example, typing 846(Tho) would match + * "Phillips Thomas", but 466(hom) would not. + * + *

Also, a match can extend across tokens. For example, typing 37337(FredS) would match (Fred + * S)mith. + * + * @param displayName The normalized(no accented characters) display name we intend to match + * against. + * @return Returns true if a combination of the tokens in displayName match the query string + * contained in query. If the function returns true, matchList will contain an ArrayList of + * match positions (multiple matches correspond to initial matches). + */ public boolean matches(String displayName) { mMatchPositions.clear(); return matchesCombination(displayName, mQuery, mMatchPositions); @@ -409,15 +401,7 @@ public class SmartDialNameMatcher { public ArrayList getMatchPositions() { // Return a clone of mMatchPositions so that the caller can use it without // worrying about it changing - return new ArrayList(mMatchPositions); - } - - public String getNameMatchPositionsInString() { - return mNameMatchMask; - } - - public String getNumberMatchPositionsInString() { - return mPhoneNumberMatchMask; + return new ArrayList<>(mMatchPositions); } public String getQuery() { -- cgit v1.2.3