This is for the Verizon LTE version of the Samsung Galaxy Nexus.
I am tasked with writing a tiny app that will effectively disable/enable 4G capability. This can be done manually via settings > mobile network > network mode and choosing either LTE/CDMA (4g enabled) or CDMA (3g only).
I have not tried anything yet because Android development isn't my strong suit. I am looking for guidance... examples, code samples etc. I am assuming this should almost be a one-liner, but it has been my experience that with Android development nothing is as simple as it appears.
Any help will be greatly appreciated.
There is a preference in the Settings.Secure class that is hidden from the SDK:
/**
* The preferred network mode 7 = Global
* 6 = EvDo only
* 5 = CDMA w/o EvDo
* 4 = CDMA / EvDo auto
* 3 = GSM / WCDMA auto
* 2 = WCDMA only
* 1 = GSM only
* 0 = GSM / WCDMA preferred
* #hide
*/
public static final String PREFERRED_NETWORK_MODE =
"preferred_network_mode";
You could use Reflection on this or just localize the constant to your project. The problem with this is that you cannot change the value of this setting (as with all secure settings), you can only read it. The aforementioned values are not the only possible ones, there are actually a few more located in com.android.internal.telephony.RILConstants, which is again hidden from the SDK and would require Reflection to access.
There is another hidden method in TelephonyManager, but again it is read only there is no other method for setting this constant. This would tell you exactly what you want to know, whether the device is set to "LTE/ CDMA" (LTE_ON_CDMA_TRUE) or "CDMA only" (LTE_ON_CDMA_FALSE):
/**
* Return if the current radio is LTE on CDMA. This
* is a tri-state return value as for a period of time
* the mode may be unknown.
*
* #return {#link Phone#LTE_ON_CDMA_UNKNOWN}, {#link Phone#LTE_ON_CDMA_FALSE}
* or {#link Phone#LTE_ON_CDMA_TRUE}
*
* #hide
*/
public int getLteOnCdmaMode() {
try {
return getITelephony().getLteOnCdmaMode();
} catch (RemoteException ex) {
// Assume no ICC card if remote exception which shouldn't happen
return Phone.LTE_ON_CDMA_UNKNOWN;
} catch (NullPointerException ex) {
// This could happen before phone restarts due to crashing
return Phone.LTE_ON_CDMA_UNKNOWN;
}
}
From my research you could not make such an application without root access and using something like setprop from the command line, but even then you may need to restart the entire Telephony process in order for this setting to take effect.
Finally, if you are still interested see com.android.phone.Settings to see how the system handles this toggle. It is rather elaborate, and as I mentioned would require permissions that a normal Android application would not be granted.
I'm also interested in changing the settings WCDMA-only, WCDMA/LTE, ...
I found the way to change Settings.secure.* with root privilege as is shown the below.
new ExecuteAsRootBase() {
#Override
protected ArrayList<String> getCommandsToExecute() {
ArrayList<String> cmds = new ArrayList<String>();
cmds.add("su -c 'chmod 755 "+mySqlite+"'");
cmds.add("echo \"UPDATE secure SET value='"+ value +"' WHERE name='"+ key +"'; \" | "+mySqlite+" /data/data/com.android.providers.settings/databases/settings.db");
//TODO: SQL injection can be done!!!
return cmds;
}
}.execute();
ExecuteAsRootBase is introduced here, and mySqlite is "/data/data/"+context.getPackageName()+"/files/sqlite3" where sqlite3 is put in advance.
However, it seems that we have to call com.android.internal.telephony.Phone.setPreferredNetworkType() for switching (WCDMA only<=>WCDMA/LTE) after setting Settings.secure.PREFERRED_NETWORK_MODE.
My phone (even set Settings.secure.PREFERRED_NETWORK_MODE = 2) attached to LTE network...
All the other answers are correct that this requires access to Settings.Secure. Take a look at how the phone app handles this setting https://github.com/dzo/packages_apps_phone/blob/master/src/com/android/phone/Use2GOnlyCheckBoxPreference.java
or take a look at the Toggle2G app source:
https://github.com/TheMasterBaron/Toggle-2G
http://developer.android.com/reference/android/provider/Settings.System.html
Aside from writing the code in your Activity.java, you will probably have to ask for permission to access these settings in the AndroidManifest.xml. So it's annoying but should be simple enough.
Related
As per documentation for app shortcuts
Rate Limiting
When using the setDynamicShortcuts(), addDynamicShortcuts(), or
updateShortcuts() methods, keep in mind that you might only be able to
call these methods a specific number of times in a background app, an
app with no activities or services currently in the foreground. In a
production environment, you can reset this rate limiting by bringing
your app to the foreground.
What is rate limiting in concern with app shortcuts? when isRateLimitingActive() should be used?
Looking at the source code it seems that the isRateLimitingActive() method returns false if you do not have any remaining calls left to the ShortcutManager API (hence the "0"). I guess rate limiting is needed because the API is resource intensive. I can imagine that at least the following will happen if you update a shortcut:
The launcher app (and other listeners) needs to be notified and starts updating it's UI or whatever is needed (depends on the launcher);
The system needs to store the new dynamic shortcut information;
You could use this method to find out if a call to setDynamicShortcuts(), addDynamicShortcuts() or updateShortcuts() will succeed before even trying to do so.
Source:
/**
* Return {#code true} when rate-limiting is active for the caller application.
*
* <p>See the class level javadoc for details.
*
* #throws IllegalStateException when the user is locked.
*/
public boolean isRateLimitingActive() {
try {
return mService.getRemainingCallCount(mContext.getPackageName(), injectMyUserId())
== 0;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
Bonus: setDynamicShortcuts(), addDynamicShortcuts() or updateShortcuts() return false if they did not succeed due to Rate Limiting.
The recommended maximum number of shortcuts is 4, although it is possible to publish up to 5. You can read more here.
I wanted to use the helper method isLowRamDevice for my app, which streams videos. As I support devices down do API level 15, I had to use ActivityManagerCompat.isLowRamDevice().
I was really confused, that it always returned false, even if I use really old devices. Then I checked the method itself and saw this:
public static boolean isLowRamDevice(#NonNull ActivityManager am) {
if (Build.VERSION.SDK_INT >= 19) {
return ActivityManagerCompatKitKat.isLowRamDevice(am);
}
return false;
}
So no wonder it always returns false on my Android 4.0.4 device. But for me this makes absolutely no sense. Or am I missing something?
So no wonder it always returns false
It does not always return false.
On devices running Android 4.3 or older, it will always return false. That is because the system flag for being a low-RAM device did not exist back then.
On devices running Android 4.4 or higher, it will return the value of the system flag for whether this is a low-RAM device or not:
/**
* Returns true if this is a low-RAM device. Exactly whether a device is low-RAM
* is ultimately up to the device configuration, but currently it generally means
* something in the class of a 512MB device with about a 800x480 or less screen.
* This is mostly intended to be used by apps to determine whether they should turn
* off certain features that require more RAM.
*/
public boolean isLowRamDevice() {
return isLowRamDeviceStatic();
}
/** #hide */
public static boolean isLowRamDeviceStatic() {
return "true".equals(SystemProperties.get("ro.config.low_ram", "false"));
}
(from the ActivityManager source code)
AFAIK, low-RAM devices mostly will be Android One devices. Depending upon where you get your devices, you may not encounter one of those.
For my instrumentation tests I am using Robotium. Mostly I am able to test everything but offline cases.
As soon as I disable data (using adb, F8 shortcut in emulator, etc. ...) the test disconnects. It goes on in the device/emulator but no results are reported.
So, I have got an idea to put just the app in offline mode and not the whole device. The problem is I don't know how...
Using iptablesApi I would need to root my device. I have read that Mobiwol app uses some kind of a VPN to restrict apps internet access without the need of rooting a device.
Question
How does Mobiwol app blocks the internet connection per application? Or is there another way how to test apks offline?
EDIT 12/30/2014
I forgot to say that I am able to run tests offline but I have to start tests when the device is in offline state. Currently, I divided my tests into OFFLINE and ONLINE ones. After running ONLINEs I execute the famous adb kill-server and adb start-server. After that I execute OFFLINEs.
Just making a few suggestions since there seem to be different questions here.
1) If all you want to do is turn off the data before running the OFFLINE test case you might want to simply try using robotium itself to do so..
Example:
For WiFi:
WifiManager wifi=(WifiManager)solo.getCurrentActivity().getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(false);
For Mobile Data(using reflections):
ConnectivityManager dataManager=(ConnectivityManager)solo.getCurrentActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
Method dataClass = ConnectivityManager.class.getDeclaredMethod(“setMobileDataEnabled”, boolean.class);
dataClass.setAccessible(true);
dataClass.invoke(dataManager, true);
You can do the two above calls in the setup() method before running the individual test case in the OFFLINE suite.
Once all the test case in the OFFLINE suite are done with you can enable the WiFi/DATA back on in the teardown() method at the very end.
2) Looking at the app that you posted in the OP, it seems pretty much that it:
Uses the ipTables based on the OS version
Creates a script header based on the UID's for all the applications
that need WiFi/Data
Should be getting the list of installed apps on the device along with
any hidden apps etc from the package manager.
And again executes scripts based on user selection for black list and
overrides the existing rules in the ipTable with the user desired
rules.
Pretty sure though must have been quite hard to code all of that..Sounds much easier in the form of bullet points.
Hope this helps you somewhat.
P.S: If you do figure out something please post an updated answer, would like to know how did you make it work
Update: Make sure you have the neccessary permissions for setting the WiFi/Data on/off in your application manifest. NOT the test apk manifest. IT HAS TO BE THE APPLICATION MANIFEST ITSELF.
There is this library which might help you. Its an extension to solo. http://adventuresinqa.com/2014/02/17/extsolo-library-to-extend-your-robotium-test-automation/
After spending hours trying to do it similar to user2511882s solution, I still had an exception, because of missing permissions (yes the "modify system settings" permission was activated).
I ended up doing it with UI automator:
public static void setAirplaneMode(boolean enable)
{
if ((enable ? 1 : 0) == Settings.System.getInt(getInstrumentation().getContext().getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, 0))
{
return;
}
UiDevice device = UiDevice.getInstance(getInstrumentation());
device.openQuickSettings();
// Find the text of your language
BySelector description = By.desc("Airplane mode");
// Need to wait for the button, as the opening of quick settings is animated.
device.wait(Until.hasObject(description), 500);
device.findObject(description).click();
getInstrumentation().getContext().sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
}
You will need the ACCESS_NETWORK_STATE in your androidTest manifest file:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Don't forget to disable it after the test.
If you have other languages than english, you need to change "Airplane mode" to the text of your language. As I have several translations, I read it from a ressource string.
There is great library from LinkedIn Test Butler, you can enable, disable both WiFi and mobile data by simply calling:
TestButler.setGsmState(false);
TestButler.setWifiState(false);
The main advantage of this library is that it does not require any permission in your manifest, for more details please refer to project website:
https://github.com/linkedin/test-butler
Sorry if I'm oversimplifying this, but what about just putting the phone/emulator in airplane mode? Through the actual user interface. That's what I do to test offline cases.
Here is a solution that uses UiAutomator to enable or disable "Aeroplane mode" from the drop-down status bar, which turns off all networking if enabled. It works on most Android OS versions, and it uses parts of the answer from user Aorlinn (12 October 2019).
app/build.gradle
dependencies {
androidTestImplementation "androidx.test.uiautomator:uiautomator:2.2.0"
}
AndroidManifest.xml
No extra permissions are needed, not even <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> , because UiAutomator is only clicking on a button in the status bar UI. Therefore the app does not need direct access to modify the device's Wifi or mobile data settings.
Kotlin
import android.os.Build
import android.provider.Settings
import androidx.test.espresso.matcher.ViewMatchers.assertThat
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiObjectNotFoundException
import androidx.test.uiautomator.Until
import org.hamcrest.Matchers.`is`
import org.junit.Assert
import org.junit.Assume.assumeNoException
import org.junit.Assume.assumeThat
import java.io.IOException
private var airplaneModeOn = 0
private val OFF = 0
private val ON = 1
private var airplaneModeButtonPosition: Point? = null
/**
* Turn off the Internet connectivity by switching "Aeroplane mode" (flight mode) on. From:
* https://stackoverflow.com/questions/27620976/android-instrumentation-test-offline-cases#68956544
*/
#Test
fun checkAppWillWork_withNoInternetConnection() {
try {
airplaneModeOn = getCurrentAirplaneModeSetting()
} catch (e: Exception) {
e.printStackTrace()
assumeNoException("Cannot retrieve device setting of 'Airplane Mode'. Aborting the test.", e)
}
// Check that Airplane mode is off
assertThat(airplaneModeOn, `is`(OFF))
// Press the "Aeroplane mode" button on the 'Quick Settings' panel
toggleAeroplaneModeButton()
// Verify Airplane mode is on
assumeThat("Cannot change the 'Aeroplane Mode' setting. Test aborted.", airplaneModeOn, `is`(ON))
assertThat(airplaneModeOn, `is`(ON))
// Do some tests when the Internet is down
// Note: Switch the Internet back on in cleanup()
}
/**
* Turn the Internet connectivity on or off by pressing the "Aeroplane mode" button. It opens the
* status bar at the top, then drags it down to reveal the buttons on the 'Quick Settings' panel.
*/
#Throws(UiObjectNotFoundException::class)
private fun toggleAeroplaneModeButton() {
try {
airplaneModeOn = getCurrentAirplaneModeSetting()
} catch (e: SecurityException) {
e.printStackTrace()
Assert.fail()
} catch (e: IOException) {
e.printStackTrace()
Assert.fail()
}
// Open the status bar at the top; drag it down to reveal the buttons
val device = UiDevice.getInstance(getInstrumentation())
device.openQuickSettings()
// Wait for the button to be visible, because opening the Quick Settings is animated.
// You can use any string here; You only need a time delay wait here.
val description = By.desc("AeroplaneMode")
device.wait(Until.hasObject(description), 2000)
// Search for and click the button
var buttonClicked = clickObjectIfFound(device,
"Aeroplane mode", "Airplane mode", "機内モード", "Modo avión")
if (!buttonClicked) {
// Swipe the Quick Panel window to the LEFT, if possible
val screenWidth = device.displayWidth
val screenHeight = device.displayHeight
device.swipe((screenWidth * 0.80).toInt(), (screenHeight * 0.30).toInt(),
(screenWidth * 0.20).toInt(), (screenHeight * 0.30).toInt(), 50)
buttonClicked = clickObjectIfFound(device,
"Aeroplane mode", "Airplane mode", "機内モード", "Modo avión")
}
if (!buttonClicked) {
// Swipe the Quick Panel window to the RIGHT, if possible
val screenWidth = device.displayWidth
val screenHeight = device.displayHeight
device.swipe((screenWidth * 0.20).toInt(), (screenHeight * 0.30).toInt(),
(screenWidth * 0.80).toInt(), (screenHeight * 0.30).toInt(), 50)
clickObjectIfFound(device,
"Aeroplane mode", "Airplane mode", "機内モード", "Modo avión")
}
// Wait for the Internet to disconnect or re-connect
device.wait(Until.hasObject(description), 6000)
// Close the Quick Settings panel
getInstrumentation().context
.sendBroadcast(Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))
// Verify change in device settings
try {
airplaneModeOn = getCurrentAirplaneModeSetting()
} catch (e: SecurityException) {
e.printStackTrace()
Assert.fail()
} catch (e: IOException) {
e.printStackTrace()
Assert.fail()
}
}
/**
* On Android 8/9, use an 'adb shell' command to retrieve the "Airplane Mode" setting, like this:
*
*
* `adb shell settings list global | grep airplane_mode_on ==> "airplane_mode_on=0"`
*
*
* (But note that grep is not available on the Android shell. See guidance URLs below)
*
*
* * https://www.reddit.com/r/tasker/comments/fbi5ai/psa_you_can_use_adb_to_find_all_the_settings_that/
* * https://stackoverflow.com/questions/33970956/test-if-soft-keyboard-is-visible-using-espresso
*
*
* On all other Android OS versions, use `Settings.System.getInt()` to retrieve the "Airplane Mode" setting.
* It sets `airplaneModeOn = 1 (true)` or `airplaneModeOn = 0 (false)`
*
* #throws IOException if `executeShellCommand()` didn't work
* #throws SecurityException if `Settings.System.getInt()` didn't work
*/
#Throws(IOException::class, SecurityException::class)
private fun getCurrentAirplaneModeSetting(): Int {
if (Build.VERSION.SDK_INT in 26..28 /*Android 8-9*/) {
val shellResponse = UiDevice
.getInstance(getInstrumentation())
.executeShellCommand("settings list global")
airplaneModeOn = when {
shellResponse.contains("airplane_mode_on=1") -> 1
shellResponse.contains("airplane_mode_on=0") -> 0
else -> throw IOException("Unsuitable response from adb shell command 'settings list global'")
}
} else {
// Oddly this causes a SecurityException on Android 8,9 devices
airplaneModeOn = Settings.System.getInt(
getInstrumentation().context.contentResolver,
Settings.Global.AIRPLANE_MODE_ON,
0)
}
return airplaneModeOn
}
/**
* Make UiAutomator search for and click a single button, based on its text label.
*
* Sometimes multiple buttons will match the required text label. For example,
* when Airplane mode is switched on, "Mobile data Aeroplane mode" and "Aeroplane mode"
* are 2 separate buttons on the Quick Settings panel, on Android 10+.
* For Aeroplane mode, always click on the last matched item.
*
* #param textLabels You must supply the language variants of the button that you want to click,
* for example "Cancel" (English), "Cancelar" (Spanish), "취소" (Korean)
* #return True if a button was found and clicked, otherwise return false
*/
private fun clickObjectIfFound(device: UiDevice, vararg textLabels: String): Boolean {
for (languageVariant in textLabels) {
val availableButtons = device.findObjects(By.text(languageVariant))
if (availableButtons.size >= 1) {
if (airplaneModeButtonPosition == null) {
availableButtons[availableButtons.size - 1].click()
airplaneModeButtonPosition = availableButtons[availableButtons.size - 1].visibleCenter
return true
} else {
// Use the stored position to avoid clicking on the wrong button
for (button in availableButtons) {
if (button.visibleCenter == airplaneModeButtonPosition) {
button.click()
airplaneModeButtonPosition = null
return true
}
}
}
}
}
return false
}
#After
fun cleanup() {
// Switch the Internet connectivity back on, for other tests.
if (airplaneModeOn == ON) {
toggleAeroplaneModeButton()
assertThat(airplaneModeOn, `is`(OFF))
}
}
You will have to adjust the string "Aeroplane mode" if your device is in a different language to English. For example, you could check for about 70 language translations here: https://github.com/aosp-mirror/platform_frameworks_base/search?q=global_actions_toggle_airplane_mode
Due to #user2511882 answer you can use Application context instead of Activity in Android X Test via:
internal fun switchWifi(value: Boolean) {
val wifiManager = ApplicationProvider.getApplicationContext<YourApplicationClass>().getSystemService(Context.WIFI_SERVICE) as WifiManager
wifiManager.isWifiEnabled = value}
Consider that this approach only works on API <= 28. There are other approaches like using UI Automator or API > 28
I am trying to trace the wifi settings code. My intention is to know the flow from application to kernel layer after toggling the WIFI button OFF to ON.
While we go to Settings page in Android, toggle the WLAN(WIFI) button, then
your wifi should be enabled.
I found that this page corresponds to WifiSettings.java. In this file, while you toggle the button from OFF to ON:
private void updateWifiState(int state) {
getActivity().invalidateOptionsMenu();
switch (state) {
case WifiManager.WIFI_STATE_ENABLING:
addMessagePreference(R.string.wifi_starting);
break;
}
mLastInfo = null;
mLastState = null;
mScanner.pause();
}
This function will be called.
I then go to check WifiManager.java. I found:
/**
* Wi-Fi is currently being enabled. The state will change to
{#link#WIFI_STATE_ENABLED}
if it finishes successfully.
*
* #see #WIFI_STATE_CHANGED_ACTION
* #see #getWifiState()
*/
public static final int WIFI_STATE_ENABLING = 2;
However, after this, I did not really understand how to dig deeper in tracing the flow.
You should look at WifiEnabler.java, since the code you mentioned just shows some string.
In WifiEnabler::onCheckChanged(), you can see that mWifiManager.setWifiEnabled() is called.
After that, you may look at WifiManager.java and other related files in that directory. There is a state machine and you should trace the state transitions.
Generally, Android is using wpa_supplicant, which is nearly the same as Linux. The configuration file is at /data/misc/wifi/wpa_supplicant.conf, and is generated by Android. After you toggle the wifi switch, Android starts wpa_supplicant and communicates with it. The wpa_supplicant is in charge of scanning and connecting to wifi station.
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.
So I was looking at the link that commonsware.com posted, and I found that the source had actually changed. And so I might still have a shot.
int check_period = Settings.Gservices.getInt(mResolver,
Settings.Gservices.SMS_OUTGOING_CEHCK_INTERVAL_MS,
DEFAULT_SMS_CHECK_PERIOD);
int max_count = Settings.Gservices.getInt(mResolver,
Settings.Gservices.SMS_OUTGOING_CEHCK_MAX_COUNT,
DEFAULT_SMS_MAX_COUNT);
mCounter = new SmsCounter(max_count, check_period);
This is getting checkPeriod and maxCount from a settings table. But I don't seem to have access to the same table. That source should be Android 1.1, which is the same I'm using. When I try to import android.provider.Settings.Gservices, I get an error saying that the import can't be resolved.
What is going on?
Did you try using "import android.provider.Settings;" instead of "import android.provider.Settings.GServices"? (see line 36 of SMSDispatcher.java)
Also, not sure how much difference it makes, but 3600000 ms is one hour not one day.
Unfortunately I think you only have a few options
1) Get root access and alter the settings table directly by doing:
sqlite3 /data/data/com.android.providers.settings/databases/settings.db
sqlite> INSERT INTO gservices (name, value) VALUES
('sms_outgoing_check_interval_ms', 0);
2) Use multiple apps since it's a per app limit
3) Perhaps take out the battery after you reach the limit? It looks like the limit is stored in memory. I haven't tried this yet though.
This appears to be built into the Android source tree, so the only way to push this change down to the users would be the build your own ROM and have them install it.
As for ideas on getting around it, why not check for network connectivity first rather than just assuming it doesn't exist. Even if it is not present on a significant majority of devices today, that certainly won't always be the case. Let SMS be the fall back mechanism. If it is the fall back mechanism, you can then prompt the user letting them know that they will be prompted to confirm the level of SMS activity every 100 messages or so. Who knows, they may roam into a Wifi hotspot and have connectivity part of the day too.
Otherwise, you will get into a game of installing a bunch of other Activities+Intents that can act as silent SMS proxies to get around the limit. Of course, this has its own certain set of undesirable qualities as well and I can hardly believe I just typed/suggested something that evil.