Skip to content

fix: [SDK-4193] suppress unchecked cast warnings in Android bridge#1129

Merged
fadi-george merged 2 commits intomainfrom
fadi/sdk-4193-suppress-unchecked-cast-warnings-in-android-flutter-bridge
Mar 19, 2026
Merged

fix: [SDK-4193] suppress unchecked cast warnings in Android bridge#1129
fadi-george merged 2 commits intomainfrom
fadi/sdk-4193-suppress-unchecked-cast-warnings-in-android-flutter-bridge

Conversation

@fadi-george
Copy link
Collaborator

Description

One Line Summary

Add @SuppressWarnings("unchecked") to 7 methods in the Android Java bridge to eliminate unchecked cast compiler warnings.

Details

Motivation

Fixes GitHub issue #1122. Users with -Xlint:unchecked enabled in their Gradle config see 7 unchecked cast warnings when compiling the plugin. These casts are safe because Flutter's StandardMessageCodec guarantees the types from the Dart side, and most are already guarded by ClassCastException try-catch blocks.

Scope

Only affects Android Java bridge layer. No behavioral changes — warnings are suppressed, not the casts themselves.

Affected methods:

  • OneSignalNotifications.getJsonFromMap()ObjectMap<String, Object>
  • OneSignalUser.addAliases()call.argumentsMap<String, String>
  • OneSignalUser.removeAliases()call.argumentsList<String>
  • OneSignalUser.addTags()call.argumentsMap<String, String>
  • OneSignalUser.removeTags()call.argumentsList<String>
  • OneSignalInAppMessages.addTriggers()call.argumentsMap<String, String>
  • OneSignalInAppMessages.removeTriggers()call.argumentsCollection<String>

Also removed redundant comments that just restated what the code does.

Testing

Manual testing

Reproduced the 7 warnings by temporarily adding -Xlint:unchecked to the plugin's build.gradle and running ./gradlew :onesignal_flutter:compileDebugJavaWithJavac from the example app. After applying the fix, all 7 warnings are resolved.

Affected code checklist

  • Notifications
  • In-App Messaging

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

Made with Cursor

@fadi-george fadi-george requested a review from a team as a code owner March 19, 2026 18:47
Comment on lines +9 to +13
uses: OneSignal/sdk-shared/.github/workflows/linear-deployed.yml@main
with:
release_body: ${{ github.event.release.body }}
secrets:
LINEAR_GITHUB_API_KEY: ${{ secrets.LINEAR_GITHUB_API_KEY }}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 8 days ago

In general, the fix is to add an explicit permissions block that grants only the minimum GITHUB_TOKEN scopes required for this workflow. Because this workflow only triggers on releases and passes github.event.release.body into a reusable workflow, the calling workflow itself does not appear to need any write permissions. A safe and minimal default is to set contents: read at the workflow level, which is equivalent to a read‑only GITHUB_TOKEN for repo contents. The reusable workflow can still request additional permissions if it truly needs them.

Concretely, in .github/workflows/linear-deployed.yml, add a permissions: block near the top level, alongside name: and on: (or immediately after name:). Set contents: read, which is the typical baseline for workflows that only need to read repository data. No imports or external dependencies are needed, since this is pure YAML configuration. Existing behavior of the workflow will remain the same in normal cases, except that unintended write capabilities via GITHUB_TOKEN will be removed unless explicitly re‑granted.

Suggested changeset 1
.github/workflows/linear-deployed.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/linear-deployed.yml b/.github/workflows/linear-deployed.yml
--- a/.github/workflows/linear-deployed.yml
+++ b/.github/workflows/linear-deployed.yml
@@ -1,5 +1,8 @@
 name: Move Linear tickets to Deployed
 
+permissions:
+  contents: read
+
 on:
   release:
     types: [published, edited]
EOF
@@ -1,5 +1,8 @@
name: Move Linear tickets to Deployed

permissions:
contents: read

on:
release:
types: [published, edited]
Copilot is powered by AI and may make mistakes. Always verify output.
@fadi-george fadi-george merged commit c4fa58d into main Mar 19, 2026
5 checks passed
@fadi-george fadi-george deleted the fadi/sdk-4193-suppress-unchecked-cast-warnings-in-android-flutter-bridge branch March 19, 2026 19:16
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.

[question]: unchecked cast Android

2 participants