Skip to content

Introduce check location disabled usecase#6734

Merged
TimoPtr merged 2 commits into
mainfrom
feature/check_location_disabled_usecase
Apr 24, 2026
Merged

Introduce check location disabled usecase#6734
TimoPtr merged 2 commits into
mainfrom
feature/check_location_disabled_usecase

Conversation

@TimoPtr
Copy link
Copy Markdown
Member

@TimoPtr TimoPtr commented Apr 20, 2026

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

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 20, 2026

Test Results

  233 files    241 suites   10m 25s ⏱️
1 793 tests 1 792 ✅ 0 💤 1 ❌
1 864 runs  1 862 ✅ 0 💤 2 ❌

For more details on these failures, see this check.

Results for commit a838811.

♻️ This comment has been updated with latest results.

@TimoPtr TimoPtr marked this pull request as ready for review April 20, 2026 14:30
Copilot AI review requested due to automatic review settings April 20, 2026 14:30
@TimoPtr TimoPtr changed the base branch from main to feature/start_workers April 20, 2026 14:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CheckLocationDisabledUseCase and wired it into the legacy WebViewActivity flow and the new LaunchActivity (Frontend V2) flow
  • Refactored DisabledLocationHandler to provide a reusable locationSettingsIntent(...) and a dedicated showLocationDisabledNotification(...)
  • 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

@jpelgrom
Copy link
Copy Markdown
Member

and show a permission

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?

@TimoPtr
Copy link
Copy Markdown
Member Author

TimoPtr commented Apr 22, 2026

and show a permission

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?

I made this change because I think that in the current impl we never show the dialog we only show the notification

image

We set the showAsNotification to true and then the logic if ((!withDisableOption || callback == null) && showAsNotification) { where the callback is always null. Am I missing something?

@TimoPtr TimoPtr force-pushed the feature/check_location_disabled_usecase branch from 231cf9a to ea71a61 Compare April 22, 2026 08:52
@TimoPtr TimoPtr added the WebViewActivity replacement Ongoing work to replace the WebViewActivity in favor of a well tested compose screen using nav. label Apr 22, 2026
@TimoPtr TimoPtr mentioned this pull request Apr 22, 2026
4 tasks
@jpelgrom
Copy link
Copy Markdown
Member

I made this change because I think that in the current impl we never show the dialog we only show the notification

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.

Copy link
Copy Markdown
Member

@jpelgrom jpelgrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When testing I forgot to actually enable something that requires location 🤦. After adding a home Wi-Fi network it worked perfectly!

Base automatically changed from feature/start_workers to main April 23, 2026 15:16
@TimoPtr TimoPtr force-pushed the feature/check_location_disabled_usecase branch from a6345c7 to a838811 Compare April 23, 2026 15:19
@TimoPtr TimoPtr enabled auto-merge (squash) April 23, 2026 15:21
@TimoPtr TimoPtr disabled auto-merge April 24, 2026 06:24
@TimoPtr TimoPtr merged commit 0864f47 into main Apr 24, 2026
80 of 93 checks passed
@TimoPtr TimoPtr deleted the feature/check_location_disabled_usecase branch April 24, 2026 06:24
cddu33 added a commit to cddu33/android that referenced this pull request May 14, 2026
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed WebViewActivity replacement Ongoing work to replace the WebViewActivity in favor of a well tested compose screen using nav.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants