Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d820ecc authored by Jake Hamby's avatar Jake Hamby Committed by Android (Google) Code Review
Browse files

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

parents de1ddd0f 8367627f
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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();
+0 −31
Original line number Diff line number Diff line
@@ -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