Skip to content

VPN-7203 - Add a warning when not running with "unristricted" background usage permission#11169

Open
strseb wants to merge 8 commits intomainfrom
basti/vpn-7203
Open

VPN-7203 - Add a warning when not running with "unristricted" background usage permission#11169
strseb wants to merge 8 commits intomainfrom
basti/vpn-7203

Conversation

@strseb
Copy link
Copy Markdown
Collaborator

@strseb strseb commented Mar 31, 2026

This adds a warning if the User is running the App not in "unrestricted" background usage mode. - Clicking it will force a system prompt. We will show this warning only until interacted with it once, so users can dismis it.

screen-20260331-190155-1774976507904.mp4

@strseb strseb requested a review from mcleinman March 31, 2026 17:28
@strseb strseb changed the title VPN-7203 - Add a warning on BatteryOptimization VPN-7203 - Add a warning ehrn not running with "unristricted" background usage permission Mar 31, 2026
@strseb strseb changed the title VPN-7203 - Add a warning ehrn not running with "unristricted" background usage permission VPN-7203 - Add a warning when not running with "unristricted" background usage permission Mar 31, 2026
@strseb strseb marked this pull request as ready for review March 31, 2026 17:33
@strseb strseb requested a review from flodolo as a code owner March 31, 2026 17:33
@strseb strseb requested review from artfwo and oskirby March 31, 2026 17:57
Copy link
Copy Markdown
Collaborator

@mcleinman mcleinman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like using the MZInformationCard with a mousearea for this, from a design perspective. Even with tap here I'm not sure it's discoverable, and I'm of the opinion we should keep the info cards read-only. If you want, I'm happy to build an optional button in the info card. Want me to work on that real quick?

If we went that route, I'd suggest the card say Allow Mozilla VPN to run in background to ensure VPN connection is maintained. combined with Allow background permissions for the button. Also, if this is something that will probably happen, I'd suggest we make this an error info card, or something even stronger.

@strseb
Copy link
Copy Markdown
Collaborator Author

strseb commented Apr 1, 2026

If you want, I'm happy to build an optional button in the info card. Want me to work on that real quick?

I will never refuse an offer to help me on UI stuff! Please!

@mcleinman
Copy link
Copy Markdown
Collaborator

If you want, I'm happy to build an optional button in the info card. Want me to work on that real quick?

I will never refuse an offer to help me on UI stuff! Please!

@strseb PR is up: #11173

@strseb strseb requested a review from mcleinman April 7, 2026 21:00
@strseb
Copy link
Copy Markdown
Collaborator Author

strseb commented Apr 7, 2026

Screenshot (7 Apr 2026 23_00_54)

thanks @mcleinman 🥳

Comment thread src/translations/strings.yaml Outdated
_buttonAction: function() {
MZSettings.hasDismissedBatteryOptimization = true
BatteryOptimizer.triggerBatteryOptimizationIntent()
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once we set hasDismissedBatteryOptimization to true, the warning won't reappear, right? (e.g. if the user dismissed the system dialog)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the idea :) - The intention is to give a hint, not to force them to enable this.

@mcleinman
Copy link
Copy Markdown
Collaborator

Why do we want to make this dismissable? If we're pretty confident this is going to hurt the VPN experience, why not leave it there? (This also covers the case where someone taps the button, goes to system page, gets a text or something and goes to deal with it, but then forgets to come back to giving the system permission.)

Copy link
Copy Markdown
Collaborator

@mcleinman mcleinman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, but with the prior comment that we may not want to make this dismissable. That said, won't block on that.

id: batteryWarningText
Layout.fillWidth: true
text: MZI18n.SettingsBatteryOptimizationWarning
//verticalAlignment: Text.AlignVCenter
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

@strseb
Copy link
Copy Markdown
Collaborator Author

strseb commented Apr 9, 2026

Why do we want to make this dismissable? If we're pretty confident this is going to hurt the VPN experience, why not leave it there? (This also covers the case where someone taps the button, goes to system page, gets a text or something and goes to deal with it, but then forgets to come back to giving the system permission.)

My rationale would be that this actually can hurt your battery lifetime,(i.e keep the deamon alive longer when not connected) and depending on the manufaturer it might not even be needed. I.e my google pixel i never even had to do this and i have weeks of background connectivity.
Even after dismissal people can go to the apps permissions and enable/disable this as needed, i dont think we need to build a 2nd permanent ui for that.
So i thought of this as maybe more as a hint of "hey this exists"

@mcleinman
Copy link
Copy Markdown
Collaborator

Why do we want to make this dismissable? If we're pretty confident this is going to hurt the VPN experience, why not leave it there? (This also covers the case where someone taps the button, goes to system page, gets a text or something and goes to deal with it, but then forgets to come back to giving the system permission.)

My rationale would be that this actually can hurt your battery lifetime,(i.e keep the deamon alive longer when not connected) and depending on the manufaturer it might not even be needed. I.e my google pixel i never even had to do this and i have weeks of background connectivity. Even after dismissal people can go to the apps permissions and enable/disable this as needed, i dont think we need to build a 2nd permanent ui for that. So i thought of this as maybe more as a hint of "hey this exists"

So I understand - the issue is that sometimes this causes the VPN to be closed in the background, but sometimes it does nothing harmful at all? And we're trying to find messaging that lets folks know that? If so, perhaps the message should be adjusted to "...in some situations, this causes the VPN to be disconnected. If this is something you've experienced, consider changing this setting..."? (There isn't a way we can track if the daemon has been closed by the OS, right?)

@strseb
Copy link
Copy Markdown
Collaborator Author

strseb commented Apr 13, 2026

"...in some situations, this causes the VPN to be disconnected. If this is something you've experienced, consider changing this setting..."?

Wouldn't this be too long for the text box? 😅

There isn't a way we can track if the daemon has been closed by the OS, right?

There is ApplicationExitInfo - theoretically we could check whether the last exit was not clean and take that as a signal, but then again we'd need to be trusting the manufacturer works per-spec (and does not just simulate a swipe-kill) - where if it would be this would all not be needed as we have the android:foregroundServiceType="systemExempted" flag on the daemon.

@mcleinman
Copy link
Copy Markdown
Collaborator

"...in some situations, this causes the VPN to be disconnected. If this is something you've experienced, consider changing this setting..."?

Wouldn't this be too long for the text box? 😅

Doesn't look like it (that ellipses at the end was how I wrote it):
Screenshot 92

There isn't a way we can track if the daemon has been closed by the OS, right?

There is ApplicationExitInfo - theoretically we could check whether the last exit was not clean and take that as a signal, but then again we'd need to be trusting the manufacturer works per-spec (and does not just simulate a swipe-kill) - where if it would be this would all not be needed as we have the android:foregroundServiceType="systemExempted" flag on the daemon.

That seems not worth it. But maybe a slightly longer explanation?

strseb and others added 7 commits May 4, 2026 13:46
This patch picks up PR #10897 - and wires up android batteryOptimization status to QML

Co-authored-by: im7mortal <5336231+im7mortal@users.noreply.github.com>
Co-authored-by: Francesco Lodolo <flod@lodolo.net>
@strseb strseb force-pushed the basti/vpn-7203 branch from 85492a6 to 3cd7a6d Compare May 4, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants