Skip to content
Merged
4 changes: 2 additions & 2 deletions android-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
exclude 'META-INF/LICENSE'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.toVersion(JAVA_VERSION)
targetCompatibility JavaVersion.toVersion(JAVA_VERSION)
}

String url = '\"\"'
Expand Down
32 changes: 27 additions & 5 deletions android-core/proguard.pro
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,33 @@
public static final ** CREATOR;
}

-keepclassmembers class com.mparticle.Rokt {
<init>(...);
void *(...);
void *$default(...);
<fields>;
# Firebase and GMS CloudMessaging
-dontwarn com.google.android.gms.cloudmessaging.**
-dontwarn com.google.firebase.messaging.**
-keep class com.google.firebase.messaging.** { *; }

# Java 9+ StringConcatFactory
-dontwarn java.lang.invoke.StringConcatFactory
-keep class java.lang.invoke.StringConcatFactory { *; }

# Keep lambdas
-keepclassmembers class * {
private static synthetic *** lambda$*(...);
}
# Additional rules to prevent minification errors with Kotlin
-keepattributes *Annotation*, InnerClasses, Signature, EnclosingMethod
-keepclassmembers class kotlin.Metadata {
public <methods>;
}
-keepclassmembers class * {
@kotlin.Metadata <methods>;
}

-keep public class com.mparticle.Rokt {
public <init>(...);
public void *(...);
public void *$default(...);
public <fields>;
}

-keep interface com.mparticle.MpRoktEventCallback { *; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,13 @@ class MParticleTest : BaseCleanStartedEachTest() {
}
}

private fun getSharedPrefsContents(name: String): String =
try {
val prefs = mContext.getSharedPreferences(name, Context.MODE_PRIVATE)
"""
private fun getSharedPrefsContents(name: String): String = try {
val prefs = mContext.getSharedPreferences(name, Context.MODE_PRIVATE)
"""
$name:
${JSONObject(prefs.all).toString(4)}
""".trimIndent()
} catch (e: JSONException) {
"error printing SharedPrefs :/"
}
""".trimIndent()
} catch (e: JSONException) {
"error printing SharedPrefs :/"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class UploadEventKotlinTest : BaseCleanStartedEachTest() {
.any {
val eventMessageName = messagesArray.getJSONObject(it).optString("n")
assertNotEquals("Should Not Upload", eventMessageName)
if (eventMessageName == "Should Upload 1" || eventMessageName == "Should Upload 2" ||
if (eventMessageName == "Should Upload 1" ||
eventMessageName == "Should Upload 2" ||
eventMessageName == "Should Upload 3"
) {
numUploadedEvents++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class IdentityApiOutgoingTest : BaseCleanStartedEachTest() {
Matcher(mServer.Endpoints().loginUrl).bodyMatch(
object :
IdentityMatcher() {
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean =
mStartingMpid == identityRequest.previousMpid
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean = mStartingMpid == identityRequest.previousMpid
},
),
)
Expand All @@ -31,8 +30,7 @@ class IdentityApiOutgoingTest : BaseCleanStartedEachTest() {
Matcher(mServer.Endpoints().loginUrl).bodyMatch(
object :
IdentityMatcher() {
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean =
mStartingMpid == identityRequest.previousMpid
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean = mStartingMpid == identityRequest.previousMpid
},
),
)
Expand All @@ -46,8 +44,7 @@ class IdentityApiOutgoingTest : BaseCleanStartedEachTest() {
Matcher(mServer.Endpoints().logoutUrl).bodyMatch(
object :
IdentityMatcher() {
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean =
mStartingMpid == identityRequest.previousMpid
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean = mStartingMpid == identityRequest.previousMpid
},
),
)
Expand All @@ -61,8 +58,7 @@ class IdentityApiOutgoingTest : BaseCleanStartedEachTest() {
Matcher(mServer.Endpoints().logoutUrl).bodyMatch(
object :
IdentityMatcher() {
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean =
mStartingMpid == identityRequest.previousMpid
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean = mStartingMpid == identityRequest.previousMpid
},
),
)
Expand All @@ -88,8 +84,7 @@ class IdentityApiOutgoingTest : BaseCleanStartedEachTest() {
Matcher(mServer.Endpoints().identifyUrl).bodyMatch(
object :
IdentityMatcher() {
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean =
mStartingMpid == identityRequest.previousMpid
override fun isIdentityMatch(identityRequest: IdentityRequestBody): Boolean = mStartingMpid == identityRequest.previousMpid
},
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ class MParticleIdentityClientImplTest : BaseCleanStartedEachTest() {
mparticle: Boolean,
) {
if (connection.url
.toString()
.contains(MParticleIdentityClientImpl.MODIFY_PATH)
.toString()
.contains(MParticleIdentityClientImpl.MODIFY_PATH)
) {
val jsonObject = payload?.let { JSONObject(it) }
val changedIdentities =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,19 @@ class AppStateManagerInstrumentedTest : BaseCleanStartedEachTest() {

@Test
@Throws(InterruptedException::class)
fun testOnApplicationForeground() =
runTest(StandardTestDispatcher()) {
val latch: CountDownLatch = MPLatch(2)
val kitManagerTester = KitManagerTester(mContext, latch)
com.mparticle.AccessUtils.setKitManager(kitManagerTester)
goToBackground()
Assert.assertNull(mAppStateManager?.currentActivity)
Thread.sleep(AppStateManager.ACTIVITY_DELAY + 100)
goToForeground()
Assert.assertNotNull(mAppStateManager?.currentActivity?.get())
latch.await()
Assert.assertTrue(kitManagerTester.onApplicationBackgroundCalled)
Assert.assertTrue(kitManagerTester.onApplicationForegroundCalled)
}
fun testOnApplicationForeground() = runTest(StandardTestDispatcher()) {
val latch: CountDownLatch = MPLatch(2)
val kitManagerTester = KitManagerTester(mContext, latch)
com.mparticle.AccessUtils.setKitManager(kitManagerTester)
goToBackground()
Assert.assertNull(mAppStateManager?.currentActivity)
Thread.sleep(AppStateManager.ACTIVITY_DELAY + 100)
goToForeground()
Assert.assertNotNull(mAppStateManager?.currentActivity?.get())
latch.await()
Assert.assertTrue(kitManagerTester.onApplicationBackgroundCalled)
Assert.assertTrue(kitManagerTester.onApplicationForegroundCalled)
}

internal inner class KitManagerTester(
context: Context?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import kotlin.test.assertNotEquals
class BatchSessionInfoTest : BaseCleanStartedEachTest() {
override fun useInMemoryDatabase() = true

override fun transformMParticleOptions(builder: MParticleOptions.Builder): MParticleOptions.Builder =
builder.logLevel(MParticle.LogLevel.INFO)
override fun transformMParticleOptions(builder: MParticleOptions.Builder): MParticleOptions.Builder = builder.logLevel(MParticle.LogLevel.INFO)

/**
* This test is in response to a bug where, when many messages (> 1 batch worth)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,11 @@ class ConfigStalenessCheckTest : BaseCleanInstallEachTest() {
assertEquals(config2.toString(), configManager.config)
}

private fun randomJson(size: Int) =
(1..size)
.map { mRandomUtils.getAlphaNumericString(4) to mRandomUtils.getAlphaNumericString(6) }
.fold(JSONObject()) { init, attribute ->
init.apply { put(attribute.first, attribute.second) }
}
private fun randomJson(size: Int) = (1..size)
.map { mRandomUtils.getAlphaNumericString(4) to mRandomUtils.getAlphaNumericString(6) }
.fold(JSONObject()) { init, attribute ->
init.apply { put(attribute.first, attribute.second) }
}

fun <T> T?.assertNotNull(): T {
assertNotNull(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ class UpgradeVersionTest : BaseTableTest() {
val sqLiteOpenHelperWrapper: SQLiteOpenHelperWrapper =
object : SQLiteOpenHelperWrapper {
override fun onCreate(db: SQLiteDatabase) {
db.execSQL(SessionTableTest.old_CREATE_SESSION_DDL)
db.execSQL(MessageTableTest.old_no_mpid_CREATE_MESSAGES_DDL)
db.execSQL(BreadcrumbTableTest.old_CREATE_BREADCRUMBS_DDL)
db.execSQL(ReportingTableTest.old_CREATE_REPORTING_DDL)
db.execSQL(UserAttributeTableTest.old_CREATE_USER_ATTRIBUTES_DDL)
db.execSQL(SessionTableTest.OLD_CREATE_SESSION_DDL)
db.execSQL(MessageTableTest.OLD_NO_MPID_CREATE_MESSAGES_DDL)
db.execSQL(BreadcrumbTableTest.OLD_CREATE_BREADCRUMBS_DDL)
db.execSQL(ReportingTableTest.OLD_CREATE_REPORTING_DDL)
db.execSQL(UserAttributeTableTest.OLD_CREATE_USER_ATTRIBUTES_DDL)
}

override fun onUpgrade(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,11 @@ class SessionServiceTest : BaseMPServiceTest() {
internal inner class MockMessageBatch(
var id: Int,
) : MessageBatch() {
override fun equals(other: Any?): Boolean =
if (other is MockMessageBatch) {
id == other.id
} else {
super.equals(other)
}
override fun equals(other: Any?): Boolean = if (other is MockMessageBatch) {
id == other.id
} else {
super.equals(other)
}

override fun hashCode(): Int = id
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BreadcrumbTableTest : BaseTableTest() {
}

companion object {
const val old_CREATE_BREADCRUMBS_DDL =
const val OLD_CREATE_BREADCRUMBS_DDL =
"CREATE TABLE IF NOT EXISTS " + BreadcrumbTable.BreadcrumbTableColumns.TABLE_NAME + " (" + BaseColumns._ID +
" INTEGER PRIMARY KEY AUTOINCREMENT, " +
BreadcrumbTable.BreadcrumbTableColumns.SESSION_ID + " STRING NOT NULL, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MessageTableTest : BaseTableTest() {
runTest(
object : SQLiteOpenHelperWrapper {
override fun onCreate(database: SQLiteDatabase) {
database.execSQL(old_no_dp_CREATE_MESSAGES_DDL)
database.execSQL(OLD_NO_DP_CREATE_MESSAGES_DDL)
}

override fun onUpgrade(
Expand All @@ -60,7 +60,7 @@ class MessageTableTest : BaseTableTest() {
}

companion object {
const val old_no_mpid_CREATE_MESSAGES_DDL =
const val OLD_NO_MPID_CREATE_MESSAGES_DDL =
"CREATE TABLE IF NOT EXISTS " + MessageTable.MessageTableColumns.TABLE_NAME + " (" + BaseColumns._ID +
" INTEGER PRIMARY KEY AUTOINCREMENT, " +
MessageTable.MessageTableColumns.SESSION_ID + " STRING NOT NULL, " +
Expand All @@ -71,7 +71,7 @@ class MessageTableTest : BaseTableTest() {
MessageTable.MessageTableColumns.MESSAGE_TYPE + " TEXT, " +
MessageTable.MessageTableColumns.CF_UUID + " TEXT" +
");"
private const val old_no_dp_CREATE_MESSAGES_DDL =
private const val OLD_NO_DP_CREATE_MESSAGES_DDL =
"CREATE TABLE IF NOT EXISTS " + MessageTable.MessageTableColumns.TABLE_NAME + " (" + BaseColumns._ID +
" INTEGER PRIMARY KEY AUTOINCREMENT, " +
MessageTable.MessageTableColumns.SESSION_ID + " STRING NOT NULL, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ReportingTableTest : BaseTableTest() {
}

companion object {
const val old_CREATE_REPORTING_DDL =
const val OLD_CREATE_REPORTING_DDL =
"CREATE TABLE IF NOT EXISTS " + ReportingTable.ReportingTableColumns.TABLE_NAME + " (" + BaseColumns._ID +
" INTEGER PRIMARY KEY AUTOINCREMENT, " +
ReportingTable.ReportingTableColumns.MODULE_ID + " INTEGER NOT NULL, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SessionTableTest : BaseTableTest() {
}

companion object {
const val old_CREATE_SESSION_DDL =
const val OLD_CREATE_SESSION_DDL =
"CREATE TABLE IF NOT EXISTS " + SessionTable.SessionTableColumns.TABLE_NAME + " (" + BaseColumns._ID +
" INTEGER PRIMARY KEY AUTOINCREMENT, " +
SessionTable.SessionTableColumns.SESSION_ID + " STRING NOT NULL, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class UserAttributeTableTest : BaseTableTest() {
}

companion object {
const val old_CREATE_USER_ATTRIBUTES_DDL =
const val OLD_CREATE_USER_ATTRIBUTES_DDL =
"CREATE TABLE IF NOT EXISTS " + UserAttributesTable.UserAttributesTableColumns.TABLE_NAME + " (" + BaseColumns._ID +
" INTEGER PRIMARY KEY AUTOINCREMENT, " +
UserAttributesTable.UserAttributesTableColumns.ATTRIBUTE_KEY + " COLLATE NOCASE NOT NULL, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import com.mparticle.MParticleOptions
class PinningTestNetworkOptionsDisabled : PinningTest() {
override fun shouldPin(): Boolean = true

override fun transformMParticleOptions(builder: MParticleOptions.Builder): MParticleOptions.Builder =
builder
.environment(MParticle.Environment.Production)
.networkOptions(
NetworkOptions
.builder()
.setPinningDisabledInDevelopment(true)
.build(),
)
override fun transformMParticleOptions(builder: MParticleOptions.Builder): MParticleOptions.Builder = builder
.environment(MParticle.Environment.Production)
.networkOptions(
NetworkOptions
.builder()
.setPinningDisabledInDevelopment(true)
.build(),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import com.mparticle.MParticleOptions
class PinningTestNetworkOptionsEnabled : PinningTest() {
override fun shouldPin(): Boolean = false

override fun transformMParticleOptions(builder: MParticleOptions.Builder): MParticleOptions.Builder =
builder
.environment(MParticle.Environment.Development)
.networkOptions(
NetworkOptions
.builder()
.setPinningDisabledInDevelopment(true)
.build(),
)
override fun transformMParticleOptions(builder: MParticleOptions.Builder): MParticleOptions.Builder = builder
.environment(MParticle.Environment.Development)
.networkOptions(
NetworkOptions
.builder()
.setPinningDisabledInDevelopment(true)
.build(),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package com.mparticle.internal

import com.mparticle.Configuration

internal class KitsLoadedListenerConfiguration(
private var kitsLoadedListener: KitsLoadedListener,
) : Configuration<KitFrameworkWrapper> {
internal class KitsLoadedListenerConfiguration(private var kitsLoadedListener: KitsLoadedListener) : Configuration<KitFrameworkWrapper> {
override fun configures() = KitFrameworkWrapper::class.java

override fun apply(kitFrameworkWrapper: KitFrameworkWrapper) = kitFrameworkWrapper.addKitsLoadedListener(kitsLoadedListener)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ package com.mparticle.internal
import org.json.JSONArray

object SideloadedKitsUtils {
fun combineConfig(
kitConfig: JSONArray?,
kits: List<SideloadedKit>,
): JSONArray {
fun combineConfig(kitConfig: JSONArray?, kits: List<SideloadedKit>): JSONArray {
var results = JSONArray()
var addedIds = mutableSetOf<Int>()
kitConfig?.let { kitConfig ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

internal class UserAudiencesRetriever(
apiClient: MParticleApiClient,
) {
internal class UserAudiencesRetriever(apiClient: MParticleApiClient) {
private val mApiClient: MParticleApiClient = apiClient

fun fetchAudiences(
mpId: Long,
featureFlagEnabled: Boolean,
): AudienceTask<AudienceResponse> {
fun fetchAudiences(mpId: Long, featureFlagEnabled: Boolean): AudienceTask<AudienceResponse> {
val task = BaseAudienceTask()
if (featureFlagEnabled) {
CoroutineScope(Dispatchers.IO).launch {
Expand Down
Loading
Loading