Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancing App Locking Mechanism and Handling Edge Cases #815

Merged
merged 1 commit into from
Jun 1, 2023

Conversation

acezard
Copy link
Contributor

@acezard acezard commented Jun 1, 2023

This pull request refines the app's locking mechanism by centralizing its logic and improving the handling of edge cases. Here are the key changes:

  1. Refactoring: The globalAppState now uses the same locking service as the homeView. This change eliminates potential conflicts that could arise from different services handling the lock mechanism. It centralizes the logic, making the code more maintainable and less prone to bugs.

  2. Enhanced Error Handling: With this update, we've introduced better handling of edge cases that were previously unhandled. This includes situations where the route may be undefined or the time since the last activity is negative. Instead of letting these cases cause potential bugs, the app will now default to a locked state, thus improving its security.

  3. Test Coverage: To ensure these changes function as expected, we've added a comprehensive set of tests. These tests cover situations including various states of app activity, different device platforms, and unexpected route values. These tests ensure our app lock mechanism is robust and can handle multiple situations correctly.

  4. Improved User Experience: Finally, these changes result in an overall improvement in the user experience. By ensuring the app always behaves predictably, even in edge cases, users can rely on the app to maintain their privacy and security.

This pull request is a step towards improving the app's resilience and reliability. It minimizes potential bugs and makes the code more maintainable. With these enhancements, the app becomes more secure and user-friendly.

graph LR;
    A[Start] --> B{Check AppState}
    B --> |Background| C[HandleSleep]
    B --> |Active| D[HandleWakeUp]
    C --> |Store Timestamp| E[End]
    D --> |Retrieve LastActivity| F{Check timeSinceLastActivity}
    F --> |Negative Time| G[Default to Lock]
    F --> |Time <= TIMEOUT_VALUE| H[Hide SplashScreen]
    F --> |Time > TIMEOUT_VALUE| I[Lock App]
    G --> |Lock App| E
    H --> |End| E
    I --> |Redirect to Lock Screen| E
Loading

@acezard acezard changed the title refactor: update wakeup lock check Enhancing App Locking Mechanism and Handling Edge Cases Jun 1, 2023
@zatteo
Copy link
Contributor

zatteo commented Jun 1, 2023

Nice tests and nice refactoring.

The schema could be stored in /docs ?

@acezard
Copy link
Contributor Author

acezard commented Jun 1, 2023

Nice tests and nice refactoring.

The schema could be stored in /docs ?

I guess it could be kept somewhere in the repo yeah, maybe a /docs/autolock.md or something

@acezard acezard force-pushed the refactor--update-wakeup-lock-check branch from 2d966f6 to 7318f0f Compare June 1, 2023 08:10
@acezard acezard force-pushed the refactor--update-wakeup-lock-check branch 2 times, most recently from 7b4354e to ff4866a Compare June 1, 2023 11:36
After removing the global didRenderOnce from home,
we had some cases where a double lock could happen because the home was
rerendered due to a side-effect in globalAppState.
To remove that, we make globalAppState use
the same locking service as homeView,
with this centralized logic we remove potential conflicts.
We also add tests and handle edge cases that
were not previously handled
@acezard acezard force-pushed the refactor--update-wakeup-lock-check branch from ff4866a to 399f4b9 Compare June 1, 2023 11:43
@acezard acezard merged commit 5b233d9 into master Jun 1, 2023
@acezard acezard deleted the refactor--update-wakeup-lock-check branch June 1, 2023 12:05
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.

2 participants