Merge "Allow apps with SEND_SMS_NO_CONFIRMATION to bypass short code check." into jb-dev

This commit is contained in:
Jake Hamby
2012-05-29 13:54:19 -07:00
committed by Android (Google) Code Review
2 changed files with 6 additions and 32 deletions

View File

@@ -78,6 +78,10 @@ public abstract class SMSDispatcher extends Handler {
public static final String RECEIVE_EMERGENCY_BROADCAST_PERMISSION =
"android.permission.RECEIVE_EMERGENCY_BROADCAST";
/** Permission required to send SMS to short codes without user confirmation. */
private static final String SEND_SMS_NO_CONFIRMATION_PERMISSION =
"android.permission.SEND_SMS_NO_CONFIRMATION";
/** Query projection for checking for duplicate message segments. */
private static final String[] PDU_PROJECTION = new String[] {
"pdu"
@@ -944,7 +948,8 @@ public abstract class SMSDispatcher extends Handler {
* @return true if the destination is approved; false if user confirmation event was sent
*/
boolean checkDestination(SmsTracker tracker) {
if (mUsageMonitor.isApprovedShortCodeSender(tracker.mAppPackage)) {
if (mContext.checkCallingOrSelfPermission(SEND_SMS_NO_CONFIRMATION_PERMISSION)
== PackageManager.PERMISSION_GRANTED) {
return true; // app is pre-approved to send to short codes
} else {
String countryIso = mTelephonyManager.getSimCountryIso();

View File

@@ -81,12 +81,6 @@ public class SmsUsageMonitor {
private final HashMap<String, ArrayList<Long>> mSmsStamp =
new HashMap<String, ArrayList<Long>>();
/**
* Hash of package names that are allowed to send to short codes.
* TODO: persist this across reboots.
*/
private final HashSet<String> mApprovedShortCodeSenders = new HashSet<String>();
/** Context for retrieving regexes from XML resource. */
private final Context mContext;
@@ -248,9 +242,6 @@ public class SmsUsageMonitor {
DEFAULT_SMS_CHECK_PERIOD);
mSettingsObserverHandler = new SettingsObserverHandler();
// system MMS app is always allowed to send to short codes
mApprovedShortCodeSenders.add("com.android.mms");
}
/**
@@ -357,28 +348,6 @@ public class SmsUsageMonitor {
}
}
/**
* Return whether the app is approved to send to any short code.
* @param appName the package name of the app requesting to send an SMS
* @return true if the app is approved; false if we need to confirm short code destinations
*/
public boolean isApprovedShortCodeSender(String appName) {
synchronized (mApprovedShortCodeSenders) {
return mApprovedShortCodeSenders.contains(appName);
}
}
/**
* Add app package name to the list of approved short code senders.
* @param appName the package name of the app to add
*/
public void addApprovedShortCodeSender(String appName) {
if (DBG) log("Adding " + appName + " to list of approved short code senders.");
synchronized (mApprovedShortCodeSenders) {
mApprovedShortCodeSenders.add(appName);
}
}
/**
* Check if the destination is a possible premium short code.
* NOTE: the caller is expected to strip non-digits from the destination number with