Skip to content

Introduce Play Integrity API Canonical Sample App#124

Merged
robclifford27 merged 5 commits into
android:mainfrom
pcekwerike:main
May 22, 2026
Merged

Introduce Play Integrity API Canonical Sample App#124
robclifford27 merged 5 commits into
android:mainfrom
pcekwerike:main

Conversation

@pcekwerike
Copy link
Copy Markdown
Contributor

@pcekwerike pcekwerike commented May 22, 2026

Overview

This PR introduces the Play Integrity API Canonical Sample App to the repository. Many developers currently find integrating the API difficult due to backend-frontend coordination complexities and the steep learning curve of advanced features. This open-source, full-stack project serves as a best-practice blueprint to demystify the integration process and provide a tangible foundation for a production-ready setup.

Architecture Summary

To ensure architectural symmetry and educational clarity, this sample uses a full-stack approach:

  • Android Client: Built with Kotlin and Jetpack Compose, adhering to Modern Android Development (MAD) best practices. It utilizes a feature-based multi-module approach with a Unidirectional Data Flow (UDF) pattern.
  • Node.js Backend: Built using the Express.js framework, featuring a widely understood three-tier architecture. It operates as an intentionally stateless server without a traditional database layer to keep the focus strictly on Play Integrity API integration.

Included Micro-Apps

Rather than basic code snippets, the integration is demonstrated through three isolated, self-contained micro-app scenarios:

  • Bank Micro-app (Protecting a high-value action): A secure funds transfer simulation demonstrating secure data transmission, payload hashing for content binding, and triggering user remediation dialogs when security standards are not met.
  • Streaming Micro-app (Protecting a server-side resource): A Video-on-Demand (VOD) scenario showcasing a tiered trust strategy. The server dynamically modifies DASH XML manifests to offer higher or lower video resolutions to ExoPlayer based on the device's integrity verdicts.
  • Game Micro-app (Protecting a session environment): A real-time rhythm game that leverages Play Integrity's advanced environment signals to protect active gameplay. It demonstrates a defence against Time-of-Check to Time-of-Use (TOCTOU) exploits by requiring periodic background integrity checks to block screen capturing, accessibility misuse, and known malware.

Setup & Documentation

A follow-up PR will include the setup guide and project documentation.

@pcekwerike pcekwerike requested a review from TKBurner as a code owner May 22, 2026 10:52
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a sample application demonstrating Play Integrity API integration for banking, streaming, and gaming use cases, including both Android client and Node.js server components. The review identifies several technical issues and improvement opportunities: the need for deterministic JSON serialization to ensure consistent content binding hashes, the use of monotonic clocks instead of wall clocks for game timing, and the adoption of BigDecimal for financial precision. Further feedback suggests centralizing SDK versions and UI colors, implementing session cleanup on the server to prevent memory leaks, and disabling application backups to align with security best practices.

Comment thread PlayIntegrityAPI/android-client/app/src/main/AndroidManifest.xml Outdated
Comment thread PlayIntegrityAPI/android-client/feature/streaming/build.gradle.kts
Comment thread PlayIntegrityAPI/android-client/feature/streaming/build.gradle.kts
Comment thread PlayIntegrityAPI/node-server/src/features/game/game.controller.js
Comment thread PlayIntegrityAPI/node-server/src/services/crypto.service.js Outdated
Adds a full-stack Canonical Sample App for the Play Integrity API (PIA).
This blueprint demystifies integration complexities between frontend and
backend systems, providing developers with a production-ready foundation.

Architecture highlights:
- Android Client: Kotlin and Jetpack Compose, adhering to MAD best
  practices with a feature-based multi-module UDF approach.
- Node.js Backend: Express.js server using a three-tier architecture,
  kept intentionally stateless to focus strictly on PIA integration.

Includes three isolated micro-app scenarios:
- Bank (High-value action): Demonstrates secure data transmission,
  payload hashing for content binding, and user remediation dialogs.
- Streaming (Server-side resource): Showcases a tiered trust strategy
  that dynamically modifies DASH XML manifests to adjust ExoPlayer video
  resolutions based on integrity verdicts.
- Game (Session environment): Uses advanced environment signals in a
  real-time rhythm game to counter TOCTOU exploits, requiring periodic
  checks to block screen capturing, accessibility misuse, and malware.

Includes comprehensive end-to-end setup guides and dedicated READMEs
detailing the security theory and integration steps for each scenario.
@robclifford27 robclifford27 requested review from robclifford27 and removed request for TKBurner May 22, 2026 13:13
bkepez-go added 2 commits May 22, 2026 17:44
Update top-level README.md for PlayIntegrityAPI and add PlayIntegrity…
Copy link
Copy Markdown
Contributor

@robclifford27 robclifford27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved addition of play integrity API sample

@robclifford27 robclifford27 merged commit dca5991 into android:main May 22, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants