Skip to content

Commit

Permalink
update: remove hardware ids
Browse files Browse the repository at this point in the history
  • Loading branch information
Hemant-Mann committed Jan 21, 2022
1 parent 6e0bcaa commit 40ec4fe
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 34 deletions.
4 changes: 2 additions & 2 deletions TrackierSDK/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ POM_DEVELOPER_ID=trackier
POM_DEVELOPER_NAME=Trackier
PUBLISH_DEVELOPER_EMAIL=[email protected]
POM_LICENCE_DIST=repo
VERSION_CODE=19
VERSION_NAME=1.6.16
VERSION_CODE=20
VERSION_NAME=1.6.17
GROUP=com.trackier
POM_SCM_DEV_CONNECTION=scm\:[email protected]\:trackier/android_sdk.git
POM_LICENCE_NAME=The Apache Software License, Version 2.0
Expand Down
4 changes: 2 additions & 2 deletions TrackierSDK/sdk-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 30
versionCode 19
versionName "1.6.16"
versionCode 20
versionName "1.6.17"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.trackier.sdk

object Constants {
const val SDK_VERSION = "1.6.16"
const val SDK_VERSION = "1.6.17"
const val USER_AGENT = "com.cloudstuff.trackiersdk:trackier-android:" + SDK_VERSION
const val API_VERSION = "v1"
const val BASE_URL = "https://events.trackier.io/" + API_VERSION + "/"
Expand Down
31 changes: 2 additions & 29 deletions TrackierSDK/sdk-core/src/main/java/com/trackier/sdk/DeviceInfo.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.trackier.sdk

import android.annotation.SuppressLint
import android.content.ContentResolver
import android.content.Context
import android.content.pm.PackageManager
Expand Down Expand Up @@ -57,8 +56,8 @@ data class DeviceInfo(
var connectionType: String? = null
var countryCode: String? = null
var carrier: String? = null
var macMd5: String? = null
var androidId: String? = null
var macMd5: String? = null // removed
var androidId: String? = null // removed
var isEmulator = false
var locale: String? = ""

Expand Down Expand Up @@ -86,9 +85,7 @@ data class DeviceInfo(

deviceInfo.connectionType = getConnectionType(context)
setCarrierInfo(deviceInfo, context)
deviceInfo.macMd5 = getMacAddress(context)
deviceInfo.isEmulator = checkIsEmulator()
deviceInfo.androidId = getAndroidID(context)

deviceInfo.fbAttributionId = getFBAttributionId(context.contentResolver)

Expand Down Expand Up @@ -198,30 +195,6 @@ data class DeviceInfo(
}
}

@SuppressLint("HardwareIds")
private fun getMacAddress(context: Context): String? {
return try {
// for devices above android v6
val wlanAddress = Util.loadAddress("wlan0")
if (wlanAddress?.isBlank() == false) {
return Util.md5(wlanAddress.trim().toUpperCase(Locale.US))
}
// this works below android v6
val manager = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager?
val info = manager?.connectionInfo
val mac = info?.macAddress?.trim()?.toUpperCase(Locale.US)
if (mac == "02:00:00:00:00:00" || mac?.length == 0) null else Util.md5(mac!!)
} catch (ex: Exception) {
null
}
}

@SuppressLint("HardwareIds")
private fun getAndroidID(context: Context): String {
return Settings.Secure.getString(context.contentResolver,
Settings.Secure.ANDROID_ID)
}

private fun setCarrierInfo(deviceInfo: DeviceInfo, context: Context) {
try {
val tm = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager?
Expand Down

0 comments on commit 40ec4fe

Please sign in to comment.