Try Our Course for 4 Hours @99rs

Try our course for 4 Hours and if you like it, you can go for one year or lifetime access. If you buy our (1yr or lifetime) course 99rs will be refunded !

Design (LLD) Android Unlock Pattern - Machine Coding Interview

Design (LLD) Android Unlock Pattern - Machine Coding Interview

Features Required

  1. 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.

  2. 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.

  3. 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.

  4. User Interface

    • Intuitive and responsive UI for pattern input.

    • Indicate errors and lockout status to the user.

    • Support for different screen sizes and orientations.

  5. Accessibility

    • Support for accessibility features such as TalkBack.

    • Ensure that the app is usable for users with disabilities.

  6. Performance

    • Smooth and responsive touch handling.

    • Efficient use of resources to minimize battery consumption.

Design Patterns Used

  1. 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.

  2. 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.

  3. Strategy Pattern

    • Purpose: Define a family of algorithms, encapsulate each one, and make them interchangeable.

    • Usage: Implementing different encryption algorithms or validation strategies.

  4. 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.

  5. Decorator Pattern

    • Purpose: Attach additional responsibilities to an object dynamically.

    • Usage: Adding encryption functionality to pattern storage without changing its interface.

  6. 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

  1. Pattern Validation Algorithm

    • Validates the unlock pattern according to Android's rules.
  2. Encryption Algorithm

    • Securely encrypts and decrypts the stored pattern.
  3. Lockout Algorithm

    • Locks the pattern input after a certain number of failed attempts for a specified duration.
  4. 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