Skip to content

Commit b4bc99e

Browse files
Jake HambyAndroid (Google) Code Review
authored andcommitted
Add user confirmation dialog before sending SMS to short code.
Non-system apps now require user confirmation before sending an SMS to a short code that may potentially cost the user money. The number is tested against regex patterns for short codes for the country matching the user's SIM card or network. The user is warned if the phone number is potentially or definitely a premium SMS number. The regex patterns are loaded from core/res/res/xml/sms_short_codes.xml. If the user's country is not found, then phone numbers of 5 digits or less (excluding known emergency phone numbers) are considered to be potential SMS short codes. Command to run test cases: $ runtest -c com.android.internal.telephony.SmsUsageMonitorShortCodeTest frameworks-telephony Bug: 5513975 Change-Id: Ic0b483153390e974c632302f3061300bc2a2274a
1 parent 4dfbe83 commit b4bc99e

File tree

9 files changed

+1165
-122
lines changed

9 files changed

+1165
-122
lines changed

core/res/res/values/public.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,17 @@
787787
<java-symbol type="string" name="sipAddressTypeHome" />
788788
<java-symbol type="string" name="sipAddressTypeOther" />
789789
<java-symbol type="string" name="sipAddressTypeWork" />
790-
<java-symbol type="string" name="sms_control_default_app_name" />
791790
<java-symbol type="string" name="sms_control_message" />
792-
<java-symbol type="string" name="sms_control_no" />
793791
<java-symbol type="string" name="sms_control_title" />
792+
<java-symbol type="string" name="sms_control_no" />
794793
<java-symbol type="string" name="sms_control_yes" />
794+
<java-symbol type="string" name="sms_premium_short_code_confirm_message" />
795+
<java-symbol type="string" name="sms_premium_short_code_confirm_title" />
796+
<java-symbol type="string" name="sms_short_code_confirm_allow" />
797+
<java-symbol type="string" name="sms_short_code_confirm_deny" />
798+
<java-symbol type="string" name="sms_short_code_confirm_message" />
799+
<java-symbol type="string" name="sms_short_code_confirm_report" />
800+
<java-symbol type="string" name="sms_short_code_confirm_title" />
795801
<java-symbol type="string" name="submit" />
796802
<java-symbol type="string" name="sync_binding_label" />
797803
<java-symbol type="string" name="sync_do_nothing" />
@@ -1095,6 +1101,7 @@
10951101
<java-symbol type="xml" name="password_kbd_symbols_shift" />
10961102
<java-symbol type="xml" name="power_profile" />
10971103
<java-symbol type="xml" name="time_zones_by_country" />
1104+
<java-symbol type="xml" name="sms_short_codes" />
10981105

10991106
<java-symbol type="raw" name="incognito_mode_start_page" />
11001107
<java-symbol type="raw" name="loaderror" />

core/res/res/values/strings.xml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2789,16 +2789,30 @@
27892789
<string name="select_character">Insert character</string>
27902790

