Skip to content

Commit 298bf49

Browse files
author
Oleksii Korniienko
authored
Merge pull request #101 from GlobalMessageServices/PEGMS-2526-update-dependencies
PEGMS-2526 update dependencies. fix AEADBadTagException
2 parents d16d696 + 19f8bee commit 298bf49

File tree

4 files changed

+51
-14
lines changed

4 files changed

+51
-14
lines changed

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44

55
buildscript {
6-
ext.kotlin_version = '1.9.22'
7-
ext.gradleVersion = '8.4.0'
8-
ext.dokka_version = "1.9.10"
6+
ext.kotlin_version = '2.0.20'
7+
ext.gradleVersion = '8.6.0'
8+
ext.dokka_version = "1.9.20"
99
ext.jacocoVersion = '0.8.12'
1010
repositories {
1111
google()
@@ -59,5 +59,5 @@ allprojects {
5959
}
6060

6161
task clean(type: Delete) {
62-
delete rootProject.buildDir
62+
delete layout.buildDirectory.get()
6363
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Tue May 07 14:00:08 CEST 2024
1+
#Tue Sep 10 08:58:46 CEST 2024
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

pushsdkandroid/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ apply plugin: 'org.jetbrains.dokka'
88
apply plugin: 'maven-publish'
99
apply plugin: 'jacoco'
1010

11-
ext.build_version_name = '1.1.9'
11+
ext.build_version_name = '1.1.11'
1212

1313
android {
1414
namespace = "com.push.android.pushsdkandroid"
@@ -69,13 +69,13 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea
6969
}
7070

7171
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
72-
def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/debug", excludes: fileFilter)
72+
def debugTree = fileTree(dir: "${layout.buildDirectory.get()}/intermediates/classes/debug", excludes: fileFilter)
7373
def mainSrc = "${project.projectDir}/src/main/java"
7474

7575

7676
sourceDirectories.setFrom(files([mainSrc]))
7777
classDirectories.setFrom(files([debugTree]))
78-
executionData.setFrom(fileTree(dir: "$buildDir", includes: [
78+
executionData.setFrom(fileTree(dir: "${layout.buildDirectory.get()}", includes: [
7979
"jacoco/testDebugUnitTest.exec",
8080
"outputs/code-coverage/connected/*coverage.ec"
8181
]))
@@ -88,8 +88,8 @@ dependencies {
8888
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
8989
//implementation 'androidx.appcompat:appcompat:1.3.0'
9090
implementation 'androidx.core:core-ktx:1.13.1'
91-
implementation 'androidx.lifecycle:lifecycle-process:2.8.3'
92-
implementation 'androidx.test:monitor:1.7.1'
91+
implementation 'androidx.lifecycle:lifecycle-process:2.8.5'
92+
implementation 'androidx.test:monitor:1.7.2'
9393
implementation 'androidx.security:security-crypto:1.1.0-alpha06'
9494

9595

@@ -120,7 +120,7 @@ dependencies {
120120
implementation 'com.google.code.gson:gson:2.10.1'
121121

122122
//WorkManager Version 2.7.0 is required for apps targeting Android 12 (S) or higher
123-
implementation 'androidx.work:work-runtime-ktx:2.9.0'
123+
implementation 'androidx.work:work-runtime-ktx:2.9.1'
124124
}
125125

126126
//get HEAD commit hash
@@ -182,7 +182,7 @@ afterEvaluate {
182182
repositories {
183183
maven {
184184
//publish locally for now
185-
url "$buildDir/maven-repos/"
185+
url "${layout.buildDirectory.get()}/maven-repos/"
186186
// def releasesRepoUrl = "$buildDir/maven-repos/releases"
187187
// def snapshotsRepoUrl = "$buildDir/maven-repos/snapshots"
188188
// url = version.endsWith('RELEASE') ? releasesRepoUrl : snapshotsRepoUrl

pushsdkandroid/src/main/java/com/push/android/pushsdkandroid/core/SharedPreferencesHandler.kt

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,52 @@ package com.push.android.pushsdkandroid.core
22

33
import android.content.Context
44
import android.content.SharedPreferences
5+
import android.os.Build
6+
import android.util.Log
57
import androidx.security.crypto.EncryptedSharedPreferences
68
import androidx.security.crypto.MasterKey
9+
import com.push.android.pushsdkandroid.utils.PushSDKLogger
10+
import java.io.File
11+
import javax.crypto.AEADBadTagException
712

813
@Suppress("unused")
914
internal class SharedPreferencesHandler(context: Context) {
1015
private val preferenceDatabase = "push_k_database"
11-
private var sharedPref: SharedPreferences = getEncryptedSharedPref(context)
16+
private var sharedPref: SharedPreferences = initializeSharedPref(context)
1217

1318

19+
private fun initializeSharedPref(context: Context): SharedPreferences {
20+
return try {
21+
getEncryptedSharedPref(context)
22+
} catch (e: AEADBadTagException) {
23+
PushSDKLogger.error(
24+
"Shared preference initializing failed with exception: " +
25+
Log.getStackTraceString(e)
26+
)
27+
// Handle exception, likely data corruption or key change (e.g. app was uninstalled and installed again)
28+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
29+
context.deleteSharedPreferences(preferenceDatabase)
30+
} else {
31+
deleteSharedPreferences(preferenceDatabase, context)
32+
}
33+
getEncryptedSharedPref(context)
34+
}
35+
}
36+
37+
private fun deleteSharedPreferences(preferenceDatabase: String, context: Context) {
38+
try {
39+
val sharedPrefsFile =
40+
File(context.filesDir.parent + "/shared_prefs/" + preferenceDatabase + ".xml")
41+
if (sharedPrefsFile.exists()) {
42+
sharedPrefsFile.delete()
43+
}
44+
} catch (e: Exception) {
45+
PushSDKLogger.error(
46+
"Shared preference deleting failed with exception: " +
47+
Log.getStackTraceString(e)
48+
)
49+
}
50+
}
1451

1552
private fun getEncryptedSharedPref(context: Context): SharedPreferences {
1653
return EncryptedSharedPreferences.create(

0 commit comments

Comments
 (0)