From 2df451c8e7ea9e315152584cc4346f47f813a02e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joris=20Pelgr=C3=B6m?= Date: Fri, 10 Jan 2025 17:08:13 +0100 Subject: [PATCH] Remove assistant app/Assist with button on Automotive (#4965) Remove assistant app on Automotive --- .../companion/android/settings/SettingsFragment.kt | 2 ++ .../android/settings/SettingsPresenterImpl.kt | 8 +++++++- automotive/src/main/AndroidManifest.xml | 13 ------------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/SettingsFragment.kt b/app/src/main/java/io/homeassistant/companion/android/settings/SettingsFragment.kt index a2e0ac6efe4..a0e0780efab 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/SettingsFragment.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/SettingsFragment.kt @@ -176,6 +176,8 @@ class SettingsFragment( val isAutomotive = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && requireContext().packageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE) + findPreference("assist")?.isVisible = !isAutomotive + findPreference("widgets")?.isVisible = Build.MODEL != "Quest" && !isAutomotive findPreference("manage_widgets")?.setOnPreferenceClickListener { parentFragmentManager.commit { diff --git a/app/src/main/java/io/homeassistant/companion/android/settings/SettingsPresenterImpl.kt b/app/src/main/java/io/homeassistant/companion/android/settings/SettingsPresenterImpl.kt index 5e8887fe0e6..f6967098ff8 100644 --- a/app/src/main/java/io/homeassistant/companion/android/settings/SettingsPresenterImpl.kt +++ b/app/src/main/java/io/homeassistant/companion/android/settings/SettingsPresenterImpl.kt @@ -257,7 +257,13 @@ class SettingsPresenterImpl @Inject constructor( // Assist var assistantSuggestion = serverManager.defaultServers.any { it.version?.isAtLeast(2023, 5) == true } - assistantSuggestion = if (assistantSuggestion && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + assistantSuggestion = if ( + assistantSuggestion && + Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && + context.packageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE) + ) { + false + } else if (assistantSuggestion && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { val roleManager = context.getSystemService() roleManager?.isRoleAvailable(RoleManager.ROLE_ASSISTANT) == true && !roleManager.isRoleHeld(RoleManager.ROLE_ASSISTANT) } else if (assistantSuggestion && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { diff --git a/automotive/src/main/AndroidManifest.xml b/automotive/src/main/AndroidManifest.xml index 24cb671d1a8..072720277e8 100644 --- a/automotive/src/main/AndroidManifest.xml +++ b/automotive/src/main/AndroidManifest.xml @@ -423,20 +423,7 @@ android:autoRemoveFromRecents="true" android:showWhenLocked="true" android:theme="@style/Theme.HomeAssistant.Assist"> - - - - - - - - - -