Introduce check location disabled usecase#6734
Conversation
Test Results 233 files 241 suites 10m 25s ⏱️ For more details on these failures, see this check. Results for commit a838811. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Pull request overview
This PR introduces a dedicated use case to centralize the “location disabled while location-dependent features are active” check, and refactors call sites to use the extracted logic and shared settings intent creation.
Changes:
- Added
CheckLocationDisabledUseCaseand wired it into the legacyWebViewActivityflow and the newLaunchActivity(Frontend V2) flow - Refactored
DisabledLocationHandlerto provide a reusablelocationSettingsIntent(...)and a dedicatedshowLocationDisabledNotification(...) - Updated multiple call sites to reuse
locationSettingsIntent(...)and added unit tests for the new use case
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| common/src/main/kotlin/io/homeassistant/companion/android/common/util/DisabledLocationHandler.kt | Adds locationSettingsIntent + notification helper; simplifies dialog path; makes warning removal accept Context |
| app/src/main/kotlin/io/homeassistant/companion/android/util/CheckLocationDisabledUseCase.kt | New use case that decides whether to show/remove the location-disabled notification |
| app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewActivity.kt | Replaces inline location-disabled checking logic with the injected use case |
| app/src/main/kotlin/io/homeassistant/companion/android/launch/LaunchActivity.kt | Invokes the use case on onResume when Frontend V2 flag is enabled |
| app/src/main/kotlin/io/homeassistant/companion/android/webview/insecure/BlockInsecureFragment.kt | Reuses DisabledLocationHandler.locationSettingsIntent(...) |
| app/src/main/kotlin/io/homeassistant/companion/android/util/compose/HANavHost.kt | Reuses DisabledLocationHandler.locationSettingsIntent(...) |
| app/src/main/kotlin/io/homeassistant/companion/android/settings/ssid/SsidFragment.kt | Removes now-deleted showAsNotification argument from dialog call |
| app/src/test/kotlin/io/homeassistant/companion/android/frontend/CheckLocationDisabledUseCaseTest.kt | Adds unit tests for the new use case |
I'm guessing you meant to write 'and show a notification'. Some users have notifications disabled and/or ignore notifications. This change also removes the dialog in the WebViewActivity, making it easier to miss. I think there still should be something harder to ignore when actually opening the app, no? |
231cf9a to
ea71a61
Compare
You're right 🤔. I remember seeing this at some point but the git history says it's been like this for a long time. I still think there's an argument that we need to highlight this better but then that's outside the scope of the PR. |
jpelgrom
left a comment
There was a problem hiding this comment.
When testing I forgot to actually enable something that requires location 🤦. After adding a home Wi-Fi network it worked perfectly!
a6345c7 to
a838811
Compare
* Introduce WebViewAction and enforce EvaluateScriptUsage (home-assistant#6713) * Introduce WebViewActions and enforce EvaluateScriptUsage * Apply Copilot feedback * Update app/src/main/kotlin/io/homeassistant/companion/android/frontend/WebViewAction.kt Co-authored-by: Joris Pelgröm <[email protected]> --------- Co-authored-by: Joris Pelgröm <[email protected]> * Update github/codeql-action action to v4.35.2 (home-assistant#6728) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update ruby/setup-ruby action to v1.302.0 (home-assistant#6731) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Bump changelog_master.xml for weekly release 2026.4.5 (home-assistant#6730) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Handle missing client certificate chooser activity (home-assistant#6716) * Add support for Gesture in FrontendScreen (home-assistant#6714) --------- Co-authored-by: Joris Pelgröm <[email protected]> * Update lokalise/lokalise-pull-action action to v5.2.1 (home-assistant#6724) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Enable cookie in FrontendScreen (home-assistant#6715) * Update dependency io.sentry:sentry-android-core to v8.39.1 (home-assistant#6732) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Update fastlane to 2.233.0 (home-assistant#6737) * Allow artifacts update for Ruby with renovate (home-assistant#6738) * Add support for NFC write in FrontendScreen (home-assistant#6719) * Add support for NFC write in FrontendScreen * Apply suggestions * Apply suggestion and improve NfcSetupActivity * Renovate: split Compose screenshot updates from other com.android updates (home-assistant#6743) * Update runConfigurations to work properly on Android 17 (home-assistant#6740) * Update com.android.* (home-assistant#6675) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Timothy <[email protected]> * Remove Trigger workflow step from Renovate lockfile worflow (home-assistant#6747) * Remove unnecessary permissions for actions (home-assistant#6748) * Adjust LaunchActivity configChanges flags (home-assistant#6751) * Ignore Chromium keystore disk write strict mode issue (home-assistant#6758) * Add start workers in LaunchActivity (home-assistant#6720) * Introduce check location disabled usecase and show Changelog on LaunchActivity (home-assistant#6734) * Add support for Zoom in FrontendScreen (home-assistant#6739) * Allow observeChanges on LocalStorate * Update dependency sh.calvin.reorderable:reorderable to v3.1.0 (home-assistant#6761) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Initialize Timber before Application.onCreate (home-assistant#6757) * Disable microwakeword test on wearOS (home-assistant#6766) * Add lint rule for webview evaluate javascript (home-assistant#6741) * Configure Composer diagnostic stacktrace (home-assistant#6764) * Ignore JobService leak in InstrumentationTest for API23 (home-assistant#6765) --------- Co-authored-by: Joris Pelgröm <[email protected]> * Update ruby/setup-ruby action to v1.304.0 (home-assistant#6770) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update ruby/setup-ruby action to v1.305.0 (home-assistant#6772) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency ruby to v4.0.3 (home-assistant#6762) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Lock file maintenance (home-assistant#6783) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Bump changelog_master.xml for weekly release 2026.4.6 (home-assistant#6778) --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Timothy <[email protected]> * Update dependency io.sentry:sentry-android-core to v8.40.0 (home-assistant#6775) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Update dependency androidx.navigation:navigation-testing to v2.9.8 (home-assistant#6776) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Timothy <[email protected]> * Update org.jetbrains.kotlin.* (home-assistant#6774) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Timothy <[email protected]> * Update androidx.compose.* (home-assistant#6777) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Timothy <[email protected]> * Update com.android.* (home-assistant#6769) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Timothy <[email protected]> * Remove the use of Dispachers.Default in AppLockViewModel (home-assistant#6784) * Fix compose unit test and kotlin configuration after update (home-assistant#6785) --------- Co-authored-by: Joris Pelgröm <[email protected]> * Honor user-installed CAs in OkHttp trust store (home-assistant#6753) --------- Co-authored-by: Timothy <[email protected]> Co-authored-by: Copilot <[email protected]> * Add support for JSConfirm dialog in FrontendScreen (home-assistant#6749) * Fix resize cast for ExoPlayer in WebViewActivity causing blank player (home-assistant#6767) * Fix resize cast for ExoPlayer in WebViewActivity causing blank player * Use Double instead of Float * Enable fullscreen support at the LaunchActivity level (home-assistant#6759) * Enable fullscreen support at the LaunchActivity level * Add missing tests * Update ruby/setup-ruby action to v1.306.0 (home-assistant#6789) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Setup emulator WTF (home-assistant#6768) --------- Co-authored-by: Joris Pelgröm <[email protected]> * Add file chooser capability to FrontendScreen (home-assistant#6755) * Use a queue to handle FileChooserRequest --------- Co-authored-by: Copilot <[email protected]> * Adjust PermissionManager to use awaitResult (home-assistant#6787) * Update Gradle to v9.5.0 (home-assistant#6796) * Update Gradle to v9.5.0 * Update wrapper: gradlew wrapper --gradle-version 9.5.0 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Joris Pelgröm <[email protected]> * Bump changelog_master.xml for weekly release 2026.5.1 (home-assistant#6795) * Bump changelog_master.xml for weekly release 2026.5.1 * Empty commit for CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Joris Pelgröm <[email protected]> * Lock file maintenance (home-assistant#6802) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Bump changelog_master.xml for weekly release 2026.5.2 (home-assistant#6800) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Use OIDC to authenticate on Emulator.wtf (home-assistant#6803) * Add HTTP basic auth dialog to FrontendScreen (home-assistant#6750) * Introduce HACheckbox * Fix WebViewActivity leak via Handler.postDelayed in waitForConnection (home-assistant#5453) (home-assistant#6791) --------- Co-authored-by: jim-daf <[email protected]> Co-authored-by: Timothy <[email protected]> * Add app lock feature to FrontendScreen (home-assistant#6756) * Add Blur overlay to LaunchActivity * Migrate to AppLockStateManager * Fix leak of WebMessageListener by properly removing it in onDestroy (home-assistant#6805) --------- Co-authored-by: Joris Pelgröm <[email protected]> * Update lokalise/lokalise-pull-action action to v5.2.2 (home-assistant#6807) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update github/codeql-action action to v4.35.3 (home-assistant#6808) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Add ExoPlayer support for FrontendScreen from frontend request (home-assistant#6771) * Introduce FrontendExoPlayerManager * Allow HAApp to make fullscreen request to the LaunchActivity * Add support for ExoPlayer in FrontendScreen * Use Double for resize * Use ktx * Fix unit test * Fix tests * Apply Copilot feedbacks * Apply last suggestions * Apply suggestions on tests * Bump Gradle actions to 6.1.0 and use basic cache provider (home-assistant#6811) * Update aboutlibraries to v14.1.0 (home-assistant#6809) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Joris Pelgröm <[email protected]> * Add support for custom view in FrontendScreen (home-assistant#6790) Instanciate the HAWebChromeClient from Compose to get the custom view * Support for auto play video in FrontendScreen (home-assistant#6806) * Support for auto play video in FrontendScreen * Adjust logic to address Copilot concern * Update app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendViewModel.kt Co-authored-by: Joris Pelgröm <[email protected]> * Make observeChanges support multiples keys * Move entirely to LocalStorage --------- Co-authored-by: Joris Pelgröm <[email protected]> * Update com.android.* (home-assistant#6820) * Update com.android.* * Update dependency lockfiles * Empty commit for CI --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Joris Pelgröm <[email protected]> * Update androidx.compose.* (home-assistant#6823) * Update androidx.compose.* * Update dependency lockfiles * Empty commit for CI --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Joris Pelgröm <[email protected]> * Update dependency com.google.android.gms:play-services-wearable to v20 (home-assistant#6797) * Update dependency com.google.android.gms:play-services-wearable to v20 * Update dependency lockfiles * Empty commit for CI --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Joris Pelgröm <[email protected]> * Update github/codeql-action action to v4.35.4 (home-assistant#6830) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Lock file maintenance (home-assistant#6833) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency com.google.firebase:firebase-bom to v34.13.0 (home-assistant#6831) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Bump changelog_master.xml for weekly release 2026.5.3 (home-assistant#6827) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Update org.jetbrains.kotlin.* to v1.11.0 (home-assistant#6832) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Timothy <[email protected]> * Introduce RequestAccurateLocationReceiver and restrict LocationSensorManager export (home-assistant#6837) Introduce RequestAcurateLocationReceiver to stop exporting LocationSensorManager * Update aboutlibraries to v14.2.0 (home-assistant#6828) * Update aboutlibraries to v14.2.0 * Update dependency lockfiles * Empty commit for CI --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Joris Pelgröm <[email protected]> * Update dependency com.slack.lint.compose:compose-lint-checks to v1.4.3 (home-assistant#6825) * Update dependency com.slack.lint.compose:compose-lint-checks to v1.4.3 * Update dependency lockfiles * Empty commit for CI --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Joris Pelgröm <[email protected]> * Restore HTTP 404/410 handling for updating registration (home-assistant#6835) * Update dependency io.sentry:sentry-android-core to v8.41.0 (home-assistant#6826) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Move the debug flag for WebView into the Application and Settings (home-assistant#6813) * Update androidx.* (home-assistant#6824) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Timothy <[email protected]> * Add Improv external bus messages models (home-assistant#6817) * Fix crash on start in release due to WebView remote debug pref (home-assistant#6841) * Add support for PiP for FrontendScreen (home-assistant#6812) * Deprecated the old Material Design 2 theme to avoid using it (home-assistant#6815) * Deprecated the old Material Design 2 theme to avoid using it * Remove Autofix * Add action to open Settings View from Automotive main screen (home-assistant#6834) * Migrate TagReaderActivity to use BottomSheet and add confirmation buttons (home-assistant#6814) * Support next.home-assistant.io in Debug * Make TagReaderActivity standalone and translucent * Add preference to stored allowed tag and clearing in dev settings * Introduce PainterResourceUtil to load app icon --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> Co-authored-by: Joris Pelgröm <[email protected]> * Update emulator wtf actions (home-assistant#6843) * isDrivingDistracted --------- Co-authored-by: Timothy <[email protected]> Co-authored-by: Joris Pelgröm <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Runye Zhang <[email protected]> Co-authored-by: Dimitris Dafnis <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Joris Pelgröm <[email protected]> Co-authored-by: jim-daf <[email protected]>

Summary
Introduce a new use case to extract the logic to check if the location permission is missing and show a permission. Add the use case to the new
FrontendScreen.Based on #6720.
Checklist