Loading play-services-location/core/src/main/kotlin/org/microg/gms/location/network/cell/CellDetailsSource.kt +15 −11 Original line number Diff line number Diff line Loading @@ -28,19 +28,23 @@ class CellDetailsSource(private val context: Context, private val callback: Cell if (details.isNotEmpty()) callback.onCellDetailsAvailable(details) } }) return } else if (SDK_INT >= 17) { val details = telephonyManager.allCellInfo.map(CellInfo::toCellDetails).map { it.repair(context) }.filter(CellDetails::isValid) if (details.isNotEmpty()) callback.onCellDetailsAvailable(details) } else { val allCellInfo = telephonyManager.allCellInfo if (allCellInfo != null) { val details = allCellInfo.map(CellInfo::toCellDetails).map { it.repair(context) }.filter(CellDetails::isValid) if (details.isNotEmpty()) { callback.onCellDetailsAvailable(details) return } } } val networkOperator = telephonyManager.networkOperator var mcc: Int? = null var mnc: Int? = null if (networkOperator != null && networkOperator.length > 4) { mcc = networkOperator.substring(0, 3).toIntOrNull() mnc = networkOperator.substring(3).toIntOrNull() } val detail = telephonyManager.cellLocation.toCellDetails(mcc, mnc) if (detail.isValid) callback.onCellDetailsAvailable(listOf(detail)) val mcc = networkOperator.substring(0, 3).toIntOrNull() val mnc = networkOperator.substring(3).toIntOrNull() val detail = telephonyManager.cellLocation?.toCellDetails(mcc, mnc) if (detail?.isValid == true) callback.onCellDetailsAvailable(listOf(detail)) } } Loading play-services-location/core/src/main/kotlin/org/microg/gms/location/ui/LocationAppFragment.kt +17 −6 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import android.net.Uri import android.os.Build.VERSION.SDK_INT import android.os.Bundle import android.text.format.DateUtils import android.util.Log import androidx.lifecycle.lifecycleScope import androidx.preference.Preference import androidx.preference.PreferenceCategory Loading @@ -23,6 +24,7 @@ import org.microg.gms.location.core.R import org.microg.gms.location.manager.LocationAppsDatabase import org.microg.gms.ui.AppHeadingPreference import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException import kotlin.coroutines.suspendCoroutine class LocationAppFragment : PreferenceFragmentCompat() { Loading Loading @@ -86,15 +88,24 @@ class LocationAppFragment : PreferenceFragmentCompat() { lastLocation.title = DateUtils.getRelativeTimeSpanString(location.time) lastLocation.intent = Intent(Intent.ACTION_VIEW, Uri.parse("geo:${location.latitude},${location.longitude}")) lastLocationMap.location = location val address = if (SDK_INT > 33) { val address = try { if (SDK_INT > 33) { suspendCoroutine { continuation -> try { Geocoder(context).getFromLocation(location.latitude, location.longitude, 1) { continuation.resume(it.firstOrNull()) } } catch (e: Exception) { continuation.resumeWithException(e) } } } else { withContext(Dispatchers.IO) { Geocoder(context).getFromLocation(location.latitude, location.longitude, 1)?.firstOrNull() } } } catch (e: Exception) { Log.w(TAG, e) null } if (address != null) { val addressLine = StringBuilder() var i = 0 Loading Loading
play-services-location/core/src/main/kotlin/org/microg/gms/location/network/cell/CellDetailsSource.kt +15 −11 Original line number Diff line number Diff line Loading @@ -28,19 +28,23 @@ class CellDetailsSource(private val context: Context, private val callback: Cell if (details.isNotEmpty()) callback.onCellDetailsAvailable(details) } }) return } else if (SDK_INT >= 17) { val details = telephonyManager.allCellInfo.map(CellInfo::toCellDetails).map { it.repair(context) }.filter(CellDetails::isValid) if (details.isNotEmpty()) callback.onCellDetailsAvailable(details) } else { val allCellInfo = telephonyManager.allCellInfo if (allCellInfo != null) { val details = allCellInfo.map(CellInfo::toCellDetails).map { it.repair(context) }.filter(CellDetails::isValid) if (details.isNotEmpty()) { callback.onCellDetailsAvailable(details) return } } } val networkOperator = telephonyManager.networkOperator var mcc: Int? = null var mnc: Int? = null if (networkOperator != null && networkOperator.length > 4) { mcc = networkOperator.substring(0, 3).toIntOrNull() mnc = networkOperator.substring(3).toIntOrNull() } val detail = telephonyManager.cellLocation.toCellDetails(mcc, mnc) if (detail.isValid) callback.onCellDetailsAvailable(listOf(detail)) val mcc = networkOperator.substring(0, 3).toIntOrNull() val mnc = networkOperator.substring(3).toIntOrNull() val detail = telephonyManager.cellLocation?.toCellDetails(mcc, mnc) if (detail?.isValid == true) callback.onCellDetailsAvailable(listOf(detail)) } } Loading
play-services-location/core/src/main/kotlin/org/microg/gms/location/ui/LocationAppFragment.kt +17 −6 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import android.net.Uri import android.os.Build.VERSION.SDK_INT import android.os.Bundle import android.text.format.DateUtils import android.util.Log import androidx.lifecycle.lifecycleScope import androidx.preference.Preference import androidx.preference.PreferenceCategory Loading @@ -23,6 +24,7 @@ import org.microg.gms.location.core.R import org.microg.gms.location.manager.LocationAppsDatabase import org.microg.gms.ui.AppHeadingPreference import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException import kotlin.coroutines.suspendCoroutine class LocationAppFragment : PreferenceFragmentCompat() { Loading Loading @@ -86,15 +88,24 @@ class LocationAppFragment : PreferenceFragmentCompat() { lastLocation.title = DateUtils.getRelativeTimeSpanString(location.time) lastLocation.intent = Intent(Intent.ACTION_VIEW, Uri.parse("geo:${location.latitude},${location.longitude}")) lastLocationMap.location = location val address = if (SDK_INT > 33) { val address = try { if (SDK_INT > 33) { suspendCoroutine { continuation -> try { Geocoder(context).getFromLocation(location.latitude, location.longitude, 1) { continuation.resume(it.firstOrNull()) } } catch (e: Exception) { continuation.resumeWithException(e) } } } else { withContext(Dispatchers.IO) { Geocoder(context).getFromLocation(location.latitude, location.longitude, 1)?.firstOrNull() } } } catch (e: Exception) { Log.w(TAG, e) null } if (address != null) { val addressLine = StringBuilder() var i = 0 Loading