Skip to content

Commit

Permalink
fix: sets the correct permissions on PlacesClient.awaitFindCurrentPla…
Browse files Browse the repository at this point in the history
…ce @RequiresPermission annotation (#231)

Co-authored-by: Dale Hawkins <[email protected]>
  • Loading branch information
dkhawk and dkhawk authored Feb 7, 2024
1 parent a36a5bb commit 791ec4f
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,13 +29,15 @@ 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

/**
* Wraps [PlacesClient.fetchPhoto] in a suspending function.
*
* Fetches a photo. If an error occurred, an [ApiException] will be thrown.
*/
@ExperimentalCoroutinesApi
public suspend fun PlacesClient.awaitFetchPhoto(
photoMetadata: PhotoMetadata,
actions: FetchPhotoRequest.Builder.() -> Unit = {}
Expand All @@ -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<Place.Field>,
Expand All @@ -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 {
Expand All @@ -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<Place.Field>
): FindCurrentPlaceResponse {
Expand Down

0 comments on commit 791ec4f

Please sign in to comment.