# martinkayjr/autocheckinplugin architecture

> Architecture diagram of the GitHub repository martinkayjr/autocheckinplugin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/martinkayjr/autocheckinplugin
- Repository: https://github.com/martinkayjr/autocheckinplugin

## Overview

##### Main Components
- App Module (“app”): The central Android codebase that includes the UI components (activities, layouts), core check-in services, accessibility service (MyAccessibilityService), and various helper utilities.
- Service Layer: Contains background services (AutoCheckinService, AssistService, WifiLockService) that handle the automated checkin logic, notification keep-alive, and remote control commands.
- Handlers and Processors: A set of handler classes (including page processors for WeChat such as LoginProcessor, SiginInProcessor, etc.) that encapsulate the business logic for navigating different states of the check-in process.
- Communication/Utility Components: This includes helper utilities (ShellUtils, TimeUtil, DialogUtils, etc.) and configuration classes (Constant.java) which provide the low-level support needed throughout the app.
- “randompkg” Module: This component is designed to generate random package names and sign APKs to prevent detection. It houses utility classes for APK signing (ApkSignerV2, ZipUtils) and key generation.
- “smart/detect” Module: Likely dedicated to detection or monitoring, possibly performing tests or ensuring that the application’s behavior meets automated check-in criteria.
- External Services and Interfaces: These include integration with email notifications, remote command listeners (for QQ, WeChat, TIM, Alipay), and interactions using ADB commands or rooted/shizuku environments.

##### Depicting Relationships and Interactions
- That the UI layer (MainActivity, layouts) initiates user actions and settings which are then relayed to the Service Layer.
- Services being triggered either by scheduled tasks (or by the device’s state like screen on/off) to launch auto-checkin routines.
- That services invoke the appropriate Handlers/PageProcessors when interacting with WeChat to perform check-in operations.
- That the Utility classes provide common functionality (date handling, shell commands, logging) across multiple layers.

##### Architectural Patterns and Design Principles
- Layered Architecture: Separate UI, Service, Handler/Processor, and Utility layers.
- Modularization: Distinct modules for main check-in functionality, random package generation, and smart detection.
- Service-Oriented Approach: Background services and accessibility service run independently while communicating to fulfill the app’s automation tasks.
- Resilience: Mechanisms for notification and keep-alive features ensuring the background services remain active even in restrictive environments.

##### Essential Technologies, Frameworks, and Libraries
- Android SDK for the core app and UI components.
- Gradle (with Kotlin DSL) for build management (note the app/build.gradle.kts and settings.gradle.kts).
- Accessibility frameworks to interact with the system for automated UI tasks.
- Root and Shizuku integration using hidden APIs (requiring a special AOSP Android jar).
- Email services and communication protocols used for notifications.

##### Detailed Customization for This Project
- Since this is a full-fledged, automated check-in solution for an enterprise scenario, highlight the interaction between user configuration (through the UI), service orchestration, and automated execution via accessibility services.
- Keep the separation clean between the core auto-checkin logic (in the main app module) and the counter-detection measures (in the “randompkg” module). Also, illustrate how the “smart/detect” module verifies or supports the primary function.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Top-level Core Application Node
    AM["App Module (Core)"]:::app

    %% UI/Presentation Layer Subgraph
    subgraph "UI/Presentation Layer"
        UI1["MainActivity & UI Layouts"]:::ui
        UI2["AndroidManifest"]:::ui
    end

    %% Service & Process Layer Subgraph
    subgraph "Service & Process Layer"
        SL["Service Layer"]:::serviceLayer
        HP["Handlers/Processors"]:::processor
        HPP["Page Processors (Login, SignIn, Complete, etc.)"]:::processor
        UTL["Communication/Utility"]:::utility
        UTL2["Additional Utils"]:::utility
        S1["AutoCheckinService"]:::service
        S2["AssistService"]:::service
        S3["MyAccessibilityService"]:::service
        S4["WifiLockService"]:::service
    end

    %% External Modules Subgraph
    subgraph "External Modules"
        RP["randompkg Module"]:::external
        SD["smart/detect Module"]:::external
        EC["Email & Remote Command Services"]:::external
    end

    %% Connections between Core Application and Layers
    AM -->|"triggers"| UI1
    AM -->|"triggers"| SL

    %% Connections within UI Layer and Service Layer
    UI1 -->|"sends config"| UTL
    UI2 -->|"configures services"| S3

    %% Service Layer interactions
    SL -->|"initiates"| S1
    SL -->|"initiates"| S2
    SL -->|"initiates"| S3
    SL -->|"initiates"| S4
    S1 -->|"invokes"| HPP
    S2 -->|"assists"| HPP
    S3 -->|"reports events to"| HPP
    S4 -->|"maintains network"| HPP
    HP -->|"orchestrates"| HPP
    HPP -->|"utilizes"| UTL
    HP -->|"utilizes"| UTL
    UTL -->|"accesses"| UTL2

    %% Interactions with External Modules
    S1 -->|"sends notifications"| EC
    HPP -->|"applies randomization"| RP
    HPP -->|"monitors environment"| SD

    %% Click Events
    click AM "https://github.com/martinkayjr/autocheckinplugin/tree/master/app/"
    click SL "https://github.com/martinkayjr/autocheckinplugin/tree/master/app/src/main/java/cn/martinkay/checkin/service"
    click HP "https://github.com/martinkayjr/autocheckinplugin/tree/master/app/src/main/java/cn/martinkay/checkin/handler"
    click HPP "https://github.com/martinkayjr/autocheckinplugin/tree/master/app/src/main/java/cn/martinkay/checkin/handler/pageprocessor"
    click UTL "https://github.com/martinkayjr/autocheckinplugin/tree/master/app/src/main/java/cn/martinkay/checkin/util"
    click UTL2 "https://github.com/martinkayjr/autocheckinplugin/tree/master/app/src/main/java/cn/martinkay/checkin/utils"
    click RP "https://github.com/martinkayjr/autocheckinplugin/tree/master/randompkg/"
    click SD "https://github.com/martinkayjr/autocheckinplugin/tree/master/smart/detect/"

    %% Style Definitions
    classDef app fill:#E0BBE4,stroke:#000,stroke-width:2px;
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef service fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef serviceLayer fill:#98FB98,stroke:#000,stroke-width:2px;
    classDef processor fill:#FFC0CB,stroke:#000,stroke-width:2px;
    classDef utility fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef external fill:#FFE4B5,stroke:#000,stroke-width:2px;

    %% Assign Classes to Nodes
    class AM app;
    class UI1,UI2 ui;
    class SL serviceLayer;
    class S1,S2,S3,S4 service;
    class HP,HPP processor;
    class UTL,UTL2 utility;
    class RP,SD,EC external;
```
