mirror of
https://github.com/home-assistant/android
synced 2024-09-06 17:23:32 +00:00
Hide a few GMS features unavailable on Automotive (#3623)
This commit is contained in:
parent
b0a7641a1a
commit
8dbdfebb7b
|
@ -3,6 +3,7 @@ package io.homeassistant.companion.android.matter
|
|||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.IntentSender
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import com.google.android.gms.home.matter.Matter
|
||||
|
@ -12,7 +13,8 @@ import io.homeassistant.companion.android.common.data.websocket.impl.entities.Ma
|
|||
import javax.inject.Inject
|
||||
|
||||
class MatterManagerImpl @Inject constructor(
|
||||
private val serverManager: ServerManager
|
||||
private val serverManager: ServerManager,
|
||||
private val packageManager: PackageManager
|
||||
) : MatterManager {
|
||||
|
||||
companion object {
|
||||
|
@ -20,7 +22,7 @@ class MatterManagerImpl @Inject constructor(
|
|||
}
|
||||
|
||||
override fun appSupportsCommissioning(): Boolean =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && !packageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)
|
||||
|
||||
override suspend fun coreSupportsCommissioning(serverId: Int): Boolean {
|
||||
if (!serverManager.isRegistered() || serverManager.getServer(serverId)?.user?.isAdmin != true) return false
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.homeassistant.companion.android.settings.wear
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.util.Log
|
||||
import com.google.android.gms.common.api.ApiException
|
||||
import com.google.android.gms.common.api.CommonStatusCodes
|
||||
|
@ -16,6 +17,7 @@ object SettingsWearDetection {
|
|||
* if they have the Home Assistant app installed.
|
||||
*/
|
||||
suspend fun hasAnyNodes(context: Context): Boolean {
|
||||
if (context.packageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) return false
|
||||
return try {
|
||||
val nodeClient = Wearable.getNodeClient(context)
|
||||
nodeClient.connectedNodes.await().any()
|
||||
|
|
|
@ -3,6 +3,7 @@ package io.homeassistant.companion.android.thread
|
|||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.IntentSender
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.activity.result.ActivityResult
|
||||
|
@ -21,7 +22,8 @@ import kotlin.coroutines.resumeWithException
|
|||
import kotlin.coroutines.suspendCoroutine
|
||||
|
||||
class ThreadManagerImpl @Inject constructor(
|
||||
private val serverManager: ServerManager
|
||||
private val serverManager: ServerManager,
|
||||
private val packageManager: PackageManager
|
||||
) : ThreadManager {
|
||||
companion object {
|
||||
private const val TAG = "ThreadManagerImpl"
|
||||
|
@ -31,7 +33,7 @@ class ThreadManagerImpl @Inject constructor(
|
|||
}
|
||||
|
||||
override fun appSupportsThread(): Boolean =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && !packageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)
|
||||
|
||||
override suspend fun coreSupportsThread(serverId: Int): Boolean {
|
||||
if (!serverManager.isRegistered() || serverManager.getServer(serverId)?.user?.isAdmin != true) return false
|
||||
|
|
|
@ -139,6 +139,10 @@ abstract class DataModule {
|
|||
@Provides
|
||||
@Singleton
|
||||
fun wifiManager(@ApplicationContext appContext: Context) = appContext.getSystemService<WifiManager>()
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun packageManager(@ApplicationContext appContext: Context) = appContext.packageManager
|
||||
}
|
||||
|
||||
@Binds
|
||||
|
|
Loading…
Reference in a new issue