Skip to content

fix(android): stop using deprecated hasPermission to read Cordova prefs - #8550

Merged
OS-ruimoreiramendes merged 8 commits into
nextfrom
fix/RMET-5358/deprecated-haspermission-android
Aug 7, 2026
Merged

fix(android): stop using deprecated hasPermission to read Cordova prefs#8550
OS-ruimoreiramendes merged 8 commits into
nextfrom
fix/RMET-5358/deprecated-haspermission-android

Conversation

@OS-ruimoreiramendes

@OS-ruimoreiramendes OS-ruimoreiramendes commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

Bridge.isDeployDisabled() and Bridge.shouldKeepRunning() used Plugin.hasPermission(String), a
deprecated Android permission API to fetch the Cordova DisableDeploy and KeepRunning preferences
from the internal CordovaPlugin. Those strings are not Android permissions, they are Cordova
config.xml preferences.

Introduce a small CordovaBridgeConfig interface in com.getcapacitor, implemented by CordovaPlugin (in capacitor-cordova-android). The Bridge now queries the plugin instance via instanceof and reads the preferences through the interface. The misleading hasPermission override in CordovaPlugin is removed.

ref: https://outsystemsrd.atlassian.net/browse/RMET-5358

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation
  • Other (CI, chores, etc.)

Rationale / Problems Fixed

Plugin.hasPermission(String) has been @Deprecated for a while and is meant for Android runtime permissions, not for reading arbitrary configuration values. The CordovaPlugin was overriding it to intercept two strings (DisableDeploy, KeepRunning) and route them to preferences.getBoolean(), which does not match the API's intent and produces deprecation warnings at both call sites in Bridge.

The new CordovaBridgeConfig interface:

  • Uses semantically correct names (isDeployDisabled, shouldKeepRunning)
  • Keeps the module boundary intact, capacitor-android does not depend on capacitor-cordova-android, so the interface acts as the bridge between them
  • Removes the two deprecation warnings on every build

Tests or Reproductions

Validated using capacitor-testapp with runtime validation. A Cordova plugin was registered and config.xml preferences set:

<preference name="DisableDeploy" value="true" />
<preference name="KeepRunning" value="false" />

Bridge returned isDeployDisabled=true, shouldKeepRunning=false meaning values read correctly through the interface. Fallback path (no Cordova plugin registered) returns false for both, matching prior behavior.

Platforms Affected

  • Android
  • iOS
  • Web

@OS-ruimoreiramendes
OS-ruimoreiramendes merged commit 7e240f2 into next Aug 7, 2026
7 checks passed
@OS-ruimoreiramendes
OS-ruimoreiramendes deleted the fix/RMET-5358/deprecated-haspermission-android branch August 7, 2026 12:52
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