platform-samples icon indicating copy to clipboard operation
platform-samples copied to clipboard

Add safer intents sample

Open yrezgui opened this issue 1 year ago • 2 comments

yrezgui avatar May 01 '24 23:05 yrezgui

/gemini summary

yrezgui avatar Mar 18 '25 16:03 yrezgui

Summary of Changes

This pull request adds a new sample, SaferIntents, to demonstrate the importance of handling intents correctly to avoid potential crashes. The sample includes two buttons: one that sends a NULL intent (which is now handled with exception handling to prevent crashes) and another that sends a regular intent. The PR also updates the Gradle configuration, including upgrading the Android Gradle Plugin (AGP) and Gradle version, and adjusts the minimum SDK version for the app.

Highlights

  • New Sample: SaferIntents: Introduces a new sample demonstrating how to handle intents safely to prevent ActivityNotFoundException crashes when a NULL intent is sent.
  • Gradle Updates: Updates the Gradle version to 8.6 and the Android Gradle Plugin (AGP) to 8.4.1. Also, the minimum SDK version is increased to 24.
  • Workflow Updates: Updates the GitHub Actions workflow to use actions/checkout@v4 and actions/upload-artifact@v4 and targets API levels 31 and 34 for testing.

Changelog

Click here to see the changelog
  • .github/workflows/build.yml
    • Updates actions/checkout to v4 (line 19).
    • Updates actions/upload-artifact to v4 (lines 49, 56, and 97).
    • Changes runs-on to macos-latest-large (line 63).
    • Updates the API levels tested to 31 and 34 (line 67).
  • app/build.gradle.kts
    • Increases minSdk to 24 (line 37).
  • gradle/libs.versions.toml
    • Updates agp to version 8.4.1 (line 21).
    • Updates Gradle version to 8.6 (line 20).
  • gradle/wrapper/gradle-wrapper.properties
    • Updates distributionUrl to Gradle 8.6 (line 20).
  • samples/README.md
    • Adds a link to the new SaferIntents sample (line 93).
  • samples/security/intents/README.md
    • Creates a README file for the SaferIntents sample, explaining its purpose and functionality.
  • samples/security/intents/build.gradle.kts
    • Creates a build.gradle.kts file for the SaferIntents sample, including the plugin and namespace.
  • samples/security/intents/src/main/AndroidManifest.xml
    • Creates an AndroidManifest.xml file for the SaferIntents sample, declaring the SaferIntentsActivity and intent filter.
  • samples/security/intents/src/main/java/com/example/platform/security/intents/SaferIntents.kt
    • Creates the SaferIntents composable function, which includes buttons to send a NULL intent (with exception handling) and a regular intent.
  • samples/security/intents/src/main/java/com/example/platform/security/intents/SaferIntentsActivity.kt
    • Creates the SaferIntentsActivity, which displays a simple "Hello Android!" screen.

Activity

  • yrezgui requested a summary of the pull request using the command /gemini summary.
  • yrezgui suggested using RequiresApi annotation instead of upgrading the minSdk version.
  • yrezgui suggested inlining the HelloAndroidScreen function directly inside the Surface composable.
  • yrezgui asked for clarification on whether the activity can be launched with a NULL intent without the intent action filter, and if so, to explain it in the comments.

gemini-code-assist[bot] avatar Mar 18 '25 17:03 gemini-code-assist[bot]