Commit 9bc2e765 authored by wanglei's avatar wanglei

...

parent 1c879217
...@@ -4,6 +4,7 @@ import android.annotation.SuppressLint ...@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils
import com.base.datarecovery.activity.SplashActivity import com.base.datarecovery.activity.SplashActivity
import com.base.datarecovery.ads.AdmobOpenUtils import com.base.datarecovery.ads.AdmobOpenUtils
import com.base.datarecovery.bean.ConstObject.ifAgreePrivacy import com.base.datarecovery.bean.ConstObject.ifAgreePrivacy
...@@ -18,10 +19,17 @@ import com.base.datarecovery.utils.InstallHelps ...@@ -18,10 +19,17 @@ import com.base.datarecovery.utils.InstallHelps
import com.base.datarecovery.utils.LogEx import com.base.datarecovery.utils.LogEx
import com.base.datarecovery.utils.NewComUtils import com.base.datarecovery.utils.NewComUtils
import com.google.android.gms.ads.MobileAds 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() { class MyApplication : BaseApplication() {
private val TAG = "MyApplication" private val TAG = "MyApplication"
var uuid = ""
companion object { companion object {
@JvmField @JvmField
...@@ -30,8 +38,19 @@ class MyApplication : BaseApplication() { ...@@ -30,8 +38,19 @@ class MyApplication : BaseApplication() {
override fun init() { override fun init() {
initApp() 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() { fun initApp() {
val topic = ConfigHelper.packageName + "_push" val topic = ConfigHelper.packageName + "_push"
FCMManager.initFirebase(this) FCMManager.initFirebase(this)
...@@ -57,6 +76,17 @@ class MyApplication : BaseApplication() { ...@@ -57,6 +76,17 @@ class MyApplication : BaseApplication() {
InstallHelps.init() InstallHelps.init()
MobileAds.initialize(this) { initializationStatus -> 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() initLifeListener()
} }
......
...@@ -9,7 +9,7 @@ import org.json.JSONException ...@@ -9,7 +9,7 @@ import org.json.JSONException
import org.json.JSONObject import org.json.JSONObject
object EventUtils { object EventUtils {
private val TAG = "EventUtils"
fun event( fun event(
key: String, key: String,
value: String? = null, value: String? = null,
...@@ -52,11 +52,12 @@ object EventUtils { ...@@ -52,11 +52,12 @@ object EventUtils {
.put("data", s) .put("data", s)
.put("bp", s2) .put("bp", s2)
.toString() .toString()
LogEx.logDebug(TAG, "data=${AppPreferences.getInstance().getString("uuid", "")}")
parmJson = AESHelper.encrypt(data) parmJson = AESHelper.encrypt(data)
} catch (e: JSONException) { } catch (e: JSONException) {
parmJson = "" parmJson = ""
} }
LogEx.logDebug(TAG, "report!")
doPost( doPost(
url, url,
HashMap(), HashMap(),
......
...@@ -9,6 +9,7 @@ import java.net.URL; ...@@ -9,6 +9,7 @@ import java.net.URL;
import java.util.Map; import java.util.Map;
public class ReportUtils { public class ReportUtils {
private static String TAG = "ReportUtils";
public static String doPost(String urlPath, Map<String, String> paramsMap, String json) { public static String doPost(String urlPath, Map<String, String> paramsMap, String json) {
try { try {
...@@ -39,10 +40,12 @@ public class ReportUtils { ...@@ -39,10 +40,12 @@ public class ReportUtils {
} else { } else {
s = ""; s = "";
} }
LogEx.INSTANCE.logDebug(TAG, "code=200", false);
return s; return s;
} else { } else {
LogEx.INSTANCE.logDebug(TAG, "code!=200", false);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); 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