mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Handle failed MMS connectivity state appropriately.
This commit is contained in:
parent
43214a854c
commit
e07c1a8e92
@ -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>
|
||||
|
@ -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));
|
||||
|
@ -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.");
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user