Features Required
Pattern Input Handling
Support for users to input unlock patterns on a 3x3 grid.
Visual feedback for touch events, including highlighting selected dots and drawing lines between them.
Validation of input patterns according to Android's unlock rules:
No repeated dots.
Lines cannot skip dots unless the skipped dot has been used.
Pattern Storage and Verification
Securely store the user's chosen unlock pattern.
Allow users to set, confirm, and change their unlock patterns.
Verify input patterns against the stored pattern.
Security Features
Encrypt the stored pattern to prevent unauthorized access.
Implement a lockout mechanism after a certain number of failed attempts.
Provide feedback messages for incorrect patterns and lockout status.
User Interface
Intuitive and responsive UI for pattern input.
Indicate errors and lockout status to the user.
Support for different screen sizes and orientations.
Accessibility
Support for accessibility features such as TalkBack.
Ensure that the app is usable for users with disabilities.
Performance
Smooth and responsive touch handling.
Efficient use of resources to minimize battery consumption.
Design Patterns Used
Singleton Pattern
Purpose: Ensure a class has only one instance and provide a global point of access.
Usage: Managing a single instance of the security manager and pattern storage.
Factory Pattern
Purpose: Create objects without specifying the exact class of object that will be created.
Usage: Generating different types of pattern validators or encryption strategies.
Strategy Pattern
Purpose: Define a family of algorithms, encapsulate each one, and make them interchangeable.
Usage: Implementing different encryption algorithms or validation strategies.
Observer Pattern
Purpose: Allow an object to publish changes to its state. Other objects subscribe to be immediately notified of any changes.
Usage: Updating the UI based on changes in pattern input or lockout status.
Decorator Pattern
Purpose: Attach additional responsibilities to an object dynamically.
Usage: Adding encryption functionality to pattern storage without changing its interface.
Command Pattern
Purpose: Encapsulate a request as an object, thereby allowing for the parameterization of clients with queues, requests, and operations.
Usage: Handling user actions such as pattern drawing, undo, and reset.
Algorithms Involved
Pattern Validation Algorithm
- Validates the unlock pattern according to Android's rules.
Encryption Algorithm
- Securely encrypts and decrypts the stored pattern.
Lockout Algorithm
- Locks the pattern input after a certain number of failed attempts for a specified duration.
Touch Event Handling Algorithm
- Efficiently handles touch events to provide smooth pattern drawing.
Code (In Java)
Will be Covered in Our LLD Course (with Video Explanation) - http://interview.lldcoding.com/course/low-level-design-and-concurrency-machine-coding-course-360