[PR #1442] [MERGED] Fix for vault timeout locking issue on android #2892

Closed
opened 2025-11-26 23:25:34 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/1442
Author: @mpbw2
Created: 6/28/2021
Status: Merged
Merged: 6/29/2021
Merged by: @mpbw2

Base: masterHead: bugfix-android-vault-timeout-lock


📝 Commits (1)

  • 7c1cb27 fix for vault timeout locking issue on android

📊 Changes

4 files changed (+6 additions, -41 deletions)

View changed files

📝 src/Android/Android.csproj (+0 -1)
📝 src/Android/MainActivity.cs (+1 -18)
src/Android/Receivers/LockAlarmReceiver.cs (+0 -16)
📝 src/App/App.xaml.cs (+5 -6)

📄 Description

This PR closes a gap where the Android app would not lock after the vault timeout time elapsed. It has some history, starting with a HackerOne report in December, where we introduced use of the system monotonic clock for tracking time and performing the time check when the app resumed from background. This replaced a timer that started when the app first entered the background, but occasionally never fired if the system terminated the process. (PR #1175).

Shortly after that went live we started receiving reports of Android failing to lock at all (but just Android - iOS was fine). At the time I was unable to figure out why, so we restored the lock timers for Android only (PR #1220).

This brings us to today, where a recent bug full of red herrings led me to discover why Android was (seemingly) randomly failing to lock after the first PR. The culprit is the Android back button/gesture and how it relates to Xamarin Forms app lifecycles. I incorrectly assumed Xamarin's OnResume() would always fire when the app was brought back to the foreground, regardless of how it got to the background (native Android does this). Turns out this only works when the app is backgrounded via the home button/gesture. When the back button/gesture is used, the next time the app is brought to the foreground it will call Xamarin's OnStart() method, which until this PR was not checking the vault lock timer. That hole is now plugged, fixing the reported bug as well as the original issue from December and (finally) negating the need for the timer (which has been removed again).

TL;DR: Vault timeout clock check additionally needs to be performed in Xamarin OnStart() for Android to catch multiple backgrounding/foregrounding flows.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/1442 **Author:** [@mpbw2](https://github.com/mpbw2) **Created:** 6/28/2021 **Status:** ✅ Merged **Merged:** 6/29/2021 **Merged by:** [@mpbw2](https://github.com/mpbw2) **Base:** `master` ← **Head:** `bugfix-android-vault-timeout-lock` --- ### 📝 Commits (1) - [`7c1cb27`](https://github.com/bitwarden/android/commit/7c1cb27d5b39adeb8eae42ae67925da1cbac0982) fix for vault timeout locking issue on android ### 📊 Changes **4 files changed** (+6 additions, -41 deletions) <details> <summary>View changed files</summary> 📝 `src/Android/Android.csproj` (+0 -1) 📝 `src/Android/MainActivity.cs` (+1 -18) ➖ `src/Android/Receivers/LockAlarmReceiver.cs` (+0 -16) 📝 `src/App/App.xaml.cs` (+5 -6) </details> ### 📄 Description This PR closes a gap where the Android app would not lock after the vault timeout time elapsed. It has some history, starting with a HackerOne report in December, where we introduced use of the system monotonic clock for tracking time and performing the time check when the app resumed from background. This replaced a timer that started when the app first entered the background, but occasionally never fired if the system terminated the process. (PR #1175). Shortly after that went live we started receiving reports of Android failing to lock at all (but just Android - iOS was fine). At the time I was unable to figure out why, so we restored the lock timers for Android only (PR #1220). This brings us to today, where a recent bug full of red herrings led me to discover why Android was (seemingly) randomly failing to lock after the first PR. The culprit is the Android back button/gesture and how it relates to Xamarin Forms app lifecycles. I incorrectly assumed Xamarin's `OnResume()` would always fire when the app was brought back to the foreground, regardless of how it got to the background (native Android does this). Turns out this only works when the app is backgrounded via the home button/gesture. When the back button/gesture is used, the next time the app is brought to the foreground it will call Xamarin's `OnStart()` method, which until this PR was _not_ checking the vault lock timer. That hole is now plugged, fixing the reported bug as well as the original issue from December and (finally) negating the need for the timer (which has been removed again). **TL;DR:** Vault timeout clock check additionally needs to be performed in Xamarin `OnStart()` for Android to catch multiple backgrounding/foregrounding flows. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-26 23:25:34 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#2892