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

Commit db20c5e6 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

IccSmsInterfaceManager: Don't intercept short-code premium messages

For both charging and potential timing factors on emergency and carrier
services, short codes should be delivered directly to the network.

Change-Id: If9d288048f9925573f8c5f2e51f0c2df789277bd
parent 553635e8
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.os.Message;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.telephony.Rlog;
import android.telephony.TelephonyManager;
import android.util.Log;

import com.android.internal.telephony.ISms;
@@ -823,4 +824,28 @@ public class IccSmsInterfaceManager extends ISms.Stub {
    public String getImsSmsFormat() {
        return mDispatcher.getImsSmsFormat();
    }

    /** @hide **/
    public boolean isShortSMSCode(String destAddr) {
        TelephonyManager telephonyManager;
        int smsCategory = SmsUsageMonitor.CATEGORY_NOT_SHORT_CODE;

        telephonyManager =(TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);

        String countryIso = telephonyManager.getSimCountryIso();
        if (countryIso == null || countryIso.length() != 2) {
            countryIso = telephonyManager.getNetworkCountryIso();
        }

        smsCategory = SmsUsageMonitor.mergeShortCodeCategories(smsCategory,
                mPhone.mSmsUsageMonitor.checkDestination(destAddr, countryIso));

        if (smsCategory == SmsUsageMonitor.CATEGORY_NOT_SHORT_CODE
                || smsCategory == SmsUsageMonitor.CATEGORY_FREE_SHORT_CODE
                || smsCategory == SmsUsageMonitor.CATEGORY_STANDARD_SHORT_CODE) {
            return false;    // not a premium short code
        }

        return true;
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -186,6 +186,11 @@ public class IccSmsInterfaceManagerProxy extends ISms.Stub {
        mContext.enforceCallingPermission(
                android.Manifest.permission.SEND_SMS,
                "Sending SMS message");
        if (mIccSmsInterfaceManager.isShortSMSCode(destAddr)) {
            mIccSmsInterfaceManager.sendText(callingPackage, destAddr, scAddr, text,
                    sentIntent, deliveryIntent);
            return;
        }
        ArrayList<String> parts = new ArrayList<String>();
        parts.add(text);
        ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
@@ -203,6 +208,11 @@ public class IccSmsInterfaceManagerProxy extends ISms.Stub {
        mContext.enforceCallingPermission(
                android.Manifest.permission.SEND_SMS,
                "Sending SMS message");
        if (mIccSmsInterfaceManager.isShortSMSCode(destAddr)) {
            mIccSmsInterfaceManager.sendMultipartText(callingPackage, destAddr, scAddr,
                    parts, sentIntents, deliveryIntents);
            return;
        }
        broadcastOutgoingSms(callingPackage, destAddr, scAddr, true, new ArrayList<String>(parts),
                new ArrayList<PendingIntent>(sentIntents), new ArrayList<PendingIntent>(deliveryIntents),
                -1);