From 2b1490c00fc7c8505931510d31aac12c68bae513 Mon Sep 17 00:00:00 2001 From: 4RK4N <4rk4nus@googlemail.com> Date: Fri, 2 Feb 2024 23:35:37 +0100 Subject: [PATCH 01/13] NL sends braodcasts onPosted don't initialize readReciever and keepAliveReciever when patched_es = false time_interval = 5_min * 1.00 --- app/src/main/java/esel/esel/esel/Esel.java | 10 ++++++++-- .../esel/esel/datareader/EsNotificationListener.java | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/esel/esel/esel/Esel.java b/app/src/main/java/esel/esel/esel/Esel.java index 639059e..6983122 100644 --- a/app/src/main/java/esel/esel/esel/Esel.java +++ b/app/src/main/java/esel/esel/esel/Esel.java @@ -6,6 +6,8 @@ import esel.esel.esel.receivers.KeepAliveReceiver; import esel.esel.esel.receivers.ReadReceiver; +import esel.esel.esel.util.SP; + /** * Created by adrian on 04/08/17. */ @@ -23,8 +25,12 @@ public void onCreate() { super.onCreate(); sInstance = this; sResources = getResources(); - startReadReceiver(); - startKeepAliveService(); + + boolean use_patched_es = SP.getBoolean("use_patched_es", true); + if (!use_patched_es) { + startReadReceiver(); + startKeepAliveService(); + } } public static Esel getsInstance() { diff --git a/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java b/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java index 18af204..823a2db 100644 --- a/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java +++ b/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java @@ -9,6 +9,7 @@ import java.util.List; import esel.esel.esel.util.SP; +import esel.esel.esel.receivers.ReadReceiver; /** * Created by bernhard on 24-01-18. @@ -16,6 +17,7 @@ public class EsNotificationListener extends NotificationListenerService { private static List lastReadings = new ArrayList(); + private static final ReadReceiver rr = new ReadReceiver(); @Override public void onNotificationPosted(StatusBarNotification sbn) { @@ -37,6 +39,10 @@ public void onNotificationPosted(StatusBarNotification sbn) { } catch (NumberFormatException err) { err.printStackTrace(); } + + long lastReadingTime = SP.getLong("lastReadingTime", System.currentTimeMillis()); + rr.broadcastData(null, lastReadingTime, true); + } } @@ -80,7 +86,7 @@ public static SGV generateSGV(Notification notification ,int record){ SGV oldSgv = lastReadings.get(lastReadings.size() - 1); long lastreadingtime = oldSgv.timestamp; // SP.getLong("lastreadingtime_nl",timestamp); int lastreadingvalue = oldSgv.raw; //SP.getInt("lastreadingvalue_nl",value); - if (value == lastreadingvalue && (lastreadingtime + (five_min * 1.05)) > timestamp ) { // no new value + if (value == lastreadingvalue && (lastreadingtime + (five_min * 1.00)) > timestamp ) { // no new value return null; } } From 138786d221027ee82e41411c1c6b9795c2808ada Mon Sep 17 00:00:00 2001 From: 4RK4N <4rk4nus@googlemail.com> Date: Fri, 2 Feb 2024 23:42:21 +0100 Subject: [PATCH 02/13] wrong condition --- .idea/modules.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/modules.xml b/.idea/modules.xml index 25bb056..1e8560f 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + From 9f72059fc01c6085a7f6eca2a5d355082ab56e12 Mon Sep 17 00:00:00 2001 From: 4RK4N <4rk4nus@googlemail.com> Date: Fri, 2 Feb 2024 23:42:40 +0100 Subject: [PATCH 03/13] wrong condition --- app/src/main/java/esel/esel/esel/Esel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/esel/esel/esel/Esel.java b/app/src/main/java/esel/esel/esel/Esel.java index 6983122..85ebc8f 100644 --- a/app/src/main/java/esel/esel/esel/Esel.java +++ b/app/src/main/java/esel/esel/esel/Esel.java @@ -27,7 +27,7 @@ public void onCreate() { sResources = getResources(); boolean use_patched_es = SP.getBoolean("use_patched_es", true); - if (!use_patched_es) { + if (use_patched_es) { startReadReceiver(); startKeepAliveService(); } From 3205d36f47cf32fd8bdae568b049bb3f18068c34 Mon Sep 17 00:00:00 2001 From: 4RK4N <4rk4nus@googlemail.com> Date: Fri, 2 Feb 2024 23:42:40 +0100 Subject: [PATCH 04/13] wrong condition --- app/src/main/java/esel/esel/esel/Esel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/esel/esel/esel/Esel.java b/app/src/main/java/esel/esel/esel/Esel.java index 6983122..85ebc8f 100644 --- a/app/src/main/java/esel/esel/esel/Esel.java +++ b/app/src/main/java/esel/esel/esel/Esel.java @@ -27,7 +27,7 @@ public void onCreate() { sResources = getResources(); boolean use_patched_es = SP.getBoolean("use_patched_es", true); - if (!use_patched_es) { + if (use_patched_es) { startReadReceiver(); startKeepAliveService(); } From fe3f8307f05d32c7a8f5fc0e6fd77b5e1306fd3c Mon Sep 17 00:00:00 2001 From: 4RK4N <4rk4nus@googlemail.com> Date: Sat, 3 Feb 2024 11:28:26 +0100 Subject: [PATCH 05/13] five_min *1.02 test (5 min 6 secs) --- .../java/esel/esel/esel/datareader/EsNotificationListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java b/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java index 823a2db..8a95f72 100644 --- a/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java +++ b/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java @@ -86,7 +86,7 @@ public static SGV generateSGV(Notification notification ,int record){ SGV oldSgv = lastReadings.get(lastReadings.size() - 1); long lastreadingtime = oldSgv.timestamp; // SP.getLong("lastreadingtime_nl",timestamp); int lastreadingvalue = oldSgv.raw; //SP.getInt("lastreadingvalue_nl",value); - if (value == lastreadingvalue && (lastreadingtime + (five_min * 1.00)) > timestamp ) { // no new value + if (value == lastreadingvalue && (lastreadingtime + (five_min * 1.02)) > timestamp ) { // no new value return null; } } From 37ccbdd05b59ba7b22a658d7a53b03eebe5f92d6 Mon Sep 17 00:00:00 2001 From: 4RK4N <4rk4nus@googlemail.com> Date: Sat, 3 Feb 2024 11:35:54 +0100 Subject: [PATCH 06/13] five_min *1.05 again (5 min 15 secs) --- .../java/esel/esel/esel/datareader/EsNotificationListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java b/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java index 8a95f72..c274164 100644 --- a/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java +++ b/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java @@ -86,7 +86,7 @@ public static SGV generateSGV(Notification notification ,int record){ SGV oldSgv = lastReadings.get(lastReadings.size() - 1); long lastreadingtime = oldSgv.timestamp; // SP.getLong("lastreadingtime_nl",timestamp); int lastreadingvalue = oldSgv.raw; //SP.getInt("lastreadingvalue_nl",value); - if (value == lastreadingvalue && (lastreadingtime + (five_min * 1.02)) > timestamp ) { // no new value + if (value == lastreadingvalue && (lastreadingtime + (five_min * 1.05)) > timestamp ) { // no new value return null; } } From 05ac090f910a140ebc8e532aec3f74a4d9e9ddde Mon Sep 17 00:00:00 2001 From: 4RK4N <4rk4nus@googlemail.com> Date: Sun, 4 Feb 2024 01:52:38 +0100 Subject: [PATCH 07/13] watch use_patched_es setting start and stop recievers on change --- app/src/main/java/esel/esel/esel/Esel.java | 2 +- .../java/esel/esel/esel/MainActivity.java | 21 +++++++++++++++++++ app/src/main/java/esel/esel/esel/util/SP.java | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/esel/esel/esel/Esel.java b/app/src/main/java/esel/esel/esel/Esel.java index 85ebc8f..5343d87 100644 --- a/app/src/main/java/esel/esel/esel/Esel.java +++ b/app/src/main/java/esel/esel/esel/Esel.java @@ -60,7 +60,7 @@ public synchronized void stopReadReceiver() { } - private void startKeepAliveService() { + public void startKeepAliveService() { if (keepAliveReceiver == null) { keepAliveReceiver = new KeepAliveReceiver(); keepAliveReceiver.setAlarm(this); diff --git a/app/src/main/java/esel/esel/esel/MainActivity.java b/app/src/main/java/esel/esel/esel/MainActivity.java index 23d5593..1110d33 100644 --- a/app/src/main/java/esel/esel/esel/MainActivity.java +++ b/app/src/main/java/esel/esel/esel/MainActivity.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.SharedPreferences; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -19,6 +20,7 @@ import java.io.File; import java.util.List; +import java.util.Objects; import esel.esel.esel.datareader.Datareader; import esel.esel.esel.datareader.EsNowDatareader; @@ -56,6 +58,25 @@ public void onClick(View view) { .setAction("Action", null).show(); } });*/ + + SharedPreferences.OnSharedPreferenceChangeListener settingsListener = new SharedPreferences.OnSharedPreferenceChangeListener() { + @Override + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + if (key.equals("use_patched_es")){ + if (SP.getBoolean("use_patched_es", false)){ + Esel.getsInstance().startKeepAliveService(); + Esel.getsInstance().startReadReceiver(); + EselLog.LogI(TAG, "started recievers for patched_es mode"); + } else { + Esel.getsInstance().stopKeepAliveService(); + Esel.getsInstance().stopReadReceiver(); + EselLog.LogI(TAG, "stopped recievers for patched_es mode"); + } + } + } + }; + SP.sharedPreferences.registerOnSharedPreferenceChangeListener(settingsListener); + buttonReadValue.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/app/src/main/java/esel/esel/esel/util/SP.java b/app/src/main/java/esel/esel/esel/util/SP.java index cf8b4f3..2042855 100644 --- a/app/src/main/java/esel/esel/esel/util/SP.java +++ b/app/src/main/java/esel/esel/esel/util/SP.java @@ -11,7 +11,7 @@ */ public class SP { - static SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(Esel.getsInstance().getApplicationContext()); + static public SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(Esel.getsInstance().getApplicationContext()); static public boolean contains(String key) { return sharedPreferences.contains(key); From be9bb41c8858daf0686df30d87210e858cbe1373 Mon Sep 17 00:00:00 2001 From: 4RK4N <4rk4nus@googlemail.com> Date: Sun, 4 Feb 2024 01:52:38 +0100 Subject: [PATCH 08/13] watch use_patched_es setting start and stop recievers on change --- app/src/main/java/esel/esel/esel/Esel.java | 2 +- .../java/esel/esel/esel/MainActivity.java | 20 +++++++++++++++++++ app/src/main/java/esel/esel/esel/util/SP.java | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/esel/esel/esel/Esel.java b/app/src/main/java/esel/esel/esel/Esel.java index 85ebc8f..5343d87 100644 --- a/app/src/main/java/esel/esel/esel/Esel.java +++ b/app/src/main/java/esel/esel/esel/Esel.java @@ -60,7 +60,7 @@ public synchronized void stopReadReceiver() { } - private void startKeepAliveService() { + public void startKeepAliveService() { if (keepAliveReceiver == null) { keepAliveReceiver = new KeepAliveReceiver(); keepAliveReceiver.setAlarm(this); diff --git a/app/src/main/java/esel/esel/esel/MainActivity.java b/app/src/main/java/esel/esel/esel/MainActivity.java index 23d5593..3bb5d8a 100644 --- a/app/src/main/java/esel/esel/esel/MainActivity.java +++ b/app/src/main/java/esel/esel/esel/MainActivity.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.SharedPreferences; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -56,6 +57,25 @@ public void onClick(View view) { .setAction("Action", null).show(); } });*/ + + SharedPreferences.OnSharedPreferenceChangeListener settingsListener = new SharedPreferences.OnSharedPreferenceChangeListener() { + @Override + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + if (key.equals("use_patched_es")){ + if (SP.getBoolean("use_patched_es", false)){ + Esel.getsInstance().startKeepAliveService(); + Esel.getsInstance().startReadReceiver(); + EselLog.LogI(TAG, "started recievers for patched_es mode"); + } else { + Esel.getsInstance().stopKeepAliveService(); + Esel.getsInstance().stopReadReceiver(); + EselLog.LogI(TAG, "stopped recievers for patched_es mode"); + } + } + } + }; + SP.sharedPreferences.registerOnSharedPreferenceChangeListener(settingsListener); + buttonReadValue.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/app/src/main/java/esel/esel/esel/util/SP.java b/app/src/main/java/esel/esel/esel/util/SP.java index cf8b4f3..2042855 100644 --- a/app/src/main/java/esel/esel/esel/util/SP.java +++ b/app/src/main/java/esel/esel/esel/util/SP.java @@ -11,7 +11,7 @@ */ public class SP { - static SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(Esel.getsInstance().getApplicationContext()); + static public SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(Esel.getsInstance().getApplicationContext()); static public boolean contains(String key) { return sharedPreferences.contains(key); From 2a8e5fc3f0ab95102827e8b9a049c6a4bddf536d Mon Sep 17 00:00:00 2001 From: 4RK4N <4rk4nus@googlemail.com> Date: Sun, 4 Feb 2024 02:12:37 +0100 Subject: [PATCH 09/13] minor code cleanup --- app/src/main/java/esel/esel/esel/Esel.java | 9 +++++---- app/src/main/java/esel/esel/esel/MainActivity.java | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/esel/esel/esel/Esel.java b/app/src/main/java/esel/esel/esel/Esel.java index 5343d87..d47d81d 100644 --- a/app/src/main/java/esel/esel/esel/Esel.java +++ b/app/src/main/java/esel/esel/esel/Esel.java @@ -26,7 +26,7 @@ public void onCreate() { sInstance = this; sResources = getResources(); - boolean use_patched_es = SP.getBoolean("use_patched_es", true); + boolean use_patched_es = SP.getBoolean("use_patched_es", false); if (use_patched_es) { startReadReceiver(); startKeepAliveService(); @@ -54,9 +54,10 @@ public synchronized void startReadReceiver() { public synchronized void stopReadReceiver() { - if (readReceiver != null) + if (readReceiver != null) { readReceiver.cancelAlarm(this); readReceiver = null; + } } @@ -69,8 +70,8 @@ public void startKeepAliveService() { public void stopKeepAliveService() { - if (keepAliveReceiver != null) + if (keepAliveReceiver != null) { keepAliveReceiver.cancelAlarm(this); + } } - } diff --git a/app/src/main/java/esel/esel/esel/MainActivity.java b/app/src/main/java/esel/esel/esel/MainActivity.java index 1110d33..3bb5d8a 100644 --- a/app/src/main/java/esel/esel/esel/MainActivity.java +++ b/app/src/main/java/esel/esel/esel/MainActivity.java @@ -20,7 +20,6 @@ import java.io.File; import java.util.List; -import java.util.Objects; import esel.esel.esel.datareader.Datareader; import esel.esel.esel.datareader.EsNowDatareader; From 501b2f673b0f840d40b3af64e2d8e312c7525294 Mon Sep 17 00:00:00 2001 From: 4RK4N <4rk4nus@googlemail.com> Date: Sun, 4 Feb 2024 02:37:41 +0100 Subject: [PATCH 10/13] minor code cleanup --- app/src/main/java/esel/esel/esel/Esel.java | 6 +++--- app/src/main/java/esel/esel/esel/MainActivity.java | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/esel/esel/esel/Esel.java b/app/src/main/java/esel/esel/esel/Esel.java index d47d81d..b4a37da 100644 --- a/app/src/main/java/esel/esel/esel/Esel.java +++ b/app/src/main/java/esel/esel/esel/Esel.java @@ -28,8 +28,8 @@ public void onCreate() { boolean use_patched_es = SP.getBoolean("use_patched_es", false); if (use_patched_es) { - startReadReceiver(); startKeepAliveService(); + startReadReceiver(); } } @@ -61,7 +61,7 @@ public synchronized void stopReadReceiver() { } - public void startKeepAliveService() { + public synchronized void startKeepAliveService() { if (keepAliveReceiver == null) { keepAliveReceiver = new KeepAliveReceiver(); keepAliveReceiver.setAlarm(this); @@ -69,7 +69,7 @@ public void startKeepAliveService() { } - public void stopKeepAliveService() { + public synchronized void stopKeepAliveService() { if (keepAliveReceiver != null) { keepAliveReceiver.cancelAlarm(this); } diff --git a/app/src/main/java/esel/esel/esel/MainActivity.java b/app/src/main/java/esel/esel/esel/MainActivity.java index 3bb5d8a..517d7ca 100644 --- a/app/src/main/java/esel/esel/esel/MainActivity.java +++ b/app/src/main/java/esel/esel/esel/MainActivity.java @@ -65,11 +65,9 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin if (SP.getBoolean("use_patched_es", false)){ Esel.getsInstance().startKeepAliveService(); Esel.getsInstance().startReadReceiver(); - EselLog.LogI(TAG, "started recievers for patched_es mode"); } else { - Esel.getsInstance().stopKeepAliveService(); Esel.getsInstance().stopReadReceiver(); - EselLog.LogI(TAG, "stopped recievers for patched_es mode"); + Esel.getsInstance().stopKeepAliveService(); } } } From f14451e64c86827a2c212c339a0bb67b3e0b7b41 Mon Sep 17 00:00:00 2001 From: 4RK4N <4rk4nus@googlemail.com> Date: Sun, 4 Feb 2024 21:49:42 +0100 Subject: [PATCH 11/13] more logs, try fix recievers shutdown crash --- app/src/main/java/esel/esel/esel/Esel.java | 3 +++ app/src/main/java/esel/esel/esel/MainActivity.java | 4 ++++ .../esel/esel/esel/datareader/EsNotificationListener.java | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/esel/esel/esel/Esel.java b/app/src/main/java/esel/esel/esel/Esel.java index b4a37da..15c9b95 100644 --- a/app/src/main/java/esel/esel/esel/Esel.java +++ b/app/src/main/java/esel/esel/esel/Esel.java @@ -65,6 +65,8 @@ public synchronized void startKeepAliveService() { if (keepAliveReceiver == null) { keepAliveReceiver = new KeepAliveReceiver(); keepAliveReceiver.setAlarm(this); + } else { + keepAliveReceiver.setAlarm(this); } } @@ -72,6 +74,7 @@ public synchronized void startKeepAliveService() { public synchronized void stopKeepAliveService() { if (keepAliveReceiver != null) { keepAliveReceiver.cancelAlarm(this); + keepAliveReceiver = null; } } } diff --git a/app/src/main/java/esel/esel/esel/MainActivity.java b/app/src/main/java/esel/esel/esel/MainActivity.java index 517d7ca..ed0a230 100644 --- a/app/src/main/java/esel/esel/esel/MainActivity.java +++ b/app/src/main/java/esel/esel/esel/MainActivity.java @@ -64,10 +64,14 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin if (key.equals("use_patched_es")){ if (SP.getBoolean("use_patched_es", false)){ Esel.getsInstance().startKeepAliveService(); + EselLog.LogV(TAG, "START patches_es keepAlive recievers"); Esel.getsInstance().startReadReceiver(); + EselLog.LogV(TAG, "START patches_es Read recievers"); } else { Esel.getsInstance().stopReadReceiver(); + EselLog.LogV(TAG, "STOP patches_es Read recievers"); Esel.getsInstance().stopKeepAliveService(); + EselLog.LogV(TAG, "STOP patches_es keepAlive recievers"); } } } diff --git a/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java b/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java index c274164..f9bb855 100644 --- a/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java +++ b/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java @@ -86,7 +86,7 @@ public static SGV generateSGV(Notification notification ,int record){ SGV oldSgv = lastReadings.get(lastReadings.size() - 1); long lastreadingtime = oldSgv.timestamp; // SP.getLong("lastreadingtime_nl",timestamp); int lastreadingvalue = oldSgv.raw; //SP.getInt("lastreadingvalue_nl",value); - if (value == lastreadingvalue && (lastreadingtime + (five_min * 1.05)) > timestamp ) { // no new value + if (value == lastreadingvalue && (lastreadingtime + (five_min * 1.0835)) > timestamp ) { // no new value // 5 min 25 secs grace time return null; } } From 38ee36f1a7a750189f15c30804632d8939ed50e2 Mon Sep 17 00:00:00 2001 From: 4RK4N <4rk4nus@googlemail.com> Date: Sun, 4 Feb 2024 21:49:42 +0100 Subject: [PATCH 12/13] more logs, try fix recievers shutdown crash --- app/src/main/java/esel/esel/esel/Esel.java | 3 +++ app/src/main/java/esel/esel/esel/MainActivity.java | 4 ++++ .../esel/esel/esel/datareader/EsNotificationListener.java | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/esel/esel/esel/Esel.java b/app/src/main/java/esel/esel/esel/Esel.java index b4a37da..15c9b95 100644 --- a/app/src/main/java/esel/esel/esel/Esel.java +++ b/app/src/main/java/esel/esel/esel/Esel.java @@ -65,6 +65,8 @@ public synchronized void startKeepAliveService() { if (keepAliveReceiver == null) { keepAliveReceiver = new KeepAliveReceiver(); keepAliveReceiver.setAlarm(this); + } else { + keepAliveReceiver.setAlarm(this); } } @@ -72,6 +74,7 @@ public synchronized void startKeepAliveService() { public synchronized void stopKeepAliveService() { if (keepAliveReceiver != null) { keepAliveReceiver.cancelAlarm(this); + keepAliveReceiver = null; } } } diff --git a/app/src/main/java/esel/esel/esel/MainActivity.java b/app/src/main/java/esel/esel/esel/MainActivity.java index 517d7ca..5a24fed 100644 --- a/app/src/main/java/esel/esel/esel/MainActivity.java +++ b/app/src/main/java/esel/esel/esel/MainActivity.java @@ -64,10 +64,14 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin if (key.equals("use_patched_es")){ if (SP.getBoolean("use_patched_es", false)){ Esel.getsInstance().startKeepAliveService(); + EselLog.LogV(TAG, "START patches_ed keepAlive recievers"); Esel.getsInstance().startReadReceiver(); + EselLog.LogV(TAG, "START patches_ed Read recievers"); } else { Esel.getsInstance().stopReadReceiver(); + EselLog.LogV(TAG, "STOP patches_ed Read recievers"); Esel.getsInstance().stopKeepAliveService(); + EselLog.LogV(TAG, "STOP patches_ed keepAlive recievers"); } } } diff --git a/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java b/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java index c274164..f9bb855 100644 --- a/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java +++ b/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java @@ -86,7 +86,7 @@ public static SGV generateSGV(Notification notification ,int record){ SGV oldSgv = lastReadings.get(lastReadings.size() - 1); long lastreadingtime = oldSgv.timestamp; // SP.getLong("lastreadingtime_nl",timestamp); int lastreadingvalue = oldSgv.raw; //SP.getInt("lastreadingvalue_nl",value); - if (value == lastreadingvalue && (lastreadingtime + (five_min * 1.05)) > timestamp ) { // no new value + if (value == lastreadingvalue && (lastreadingtime + (five_min * 1.0835)) > timestamp ) { // no new value // 5 min 25 secs grace time return null; } } From 1fc7439d80b2a4db1098eb0ce47c0acb04698c3e Mon Sep 17 00:00:00 2001 From: 4RK4N <4rk4nus@googlemail.com> Date: Sun, 4 Feb 2024 22:13:38 +0100 Subject: [PATCH 13/13] 30 secs grace time for new value --- .../java/esel/esel/esel/datareader/EsNotificationListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java b/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java index f9bb855..53bdbd4 100644 --- a/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java +++ b/app/src/main/java/esel/esel/esel/datareader/EsNotificationListener.java @@ -86,7 +86,7 @@ public static SGV generateSGV(Notification notification ,int record){ SGV oldSgv = lastReadings.get(lastReadings.size() - 1); long lastreadingtime = oldSgv.timestamp; // SP.getLong("lastreadingtime_nl",timestamp); int lastreadingvalue = oldSgv.raw; //SP.getInt("lastreadingvalue_nl",value); - if (value == lastreadingvalue && (lastreadingtime + (five_min * 1.0835)) > timestamp ) { // no new value // 5 min 25 secs grace time + if (value == lastreadingvalue && (lastreadingtime + (five_min * 1.1)) > timestamp ) { // no new value // 5 min 30 secs grace time return null; } }