com.phosra.sdk Kotlin library provides on-device child safety enforcement for Android using UsageStatsManager, DevicePolicyManager, VpnService, and AccessibilityService.
Overview
The SDK has a two-layer architecture:- API Client — Communicates with the Phosra API to register devices, fetch compiled policies, submit enforcement reports, and acknowledge policy versions.
- Enforcement Engine — Translates the compiled policy document into native Android API calls to enforce content filters, screen time limits, web filtering, purchase controls, and more.
API Client
Handles device registration, policy sync, and reporting via the Phosra REST API.
Enforcement Engine
Maps policy rules to UsageStatsManager, DevicePolicyManager, VpnService, and AccessibilityService.
Requirements
Installation
The
com.phosra:sdk Android library is in private preview — it is not published to Maven Central or Google’s Maven repo yet. Email developers@phosra.com for the AAR / private Maven URL and access credentials. Once you have access, add the private repository and the dependency to your Gradle build:settings.gradle.kts
build.gradle.kts:
kotlinx-coroutines-android— Async operationskotlinx-serialization-json— JSON parsingokhttp3— HTTP networkingandroidx.work:work-runtime-ktx— Background syncandroidx.security:security-crypto— Encrypted key storage
Quick Start
Device Registration
The registration flow requires parent authentication and produces a device-specific API key:RegisterDeviceRequest includes device metadata and capability declarations:
Policy Sync
WorkManager-Based Sync
The SDK uses WorkManager for reliable background policy synchronization:Firebase Cloud Messaging (FCM)
For immediate policy refresh when a parent modifies rules, handle FCM data messages:Enforcement Engine
Each enforcer handles a specific policy section and maps it to the appropriate Android API.Content Filter Enforcer
Monitors the foreground app using UsageStatsManager and AccessibilityService. Blocks restricted apps by displaying a full-screen overlay.Screen Time Enforcer
Tracks cumulative daily usage and enforces time limits.Web Filter Enforcer
Runs a local VPN service that intercepts DNS queries and blocks restricted domains.Purchase Enforcer
Social Enforcer
Notification Enforcer
Permission Management
Android requires several special permissions. Each must be granted by the parent through system settings.- Usage Stats Access
- Overlay Permission
- Device Admin
- VPN Service
- Notification Listener
- Accessibility Service
Required for screen time tracking and foreground app detection.Check:
AppOpsManager.checkOpNoThrow(AppOpsManager.OPSTR_GET_USAGE_STATS, ...)Reporting
The SDK submits two types of reports to the Phosra API:Enforcement Status Report
Sent after applying a policy, contains per-category results:Screen Time Report
Aggregated daily usage data:CompiledPolicy Structure
The compiled policy is fetched fromGET /device/policy and contains all enforcement rules organized by section:
Supported Rule Categories
The 45 OCSS rule categories the Android SDK maps to native framework primitives (of the 123 categories in the OCSS rule registry; the remainder are policy-only or census-enforced and carry no client-side Android verb):Content Rules
Time Rules
Purchase Rules
Social Rules
Web Rules
Privacy Rules
Monitoring Rules
Engagement Rules
Notification Rules
Legislation-Driven Rules
Compliance Rules
Parental / Legislative Rules
Google Play Compliance
Required Declarations
-
Permissions Declaration Form: Submit in Play Console for
QUERY_ALL_PACKAGES,PACKAGE_USAGE_STATS, and Accessibility Service usage. -
Data Safety section: Declare all data collected from child devices. Phosra collects:
- App usage statistics (aggregated)
- Web activity (domain-level, via DNS)
- Device metadata (model, OS version)
- VPN usage: Declare that the VPN is used exclusively for local DNS filtering, not for routing traffic through external servers.
- Target audience: Set to “Parents” — the app is a parental control tool, not a child-facing app.
- Families Policy: If your app appears in the Play Store’s Family section, ensure compliance with Google’s Families Policy.
Tips for Approval
- Provide a detailed app description explaining the parental control use case
- Include a demo video showing the parent setup flow and enforcement in action
- Reference applicable child safety legislation (COPPA, KOSA, etc.)
- Respond promptly to any review team questions about permission usage