惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
阮一峰的网络日志
阮一峰的网络日志
Jina AI
Jina AI
博客园 - Franky
U
Unit 42
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享
B
Blog RSS Feed
雷峰网
雷峰网
D
DataBreaches.Net
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
I
InfoQ
美团技术团队
云风的 BLOG
云风的 BLOG
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
大猫的无限游戏
大猫的无限游戏
G
Google Developers Blog
T
Tailwind CSS Blog
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
月光博客
月光博客
Engineering at Meta
Engineering at Meta

IT Notes - android

IT Notes
IT Notes
Stefano Marinelli · 2023-10-19 · via IT Notes - android

Since the time I left BlackBerry behind many years ago, I've consistently sought ways to keep my phones connected to my email accounts. I enjoy receiving emails in real-time, and as a result, I've always used tools that allow me to get instant (or near-instant) notifications whenever a message arrives.

Years ago, I even used emails as a notification tool for my servers. If a server became unreachable, an email would alert me, and I'd immediately take corrective action. Nowadays, I use other systems too (like Telegram bots, Pushover, ntfy, etc.), but I still want to know when I receive a new message.

Back when I had my very first Android device (the original Android, the HTC Dream), I was already using IMAP IDLE, so my phone was always connected to my inbox. When I transitioned to the early iPhones, IMAP IDLE wasn't supported, leading me to use an app called PushMail. This app required you to send copies of your emails to it, after which it would push notifications showing the sender and subject. This approach wasn't ideal for privacy, but it was effective.

In the following years, both with iPhones and various email apps on Android, I noticed that my phones consumed more battery in standby mode than the average. Upon investigation, I found out that a significant part of this consumption was tied to the background activities of my email accounts. The energy drain wasn't so much about the software, but more about the network activity triggered by any event in my inbox. For example: an email arrives, the phone downloads it and sends out a notification. I don't check the phone because I'm at my computer, so I open the email there. In real-time, the phone wakes up in the background to mark the email as read. Then, if I move the email to a folder, the phone wakes up again to sync this change.

The same process happens when I draft an email on my computer. Every time the email client saves the intermediate draft, the phone wakes up from sleep to sync the message. Once sent, it wakes up again to remove it from drafts and copy it to the sent folder. This happens all day, for every single interaction.

This made me recall PushMail and made me realize that I don't actually need all this continuous syncing. All I want is to be alerted when an email arrives, knowing who it's from and what it's about.

With this in mind, I developed NotiMail. I chose to support multiple notification providers, though my initial tests were conducted with PushOver, which I found efficient on both iPhone and Android. It works exactly as intended.

As an additional step, I compiled ntfy for FreeBSD. I also generated Firebase keys and recompiled the Android app so I could use my server while leveraging Google's push notifications. This helps save even more battery by utilizing the always-on data connection to Google servers. It's a trade-off in terms of privacy, but I needed to test this "extreme" case.

The results were astonishing. After a few days of use, I observed an average daily battery savings of 15%, and also a variable, yet notable, data savings.

I'm also testing, on a Pixel 7 with GrapheneOS, the impact of using direct push notifications with a continuous connection to my ntfy server. It's probably less battery efficient, but it saves all the data associated with mailbox operations.

This way, whether I have 1, 5, or 50 "connected" email accounts, they don't weigh down my battery (excluding the increased notifications, of course).

NotiMail is available here: https://github.com/draga79/NotiMail