Skip to main content

API Reference

Complete class and schema documentation for the Browser Limit codebase.

Entry Points

MainActivity

File: app/src/main/java/com/example/MainActivity.kt

MethodDescription
onCreate()Installs splash screen, starts GuardService, sets up Compose content with lock screen and navigation

Composables:

FunctionDescription
LockScreen(settings, onUnlocked)PIN entry screen with optional waiting mode countdown
MainScreen()Navigation host with bottom bar (Dashboard, Exceptions, Logs, Settings)

Sealed class Screen:

ObjectRouteTitle
OnboardingonboardingSetup
DashboarddashboardDashboard
ExceptionsexceptionsExceptions
LogslogsLogs
SettingssettingsSettings

Data Layer

SettingsManager

File: app/src/main/java/com/example/data/SettingsManager.kt

SharedPreferences file: browserlimit_settings

PropertyTypeDefaultDescription
isActiveStateFlow<Boolean>trueWhether monitoring is active
useGeminiStateFlow<Boolean>trueWhether Gemini AI is enabled
showOverlayStateFlow<Boolean>trueOverlay mode enabled
autoRemoveStateFlow<Boolean>falseAuto-remove mode enabled
countdownDurationStateFlow<Int>10Overlay countdown in seconds (5-30)
runOnStartupStateFlow<Boolean>trueStart service on boot
showAnimationStateFlow<Boolean>trueShow splash animation
geminiApiKeyStateFlow<String>""Gemini API key
removeSystemChromeStateFlow<Boolean>falseRemove system Chrome
parentalLockWaitTimeStateFlow<Int>0Waiting mode duration (10-300s)
waitingModeEnabledStateFlow<Boolean>falseWaiting mode enabled
hasCompletedSetupBooleanfalseOnboarding completed
isParentalLockEnabledBooleanfalseParental lock enabled
parentalPinHashString""Parental lock PIN (plaintext)
geminiApiCountInt0API calls today
lastApiDateString""Date of last API call
geminiConfirmedBrowsersSet<String>emptySet()Cached browser classifications
geminiConfirmedNonBrowsersSet<String>emptySet()Cached non-browser classifications
MethodDescription
canUseGeminiApi(currentDateStr)Check if daily limit (20/day) is not reached; resets counter on new day
incrementGeminiApiCount()Increment the daily API counter
setActive(active)Toggle monitoring on/off
setUseGemini(use)Toggle Gemini AI
setShowOverlay(show)Set overlay mode (disables auto-remove)
setAutoRemove(auto)Set auto-remove mode (disables overlay)
setCountdownDuration(duration)Set countdown timer (5-30s)
setRunOnStartup(run)Toggle startup behavior
setShowAnimation(show)Toggle splash animation
setGeminiApiKey(key)Set Gemini API key
setRemoveSystemChrome(remove)Toggle system Chrome removal
setParentalLockWaitTime(time)Set waiting mode duration
setWaitingModeEnabled(enabled)Toggle waiting mode
addConfirmedBrowser(packageName)Cache a browser classification
addConfirmedNonBrowser(packageName)Cache a non-browser classification
removeConfirmedCache(packageName)Remove a package from both caches

ExceptionsManager

File: app/src/main/java/com/example/data/ExceptionsManager.kt

SharedPreferences file: browserlimit_exceptions

PropertyTypeDescription
exceptionsFlowStateFlow<List<String>>Observable list of exception package names
MethodDescription
isExcepted(packageName)Check if a package is in exceptions (includes permanent exceptions)
addException(packageName)Add a package to the exceptions list
removeException(packageName)Remove a package (except permanent exceptions)
setCustomExceptions(packages)Bulk-add packages to exceptions

Permanent exceptions: com.aistudio.browserlimit.abxyz, com.example


LogEntry

File: app/src/main/java/com/example/data/LogEntry.kt

Room entity for the logs table.

ColumnTypeDescription
idInt (auto-generated PK)Unique identifier
timestampLongUnix timestamp in milliseconds
appNameStringApp name from PackageManager
packageNameStringAndroid package name
detectionMethodStringClassification method used
decisionStringAction taken (Removed/Kept/Excepted/Error)
geminiResponseStringDetection reason or Gemini response
shizukuResultStringShizuku result (reserved)

