Pebble App Modding to Include Notification Filters

Pebble getting filters for notifications 
UPDATE 01/22/2017: You can find a modded 4.3.0 version with the modifications from this post clicking here.

I really like my Pebble. Also, I really like notifications on my Pebble. But I really hate that I can’t filter those annoying WhatsApp groups notifications in my Pebble without losing all my WhatsApp notifications. The Pebble really needs a notification filtering system.

Most people solve this problem by deactivating the stock notifications and installing a third-party application for that. But usually, those applications are really slow sending the notifications and lose a lot of them. I tried several but I didn’t like any of them. So I decided I wanted the stock notifications but with regular expression filtering and went ahead to modify the original Pebble application for Android.

Basically what I needed is to check the notification against some regular expressions before the Pebble application sends it to the watch. An Android application needs to create a NotificationListenerService in order to get the notifications from the phone, and implement the method onNotificationPosted to receive the notification and process it. We’re going to find where this is using a Dex to Java decompiler called jadx.

For this article we’re going to use the Pebble for Android v4.0.0-1209-98b6e71.

Now we look for the method onNotificationPosted to see where it is implemented using the search button on jadx. We can find it quickly in the class

This is a little obfuscated but it’s still very readable. You can immediately realize that z.d() is used for logging, and the notification is processed in a thread defined in the class before sending it via BlueTooth to the watch. This class b has just one method called run:

The class o is the notification parsed and the class e will process it. This class belongs to:

And that’s finally what we were looking for. This class is where the application decides to send the notification to the watch depending on things like quiet time, or if the application that is sending the notification is not selected by the user, etc. Eventually we reach this code in the method d:

Let’s change that to:

Just adding our new check there that if the notification matches and exclude list, it won’t be sent to the watch.

Now how can we do that? It’s not like we can compile all this code again in Java and then convert it to Dalvik. We have to modify this class in assembler, and that’s the fun part of it!

First install apktool (if you use Debian it’s as easy as apt-get install apktool) and unpack the apk:

And then modify the smali file for First raise the number of registers in the method:

And then before checking the next condition in the if above:

We change that jump to our code:

Here’s our code in smali for the check above:

And now you can define the static method com.scorpius.hacks.matchesExcludeList however you want. This time you can write it in Java. This is what I did: I put all my rules in regular expressions in a file in /sdcard/pblExcludeList.txt with the following format:


For example:

.*whatsapp.*:.*annoying group title.*

And then I wrote the following code to read that file and check on my rules on every single notification before sending it to the watch:

Now compile it, convert it to dex, convert it to smali and include it in the Pebble application. Somehow it has to be Java 7:

Finally build your APK and sign it:

And now you can install it in your phone. Remember that you have to uninstall the official Pebble application first since the signatures are different. Sadly you will lose the past health data in your phone but it will still be there in the watch. Also, you have to enable the option to allow installation of apps from unknown sources in your phone. If you are not getting any notifications you will need to turn off and then back on the notification access of the Pebble app in your phone, but I really prefer to reboot the phone after installing the app.

Want to try my version? I added a menu option to reload the file anytime:

Pebble application modded with a notification filter

You can get a modded 4.3.0 version here.

5 thoughts to “Pebble App Modding to Include Notification Filters”

  1. Hey, are you maybe thinking in patching the last pebble app version (4.3.0)? As the company doesn’t exist anymore we won’t see any more updates, so having the last version patched will be interesting for a lot of users I think…

    1. Good idea! I didn’t even know there was a 4.3.0. Since I’m using my own versions I never receive the official updates and I always forget to check if there was any.

  2. This is fantastic! I’ve been wrestling with Pebble Notifications for ages now and this is the ammunition I need to finally manage them. Have you done one for 4.3.0? If not, I might do it, and add in some additional features that I like from NC while I do.

    1. Well, I’ve been trying this for a while now and I’m simply not experienced enough to do this kind of thing. Some of this parsing code has changed in the new 4.3.0 app, and I think I just about managed to follow it to insert the new assembler. However, you also added a menu option etc and that, for now, is beyond me.

      Graciously awaiting you to try your hand at the 4.3.0 version.

  3. I updated the modded version to 4.3.0, I guess that’s the last official Pebble client for Android we will ever had. If Pebble opens the client code, I could do way more stuff, and improve the Pebble a lot, with things like these but with a more friendly GUI and stuff. I hope they open the code soon.

Leave a Reply