27912791
<!-- SMS per-application rate control Dialog --> <skip />
2792-
<!-- See SMS_DIALOG. This is shown if the current application's name cannot be figuerd out. -->
2793-
<string name="sms_control_default_app_name">Unknown app</string>
27942792
<!-- SMS_DIALOG: An SMS dialog is shown if an application tries to send too many SMSes. This is the title of that dialog. -->
27952793
<string name="sms_control_title">Sending SMS messages</string>
2796-
<!-- See SMS_DIALOG. This is the message shown in that dialog. -->
2797-
<string name="sms_control_message">A large number of SMS messages are being sent. Touch OK to continue, or Cancel to stop sending.</string>
2798-
<!-- See SMS_DIALOG. This is a button choice to allow sending the SMSes. -->
2799-
<string name="sms_control_yes">OK</string>
2800-
<!-- See SMS_DIALOG. This is a button choice to disallow sending the SMSes.. -->
2801-
<string name="sms_control_no">Cancel</string>
2794+
<!-- See SMS_DIALOG. This is the message shown in that dialog. [CHAR LIMIT=NONE] -->
2795+
<string name="sms_control_message">&lt;b><xliff:g id="app_name">%1$s</xliff:g>&lt;/b> is sending a large number of SMS messages. Do you want to allow this app to continue sending messages?</string>
2796+
<!-- See SMS_DIALOG. This is a button choice to allow sending the SMSes. [CHAR LIMIT=30] -->
2797+
<string name="sms_control_yes">Allow</string>
2798+
<!-- See SMS_DIALOG. This is a button choice to disallow sending the SMSes. [CHAR LIMIT=30] -->
2799+
<string name="sms_control_no">Deny</string>
2800+
2801+
<!-- SMS short code verification dialog. --> <skip />
2802+
<!-- The dialog title for the SMS short code confirmation dialog. [CHAR LIMIT=30] -->
2803+
<string name="sms_short_code_confirm_title">Send SMS to short code?</string>
2804+
<!-- The dialog title for the SMS premium short code confirmation dialog. [CHAR LIMIT=30] -->
2805+
<string name="sms_premium_short_code_confirm_title">Send premium SMS?</string>
2806+
<!-- The message text for the SMS short code confirmation dialog. [CHAR LIMIT=NONE] -->
2807+
<string name="sms_short_code_confirm_message">&lt;b><xliff:g id="app_name">%1$s</xliff:g>&lt;/b> would like to send a text message to &lt;b><xliff:g id="dest_address">%2$s</xliff:g>&lt;/b>, which appears to be an SMS short code.&lt;p>Sending text messages to some short codes may cause your mobile account to be billed for premium services.&lt;p>Do you want to allow this app to send the message?</string>
2808+
<!-- The message text for the SMS short code confirmation dialog. [CHAR LIMIT=NONE] -->
2809+
<string name="sms_premium_short_code_confirm_message">&lt;b><xliff:g id="app_name">%1$s</xliff:g>&lt;/b> would like to send a text message to &lt;b><xliff:g id="dest_address">%2$s</xliff:g>&lt;/b>, which is a premium SMS short code.&lt;p>&lt;b>Sending a message to this destination will cause your mobile account to be billed for premium services.&lt;/b>&lt;p>Do you want to allow this app to send the message?</string>
2810+
<!-- Text of the approval button for the SMS short code confirmation dialog. [CHAR LIMIT=50] -->
2811+
<string name="sms_short_code_confirm_allow">Send message</string>
2812+
<!-- Text of the cancel button for the SMS short code confirmation dialog. [CHAR LIMIT=30] -->
2813+
<string name="sms_short_code_confirm_deny">Don\'t send</string>
2814+
<!-- Text of the button for the SMS short code confirmation dialog to report a malicious app. [CHAR LIMIT=30] -->
2815+
<string name="sms_short_code_confirm_report">Report malicious app</string>
28022816