LogDao

File: app/src/main/java/com/example/data/LogDao.kt

QueryReturn TypeDescription
getAllLogs()Flow<List<LogEntry>>All logs, newest first
getLogCount()suspend IntTotal log count
getRemovedTodayCount(todayStart)Flow<Int>Count of removals today
getScannedTodayCount(todayStart)Flow<Int>Count of scans today
insertLog(log)suspendInsert a log entry
trimLogs()suspendKeep only the last 500 entries
clearAll()suspendDelete all log entries

LogDatabase

File: app/src/main/java/com/example/data/LogDatabase.kt

Room database singleton. Database name: browserlimit_logs. Version: 1.

LogDatabase.getDatabase(context).logDao()

Engine Layer

BrowserDetector

File: app/src/main/java/com/example/engine/BrowserDetector.kt

MethodDescription
checkPackage(packageName, forceRecheck)Run the full detection flow and return a DetectionResult

DetectionResult data class:

FieldTypeDescription
isBrowserBooleanWhether the app is classified as a browser
methodStringHow it was classified
reasonStringHuman-readable explanation

BrowserDatabase

File: app/src/main/java/com/example/engine/BrowserDatabase.kt

Singleton object containing the hardcoded array of 50+ known browser package names.

object BrowserDatabase {
val KNOWN_BROWSERS: Array<String> // 50+ package names
}

GeminiClient

File: app/src/main/java/com/example/engine/GeminiClient.kt

MethodDescription
isBrowser(packageName)Classify an app as browser/non-browser via Gemini API

API endpoint: POST /v1beta/models/gemini-flash-lite-latest:generateContent

Request body (serialized via kotlinx-serialization):

@Serializable
data class GenerateContentRequest(
val systemInstruction: Content? = null,
val contents: List<Content>,
val tools: List<JsonObject>? = null,
val generationConfig: GenerationConfig? = null
)

ShizukuUninstaller

File: app/src/main/java/com/example/engine/ShizukuUninstaller.kt

MethodDescription
uninstallPackage(packageName)Uninstall an app via Shizuku. Returns true on success.

NotificationHelper

File: app/src/main/java/com/example/engine/NotificationHelper.kt

MethodDescription
sendUninstallNotification(context, appName, packageName, reason)Post a notification about an app removal

Notification channel: uninstall_notifications ("Uninstalled Browsers")


Service Layer

GuardService

File: app/src/main/java/com/example/service/GuardService.kt

Foreground service that monitors for new app installations.

ActionDescription
DefaultStart foreground notification
PAUSE_RESUMEToggle isActive setting

Notification channel: GuardServiceChannel ("Browser Limit Service")


AppInstallReceiver

File: app/src/main/java/com/example/receiver/AppInstallReceiver.kt

BroadcastReceiver for ACTION_PACKAGE_ADDED. Triggers the full detection and removal flow.


BootReceiver

File: app/src/main/java/com/example/receiver/BootReceiver.kt

BroadcastReceiver for BOOT_COMPLETED and LOCKED_BOOT_COMPLETED. Starts GuardService if runOnStartup is enabled.


UI Components

ParentalUnlockDialog

File: app/src/main/java/com/example/ui/components/ParentalUnlockDialog.kt

Reusable PIN unlock dialog with optional waiting mode countdown.

ParameterTypeDescription
settingsSettingsManagerSettings instance for PIN verification
onSuccess() -> UnitCalled when correct PIN is entered
onCancel() -> UnitCalled when dialog is dismissed

Dependencies

LibraryVersionPurpose
Shizuku API13.1.5Rootless package management
Lottie Compose6.4.0Splash screen animation
kotlinx-serialization1.7.3JSON serialization for Gemini API
RoomBOM-managedLocal database
RetrofitBOM-managedHTTP client for Gemini API
OkHttpBOM-managedHTTP transport
MoshiBOM-managedJSON parsing
CoilBOM-managedImage loading
Firebase BOMBOM-managedFirebase integration (reserved)
SplashScreen1.0.1Android 12+ splash screen