How adguardteam/contentblocker works
Project Type and Purpose
• This is an Android application designed to block ads in browsers that support content-blocking (specifically Yandex Browser and Samsung Internet). Its primary function is to filter out unwanted ads by managing and applying filter lists.
• The app is open source and uses the standard Android technology stack (organized with Gradle, resource directories, AndroidManifest, etc).
Analyzing the File Structure
• The main code lies in the "adguard_cb" directory. Within it, you have the typical Android structure: an AndroidManifest, "src/main" code (including assets, Java packages, resources, layouts, etc), and test directories.
• Look into “adguard_cb/src/main/java/com/adguard/android/contentblocker” where the code is sub-divided into several packages:
• Packages related to UI (e.g., ui, ui/utils) for activities and dialogs.
• Service layer components (e.g., service, service/job) that encompass background tasks, jobs, notifications, and filter application.
• Data Access Object (DAO) packages and a “db” directory, including classes for managing and accessing the local database (likely built on SQLite).
• Network and API-related classes under “api” and “commons/network” indicate external communications (possibly for updating filters).
• Utility classes such as "BrowserUtils", "PackageUtils", etc.
• You also have test folders (androidTest and unit tests) and configuration/build files showing good practice separation.
Elements
• The UI communicates with service components.
• Services interact with the database and the network.
• System events (via BroadcastReceivers) trigger services.
• Jobs (from JobFactory/Worker classes) process tasks asynchronously.