From aa4e78469ca05200a4946d152ec4874918a73ec8 Mon Sep 17 00:00:00 2001 From: HanSJin Date: Wed, 1 Dec 2021 20:36:57 +0900 Subject: [PATCH] Bugfix: ThrowInvalidMutabilityException in previousAuthorizationStatus. (#8) * Bugfix: ThrowInvalidMutabilityException in previousAuthorizationStatus. * Apply: PR Comment(var to val type). Co-authored-by: HanPro --- build.gradle.kts | 2 +- kmm_location.podspec | 2 +- sample/shared/build.gradle.kts | 2 +- .../kotlin/com/linecorp/abc/location/LocationManager.kt | 4 ++-- .../com/linecorp/abc/location/extension/ABCLocationExt.kt | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 057af35..290efb0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,7 @@ import org.jetbrains.kotlin.cli.common.toBooleanLenient import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget val isSnapshotUpload = System.getProperty("snapshot").toBooleanLenient() ?: false -val libVersion = "0.2.7" +val libVersion = "0.2.8" val gitName = "abc-${project.name}" buildscript { diff --git a/kmm_location.podspec b/kmm_location.podspec index 1a88694..2c8fba2 100644 --- a/kmm_location.podspec +++ b/kmm_location.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'kmm_location' - spec.version = '0.2.7' + spec.version = '0.2.8' spec.homepage = '' spec.source = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" } spec.authors = '' diff --git a/sample/shared/build.gradle.kts b/sample/shared/build.gradle.kts index aa53256..9891695 100644 --- a/sample/shared/build.gradle.kts +++ b/sample/shared/build.gradle.kts @@ -6,7 +6,7 @@ plugins { kotlin("native.cocoapods") } -val abcLocationLib = "com.linecorp.abc:kmm-location:0.2.6" +val abcLocationLib = "com.linecorp.abc:kmm-location:0.2.8" version = "1.0" diff --git a/src/iosMain/kotlin/com/linecorp/abc/location/LocationManager.kt b/src/iosMain/kotlin/com/linecorp/abc/location/LocationManager.kt index c822a4b..2bdd785 100644 --- a/src/iosMain/kotlin/com/linecorp/abc/location/LocationManager.kt +++ b/src/iosMain/kotlin/com/linecorp/abc/location/LocationManager.kt @@ -36,7 +36,7 @@ internal actual class LocationManager { actual fun startLocationUpdating() = when (authorizationStatus) { LocationAuthorizationStatus.AuthorizedAlways -> startUpdating() LocationAuthorizationStatus.AuthorizedWhenInUse -> if (isRequiredAllowAlways) { - if (previousAuthorizationStatus == LocationAuthorizationStatus.AuthorizedWhenInUse) { + if (previousAuthorizationStatus.value == LocationAuthorizationStatus.AuthorizedWhenInUse) { notifyOnAlwaysAllowsPermissionRequired() } else { requestPermission() @@ -59,7 +59,7 @@ internal actual class LocationManager { // ------------------------------------------------------------------------------------------- var requiredPermission = LocationAuthorizationStatus.AuthorizedAlways - var previousAuthorizationStatus = LocationAuthorizationStatus.NotSet + val previousAuthorizationStatus = NativeAtomicReference(LocationAuthorizationStatus.NotSet) fun onAlwaysAllowsPermissionRequired( target: Any, diff --git a/src/iosMain/kotlin/com/linecorp/abc/location/extension/ABCLocationExt.kt b/src/iosMain/kotlin/com/linecorp/abc/location/extension/ABCLocationExt.kt index 6a147f7..fe830a4 100644 --- a/src/iosMain/kotlin/com/linecorp/abc/location/extension/ABCLocationExt.kt +++ b/src/iosMain/kotlin/com/linecorp/abc/location/extension/ABCLocationExt.kt @@ -22,5 +22,5 @@ fun ABCLocation.Companion.removeOnAlwaysAllowsPermissionRequired(target: Any) = locationManager.removeOnAlwaysAllowsPermissionRequired(target) internal var ABCLocation.Companion.previousAuthorizationStatus: LocationAuthorizationStatus - get() = locationManager.previousAuthorizationStatus - set(value) { locationManager.previousAuthorizationStatus = value } + get() = locationManager.previousAuthorizationStatus.value + set(value) { locationManager.previousAuthorizationStatus.value = value }