28032817
<!-- SIM swap and device reboot Dialog --> <skip />
28042818
<!-- See SIM_REMOVED_DIALOG. This is the title of that dialog. -->
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/*
4+
** Copyright 2012, The Android Open Source Project
5+
**
6+
** Licensed under the Apache License, Version 2.0 (the "License");
7+
** you may not use this file except in compliance with the License.
8+
** You may obtain a copy of the License at
9+
**
10+
** http://www.apache.org/licenses/LICENSE-2.0
11+
**
12+
** Unless required by applicable law or agreed to in writing, software
13+
** distributed under the License is distributed on an "AS IS" BASIS,
14+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
** See the License for the specific language governing permissions and
16+
** limitations under the License.
17+
*/
18+
-->
19+
20+
<!-- Regex patterns for SMS short codes by country. -->
21+
<shortcodes>
22+
23+
<!-- The country attribute is the ISO country code of the user's account (from SIM card or NV).
24+
The pattern attribute is a regex that matches all SMS short codes for the country.
25+
The premium attribute is a regex that matches premium rate SMS short codes.
26+
The free attribute matches short codes that we know will not cost the user, such as
27+
emergency numbers. The standard attribute matches short codes that are billed at the
28+
standard SMS rate. The user is warned when the destination phone number matches the
29+
"pattern" or "premium" regexes, and does not match the "free" or "standard" regexes. -->
30+
31+
<!-- Harmonised European Short Codes are 6 digit numbers starting with 116 (free helplines).
32+
Premium patterns include short codes from: http://aonebill.com/coverage&tariffs
33+
and http://mobilcent.com/info-worldwide.asp and extracted from:
34+
http://smscoin.net/software/engine/WordPress/Paid+SMS-registration/ -->
35+
36+
<!-- Albania: 5 digits, known short codes listed -->
37+
<shortcode country="al" pattern="\\d{5}" premium="15191|55[56]00" />
38+
39+
<!-- Armenia: 3-4 digits, emergency numbers 10[123] -->
40+
<shortcode country="am" pattern="\\d{3,4}" premium="11[2456]1|3024" free="10[123]" />
41+
42+
<!-- Austria: 10 digits, premium prefix 09xx, plus EU -->
43+
<shortcode country="at" pattern="11\\d{4}" premium="09.*" free="116\\d{3}" />
44+
45+
<!-- Australia: 6 or 8 digits starting with "19" -->
46+
<shortcode country="au" pattern="19(?:\\d{4}|\\d{6})" premium="19998882" />
47+
48+
<!-- Azerbaijan: 4-5 digits, known premium codes listed -->
49+
<shortcode country="az" pattern="\\d{4,5}" premium="330[12]|87744|901[234]|93(?:94|101)|9426|9525" />
50+
51+
<!-- Belgium: 4 digits, plus EU: http://www.mobileweb.be/en/mobileweb/sms-numberplan.asp -->
52+
<shortcode country="be" premium="\\d{4}" free="8\\d{3}|116\\d{3}" />
53+
54+
<!-- Bulgaria: 4-5 digits, plus EU -->
55+
<shortcode country="bg" pattern="\\d{4,5}" premium="18(?:16|423)|19(?:1[56]|35)" free="116\\d{3}" />
56+
57+
<!-- Belarus: 4 digits -->
58+
<shortcode country="by" pattern="\\d{4}" premium="3336|4161|444[4689]|501[34]|7781" />
59+
60+
<!-- Canada: 5-6 digits -->
61+
<shortcode country="ca" pattern="\\d{5,6}" premium="60999|88188" />
62+
63+
<!-- Switzerland: 3-5 digits: http://www.swisscom.ch/fxres/kmu/thirdpartybusiness_code_of_conduct_en.pdf -->
64+
<shortcode country="ch" pattern="[2-9]\\d{2,4}" premium="543|83111" />
65+
66+
<!-- China: premium shortcodes start with "1066", free shortcodes start with "1065":
67+
http://clients.txtnation.com/entries/197192-china-premium-sms-short-code-requirements -->
68+
<shortcode country="cn" premium="1066.*" free="1065.*" />
69+
70+
<!-- Cyprus: 4-6 digits (not confirmed), known premium codes listed, plus EU -->
71+
<shortcode country="cy" pattern="\\d{4,6}" premium="7510" free="116\\d{3}" />
72+
73+
<!-- Czech Republic: 7-8 digits, starting with 9, plus EU:
74+
http://www.o2.cz/osobni/en/services-by-alphabet/91670-premium_sms.html -->
75+
<shortcode country="cz" premium="9\\d{6,7}" free="116\\d{3}" />
76+
77+
<!-- Germany: 4-5 digits plus 1232xxx (premium codes from http://www.vodafone.de/infofaxe/537.pdf and http://premiumdienste.eplus.de/pdf/kodex.pdf), plus EU. To keep the premium regex from being too large, it only includes payment processors that have been used by SMS malware, with the regular pattern matching the other premium short codes. -->
78+
<shortcode country="de" pattern="\\d{4,5}|1232\\d{3}" premium="11(?:111|833)|1232(?:013|021|060|075|286|358)|118(?:44|80|86)|20[25]00|220(?:21|22|88|99)|221(?:14|21)|223(?:44|53|77)|224[13]0|225(?:20|59|90)|226(?:06|10|20|26|30|40|56|70)|227(?:07|33|39|66|76|78|79|88|99)|228(?:08|11|66|77)|23300|30030|3[12347]000|330(?:33|55|66)|33(?:233|331|366|533)|34(?:34|567)|37000|40(?:040|123|444|[3568]00)|41(?:010|414)|44(?:000|044|344|44[24]|544)|50005|50100|50123|50555|51000|52(?:255|783)|54(?:100|2542)|55(?:077|[24]00|222|333|55|[12369]55)|56(?:789|886)|60800|6[13]000|66(?:[12348]66|566|766|777|88|999)|68888|70(?:07|123|777)|76766|77(?:007|070|222|444|[567]77)|80(?:008|123|888)|82(?:002|[378]00|323|444|472|474|488|727)|83(?:005|[169]00|333|830)|84(?:141|300|32[34]|343|488|499|777|888)|85888|86(?:188|566|640|644|650|677|868|888)|870[24]9|871(?:23|[49]9)|872(?:1[0-8]|49|99)|87499|875(?:49|55|99)|876(?:0[1367]|1[1245678]|54|99)|877(?:00|99)|878(?:15|25|3[567]|8[12])|87999|880(?:08|44|55|77|99)|88688|888(?:03|10|8|89)|8899|90(?:009|999)|99999" free="116\\d{3}" />
79+
80+
<!-- Denmark: see http://iprs.webspacecommerce.com/Denmark-Premium-Rate-Numbers -->
81+
<shortcode country="dk" pattern="\\d{4,5}" premium="1\\d{3}" free="116\\d{3}" />
82+
83+
<!-- Estonia: short codes 3-5 digits starting with 1, plus premium 7 digit numbers starting with 90, plus EU.
84+
http://www.tja.ee/public/documents/Elektrooniline_side/Oigusaktid/ENG/Estonian_Numbering_Plan_annex_06_09_2010.mht -->
85+
<shortcode country="ee" pattern="1\\d{2,4}" premium="90\\d{5}|15330|1701[0-3]" free="116\\d{3}" />
86+
87+
<!-- Spain: 5-6 digits: 25xxx, 27xxx, 280xx, 35xxx, 37xxx, 795xxx, 797xxx, 995xxx, 997xxx, plus EU.
88+
http://www.legallink.es/?q=en/content/which-current-regulatory-status-premium-rate-services-spain -->
89+
<shortcode country="es" premium="[23][57]\\d{3}|280\\d{2}|[79]9[57]\\d{3}" free="116\\d{3}" />
90+
91+
<!-- Finland: 5-6 digits, premium 0600, 0700: http://en.wikipedia.org/wiki/Telephone_numbers_in_Finland -->
92+
<shortcode country="fi" pattern="\\d{5,6}" premium="0600.*|0700.*|171(?:59|63)" free="116\\d{3}" />
93+
94+
<!-- France: 5 digits, free: 3xxxx, premium [4-8]xxxx, plus EU:
95+
http://clients.txtnation.com/entries/161972-france-premium-sms-short-code-requirements -->
96+
<shortcode country="fr" premium="[4-8]\\d{4}" free="3\\d{4}|116\\d{3}" />
97+
98+
<!-- United Kingdom (Great Britain): 4-6 digits, common codes [5-8]xxxx, plus EU:
99+
http://www.short-codes.com/media/Co-regulatoryCodeofPracticeforcommonshortcodes170206.pdf -->
100+
<shortcode country="gb" pattern="\\d{4,6}" premium="[5-8]\\d{4}" free="116\\d{3}" />
101+
102+
<!-- Georgia: 4 digits, known premium codes listed -->
103+
<shortcode country="ge" pattern="\\d{4}" premium="801[234]|888[239]" />
104+
105+
<!-- Greece: 5 digits (54xxx, 19yxx, x=0-9, y=0-5): http://www.cmtelecom.com/premium-sms/greece -->
106+
<shortcode country="gr" pattern="\\d{5}" premium="54\\d{3}|19[0-5]\\d{2}" free="116\\d{3}" />
107+
108+
<!-- Hungary: 4 or 10 digits starting with 1 or 0, plus EU:
109+
http://clients.txtnation.com/entries/209633-hungary-premium-sms-short-code-regulations -->
110+
<shortcode country="hu" pattern="[01](?:\\d{3}|\\d{9})" premium="0691227910|1784" free="116\\d{3}" />
111+
112+
<!-- Ireland: 5 digits, 5xxxx (50xxx=free, 5[12]xxx=standard), plus EU:
113+
http://www.comreg.ie/_fileupload/publications/ComReg1117.pdf -->
114+
<shortcode country="ie" pattern="\\d{5}" premium="5[3-9]\\d{3}" free="50\\d{3}|116\\d{3}" standard="5[12]\\d{3}" />
115+
116+
<!-- Israel: 4 digits, known premium codes listed -->
117+
<shortcode country="il" pattern="\\d{4}" premium="4422|4545" />
118+
119+
<!-- Italy: 5 digits (premium=4xxxx), plus EU:
120+
http://clients.txtnation.com/attachments/token/di5kfblvubttvlw/?name=Italy_CASP_EN.pdf -->
121+
<shortcode country="it" pattern="\\d{5}" premium="4\\d{4}" free="116\\d{3}" />
122+
123+
<!-- Kyrgyzstan: 4 digits, known premium codes listed -->
124+
<shortcode country="kg" pattern="\\d{4}" premium="415[2367]|444[69]" />
125+
126+
<!-- Kazakhstan: 4 digits, known premium codes listed: http://smscoin.net/info/pricing-kazakhstan/ -->
127+
<shortcode country="kz" pattern="\\d{4}" premium="335[02]|4161|444[469]|77[2359]0|8444|919[3-5]|968[2-5]" />
128+
129+
<!-- Lithuania: 3-5 digits, known premium codes listed, plus EU -->
130+
<shortcode country="lt" pattern="\\d{3,5}" premium="13[89]1|1394|16[34]5" free="116\\d{3}" />
131+
132+
<!-- Luxembourg: 5 digits, 6xxxx, plus EU:
133+
http://www.luxgsm.lu/assets/files/filepage/file_1253803400.pdf -->
134+
<shortcode country="lu" premium="6\\d{4}" free="116\\d{3}" />
135+
136+
<!-- Latvia: 4 digits, known premium codes listed, plus EU -->
137+
<shortcode country="lv" pattern="\\d{4}" premium="18(?:19|63|7[1-4])" free="116\\d{3}" />
138+
139+
<!-- Mexico: 4-5 digits (not confirmed), known premium codes listed -->
140+
<shortcode country="mx" pattern="\\d{4,5}" premium="53035|7766" />
141+
142+
<!-- Malaysia: 5 digits: http://www.skmm.gov.my/attachment/Consumer_Regulation/Mobile_Content_Services_FAQs.pdf -->
143+
<shortcode country="my" pattern="\\d{5}" premium="32298|33776" />
144+
145+
<!-- The Netherlands, 4 digits, known premium codes listed, plus EU -->
146+
<shortcode country="nl" pattern="\\d{4}" premium="4466|5040" free="116\\d{3}" />
147+
148+
<!-- Norway: 4-5 digits (not confirmed), known premium codes listed -->
149+
<shortcode country="no" pattern="\\d{4,5}" premium="2201|222[67]" />
150+
151+
<!-- New Zealand: 3-4 digits, known premium codes listed -->
152+
<shortcode country="nz" pattern="\\d{3,4}" premium="3903|8995" />
153+
154+
<!-- Poland: 4-5 digits (not confirmed), known premium codes listed, plus EU -->
155+
<shortcode country="pl" pattern="\\d{4,5}" premium="74240|79(?:10|866)|92525" free="116\\d{3}" />
156+
157+
<!-- Portugal: 5 digits, plus EU:
158+
http://clients.txtnation.com/entries/158326-portugal-premium-sms-short-code-regulations -->
159+
<shortcode country="pt" premium="6[1289]\\d{3}" free="116\\d{3}" />
160+
161+
<!-- Romania: 4 digits, plus EU: http://www.simplus.ro/en/resources/glossary-of-terms/ -->
162+
<shortcode country="ro" pattern="\\d{4}" premium="12(?:63|66|88)|13(?:14|80)" free="116\\d{3}" />
163+
164+
<!-- Russia: 4 digits, known premium codes listed: http://smscoin.net/info/pricing-russia/ -->
165+
<shortcode country="ru" pattern="\\d{4}" premium="1(?:1[56]1|899)|2(?:09[57]|322|47[46]|880|990)|3[589]33|4161|44(?:4[3-9]|81)|77(?:33|81)" />
166+
167+
<!-- Sweden: 5 digits (72xxx), plus EU: http://www.viatel.se/en/premium-sms/ -->
168+
<shortcode country="se" premium="72\\d{3}" free="116\\d{3}" />
169+
170+
<!-- Singapore: 5 digits: http://clients.txtnation.com/entries/306442-singapore-premium-sms-short-code-requirements
171+
Free government directory info at 74688: http://app.sgdi.gov.sg/sms_help.asp -->
172+
<shortcode country="sg" pattern="7\\d{4}" premium="73800" standard="74688" />
173+
174+
<!-- Slovenia: 4 digits (premium=3xxx, 6xxx, 8xxx), plus EU: http://www.cmtelecom.com/premium-sms/slovenia -->
175+
<shortcode country="si" pattern="\\d{4}" premium="[368]\\d{3}" free="116\\d{3}" />
176+
177+
<!-- Slovakia: 4 digits (premium), plus EU: http://www.cmtelecom.com/premium-sms/slovakia -->
178+
<shortcode country="sk" premium="\\d{4}" free="116\\d{3}" />
179+
180+
<!-- Tajikistan: 4 digits, known premium codes listed -->
181+
<shortcode country="tj" pattern="\\d{4}" premium="11[3-7]1|4161|4333|444[689]" />
182+
183+
<!-- Ukraine: 4 digits, known premium codes listed -->
184+
<shortcode country="ua" pattern="\\d{4}" premium="444[3-9]|70[579]4|7540" />
185+
186+
<!-- USA: 5-6 digits (premium codes from https://www.premiumsmsrefunds.com/ShortCodes.htm) -->
187+
<shortcode country="us" pattern="\\d{5,6}" premium="20433|21(?:344|472)|22715|23(?:333|847)|24(?:15|28)0|25209|27(?:449|606|663)|28498|305(?:00|83)|32(?:340|941)|33(?:166|786|849)|34746|35(?:182|564)|37975|38(?:135|146|254)|41(?:366|463)|42335|43(?:355|500)|44(?:578|711|811)|45814|46(?:157|173|327)|46666|47553|48(?:221|277|669)|50(?:844|920)|51(?:062|368)|52944|54(?:723|892)|55928|56483|57370|59(?:182|187|252|342)|60339|61(?:266|982)|62478|64(?:219|898)|65(?:108|500)|69(?:208|388)|70877|71851|72(?:078|087|465)|73(?:288|588|882|909|997)|74(?:034|332|815)|76426|79213|81946|83177|84(?:103|685)|85797|86(?:234|236|666)|89616|90(?:715|842|938)|91(?:362|958)|94719|95297|96(?:040|666|835|969)|97(?:142|294|688)|99(?:689|796|807)" />
188+
189+
</shortcodes>

telephony/java/com/android/internal/telephony/PhoneBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ protected PhoneBase(PhoneNotifier notifier, Context context, CommandsInterface c
250250

251251
// Initialize device storage and outgoing SMS usage monitors for SMSDispatchers.
252252
mSmsStorageMonitor = new SmsStorageMonitor(this);
253-
mSmsUsageMonitor = new SmsUsageMonitor(context.getContentResolver());
253+
mSmsUsageMonitor = new SmsUsageMonitor(context);
254254
}
255255

256256
public void dispose() {

0 commit comments

Comments
 (0)