-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sergey Korney
committed
Feb 21, 2025
1 parent
ac90662
commit 82f7c65
Showing
17 changed files
with
204 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
attribution/src/main/java/com/affise/attribution/modules/advertising/AdvertisingApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.affise.attribution.modules.advertising | ||
|
||
import com.affise.attribution.modules.AffiseModuleApi | ||
|
||
interface AdvertisingApi : AffiseModuleApi { | ||
fun getAdvertisingId(): String? | ||
} |
7 changes: 7 additions & 0 deletions
7
attribution/src/main/java/com/affise/attribution/modules/androidid/AndroidIdApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.affise.attribution.modules.androidid | ||
|
||
import com.affise.attribution.modules.AffiseModuleApi | ||
|
||
interface AndroidIdApi : AffiseModuleApi { | ||
fun getAndroidId(): String? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
attribution/src/main/java/com/affise/attribution/usecase/PersistentUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.affise.attribution.usecase | ||
|
||
import com.affise.attribution.modules.AffiseModuleManager | ||
|
||
interface PersistentUseCase { | ||
fun init(moduleManager: AffiseModuleManager) | ||
fun getAffDeviceId(): String? | ||
} |
49 changes: 49 additions & 0 deletions
49
attribution/src/main/java/com/affise/attribution/usecase/PersistentUseCaseImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.affise.attribution.usecase | ||
|
||
import com.affise.attribution.modules.AffiseModuleApi | ||
import com.affise.attribution.modules.AffiseModuleManager | ||
import com.affise.attribution.modules.AffiseModules | ||
import com.affise.attribution.modules.advertising.AdvertisingApi | ||
import com.affise.attribution.modules.androidid.AndroidIdApi | ||
import com.affise.attribution.utils.isValidUUID | ||
import com.affise.attribution.utils.toFakeUUID | ||
|
||
internal class PersistentUseCaseImpl : PersistentUseCase { | ||
|
||
private var moduleManager: AffiseModuleManager? = null | ||
private var affDeviceId: String? = null | ||
|
||
override fun init(moduleManager: AffiseModuleManager) { | ||
this.moduleManager = moduleManager | ||
} | ||
|
||
override fun getAffDeviceId(): String? { | ||
if (affDeviceId != null) return affDeviceId | ||
affDeviceId = uuidFromAndroidId() ?: uuidFromAdvertisingId() | ||
return affDeviceId | ||
} | ||
|
||
private fun <T : AffiseModuleApi> getModule(module: AffiseModules): T? { | ||
@Suppress("UNCHECKED_CAST") | ||
return moduleManager?.getModule(module) as? T | ||
} | ||
|
||
private fun uuidFromAndroidId(): String? { | ||
val moduleAndroidId: AndroidIdApi? = getModule(AffiseModules.AndroidId) | ||
val androidId = moduleAndroidId?.getAndroidId() | ||
?.lowercase() | ||
?.toFakeUUID() | ||
androidId ?: return null | ||
if (!androidId.isValidUUID()) return null | ||
return androidId | ||
} | ||
|
||
private fun uuidFromAdvertisingId(): String? { | ||
val moduleAdvertising: AdvertisingApi? = getModule(AffiseModules.Advertising) | ||
val advertisingId = moduleAdvertising?.getAdvertisingId() | ||
?.lowercase() | ||
advertisingId ?: return null | ||
if (!advertisingId.isValidUUID()) return null | ||
return advertisingId | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.