Commit 9bc2e765 authored by wanglei's avatar wanglei

...

parent 1c879217
......@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import com.base.datarecovery.activity.SplashActivity
import com.base.datarecovery.ads.AdmobOpenUtils
import com.base.datarecovery.bean.ConstObject.ifAgreePrivacy
......@@ -18,10 +19,17 @@ import com.base.datarecovery.utils.InstallHelps
import com.base.datarecovery.utils.LogEx
import com.base.datarecovery.utils.NewComUtils
import com.google.android.gms.ads.MobileAds
import com.google.android.gms.ads.identifier.AdvertisingIdClient
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import java.util.UUID
class MyApplication : BaseApplication() {
private val TAG = "MyApplication"
var uuid = ""
companion object {
@JvmField
......@@ -30,8 +38,19 @@ class MyApplication : BaseApplication() {
override fun init() {
initApp()
initUUid()
}
private fun initUUid() {
uuid = AppPreferences.getInstance().getString("uuid", "")
if (TextUtils.isEmpty(uuid)) {
uuid = UUID.randomUUID().toString() + System.currentTimeMillis()
AppPreferences.getInstance().put("uuid", uuid)
AppPreferences.getInstance().put("install_info", uuid)
}
}
fun initApp() {
val topic = ConfigHelper.packageName + "_push"
FCMManager.initFirebase(this)
......@@ -57,6 +76,17 @@ class MyApplication : BaseApplication() {
InstallHelps.init()
MobileAds.initialize(this) { initializationStatus ->
}
MainScope().launch(Dispatchers.Main) {
val deferred = async(Dispatchers.IO) {
try {
AdvertisingIdClient.getAdvertisingIdInfo(context).id
} catch (_: Exception) {
"unknown"
}
}
val gid = deferred.await() ?: ""
AppPreferences.getInstance().put("gid", gid)
}
}
initLifeListener()
}
......
......@@ -9,7 +9,7 @@ import org.json.JSONException
import org.json.JSONObject
object EventUtils {
private val TAG = "EventUtils"
fun event(
key: String,
value: String? = null,
......@@ -52,11 +52,12 @@ object EventUtils {
.put("data", s)
.put("bp", s2)
.toString()
LogEx.logDebug(TAG, "data=${AppPreferences.getInstance().getString("uuid", "")}")
parmJson = AESHelper.encrypt(data)
} catch (e: JSONException) {
parmJson = ""
}
LogEx.logDebug(TAG, "report!")
doPost(
url,
HashMap(),
......
......@@ -9,6 +9,7 @@ import java.net.URL;
import java.util.Map;
public class ReportUtils {
private static String TAG = "ReportUtils";
public static String doPost(String urlPath, Map<String, String> paramsMap, String json) {
try {
......@@ -39,10 +40,12 @@ public class ReportUtils {
} else {
s = "";
}
LogEx.INSTANCE.logDebug(TAG, "code=200", false);
return s;
} else {
LogEx.INSTANCE.logDebug(TAG, "code!=200", false);
}
} catch (Exception e) {
e.printStackTrace();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment