Skip to content

Commit

Permalink
Remove READ_PHONE_STATE and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
DeKaN committed Jan 12, 2024
1 parent bea8918 commit a47dd13
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 54 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Piano Analytics SDK for Android

## v3.3.6-SNAPSHOT
* Removed requirement for `READ_PHONE_STATE` permission for Android 6-9
* Updated dependencies:
- androidx.lifecycle:lifecycle-process [2.6.2 -> 2.7.0]
https://developer.android.com/jetpack/androidx/releases/lifecycle#2.7.0

## v3.3.5
* Decreased default offline storage lifetime for events
* Fixed bug with cyclic read/save current privacy mode after its expiration
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ android.useAndroidX=true
android.enableJetifier=false
android.nonTransitiveRClass=true
android.nonFinalResIds=false
android.defaults.buildfeatures.buildconfig=true

org.gradle.configuration-cache=true
kotlin.incremental.useClasspathSnapshot=true
14 changes: 7 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[versions]
# Plugins
kotlin = "1.8.22"
android = "8.1.3"
versionUpdater = "0.49.0"
ktlint = "11.6.1"
android = "8.2.1"
versionUpdater = "0.50.0"
ktlint = "12.1.0"
dokka = "1.8.20"
mavenRelease = "0.25.3"
mavenRelease = "0.27.0"
moshiIR = "0.22.1"

# AndroidX libraries
compatLibrary = "1.6.1"
lifecycle = "2.6.2"
materialLibrary = "1.10.0"
lifecycle = "2.7.0"
materialLibrary = "1.11.0"

# Third party Libraries
googleAdsId = "18.0.1"
Expand All @@ -26,7 +26,7 @@ viewBindingProperty = "1.5.9"
junit = "4.13.2"
androidxTestCore = "1.5.0"
mockitoKotlin = "2.2.0"
mockitoCore = "5.7.0"
mockitoCore = "5.8.0"

[plugins]
android-library = { id = "com.android.library", version.ref = "android" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
5 changes: 4 additions & 1 deletion piano-analytics/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ android {
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
buildFeatures {
buildConfig = true
}
namespace = "io.piano.android.analytics"
}

Expand All @@ -48,7 +51,7 @@ kotlin {

ktlint {
android = true
version = "1.0.1"
version = "1.1.1"
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion piano-analytics/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=3.3.5
VERSION_NAME=3.3.6-SNAPSHOT
GROUP=io.piano.android
POM_NAME=Analytics
POM_ARTIFACT_ID=analytics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import android.net.ConnectivityManager
import android.net.NetworkCapabilities
import android.net.NetworkInfo
import android.os.Build
import android.telephony.TelephonyManager
import android.util.DisplayMetrics
import androidx.core.content.ContextCompat
import io.piano.android.analytics.model.ConnectionType
Expand Down Expand Up @@ -65,38 +64,6 @@ internal class DeviceInfoProvider(
private fun NetworkInfo?.toConnectionType(): ConnectionType = when {
this == null || !isConnected -> ConnectionType.OFFLINE
type == ConnectivityManager.TYPE_WIFI -> ConnectionType.WIFI
else -> ContextCompat.getSystemService(context, TelephonyManager::class.java)?.run {
val type = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) dataNetworkType else networkType
type.toConnectionType()
} ?: ConnectionType.UNKNOWN
}

private fun Int.toConnectionType(): ConnectionType = when (this) {
TelephonyManager.NETWORK_TYPE_GPRS -> ConnectionType.GPRS
TelephonyManager.NETWORK_TYPE_EDGE -> ConnectionType.EDGE

TelephonyManager.NETWORK_TYPE_CDMA,
TelephonyManager.NETWORK_TYPE_IDEN,
TelephonyManager.NETWORK_TYPE_1xRTT,
-> ConnectionType.TWOG

TelephonyManager.NETWORK_TYPE_UMTS,
TelephonyManager.NETWORK_TYPE_EVDO_0,
TelephonyManager.NETWORK_TYPE_EVDO_A,
TelephonyManager.NETWORK_TYPE_EVDO_B,
-> ConnectionType.THREEG

TelephonyManager.NETWORK_TYPE_HSPA,
TelephonyManager.NETWORK_TYPE_HSDPA,
TelephonyManager.NETWORK_TYPE_HSUPA,
-> ConnectionType.THREEGPLUS

TelephonyManager.NETWORK_TYPE_HSPAP,
TelephonyManager.NETWORK_TYPE_LTE,
-> ConnectionType.FOURG

TelephonyManager.NETWORK_TYPE_NR -> ConnectionType.FIVEG

else -> ConnectionType.UNKNOWN
else -> ConnectionType.MOBILE
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
package io.piano.android.analytics.model

internal enum class ConnectionType(val key: String) {
GPRS("GPRS"),
EDGE("EDGE"),
TWOG("2G"),
THREEG("3G"),
THREEGPLUS("3G+"),
FOURG("4G"),
FIVEG("5G"),
MOBILE("MOBILE"),
WIFI("WIFI"),
OFFLINE("OFFLINE"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class InternalPropertiesEventProcessorTest {
packageName = DUMMY
versionName = DUMMY
}
on { connectionType } doReturn ConnectionType.FIVEG
on { connectionType } doReturn ConnectionType.MOBILE
}
val processor = InternalPropertiesEventProcessor(configuration, deviceInfoProvider)
val events = processor.process(listOf(event))
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencyResolutionManagement {
}

plugins {
id("com.gradle.enterprise") version "3.13.3"
id("com.gradle.enterprise") version "3.16.1"
}
include(
":app",
Expand Down

0 comments on commit a47dd13

Please sign in to comment.