aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java4
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java2
-rw-r--r--src/main/java/de/pixart/messenger/parser/PresenceParser.java4
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java10
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java3
5 files changed, 18 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
index ae897a8e7..44f66735e 100644
--- a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
+++ b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
@@ -189,7 +189,9 @@ public class HttpDownloadConnection implements Transferable {
return;
}
file.setExpectedSize(size);
- if (mHttpConnectionManager.hasStoragePermission() && size <= mHttpConnectionManager.getAutoAcceptFileSize()) {
+ if (mHttpConnectionManager.hasStoragePermission()
+ && size <= mHttpConnectionManager.getAutoAcceptFileSize()
+ && mXmppConnectionService.isDataSaverDisabled()) {
HttpDownloadConnection.this.acceptedAutomatically = true;
new Thread(new FileDownloader(interactive)).start();
} else {
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index fa2d1f642..dda9163e8 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -238,7 +238,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
mXmppConnectionService.updateConversationUi();
mXmppConnectionService.updateRosterUi();
}
- } else {
+ } else if (mXmppConnectionService.isDataSaverDisabled()) {
mXmppConnectionService.fetchAvatar(account, avatar);
}
}
diff --git a/src/main/java/de/pixart/messenger/parser/PresenceParser.java b/src/main/java/de/pixart/messenger/parser/PresenceParser.java
index c2e1f3c70..31f2fdcae 100644
--- a/src/main/java/de/pixart/messenger/parser/PresenceParser.java
+++ b/src/main/java/de/pixart/messenger/parser/PresenceParser.java
@@ -104,7 +104,7 @@ public class PresenceParser extends AbstractParser implements
if (user.setAvatar(avatar)) {
mXmppConnectionService.getAvatarService().clear(user);
}
- } else {
+ } else if (mXmppConnectionService.isDataSaverDisabled()) {
mXmppConnectionService.fetchAvatar(mucOptions.getAccount(), avatar);
}
}
@@ -191,7 +191,7 @@ public class PresenceParser extends AbstractParser implements
mXmppConnectionService.updateConversationUi();
mXmppConnectionService.updateRosterUi();
}
- } else {
+ } else if (mXmppConnectionService.isDataSaverDisabled()){
mXmppConnectionService.fetchAvatar(account, avatar);
}
}
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 44aa13177..1c9defe11 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -695,6 +695,16 @@ public class XmppConnectionService extends Service {
return START_STICKY;
}
+ public boolean isDataSaverDisabled() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
+ return !connectivityManager.isActiveNetworkMetered()
+ || connectivityManager.getRestrictBackgroundStatus() == ConnectivityManager.RESTRICT_BACKGROUND_STATUS_DISABLED;
+ } else {
+ return true;
+ }
+ }
+
private void directReply(Conversation conversation, String body) {
Message message = new Message(conversation,body,conversation.getNextEncryption());
message.markUnread();
diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
index 29c5acfb8..0c8eec2bb 100644
--- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
@@ -393,7 +393,8 @@ public class JingleConnection implements Transferable {
conversation.add(message);
mXmppConnectionService.updateConversationUi();
if (mJingleConnectionManager.hasStoragePermission()
- && size < this.mJingleConnectionManager.getAutoAcceptFileSize()) {
+ && size < this.mJingleConnectionManager.getAutoAcceptFileSize()
+ && mXmppConnectionService.isDataSaverDisabled()) {
Log.d(Config.LOGTAG, "auto accepting file from "+ packet.getFrom());
this.acceptedAutomatically = true;
this.sendAccept();