diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/K9Receiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/K9Receiver.java index 9c506988f..65361cf14 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/K9Receiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/K9Receiver.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.net.Uri; +import android.os.PowerManager; public class K9Receiver extends BroadcastReceiver { @@ -13,6 +14,12 @@ public class K9Receiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { + + PowerManager powermanager = (PowerManager) context.getSystemService(context.POWER_SERVICE); + if (powermanager.isScreenOn()) { + return; + } + // get sender and subject from the Intent String sender = intent.getStringExtra("com.fsck.k9.intent.extra.FROM"); String subject = intent.getStringExtra("com.fsck.k9.intent.extra.SUBJECT"); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/NotificationListener.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/NotificationListener.java index a9b71e0a8..9a82c5f43 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/NotificationListener.java @@ -3,6 +3,7 @@ package nodomain.freeyourgadget.gadgetbridge; import android.app.Notification; import android.content.Intent; import android.os.Bundle; +import android.os.PowerManager; import android.service.notification.NotificationListenerService; import android.service.notification.StatusBarNotification; import android.util.Log; @@ -23,14 +24,21 @@ public class NotificationListener extends NotificationListenerService { @Override public void onNotificationPosted(StatusBarNotification sbn) { + + String source = sbn.getPackageName(); + Log.i(TAG, source); + + PowerManager powermanager = (PowerManager) getSystemService(POWER_SERVICE); + if (powermanager.isScreenOn() && !source.equals(getPackageName())) { + return; + } + Notification notification = sbn.getNotification(); /* do not display messages from "android" * This includes keyboard selection message, usb connection messages, etc * Hope it does not filter out too much, we will see... */ - String source = sbn.getPackageName(); - Log.i(TAG, source); if (source.equals("android") || source.equals("com.android.dialer") || @@ -39,11 +47,14 @@ public class NotificationListener extends NotificationListenerService { return; } + if ((notification.flags & Notification.FLAG_ONGOING_EVENT) == Notification.FLAG_ONGOING_EVENT) { + return; + } + Log.i(TAG, "Processing notification from source " + source); Bundle extras = notification.extras; String title = extras.getCharSequence(Notification.EXTRA_TITLE).toString(); - String content = ""; if (extras.containsKey(Notification.EXTRA_TEXT)) { CharSequence contentCS = extras.getCharSequence(Notification.EXTRA_TEXT); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/PebbleProtocol.java index 0acca9235..e08765385 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/PebbleProtocol.java @@ -64,8 +64,8 @@ public class PebbleProtocol { static final byte PHONEVERSION_APPVERSION_MAGIC = 2; // increase this if pebble complains static final byte PHONEVERSION_APPVERSION_MAJOR = 2; - static final byte PHONEVERSION_APPVERSION_MINOR = 2; - static final byte PHONEVERSION_APPVERSION_PATCH = 2; + static final byte PHONEVERSION_APPVERSION_MINOR = 3; + static final byte PHONEVERSION_APPVERSION_PATCH = 0; static final int PHONEVERSION_SESSION_CAPS_GAMMARAY = (int) 0x80000000; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/SMSReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/SMSReceiver.java index 8821d47f9..f355292ec 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/SMSReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/SMSReceiver.java @@ -4,12 +4,19 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.os.PowerManager; import android.telephony.SmsMessage; public class SMSReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { + + PowerManager powermanager = (PowerManager) context.getSystemService(context.POWER_SERVICE); + if (powermanager.isScreenOn()) { + return; + } + Bundle bundle = intent.getExtras(); if (bundle != null) { Object[] pdus = (Object[]) bundle.get("pdus");