Handle failed MMS connectivity state appropriately.

This commit is contained in:
Moxie Marlinspike 2013-05-07 15:09:24 -07:00
parent 43214a854c
commit e07c1a8e92
4 changed files with 13 additions and 3 deletions

View File

@ -225,7 +225,7 @@
<string name="MmsMessageRecord_mms_message_encrypted_for_non_existing_session">MMS message encrypted for non-existing session...</string>
<!-- MmsSender -->
<string name="MmsSender_currently_unable_to_send_your_mms_message">Currently unable to send your MMS message. It will be sent once service becomes available.</string>
<string name="MmsSender_currently_unable_to_send_your_mms_message">Currently unable to send your MMS message.</string>
<!-- ApplicationMigrationService -->
<string name="ApplicationMigrationService_import_in_progress">Import in progress</string>

View File

@ -179,7 +179,7 @@ public class MmsDownloader extends MmscProcessor {
if (pendingMessages.isEmpty())
finishConnectivity();
} else if (!isConnected() && !isConnectivityPossible()) {
} else if (!isConnected() && (!isConnectivityPossible() || isConnectivityFailure())) {
pendingMessages.clear();
handleDownloadError(downloadItems, MmsDatabase.Status.DOWNLOAD_NO_CONNECTIVITY,
context.getString(R.string.MmsDownloader_no_connectivity_available_for_mms_download_try_again_later));

View File

@ -170,7 +170,7 @@ public class MmsSender extends MmscProcessor {
protected void handleConnectivityChange() {
if (!isConnected()) {
if (!isConnectivityPossible() && !pendingMessages.isEmpty()) {
if ((!isConnectivityPossible() || isConnectivityFailure()) && !pendingMessages.isEmpty()) {
DatabaseFactory.getMmsDatabase(context).markAsSentFailed(pendingMessages.remove().request.getDatabaseMessageId());
toastHandler.makeToast(context.getString(R.string.MmsSender_currently_unable_to_send_your_mms_message));
Log.w("MmsSender", "Unable to send MMS.");

View File

@ -66,6 +66,8 @@ public abstract class MmscProcessor {
protected void issueConnectivityRequest() {
int status = connectivityManager.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, FEATURE_ENABLE_MMS);
Log.w("MmscProcessor", "startUsingNetworkFeature status: " + status);
if (status == APN_ALREADY_ACTIVE) {
issueConnectivityChange();
} else if (connectivityListener == null) {
@ -77,9 +79,17 @@ public abstract class MmscProcessor {
}
}
protected boolean isConnectivityFailure() {
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(TYPE_MOBILE_MMS);
return networkInfo == null || networkInfo.getDetailedState() == NetworkInfo.DetailedState.FAILED;
}
protected boolean isConnectivityPossible() {
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(TYPE_MOBILE_MMS);
Log.w("MmsService", "Got network info: " + networkInfo);
return networkInfo != null && networkInfo.isAvailable();
}