From c489b6a8ebf75862959a3b32fb50e7af84852c86 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 6 Dec 2017 16:57:43 +0100 Subject: [PATCH] put device id into setting for doze --- .../siacs/conversations/ui/ConversationActivity.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 3e161f9b1..efa641aa8 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -1520,14 +1520,19 @@ public class ConversationActivity extends XmppActivity return connection == null ? -1 : connection.getFeatures().getMaxHttpUploadSize(); } + private String getBatteryOptimizationPreferenceKey() { + @SuppressLint("HardwareIds") String device = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID); + return "show_battery_optimization"+(device == null ? "" : device); + } + private void setNeverAskForBatteryOptimizationsAgain() { - getPreferences().edit().putBoolean("show_battery_optimization", false).apply(); + getPreferences().edit().putBoolean(getBatteryOptimizationPreferenceKey(), false).apply(); } private void openBatteryOptimizationDialogIfNeeded() { if (hasAccountWithoutPush() && isOptimizingBattery() - && getPreferences().getBoolean("show_battery_optimization", true)) { + && getPreferences().getBoolean(getBatteryOptimizationPreferenceKey(), true)) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.battery_optimizations_enabled); builder.setMessage(R.string.battery_optimizations_enabled_dialog); @@ -1560,7 +1565,7 @@ public class ConversationActivity extends XmppActivity private boolean hasAccountWithoutPush() { for(Account account : xmppConnectionService.getAccounts()) { - if (account.getStatus() != Account.State.DISABLED && !xmppConnectionService.getPushManagementService().available(account)) { + if (account.getStatus() == Account.State.ONLINE && !xmppConnectionService.getPushManagementService().available(account)) { return true; } }