Android sending lots of SMS messages

Posted by Robert Parker on Stack Overflow See other posts from Stack Overflow or by Robert Parker
Published on 2009-11-02T20:32:56Z Indexed on 2010/03/17 7:31 UTC
Read the original article Hit count: 816

Filed under:
|

I have a app, which sends a lot of SMS messages to a central server. Each user will probably send ~300 txts/day. SMS messages are being used as a networking layer, because SMS is almost everywhere and mobile internet is not. The app is intended for use in a lot of 3rd world countries where mobile internet is not ubiquitous.

When I hit a limit of 100 messages, I get a prompt for each message sent. The prompt says "A large number of SMS messages are being sent". This is not ok for the user to get prompted each time to ask if the app can send a text message. The user doesn't want to get 30 consecutive prompts.

I found this android source file with google. It could be out of date, I can't tell. It looks like there is a limit of 100 sms messages every 3600000ms(1 day) for each application.

http://www.netmite.com/android/mydroid/frameworks/base/telephony/java/com/android/internal/telephony/gsm/SMSDispatcher.java

/** Default checking period for SMS sent without uesr permit */
private static final int DEFAULT_SMS_CHECK_PERIOD = 3600000;

/** Default number of SMS sent in checking period without uesr permit */
private static final int DEFAULT_SMS_MAX_ALLOWED = 100;

and

/**
 *  Implement the per-application based SMS control, which only allows
 *  a limit on the number of SMS/MMS messages an app can send in checking
 *  period.
 */
private class SmsCounter {
    private int mCheckPeriod;
    private int mMaxAllowed;
    private HashMap<String, ArrayList<Long>> mSmsStamp;

    /**
     * Create SmsCounter
     * @param mMax is the number of SMS allowed without user permit
     * @param mPeriod is the checking period
     */
    SmsCounter(int mMax, int mPeriod) {
        mMaxAllowed = mMax;
        mCheckPeriod = mPeriod;
        mSmsStamp = new HashMap<String, ArrayList<Long>> ();
    }

    boolean check(String appName) {
        if (!mSmsStamp.containsKey(appName)) {
            mSmsStamp.put(appName, new ArrayList<Long>());
        }

        return isUnderLimit(mSmsStamp.get(appName));
    }

    private boolean isUnderLimit(ArrayList<Long> sent) {
        Long ct =  System.currentTimeMillis();

        Log.d(TAG, "SMS send size=" + sent.size() + "time=" + ct);

        while (sent.size() > 0 && (ct - sent.get(0)) > mCheckPeriod ) {
                sent.remove(0);
        }

        if (sent.size() < mMaxAllowed) {
            sent.add(ct);
            return true;
        }
        return false;
    }
}

Is this even the real android code? It looks like it is in the package "com.android.internal.telephony.gsm", I can't find this package on the android website.

How can I disable/modify this limit? I've been googling for solutions, but I haven't found anything.

© Stack Overflow or respective owner

Related posts about android

Related posts about sms