From 26070fb788049a5ffeb2e0fdd8a875481fe8e785 Mon Sep 17 00:00:00 2001 From: Timothy <6560631+TimoPtr@users.noreply.github.com> Date: Wed, 9 Jul 2025 10:07:50 +0200 Subject: [PATCH] Add android strict mode documentation (#2719) --- docs/android.md | 1 + docs/android/tips/strict_mode.md | 20 ++++++++++++++++++++ sidebars.js | 1 + 3 files changed, 22 insertions(+) create mode 100644 docs/android/tips/strict_mode.md diff --git a/docs/android.md b/docs/android.md index 2f4fa2e6..f249d8b6 100644 --- a/docs/android.md +++ b/docs/android.md @@ -24,6 +24,7 @@ Are you ready to make a difference in the world of smart home technology? The ** We welcome contributions of all kinds! Here are some ways you can get involved: +- **Join the [beta](https://play.google.com/apps/testing/io.homeassistant.companion.android)**: Help us catch issues before they reach production. - **Code contributions**: Fix bugs, add features, or improve performance. - **Code reviews**: Help others by reviewing their work and providing constructive feedback. - **Documentation**: Keep our guides clear, concise, and up-to-date. diff --git a/docs/android/tips/strict_mode.md b/docs/android/tips/strict_mode.md new file mode 100644 index 00000000..09980d52 --- /dev/null +++ b/docs/android/tips/strict_mode.md @@ -0,0 +1,20 @@ +--- +title: "StrictMode" +sidebar_label: "StrictMode" +--- + +## StrictMode in debug builds + +StrictMode is enabled by default when you run the app in debug mode on Android. StrictMode helps you identify accidental disk or network access on the main thread, as well as other potential issues during development. For more information, see the [StrictMode documentation](https://developer.android.com/reference/android/os/StrictMode). + +StrictMode also helps us migrate to new versions of the Android API by highlighting deprecated or problematic behaviors early in development. + +The [VM policy](https://developer.android.com/reference/android/os/StrictMode.VmPolicy.Builder) is configured with the `death` penalty, and the [threading policy](https://developer.android.com/reference/android/os/StrictMode.ThreadPolicy.Builder) is set to `log`. Review the logs carefully while developing to spot and address any issues. + +If you encounter a problem caused by StrictMode during development, you can temporarily disable it by setting the `noStrictMode` Gradle flag: + +```bash +./gradlew app:assembleFullDebug -PnoStrictMode +``` + +If you need to disable StrictMode, open an issue on GitHub or reach out on Discord. This helps ensure the problem is tracked and does not impact other developers. diff --git a/sidebars.js b/sidebars.js index e59771f7..f627aaa2 100644 --- a/sidebars.js +++ b/sidebars.js @@ -351,6 +351,7 @@ module.exports = { "android/tips/sarif_reports", "android/tips/release", "android/tips/dev_playground", + "android/tips/strict_mode", ], }, "android/best_practices",