diff options
| -rw-r--r-- | core/java/android/webkit/BrowserFrame.java | 13 | ||||
| -rw-r--r-- | core/java/android/webkit/FindActionModeCallback.java | 15 | ||||
| -rw-r--r-- | core/java/android/webkit/WebView.java | 58 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewCore.java | 7 | ||||
| -rw-r--r-- | core/res/AndroidManifest.xml | 7 | ||||
| -rwxr-xr-x[-rw-r--r--] | core/res/res/values/strings.xml | 6 | ||||
| -rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 9 | ||||
| -rw-r--r-- | telephony/java/android/telephony/PhoneNumberUtils.java | 231 | ||||
| -rw-r--r-- | telephony/tests/telephonytests/src/com/android/internal/telephony/PhoneNumberUtilsTest.java | 62 |
9 files changed, 331 insertions, 77 deletions
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java index 388920c38d12..c1945599d337 100644 --- a/core/java/android/webkit/BrowserFrame.java +++ b/core/java/android/webkit/BrowserFrame.java @@ -1404,4 +1404,17 @@ class BrowserFrame extends Handler { native void nativeSslClientCert(int handle, byte[] pkcs8EncodedPrivateKey, byte[][] asn1DerEncodedCertificateChain); + + /** + * Returns true when the contents of the frame is an RTL or vertical-rl + * page. This is used for determining whether a frame should be initially + * scrolled right-most as opposed to left-most. + * @return true when the frame should be initially scrolled right-most + * based on the text direction and writing mode. + */ + /* package */ boolean getShouldStartScrolledRight() { + return nativeGetShouldStartScrolledRight(mNativeFrame); + } + + private native boolean nativeGetShouldStartScrolledRight(int nativeBrowserFrame); } diff --git a/core/java/android/webkit/FindActionModeCallback.java b/core/java/android/webkit/FindActionModeCallback.java index b85fd17f78de..fffa90b5518a 100644 --- a/core/java/android/webkit/FindActionModeCallback.java +++ b/core/java/android/webkit/FindActionModeCallback.java @@ -18,6 +18,8 @@ package android.webkit; import android.content.Context; import android.content.res.Resources; +import android.graphics.Point; +import android.graphics.Rect; import android.text.Editable; import android.text.Selection; import android.text.Spannable; @@ -254,13 +256,18 @@ class FindActionModeCallback implements ActionMode.Callback, TextWatcher, // Does nothing. Needed to implement TextWatcher. } - public int getActionModeHeight() { + private Rect mGlobalVisibleRect = new Rect(); + private Point mGlobalVisibleOffset = new Point(); + public int getActionModeGlobalBottom() { if (mActionMode == null) { return 0; } - View parent = (View) mCustomView.getParent(); - return parent != null ? parent.getMeasuredHeight() - : mCustomView.getMeasuredHeight(); + View view = (View) mCustomView.getParent(); + if (view == null) { + view = mCustomView; + } + view.getGlobalVisibleRect(mGlobalVisibleRect, mGlobalVisibleOffset); + return mGlobalVisibleRect.bottom; } } diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index df2d1264bfa8..9dfb74b7e27a 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -1484,7 +1484,21 @@ public class WebView extends AbsoluteLayout private int getVisibleTitleHeightImpl() { // need to restrict mScrollY due to over scroll return Math.max(getTitleHeight() - Math.max(0, mScrollY), - mFindCallback != null ? mFindCallback.getActionModeHeight() : 0); + getOverlappingActionModeHeight()); + } + + private int mCachedOverlappingActionModeHeight = -1; + + private int getOverlappingActionModeHeight() { + if (mFindCallback == null) { + return 0; + } + if (mCachedOverlappingActionModeHeight < 0) { + getGlobalVisibleRect(mGlobalVisibleRect, mGlobalVisibleOffset); + mCachedOverlappingActionModeHeight = Math.max(0, + mFindCallback.getActionModeGlobalBottom() - mGlobalVisibleRect.top); + } + return mCachedOverlappingActionModeHeight; } /* @@ -3375,6 +3389,7 @@ public class WebView extends AbsoluteLayout // Could not start the action mode, so end Find on page return false; } + mCachedOverlappingActionModeHeight = -1; mFindCallback = callback; setFindIsUp(true); mFindCallback.setWebView(this); @@ -3492,6 +3507,7 @@ public class WebView extends AbsoluteLayout */ void notifyFindDialogDismissed() { mFindCallback = null; + mCachedOverlappingActionModeHeight = -1; if (mWebViewCore == null) { return; } @@ -4346,6 +4362,7 @@ public class WebView extends AbsoluteLayout @Override protected void onConfigurationChanged(Configuration newConfig) { + mCachedOverlappingActionModeHeight = -1; if (mSelectingText && mOrientation != newConfig.orientation) { selectionDone(); } @@ -8721,27 +8738,6 @@ public class WebView extends AbsoluteLayout isPictureAfterFirstLayout, registerPageSwapCallback); } final Point viewSize = draw.mViewSize; - if (isPictureAfterFirstLayout) { - // Reset the last sent data here since dealing with new page. - mLastWidthSent = 0; - mZoomManager.onFirstLayout(draw); - if (!mDrawHistory) { - // Do not send the scroll event for this particular - // scroll message. Note that a scroll event may - // still be fired if the user scrolls before the - // message can be handled. - mSendScrollEvent = false; - setContentScrollTo(viewState.mScrollX, viewState.mScrollY); - mSendScrollEvent = true; - - // As we are on a new page, remove the WebTextView. This - // is necessary for page loads driven by webkit, and in - // particular when the user was on a password field, so - // the WebTextView was visible. - clearTextEntry(); - } - } - // We update the layout (i.e. request a layout from the // view system) if the last view size that we sent to // WebCore matches the view size of the picture we just @@ -8754,7 +8750,25 @@ public class WebView extends AbsoluteLayout mSendScrollEvent = false; recordNewContentSize(draw.mContentSize.x, draw.mContentSize.y, updateLayout); + + if (isPictureAfterFirstLayout) { + // Reset the last sent data here since dealing with new page. + mLastWidthSent = 0; + mZoomManager.onFirstLayout(draw); + int scrollX = viewState.mShouldStartScrolledRight + ? getContentWidth() : viewState.mScrollX; + int scrollY = viewState.mScrollY; + setContentScrollTo(scrollX, scrollY); + if (!mDrawHistory) { + // As we are on a new page, remove the WebTextView. This + // is necessary for page loads driven by webkit, and in + // particular when the user was on a password field, so + // the WebTextView was visible. + clearTextEntry(); + } + } mSendScrollEvent = true; + if (DebugFlags.WEB_VIEW) { Rect b = draw.mInvalRegion.getBounds(); Log.v(LOGTAG, "NEW_PICTURE_MSG_ID {" + diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 754d6e9f7b5e..cd61481eed67 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -1982,6 +1982,7 @@ public final class WebViewCore { int mScrollY; boolean mMobileSite; boolean mIsRestored; + boolean mShouldStartScrolledRight; } static class DrawData { @@ -2382,6 +2383,7 @@ public final class WebViewCore { viewState.mMobileSite = false; // for non-mobile site, we don't need minPrefWidth, set it as 0 viewState.mScrollX = 0; + viewState.mShouldStartScrolledRight = false; Message.obtain(mWebView.mPrivateHandler, WebView.UPDATE_ZOOM_RANGE, viewState).sendToTarget(); return; @@ -2412,6 +2414,11 @@ public final class WebViewCore { mInitialViewState.mDefaultScale = adjust; mInitialViewState.mScrollX = mRestoredX; mInitialViewState.mScrollY = mRestoredY; + mInitialViewState.mShouldStartScrolledRight = (mRestoredX == 0) + && (mRestoredY == 0) + && (mBrowserFrame != null) + && mBrowserFrame.getShouldStartScrolledRight(); + mInitialViewState.mMobileSite = (0 == mViewportWidth); if (mIsRestored) { mInitialViewState.mIsRestored = true; diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 0ed0523afc25..230df39f0840 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -1027,6 +1027,13 @@ android:label="@string/permlab_readLogs" android:description="@string/permdesc_readLogs" /> + <!-- Allows an application to use any media decoder when decoding for playback + @hide --> + <permission android:name="android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK" + android:protectionLevel="signatureOrSystem" + android:label="@string/permlab_anyCodecForPlayback" + android:description="@string/permdesc_anyCodecForPlayback" /> + <!-- ========================================= --> <!-- Permissions for special development tools --> <!-- ========================================= --> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 333736bcbb98..25ca27c0c2b4 100644..100755 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -822,6 +822,12 @@ including personal or private information.</string> <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. --> + <string name="permlab_anyCodecForPlayback">use any media decoder for playback</string> + <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. --> + <string name="permdesc_anyCodecForPlayback">Allows an application to use any installed + media decoder to decode for playback.</string> + + <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. --> <string name="permlab_diagnostic">read/write to resources owned by diag</string> <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. --> <string name="permdesc_diagnostic">Allows the app to read and write to diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 433af4abde1e..cb6fcc61ae77 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -2066,9 +2066,14 @@ uint32_t AudioFlinger::MixerThread::prepareTracks_l(const SortedVector< wp<Track // The first time a track is added we wait // for all its buffers to be filled before processing it mAudioMixer->setActiveTrack(track->name()); - // make sure that we have enough frames to mix one full buffer + // make sure that we have enough frames to mix one full buffer. + // enforce this condition only once to enable draining the buffer in case the client + // app does not call stop() and relies on underrun to stop: + // hence the test on (track->mRetryCount >= kMaxTrackRetries) meaning the track was mixed + // during last round uint32_t minFrames = 1; - if (!track->isStopped() && !track->isPausing()) { + if (!track->isStopped() && !track->isPausing() && + (track->mRetryCount >= kMaxTrackRetries)) { if (t->sampleRate() == (int)mSampleRate) { minFrames = mFrameCount; } else { diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index 34f88489ed6a..f2ccb5bf016e 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -1513,14 +1513,65 @@ public class PhoneNumberUtils static final int MIN_MATCH = 7; /** - * isEmergencyNumber: checks a given number against the list of - * emergency numbers provided by the RIL and SIM card. + * Checks a given number against the list of + * emergency numbers provided by the RIL and SIM card. * * @param number the number to look up. - * @return if the number is in the list of emergency numbers - * listed in the ril / sim, then return true, otherwise false. + * @return true if the number is in the list of emergency numbers + * listed in the RIL / SIM, otherwise return false. */ public static boolean isEmergencyNumber(String number) { + // Return true only if the specified number *exactly* matches + // one of the emergency numbers listed by the RIL / SIM. + return isEmergencyNumberInternal(number, true /* useExactMatch */); + } + + /** + * Checks if given number might *potentially* result in + * a call to an emergency service on the current network. + * + * Specifically, this method will return true if the specified number + * is an emergency number according to the list managed by the RIL or + * SIM, *or* if the specified number simply starts with the same + * digits as any of the emergency numbers listed in the RIL / SIM. + * + * This method is intended for internal use by the phone app when + * deciding whether to allow ACTION_CALL intents from 3rd party apps + * (where we're required to *not* allow emergency calls to be placed.) + * + * @param number the number to look up. + * @return true if the number is in the list of emergency numbers + * listed in the RIL / SIM, *or* if the number starts with the + * same digits as any of those emergency numbers. + * + * @hide + */ + public static boolean isPotentialEmergencyNumber(String number) { + // Check against the emergency numbers listed by the RIL / SIM, + // and *don't* require an exact match. + return isEmergencyNumberInternal(number, false /* useExactMatch */); + } + + /** + * Helper function for isEmergencyNumber(String) and + * isPotentialEmergencyNumber(String). + * + * @param number the number to look up. + * + * @param useExactMatch if true, consider a number to be an emergency + * number only if it *exactly* matches a number listed in + * the RIL / SIM. If false, a number is considered to be an + * emergency number if it simply starts with the same digits + * as any of the emergency numbers listed in the RIL / SIM. + * (Setting useExactMatch to false allows you to identify + * number that could *potentially* result in emergency calls + * since many networks will actually ignore trailing digits + * after a valid emergency number.) + * + * @return true if the number is in the list of emergency numbers + * listed in the RIL / sim, otherwise return false. + */ + private static boolean isEmergencyNumberInternal(String number, boolean useExactMatch) { // If the number passed in is null, just return false: if (number == null) return false; @@ -1540,16 +1591,26 @@ public class PhoneNumberUtils // searches through the comma-separated list for a match, // return true if one is found. for (String emergencyNum : numbers.split(",")) { - if (number.startsWith(emergencyNum)) { - return true; + if (useExactMatch) { + if (number.equals(emergencyNum)) { + return true; + } + } else { + if (number.startsWith(emergencyNum)) { + return true; + } } } // no matches found against the list! return false; } - //no ecclist system property, so use our own list. - return (number.startsWith("112") || number.startsWith("911")); + // No ecclist system property, so use our own list. + if (useExactMatch) { + return (number.equals("112") || number.equals("911")); + } else { + return (number.startsWith("112") || number.startsWith("911")); + } } /** @@ -1559,31 +1620,81 @@ public class PhoneNumberUtils * @param defaultCountryIso the specific country which the number should be checked against * @return if the number is an emergency number for the specific country, then return true, * otherwise false + * * @hide */ public static boolean isEmergencyNumber(String number, String defaultCountryIso) { - PhoneNumberUtil util = PhoneNumberUtil.getInstance(); - try { - PhoneNumber pn = util.parse(number, defaultCountryIso); - // libphonenumber guarantees short numbers such as emergency numbers are classified as - // invalid. Therefore, if the number passes the validation test, we believe it is not an - // emergency number. - // TODO: Compare against a list of country-specific known emergency numbers instead, once - // that has been collected. - if (util.isValidNumber(pn)) { - return false; - } else if ("BR".equalsIgnoreCase(defaultCountryIso) && number.length() >= 8) { - // This is to prevent Brazilian local numbers which start with 911 being incorrectly - // classified as emergency numbers. 911 is not an emergency number in Brazil; it is also - // not possible to append additional digits to an emergency number to dial the number in - // Brazil - it won't connect. - // TODO: Clean this up once a list of country-specific known emergency numbers is - // collected. - return false; - } - } catch (NumberParseException e) { - } - return isEmergencyNumber(number); + return isEmergencyNumberInternal(number, + defaultCountryIso, + true /* useExactMatch */); + } + + /** + * Checks if a given number might *potentially* result in a call to an + * emergency service, for a specific country. + * + * Specifically, this method will return true if the specified number + * is an emergency number in the specified country, *or* if the number + * simply starts with the same digits as any emergency number for that + * country. + * + * This method is intended for internal use by the phone app when + * deciding whether to allow ACTION_CALL intents from 3rd party apps + * (where we're required to *not* allow emergency calls to be placed.) + * + * @param number the number to look up. + * @param defaultCountryIso the specific country which the number should be checked against + * @return true if the number is an emergency number for the specific + * country, *or* if the number starts with the same digits as + * any of those emergency numbers. + * + * @hide + */ + public static boolean isPotentialEmergencyNumber(String number, String defaultCountryIso) { + return isEmergencyNumberInternal(number, + defaultCountryIso, + false /* useExactMatch */); + } + + /** + * Helper function for isEmergencyNumber(String, String) and + * isPotentialEmergencyNumber(String, String). + * + * @param number the number to look up. + * @param defaultCountryIso the specific country which the number should be checked against + * @param useExactMatch if true, consider a number to be an emergency + * number only if it *exactly* matches a number listed in + * the RIL / SIM. If false, a number is considered to be an + * emergency number if it simply starts with the same digits + * as any of the emergency numbers listed in the RIL / SIM. + * + * @return true if the number is an emergency number for the specified country. + */ + private static boolean isEmergencyNumberInternal(String number, + String defaultCountryIso, + boolean useExactMatch) { + PhoneNumberUtil util = PhoneNumberUtil.getInstance(); + try { + PhoneNumber pn = util.parse(number, defaultCountryIso); + // libphonenumber guarantees short numbers such as emergency numbers are classified as + // invalid. Therefore, if the number passes the validation test, we believe it is not an + // emergency number. + // TODO: Compare against a list of country-specific known emergency numbers instead, once + // that has been collected. + if (util.isValidNumber(pn)) { + return false; + } else if ("BR".equalsIgnoreCase(defaultCountryIso) && number.length() >= 8) { + // This is to prevent Brazilian local numbers which start with 911 being incorrectly + // classified as emergency numbers. 911 is not an emergency number in Brazil; it is also + // not possible to append additional digits to an emergency number to dial the number in + // Brazil - it won't connect. + // TODO: Clean this up once a list of country-specific known emergency numbers is + // collected. + return false; + } + } catch (NumberParseException e) { + } + return isEmergencyNumberInternal(number, useExactMatch); } /** @@ -1592,12 +1703,66 @@ public class PhoneNumberUtils * * @param number the number to look up. * @param context the specific context which the number should be checked against - * @return if a phone number is an emergency number for a local country, based on the - * CountryDetector. + * @return true if the specified number is an emergency number for a local country, based on the + * CountryDetector. + * * @see android.location.CountryDetector * @hide */ public static boolean isLocalEmergencyNumber(String number, Context context) { + return isLocalEmergencyNumberInternal(number, + context, + true /* useExactMatch */); + } + + /** + * Checks if a given number might *potentially* result in a call to an + * emergency service, for the country that the user is in. The current + * country is determined using the CountryDetector. + * + * Specifically, this method will return true if the specified number + * is an emergency number in the current country, *or* if the number + * simply starts with the same digits as any emergency number for the + * current country. + * + * This method is intended for internal use by the phone app when + * deciding whether to allow ACTION_CALL intents from 3rd party apps + * (where we're required to *not* allow emergency calls to be placed.) + * + * @param number the number to look up. + * @param context the specific context which the number should be checked against + * @return true if the specified number is an emergency number for a local country, based on the + * CountryDetector. + * + * @see android.location.CountryDetector + * @hide + */ + public static boolean isPotentialLocalEmergencyNumber(String number, Context context) { + return isLocalEmergencyNumberInternal(number, + context, + false /* useExactMatch */); + } + + /** + * Helper function for isLocalEmergencyNumber() and + * isPotentialLocalEmergencyNumber(). + * + * @param number the number to look up. + * @param context the specific context which the number should be checked against + * @param useExactMatch if true, consider a number to be an emergency + * number only if it *exactly* matches a number listed in + * the RIL / SIM. If false, a number is considered to be an + * emergency number if it simply starts with the same digits + * as any of the emergency numbers listed in the RIL / SIM. + * + * @return true if the specified number is an emergency number for a + * local country, based on the CountryDetector. + * + * @see android.location.CountryDetector + */ + private static boolean isLocalEmergencyNumberInternal(String number, + Context context, + boolean useExactMatch) { String countryIso; CountryDetector detector = (CountryDetector) context.getSystemService( Context.COUNTRY_DETECTOR); @@ -1609,7 +1774,7 @@ public class PhoneNumberUtils Log.w(LOG_TAG, "No CountryDetector; falling back to countryIso based on locale: " + countryIso); } - return isEmergencyNumber(number, countryIso); + return isEmergencyNumberInternal(number, countryIso, useExactMatch); } /** diff --git a/telephony/tests/telephonytests/src/com/android/internal/telephony/PhoneNumberUtilsTest.java b/telephony/tests/telephonytests/src/com/android/internal/telephony/PhoneNumberUtilsTest.java index 1a3e4877e479..a385f5575b48 100644 --- a/telephony/tests/telephonytests/src/com/android/internal/telephony/PhoneNumberUtilsTest.java +++ b/telephony/tests/telephonytests/src/com/android/internal/telephony/PhoneNumberUtilsTest.java @@ -555,21 +555,51 @@ public class PhoneNumberUtilsTest extends AndroidTestCase { } @SmallTest public void testIsEmergencyNumber() { - assertTrue(PhoneNumberUtils.isEmergencyNumber("911", "US")); - assertTrue(PhoneNumberUtils.isEmergencyNumber("112", "US")); - // The next two numbers are not valid phone numbers in the US, but can be used to trick the - // system to dial 911 and 112, which are emergency numbers in the US. For the purpose of - // addressing that, they are also classified as emergency numbers in the US. - assertTrue(PhoneNumberUtils.isEmergencyNumber("91112345", "US")); - assertTrue(PhoneNumberUtils.isEmergencyNumber("11212345", "US")); - // A valid mobile phone number from Singapore shouldn't be classified as an emergency number - // in Singapore, as 911 is not an emergency number there. - assertFalse(PhoneNumberUtils.isEmergencyNumber("91121234", "SG")); - // A valid fixed-line phone number from Brazil shouldn't be classified as an emergency number - // in Brazil, as 112 is not an emergency number there. - assertFalse(PhoneNumberUtils.isEmergencyNumber("1121234567", "BR")); - // A valid local phone number from Brazil shouldn't be classified as an emergency number in - // Brazil. - assertFalse(PhoneNumberUtils.isEmergencyNumber("91112345", "BR")); + // There are two parallel sets of tests here: one for the + // regular isEmergencyNumber() method, and the other for + // isPotentialEmergencyNumber(). + // + // (The difference is that isEmergencyNumber() will return true + // only if the specified number exactly matches an actual + // emergency number, but isPotentialEmergencyNumber() will + // return true if the specified number simply starts with the + // same digits as any actual emergency number.) + + // Tests for isEmergencyNumber(): + assertTrue(PhoneNumberUtils.isEmergencyNumber("911", "US")); + assertTrue(PhoneNumberUtils.isEmergencyNumber("112", "US")); + // The next two numbers are not valid phone numbers in the US, + // so do not count as emergency numbers (but they *are* "potential" + // emergency numbers; see below.) + assertFalse(PhoneNumberUtils.isEmergencyNumber("91112345", "US")); + assertFalse(PhoneNumberUtils.isEmergencyNumber("11212345", "US")); + // A valid mobile phone number from Singapore shouldn't be classified as an emergency number + // in Singapore, as 911 is not an emergency number there. + assertFalse(PhoneNumberUtils.isEmergencyNumber("91121234", "SG")); + // A valid fixed-line phone number from Brazil shouldn't be classified as an emergency number + // in Brazil, as 112 is not an emergency number there. + assertFalse(PhoneNumberUtils.isEmergencyNumber("1121234567", "BR")); + // A valid local phone number from Brazil shouldn't be classified as an emergency number in + // Brazil. + assertFalse(PhoneNumberUtils.isEmergencyNumber("91112345", "BR")); + + // Tests for isPotentialEmergencyNumber(): + // These first two are obviously emergency numbers: + assertTrue(PhoneNumberUtils.isPotentialEmergencyNumber("911", "US")); + assertTrue(PhoneNumberUtils.isPotentialEmergencyNumber("112", "US")); + // The next two numbers are not valid phone numbers in the US, but can be used to trick the + // system to dial 911 and 112, which are emergency numbers in the US. For the purpose of + // addressing that, they are also classified as "potential" emergency numbers in the US. + assertTrue(PhoneNumberUtils.isPotentialEmergencyNumber("91112345", "US")); + assertTrue(PhoneNumberUtils.isPotentialEmergencyNumber("11212345", "US")); + // A valid mobile phone number from Singapore shouldn't be classified as an emergency number + // in Singapore, as 911 is not an emergency number there. + assertFalse(PhoneNumberUtils.isPotentialEmergencyNumber("91121234", "SG")); + // A valid fixed-line phone number from Brazil shouldn't be classified as an emergency number + // in Brazil, as 112 is not an emergency number there. + assertFalse(PhoneNumberUtils.isPotentialEmergencyNumber("1121234567", "BR")); + // A valid local phone number from Brazil shouldn't be classified as an emergency number in + // Brazil. + assertFalse(PhoneNumberUtils.isPotentialEmergencyNumber("91112345", "BR")); } } |