From 8e025cbb9eea8d9505141026731ce5c5184d123f Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 12 Jan 2017 23:22:02 +0100 Subject: [PATCH] show doze warning when push is running on prosody --- .../siacs/conversations/services/PushManagementService.java | 4 ++++ .../java/eu/siacs/conversations/ui/ConversationActivity.java | 2 +- .../java/eu/siacs/conversations/ui/EditAccountActivity.java | 2 +- .../siacs/conversations/services/PushManagementService.java | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/free/java/eu/siacs/conversations/services/PushManagementService.java b/src/free/java/eu/siacs/conversations/services/PushManagementService.java index c6c5d2324..ffce90b8a 100644 --- a/src/free/java/eu/siacs/conversations/services/PushManagementService.java +++ b/src/free/java/eu/siacs/conversations/services/PushManagementService.java @@ -21,4 +21,8 @@ public class PushManagementService { public boolean isStub() { return true; } + + public boolean availableAndUseful(Account account) { + return false; + } } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 11fa76c29..871fa6048 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -1498,7 +1498,7 @@ public class ConversationActivity extends XmppActivity private boolean hasAccountWithoutPush() { for(Account account : xmppConnectionService.getAccounts()) { if (account.getStatus() != Account.State.DISABLED - && !xmppConnectionService.getPushManagementService().available(account)) { + && !xmppConnectionService.getPushManagementService().availableAndUseful(account)) { return true; } } diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 81d26b39d..2080ddc0b 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -836,7 +836,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat if (this.mAccount.isOnlineAndConnected() && !this.mFetchingAvatar) { Features features = this.mAccount.getXmppConnection().getFeatures(); this.mStats.setVisibility(View.VISIBLE); - boolean showBatteryWarning = !xmppConnectionService.getPushManagementService().available(mAccount) && isOptimizingBattery(); + boolean showBatteryWarning = !xmppConnectionService.getPushManagementService().availableAndUseful(mAccount) && isOptimizingBattery(); boolean showDataSaverWarning = isAffectedByDataSaver(); showOsOptimizationWarning(showBatteryWarning,showDataSaverWarning); this.mSessionEst.setText(UIHelper.readableTimeDifferenceFull(this, this.mAccount.getXmppConnection() diff --git a/src/playstore/java/eu/siacs/conversations/services/PushManagementService.java b/src/playstore/java/eu/siacs/conversations/services/PushManagementService.java index ae86f8c26..83d20aed3 100644 --- a/src/playstore/java/eu/siacs/conversations/services/PushManagementService.java +++ b/src/playstore/java/eu/siacs/conversations/services/PushManagementService.java @@ -106,6 +106,10 @@ public class PushManagementService { return connection != null && connection.getFeatures().push() && playServicesAvailable(); } + public boolean availableAndUseful(Account account) { + return account.getServerIdentity() == XmppConnection.Identity.EJABBERD && available(account); + } + private boolean playServicesAvailable() { return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(mXmppConnectionService) == ConnectionResult.SUCCESS; }