Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions library/api/library.api
Original file line number Diff line number Diff line change
Expand Up @@ -712,19 +712,52 @@ public final class com/google/maps/android/ktx/utils/location/LocationManagerKt
}

public final class com/google/maps/android/location/FusedLocationProviderKt {
public static final fun asLocationSource (Lcom/google/android/gms/location/FusedLocationProviderClient;Landroid/os/Looper;)Lcom/google/maps/android/location/LocationSource;
public static synthetic fun asLocationSource$default (Lcom/google/android/gms/location/FusedLocationProviderClient;Landroid/os/Looper;ILjava/lang/Object;)Lcom/google/maps/android/location/LocationSource;
public static final fun fusedLocationEvents (Lcom/google/android/gms/location/FusedLocationProviderClient;JFILandroid/os/Looper;)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun fusedLocationEvents$default (Lcom/google/android/gms/location/FusedLocationProviderClient;JFILandroid/os/Looper;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
public static final fun locationEvents (Lcom/google/android/gms/location/FusedLocationProviderClient;Lcom/google/android/gms/location/LocationRequest;Landroid/os/Looper;)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun locationEvents$default (Lcom/google/android/gms/location/FusedLocationProviderClient;Lcom/google/android/gms/location/LocationRequest;Landroid/os/Looper;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
}

public final class com/google/maps/android/location/LocationKt {
public static final fun getLatLng (Landroid/location/Location;)Lcom/google/android/gms/maps/model/LatLng;
public static final fun locationEvents (Lcom/google/maps/android/location/LocationSource;JFLcom/google/maps/android/location/LocationPriority;)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun locationEvents$default (Lcom/google/maps/android/location/LocationSource;JFLcom/google/maps/android/location/LocationPriority;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
}

public final class com/google/maps/android/location/LocationManagerKt {
public static final fun coarseLocationEvents (Landroid/location/LocationManager;JFLandroid/os/Looper;)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun coarseLocationEvents$default (Landroid/location/LocationManager;JFLandroid/os/Looper;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
public static final fun fineLocationEvents (Landroid/location/LocationManager;JFLandroid/os/Looper;)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun fineLocationEvents$default (Landroid/location/LocationManager;JFLandroid/os/Looper;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
}

public final class com/google/maps/android/location/LocationPriority : java/lang/Enum {
public static final field BALANCED_POWER_ACCURACY Lcom/google/maps/android/location/LocationPriority;
public static final field HIGH_ACCURACY Lcom/google/maps/android/location/LocationPriority;
public static final field LOW_POWER Lcom/google/maps/android/location/LocationPriority;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lcom/google/maps/android/location/LocationPriority;
public static fun values ()[Lcom/google/maps/android/location/LocationPriority;
}

public abstract interface class com/google/maps/android/location/LocationSource {
public abstract fun locationEvents (JFLcom/google/maps/android/location/LocationPriority;)Lkotlinx/coroutines/flow/Flow;
}

public final class com/google/maps/android/location/Location_androidKt {
public static final fun asLocationSource (Landroid/location/LocationManager;Landroid/os/Looper;)Lcom/google/maps/android/location/LocationSource;
public static synthetic fun asLocationSource$default (Landroid/location/LocationManager;Landroid/os/Looper;ILjava/lang/Object;)Lcom/google/maps/android/location/LocationSource;
public static final fun getAccuracyMeters (Landroid/location/Location;)F
public static final fun getAltitudeMeters (Landroid/location/Location;)D
public static final fun getBearingDegrees (Landroid/location/Location;)F
public static final fun getLatitude (Landroid/location/Location;)D
public static final fun getLongitude (Landroid/location/Location;)D
public static final fun getSpeedMetersPerSecond (Landroid/location/Location;)F
public static final fun getTimestampMillis (Landroid/location/Location;)J
}

public final class com/google/maps/android/model/CameraPositionKt {
public static final fun cameraPosition (Lkotlin/jvm/functions/Function1;)Lcom/google/android/gms/maps/model/CameraPosition;
}
Expand Down
39 changes: 39 additions & 0 deletions library/api/library.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
// - Show declarations: true

// Library unique name: <com.google.maps.android:library>
final enum class com.google.maps.android.location/LocationPriority : kotlin/Enum<com.google.maps.android.location/LocationPriority> { // com.google.maps.android.location/LocationPriority|null[0]
enum entry BALANCED_POWER_ACCURACY // com.google.maps.android.location/LocationPriority.BALANCED_POWER_ACCURACY|null[0]
enum entry HIGH_ACCURACY // com.google.maps.android.location/LocationPriority.HIGH_ACCURACY|null[0]
enum entry LOW_POWER // com.google.maps.android.location/LocationPriority.LOW_POWER|null[0]

final val entries // com.google.maps.android.location/LocationPriority.entries|#static{}entries[0]
final fun <get-entries>(): kotlin.enums/EnumEntries<com.google.maps.android.location/LocationPriority> // com.google.maps.android.location/LocationPriority.entries.<get-entries>|<get-entries>#static(){}[0]

final fun valueOf(kotlin/String): com.google.maps.android.location/LocationPriority // com.google.maps.android.location/LocationPriority.valueOf|valueOf#static(kotlin.String){}[0]
final fun values(): kotlin/Array<com.google.maps.android.location/LocationPriority> // com.google.maps.android.location/LocationPriority.values|values#static(){}[0]
}

abstract fun interface com.google.maps.android.location/LocationSource { // com.google.maps.android.location/LocationSource|null[0]
abstract fun locationEvents(kotlin/Long, kotlin/Float, com.google.maps.android.location/LocationPriority): kotlinx.coroutines.flow/Flow<platform.CoreLocation/CLLocation> // com.google.maps.android.location/LocationSource.locationEvents|locationEvents(kotlin.Long;kotlin.Float;com.google.maps.android.location.LocationPriority){}[0]
}

final object com.google.maps.android/MathUtil { // com.google.maps.android/MathUtil|null[0]
final const val EARTH_RADIUS // com.google.maps.android/MathUtil.EARTH_RADIUS|{}EARTH_RADIUS[0]
final fun <get-EARTH_RADIUS>(): kotlin/Double // com.google.maps.android/MathUtil.EARTH_RADIUS.<get-EARTH_RADIUS>|<get-EARTH_RADIUS>(){}[0]
Expand Down Expand Up @@ -54,3 +70,26 @@ final object com.google.maps.android/SphericalUtil { // com.google.maps.android/
final fun getPolylinePrefix(kotlin.collections/List<com.google.maps.android.model/LatLng>, kotlin/Double): kotlin.collections/List<com.google.maps.android.model/LatLng> // com.google.maps.android/SphericalUtil.getPolylinePrefix|getPolylinePrefix(kotlin.collections.List<com.google.maps.android.model.LatLng>;kotlin.Double){}[0]
final fun interpolate(com.google.maps.android.model/LatLng, com.google.maps.android.model/LatLng, kotlin/Double): com.google.maps.android.model/LatLng // com.google.maps.android/SphericalUtil.interpolate|interpolate(com.google.maps.android.model.LatLng;com.google.maps.android.model.LatLng;kotlin.Double){}[0]
}

final val com.google.maps.android.location/accuracyMeters // com.google.maps.android.location/accuracyMeters|@platform.CoreLocation.CLLocation{}accuracyMeters[0]
final fun (platform.CoreLocation/CLLocation).<get-accuracyMeters>(): kotlin/Float // com.google.maps.android.location/accuracyMeters.<get-accuracyMeters>|<get-accuracyMeters>@platform.CoreLocation.CLLocation(){}[0]
final val com.google.maps.android.location/altitudeMeters // com.google.maps.android.location/altitudeMeters|@platform.CoreLocation.CLLocation{}altitudeMeters[0]
final fun (platform.CoreLocation/CLLocation).<get-altitudeMeters>(): kotlin/Double // com.google.maps.android.location/altitudeMeters.<get-altitudeMeters>|<get-altitudeMeters>@platform.CoreLocation.CLLocation(){}[0]
final val com.google.maps.android.location/bearingDegrees // com.google.maps.android.location/bearingDegrees|@platform.CoreLocation.CLLocation{}bearingDegrees[0]
final fun (platform.CoreLocation/CLLocation).<get-bearingDegrees>(): kotlin/Float // com.google.maps.android.location/bearingDegrees.<get-bearingDegrees>|<get-bearingDegrees>@platform.CoreLocation.CLLocation(){}[0]
final val com.google.maps.android.location/latLng // com.google.maps.android.location/latLng|@platform.CoreLocation.CLLocation{}latLng[0]
final fun (platform.CoreLocation/CLLocation).<get-latLng>(): com.google.maps.android.model/LatLng // com.google.maps.android.location/latLng.<get-latLng>|<get-latLng>@platform.CoreLocation.CLLocation(){}[0]
final val com.google.maps.android.location/latitude // com.google.maps.android.location/latitude|@platform.CoreLocation.CLLocation{}latitude[0]
final fun (platform.CoreLocation/CLLocation).<get-latitude>(): kotlin/Double // com.google.maps.android.location/latitude.<get-latitude>|<get-latitude>@platform.CoreLocation.CLLocation(){}[0]
final val com.google.maps.android.location/longitude // com.google.maps.android.location/longitude|@platform.CoreLocation.CLLocation{}longitude[0]
final fun (platform.CoreLocation/CLLocation).<get-longitude>(): kotlin/Double // com.google.maps.android.location/longitude.<get-longitude>|<get-longitude>@platform.CoreLocation.CLLocation(){}[0]
final val com.google.maps.android.location/speedMetersPerSecond // com.google.maps.android.location/speedMetersPerSecond|@platform.CoreLocation.CLLocation{}speedMetersPerSecond[0]
final fun (platform.CoreLocation/CLLocation).<get-speedMetersPerSecond>(): kotlin/Float // com.google.maps.android.location/speedMetersPerSecond.<get-speedMetersPerSecond>|<get-speedMetersPerSecond>@platform.CoreLocation.CLLocation(){}[0]
final val com.google.maps.android.location/timestampMillis // com.google.maps.android.location/timestampMillis|@platform.CoreLocation.CLLocation{}timestampMillis[0]
final fun (platform.CoreLocation/CLLocation).<get-timestampMillis>(): kotlin/Long // com.google.maps.android.location/timestampMillis.<get-timestampMillis>|<get-timestampMillis>@platform.CoreLocation.CLLocation(){}[0]

final fun (com.google.maps.android.location/LocationSource).com.google.maps.android.location/locationEvents(kotlin/Long = ..., kotlin/Float = ..., com.google.maps.android.location/LocationPriority = ...): kotlinx.coroutines.flow/Flow<platform.CoreLocation/CLLocation> // com.google.maps.android.location/locationEvents|locationEvents@com.google.maps.android.location.LocationSource(kotlin.Long;kotlin.Float;com.google.maps.android.location.LocationPriority){}[0]
final fun (platform.CoreLocation/CLLocationManager).com.google.maps.android.location/asLocationSource(): com.google.maps.android.location/LocationSource // com.google.maps.android.location/asLocationSource|asLocationSource@platform.CoreLocation.CLLocationManager(){}[0]
final fun (platform.CoreLocation/CLLocationManager).com.google.maps.android.location/coarseLocationEvents(kotlin/Float = ...): kotlinx.coroutines.flow/Flow<platform.CoreLocation/CLLocation> // com.google.maps.android.location/coarseLocationEvents|coarseLocationEvents@platform.CoreLocation.CLLocationManager(kotlin.Float){}[0]
final fun (platform.CoreLocation/CLLocationManager).com.google.maps.android.location/fineLocationEvents(kotlin/Float = ...): kotlinx.coroutines.flow/Flow<platform.CoreLocation/CLLocation> // com.google.maps.android.location/fineLocationEvents|fineLocationEvents@platform.CoreLocation.CLLocationManager(kotlin.Float){}[0]
final fun (platform.CoreLocation/CLLocationManager).com.google.maps.android.location/locationEvents(kotlin/Float = ..., kotlin/Double = ...): kotlinx.coroutines.flow/Flow<platform.CoreLocation/CLLocation> // com.google.maps.android.location/locationEvents|locationEvents@platform.CoreLocation.CLLocationManager(kotlin.Float;kotlin.Double){}[0]
3 changes: 2 additions & 1 deletion library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,18 @@ kotlin {
sourceSets {
commonMain.dependencies {
api(project(":maps-model"))
api(libs.kotlinx.coroutines.core)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
implementation(libs.kotlinx.coroutines.test)
}
androidMain {
kotlin.srcDir(generateArtifactIdFile)
}
androidMain.dependencies {
api(libs.play.services.maps)
compileOnly(libs.play.services.location)
api(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.appcompat)
implementation(libs.core.ktx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import com.google.android.gms.location.LocationRequest
import com.google.android.gms.location.LocationResult
import com.google.android.gms.location.Priority
import com.google.common.truth.Truth.assertThat
import kotlin.test.assertFailsWith
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runTest
Expand All @@ -38,6 +40,7 @@ import org.mockito.ArgumentMatchers.any
import org.mockito.ArgumentMatchers.eq
import org.mockito.Captor
import org.mockito.Mock
import org.mockito.Mockito.`when`
import org.mockito.Mockito.verify
import org.mockito.junit.MockitoJUnitRunner

Expand Down Expand Up @@ -113,4 +116,21 @@ public class FusedLocationProviderTest {

verify(fusedLocationClient).removeLocationUpdates(eq(locationCallbackCaptor.value))
}

@SuppressLint("MissingPermission")
@Test
public fun testLocationEventsPermissionDeniedFailsWithSecurityException(): Unit = runTest {
val request = LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 1000L).build()
`when`(
fusedLocationClient.requestLocationUpdates(
eq(request),
any(LocationCallback::class.java),
eq(looper)
)
).thenThrow(SecurityException("Location permission denied"))

assertFailsWith<SecurityException> {
fusedLocationClient.locationEvents(request, looper).toList()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import android.location.LocationListener
import android.location.LocationManager
import android.os.Looper
import com.google.common.truth.Truth.assertThat
import kotlin.test.assertFailsWith
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.async
import kotlinx.coroutines.flow.first
Expand Down Expand Up @@ -166,4 +167,42 @@ public class LocationManagerTest {
any<Looper>()
)
}

@SuppressLint("MissingPermission")
@Test
public fun testCoarseLocationPermissionDeniedFailsWithSecurityException(): Unit = runTest {
`when`(locationManager.allProviders).thenReturn(listOf(LocationManager.NETWORK_PROVIDER))
`when`(
locationManager.requestLocationUpdates(
eq(LocationManager.NETWORK_PROVIDER),
anyLong(),
anyFloat(),
any<LocationListener>(),
any<Looper>()
)
).thenThrow(SecurityException("Location permission denied"))

assertFailsWith<SecurityException> {
locationManager.coarseLocationEvents(1_000L, 1f, looper).toList()
}
}

@SuppressLint("MissingPermission")
@Test
public fun testFineLocationPermissionDeniedFailsWithSecurityException(): Unit = runTest {
`when`(locationManager.allProviders).thenReturn(listOf(LocationManager.GPS_PROVIDER))
`when`(
locationManager.requestLocationUpdates(
eq(LocationManager.GPS_PROVIDER),
anyLong(),
anyFloat(),
any<LocationListener>(),
any<Looper>()
)
).thenThrow(SecurityException("Location permission denied"))

assertFailsWith<SecurityException> {
locationManager.fineLocationEvents(2_000L, 2f, looper).toList()
}
}
}
Loading
Loading