expo-location 16.5.2 → 16.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,12 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 16.5.3 — 2024-02-06
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - [Android] Fixed: `NullPointerException: it must not be null`. ([#26688](https://github.com/expo/expo/pull/26688) by [@lukmccall](https://github.com/lukmccall))
18
+
13
19
  ## 16.5.2 — 2024-01-10
14
20
 
15
21
  ### 🎉 New features
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '16.5.2'
6
+ version = '16.5.3'
7
7
 
8
8
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
9
9
  if (expoModulesCorePlugin.exists()) {
@@ -94,7 +94,7 @@ android {
94
94
  namespace "expo.modules.location"
95
95
  defaultConfig {
96
96
  versionCode 29
97
- versionName "16.5.2"
97
+ versionName "16.5.3"
98
98
  }
99
99
  }
100
100
 
@@ -14,6 +14,9 @@ internal class LocationBackgroundUnauthorizedException :
14
14
  internal class LocationRequestRejectedException(cause: Exception) :
15
15
  CodedException("Location request has been rejected: " + cause.message)
16
16
 
17
+ internal class CurrentLocationIsUnavailableException :
18
+ CodedException("Current location is unavailable. Make sure that location services are enabled")
19
+
17
20
  internal class LocationRequestCancelledException :
18
21
  CodedException("Location request has been cancelled")
19
22
 
@@ -69,8 +69,13 @@ class LocationHelpers {
69
69
  fun requestSingleLocation(locationProvider: FusedLocationProviderClient, locationRequest: CurrentLocationRequest, promise: Promise) {
70
70
  try {
71
71
  locationProvider.getCurrentLocation(locationRequest, null)
72
- .addOnSuccessListener {
73
- promise.resolve(LocationResponse(it))
72
+ .addOnSuccessListener { location: Location? ->
73
+ if (location == null) {
74
+ promise.reject(CurrentLocationIsUnavailableException())
75
+ return@addOnSuccessListener
76
+ }
77
+
78
+ promise.resolve(LocationResponse(location))
74
79
  }
75
80
  .addOnFailureListener {
76
81
  promise.reject(LocationRequestRejectedException(it))
@@ -166,7 +171,8 @@ class LocationHelpers {
166
171
  }
167
172
 
168
173
  fun isAnyProviderAvailable(context: Context?): Boolean {
169
- val locationManager = context?.getSystemService(Context.LOCATION_SERVICE) as? LocationManager ?: return false
174
+ val locationManager = context?.getSystemService(Context.LOCATION_SERVICE) as? LocationManager
175
+ ?: return false
170
176
  return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) || locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)
171
177
  }
172
178
 
@@ -177,7 +183,8 @@ class LocationHelpers {
177
183
  contextPermissions,
178
184
  object : Promise {
179
185
  override fun resolve(value: Any?) {
180
- val result = value as? Bundle ?: throw ConversionException(Any::class.java, Bundle::class.java, "value returned by the permission promise is not a Bundle")
186
+ val result = value as? Bundle
187
+ ?: throw ConversionException(Any::class.java, Bundle::class.java, "value returned by the permission promise is not a Bundle")
181
188
  continuation.resume(PermissionRequestResponse(result))
182
189
  }
183
190
 
@@ -197,7 +204,10 @@ class LocationHelpers {
197
204
  contextPermissions,
198
205
  object : Promise {
199
206
  override fun resolve(value: Any?) {
200
- it.resume(value as? Bundle ?: throw ConversionException(Any::class.java, Bundle::class.java, "value returned by the permission promise is not a Bundle"))
207
+ it.resume(
208
+ value as? Bundle
209
+ ?: throw ConversionException(Any::class.java, Bundle::class.java, "value returned by the permission promise is not a Bundle")
210
+ )
201
211
  }
202
212
 
203
213
  override fun reject(code: String, message: String?, cause: Throwable?) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-location",
3
- "version": "16.5.2",
3
+ "version": "16.5.3",
4
4
  "description": "Allows reading geolocation information from the device. Your app can poll for the current location or subscribe to location update events.",
5
5
  "main": "build/Location.js",
6
6
  "types": "build/Location.d.ts",
@@ -44,5 +44,5 @@
44
44
  "peerDependencies": {
45
45
  "expo": "*"
46
46
  },
47
- "gitHead": "ca014bf2516c7644ef303f4c21fdd68de4d99f76"
47
+ "gitHead": "4f3dcf3e23eae997f884117fdd34ad734efad9fd"
48
48
  }