From 8e9c3cf5cf66a0885aa363a1b36163d0003fb449 Mon Sep 17 00:00:00 2001 From: Dale Hawkins Date: Tue, 6 Feb 2024 15:53:24 -0700 Subject: [PATCH] fix: sets the correct permissions on PlacesClient.awaitFindCurrentPlace @RequiresPermission annotation --- .../libraries/places/ktx/api/net/PlacesClient.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/places-ktx/src/main/java/com/google/android/libraries/places/ktx/api/net/PlacesClient.kt b/places-ktx/src/main/java/com/google/android/libraries/places/ktx/api/net/PlacesClient.kt index bc724bd..32fa075 100644 --- a/places-ktx/src/main/java/com/google/android/libraries/places/ktx/api/net/PlacesClient.kt +++ b/places-ktx/src/main/java/com/google/android/libraries/places/ktx/api/net/PlacesClient.kt @@ -14,6 +14,7 @@ package com.google.android.libraries.places.ktx.api.net +import android.Manifest.permission import androidx.annotation.RequiresPermission import com.google.android.gms.common.api.ApiException import com.google.android.gms.tasks.CancellationTokenSource @@ -28,6 +29,7 @@ import com.google.android.libraries.places.api.net.FindAutocompletePredictionsRe import com.google.android.libraries.places.api.net.FindCurrentPlaceRequest import com.google.android.libraries.places.api.net.FindCurrentPlaceResponse import com.google.android.libraries.places.api.net.PlacesClient +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.tasks.await /** @@ -35,6 +37,7 @@ import kotlinx.coroutines.tasks.await * * Fetches a photo. If an error occurred, an [ApiException] will be thrown. */ +@ExperimentalCoroutinesApi public suspend fun PlacesClient.awaitFetchPhoto( photoMetadata: PhotoMetadata, actions: FetchPhotoRequest.Builder.() -> Unit = {} @@ -53,6 +56,7 @@ public suspend fun PlacesClient.awaitFetchPhoto( * * Fetches the details of a place. If an error occurred, an [ApiException] will be thrown. */ +@ExperimentalCoroutinesApi public suspend fun PlacesClient.awaitFetchPlace( placeId: String, placeFields: List, @@ -69,6 +73,7 @@ public suspend fun PlacesClient.awaitFetchPlace( * * Fetches autocomplete predictions. If an error occurred, an [ApiException] will be thrown. */ +@ExperimentalCoroutinesApi public suspend fun PlacesClient.awaitFindAutocompletePredictions( actions: FindAutocompletePredictionsRequest.Builder.() -> Unit ): FindAutocompletePredictionsResponse { @@ -87,9 +92,8 @@ public suspend fun PlacesClient.awaitFindAutocompletePredictions( * the appropriate permissions will result in a [SecurityException] being thrown. In addition, if * an error occurred while fetching the current place, an [ApiException] will be thrown. */ -@RequiresPermission( - allOf = ["android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_WIFI_STATE"] -) +@ExperimentalCoroutinesApi +@RequiresPermission(anyOf = [permission.ACCESS_FINE_LOCATION, permission.ACCESS_COARSE_LOCATION]) public suspend fun PlacesClient.awaitFindCurrentPlace( placeFields: List ): FindCurrentPlaceResponse {