Skip to content

Add permission security snippets for permission skill - #1044

Open
strzyzkat wants to merge 1 commit into
android:mainfrom
strzyzkat:strzyzkat/permissions-security-snippets
Open

Add permission security snippets for permission skill#1044
strzyzkat wants to merge 1 commit into
android:mainfrom
strzyzkat:strzyzkat/permissions-security-snippets

Conversation

@strzyzkat

Copy link
Copy Markdown

Adds code snippets and XML resources for the security module demonstrating Android permission security best practices and caller identity validation. These snippets ground the android-permission-security skill in tested, linted, and compiled code.

Changes made:

  • Custom Signature Permissions: Demonstrates signature protection levels for private inter-app communication in AndroidManifest.xml.
  • Known Signer Permissions (API 31+): Adds knownSigner permission configuration with certificate digest verification in security_certs.xml and AndroidManifest.xml.
  • Caller Validation (AppAuthenticator): Implements CallerVerifier.kt using Jetpack androidx.security:security-app-authenticator configured via allowed_peers.xml.
  • Runtime Permission Workflow: Adds RuntimePermissionsActivity.kt implementing modern ActivityResultContracts.RequestPermission and educational rationale checks (shouldShowRequestPermissionRationale).
  • Protected Broadcasts: Demonstrates permission-guarded broadcast dispatch, Android 14+ sender identity opt-in (BroadcastOptions.setShareIdentityEnabled), and receiver verification in ProtectedBroadcastSnippets.kt.
  • Binder IPC Method Checks: Implements FineGrainedBoundService.kt using enforceCallingPermission for method-level read/write permission segregation.
  • Content Provider Protection: Configures distinct readPermission (knownSigner) and writePermission (signature) in AndroidManifest.xml.
  • Error Handling & Signature Verification: Implements PermissionErrorHandling.kt demonstrating SecurityException handling and UID certificate checks via PackageManager.hasSigningCertificate.

@strzyzkat
strzyzkat requested a review from a team as a code owner August 21, 2026 13:52
@snippet-bot

snippet-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 17 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

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.

1 participant