Skip to content

Commit 8367627

Browse files
author
Jake Hamby
committed
Allow apps with SEND_SMS_NO_CONFIRMATION to bypass short code check.
Change SMSDispatcher to bypass SMS premium short code confirmation dialog when caller has "android.permission.SEND_SMS_NO_CONFIRMATION" permission (instead of checking package name against hardcoded list). This permission is only available to system apps or those signed with the same certificates as those in the system image. Bug: 6502817 Change-Id: I6098d448892cc5e842ba6dc10cf494295e7226af
1 parent 18afc62 commit 8367627

File tree

2 files changed

+6
-32
lines changed

2 files changed

+6
-32
lines changed

telephony/java/com/android/internal/telephony/SMSDispatcher.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ public abstract class SMSDispatcher extends Handler {
7878
public static final String RECEIVE_EMERGENCY_BROADCAST_PERMISSION =
7979
"android.permission.RECEIVE_EMERGENCY_BROADCAST";
8080

81+
/** Permission required to send SMS to short codes without user confirmation. */
82+
private static final String SEND_SMS_NO_CONFIRMATION_PERMISSION =
83+
"android.permission.SEND_SMS_NO_CONFIRMATION";
84+
8185
/** Query projection for checking for duplicate message segments. */
8286
private static final String[] PDU_PROJECTION = new String[] {
8387
"pdu"
@@ -944,7 +948,8 @@ protected void sendRawPdu(byte[] smsc, byte[] pdu, PendingIntent sentIntent,
944948
* @return true if the destination is approved; false if user confirmation event was sent
945949
*/
946950
boolean checkDestination(SmsTracker tracker) {
947-
if (mUsageMonitor.isApprovedShortCodeSender(tracker.mAppPackage)) {
951+
if (mContext.checkCallingOrSelfPermission(SEND_SMS_NO_CONFIRMATION_PERMISSION)
952+
== PackageManager.PERMISSION_GRANTED) {
948953
return true; // app is pre-approved to send to short codes
949954
} else {
950955
String countryIso = mTelephonyManager.getSimCountryIso();

telephony/java/com/android/internal/telephony/SmsUsageMonitor.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,6 @@ public class SmsUsageMonitor {
8181
private final HashMap<String, ArrayList<Long>> mSmsStamp =
8282
new HashMap<String, ArrayList<Long>>();
8383

84-
/**
85-
* Hash of package names that are allowed to send to short codes.
86-
* TODO: persist this across reboots.
87-
*/
88-
private final HashSet<String> mApprovedShortCodeSenders = new HashSet<String>();
89-
9084
/** Context for retrieving regexes from XML resource. */
9185
private final Context mContext;
9286

@@ -248,9 +242,6 @@ public SmsUsageMonitor(Context context) {
248242
DEFAULT_SMS_CHECK_PERIOD);
249243

250244
mSettingsObserverHandler = new SettingsObserverHandler();
251-
252-
// system MMS app is always allowed to send to short codes
253-
mApprovedShortCodeSenders.add("com.android.mms");
254245
}
255246

256247
/**
@@ -357,28 +348,6 @@ public boolean check(String appName, int smsWaiting) {
357348
}
358349
}
359350

360-
/**
361-
* Return whether the app is approved to send to any short code.
362-
* @param appName the package name of the app requesting to send an SMS
363-
* @return true if the app is approved; false if we need to confirm short code destinations
364-
*/
365-
public boolean isApprovedShortCodeSender(String appName) {
366-
synchronized (mApprovedShortCodeSenders) {
367-
return mApprovedShortCodeSenders.contains(appName);
368-
}
369-
}
370-
371-
/**
372-
* Add app package name to the list of approved short code senders.
373-
* @param appName the package name of the app to add
374-
*/
375-
public void addApprovedShortCodeSender(String appName) {
376-
if (DBG) log("Adding " + appName + " to list of approved short code senders.");
377-
synchronized (mApprovedShortCodeSenders) {
378-
mApprovedShortCodeSenders.add(appName);
379-
}
380-
}
381-
382351
/**
383352
* Check if the destination is a possible premium short code.
384353
* NOTE: the caller is expected to strip non-digits from the destination number with

0 commit comments

Comments
 (0)