Skip to content

feat(android): honor mediaCapturePermissionGrantType="deny" (AGE-378)#46

Closed
alexz-phantom wants to merge 1 commit into
masterfrom
alexz/age-378-android-deny-media-capture
Closed

feat(android): honor mediaCapturePermissionGrantType="deny" (AGE-378)#46
alexz-phantom wants to merge 1 commit into
masterfrom
alexz/age-378-android-deny-media-capture

Conversation

@alexz-phantom

@alexz-phantom alexz-phantom commented Jun 30, 2026

Copy link
Copy Markdown

Android previously ignored the mediaCapturePermissionGrantType prop in the dApp browser WebView fork — the native setter was a no-op. Implement the minimal native enforcement the dApp browser contract needs:

  • Persist the prop value in RNCWebChromeClient and propagate it through both the new- and old-architecture managers and RNCWebViewManagerImpl.
  • Short-circuit RNCWebChromeClient.onPermissionRequest for deny: call request.deny() and return before reading requested resources, showing the site-attributed AlertDialog, or triggering an OS CAMERA/RECORD_AUDIO request.
  • Any other value (including the default prompt) preserves existing Android behavior; iOS behavior is unchanged.
  • Add a JVM unit test proving the deny short-circuit, plus the JUnit/Mockito test deps and testOptions to run it.
  • Expose the prop on AndroidWebViewProps, update docs, and add a changeset.

Summary by CodeRabbit

  • New Features

    • Added Android support for configuring how media capture permission requests are handled.
    • The deny option now blocks camera/microphone prompts on Android, while other values keep the existing prompt behavior.
  • Documentation

    • Clarified platform support and behavior for media capture permission settings.
  • Tests

    • Added coverage for denied requests and for preserving the existing prompt flow in other cases.

Android previously ignored the `mediaCapturePermissionGrantType` prop in the
dApp browser WebView fork — the native setter was a no-op. Implement the
minimal native enforcement the dApp browser contract needs:

- Persist the prop value in RNCWebChromeClient and propagate it through both
  the new- and old-architecture managers and RNCWebViewManagerImpl.
- Short-circuit RNCWebChromeClient.onPermissionRequest for `deny`: call
  request.deny() and return before reading requested resources, showing the
  site-attributed AlertDialog, or triggering an OS CAMERA/RECORD_AUDIO request.
- Any other value (including the default prompt) preserves existing Android
  behavior; iOS behavior is unchanged.
- Add a JVM unit test proving the deny short-circuit, plus the JUnit/Mockito
  test deps and testOptions to run it.
- Expose the prop on AndroidWebViewProps, update docs, and add a changeset.

Co-authored-by: Alexandra Zinkus <214535469+alexz-phantom@users.noreply.github.com>
@alexz-phantom alexz-phantom deleted the alexz/age-378-android-deny-media-capture branch June 30, 2026 22:51
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b608f1f6-c02a-428c-aad3-2ef5f6c406a2

📥 Commits

Reviewing files that changed from the base of the PR and between 413d5ea and e2ff9cc.

📒 Files selected for processing (9)
  • .changeset/age-378-android-deny-media-capture.md
  • android/build.gradle
  • android/src/main/java/com/reactnativecommunity/webview/RNCWebChromeClient.java
  • android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt
  • android/src/newarch/com/reactnativecommunity/webview/RNCWebViewManager.java
  • android/src/oldarch/com/reactnativecommunity/webview/RNCWebViewManager.java
  • android/src/test/java/com/reactnativecommunity/webview/RNCWebChromeClientTest.java
  • docs/Reference.md
  • src/WebViewTypes.ts

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Walkthrough

This PR adds Android-native enforcement of mediaCapturePermissionGrantType="deny" in RNCWebChromeClient.onPermissionRequest, propagates the setting through RNCWebViewManagerImpl and old/new architecture RNCWebViewManager classes via a new React prop, adds unit tests and Gradle test dependencies, and updates TypeScript types, documentation, and a changeset.

Changes

Android deny media capture permission

Layer / File(s) Summary
RNCWebChromeClient deny short-circuit
android/src/main/java/com/reactnativecommunity/webview/RNCWebChromeClient.java
Adds a "deny" constant and field, a setter method, and an early-return guard in onPermissionRequest that calls request.deny() and skips the existing dialog/OS-permission flow when the grant type is "deny".
Prop wiring through manager layers
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt, android/src/newarch/.../RNCWebViewManager.java, android/src/oldarch/.../RNCWebViewManager.java
Persists and forwards the grant type from RNCWebViewManagerImpl to RNCWebChromeClient, and exposes the mediaCapturePermissionGrantType React prop via @ReactProp in both architecture variants.
Unit tests and build test config
android/build.gradle, android/src/test/.../RNCWebChromeClientTest.java
Adds testOptions and JUnit/Mockito dependencies, and a new test class verifying deny short-circuits the request while null/unknown grant types preserve the existing prompt flow.
TypeScript types, docs, and changeset
src/WebViewTypes.ts, docs/Reference.md, .changeset/age-378-android-deny-media-capture.md
Adds mediaCapturePermissionGrantType to AndroidWebViewProps with JSDoc, updates IOSWebViewProps JSDoc, updates the reference doc's platform coverage and behavior notes, and adds a patch changeset.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch alexz/age-378-android-deny-media-capture

Comment @coderabbitai help to get the list of available commands.

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.

2 participants