Skip to main content
The 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:
  1. API Client — Communicates with the Phosra API to register devices, fetch compiled policies, submit enforcement reports, and acknowledge policy versions.
  2. 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
Then add the dependency to your module-level build.gradle.kts:
The SDK pulls in the following transitive dependencies:
  • kotlinx-coroutines-android — Async operations
  • kotlinx-serialization-json — JSON parsing
  • okhttp3 — HTTP networking
  • androidx.work:work-runtime-ktx — Background sync
  • androidx.security:security-crypto — Encrypted key storage

Quick Start

Device Registration

The registration flow requires parent authentication and produces a device-specific API key:
The 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.
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 from GET /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

Apps using UsageStatsManager, AccessibilityService, VpnService, and Device Admin require additional review by Google Play. Plan for a longer review cycle.

Required Declarations

  1. Permissions Declaration Form: Submit in Play Console for QUERY_ALL_PACKAGES, PACKAGE_USAGE_STATS, and Accessibility Service usage.
  2. 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)
  3. VPN usage: Declare that the VPN is used exclusively for local DNS filtering, not for routing traffic through external servers.
  4. Target audience: Set to “Parents” — the app is a parental control tool, not a child-facing app.
  5. 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