Skip to content

Commit

Permalink
fix: 合规处理——解析解控开关控制手机运营商信息获取(腾讯新闻)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemondark committed Apr 28, 2024
1 parent 50cad7d commit 404dbfd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/tencent/msdk/dns/report/AttaHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.telephony.TelephonyManager;

import com.tencent.msdk.dns.BuildConfig;
import com.tencent.msdk.dns.DnsService;
import com.tencent.msdk.dns.base.log.DnsLog;

import java.io.IOException;
Expand All @@ -25,8 +26,7 @@ public class AttaHelper {
private static final String SYSTEMVERSION = getSystemVersion();
private static final String SESSIONID = Session.getSessionId();

public static Runnable report(final String carrier,
final String networkType,
public static Runnable report(final String networkType,
final String dnsId,
final String appId,
final String encryptType,
Expand All @@ -50,6 +50,8 @@ public static Runnable report(final String carrier,
public void run() {
HttpURLConnection connection = null;
try {
// 获取手机卡运营商code
String carrier = getSimOperator(DnsService.getAppContext());
String path = ATTA_URL
+ "?attaid=" + ATTA_ID
+ "&token=" + ATTA_TOKEN
Expand Down
15 changes: 5 additions & 10 deletions src/main/java/com/tencent/msdk/dns/report/ReportHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.tencent.msdk.dns.BackupResolver;
import com.tencent.msdk.dns.BuildConfig;
import com.tencent.msdk.dns.DnsConfig;
import com.tencent.msdk.dns.DnsService;
import com.tencent.msdk.dns.base.compat.CollectionCompat;
import com.tencent.msdk.dns.base.lifecycle.ActivityLifecycleCallbacksWrapper;
import com.tencent.msdk.dns.base.lifecycle.ActivityLifecycleDetector;
Expand Down Expand Up @@ -187,8 +186,6 @@ private static void attaReportLookupEvent(String eventName, LookupResult lookupR
StatisticsMerge statMerge = (StatisticsMerge) lookupResult.stat;

BackupResolver backupInfo = BackupResolver.getInstance();
// 获取手机卡运营商code
String carrierCode = AttaHelper.getSimOperator(DnsService.getAppContext());
// 获取当前dnsip
String dnsIp = backupInfo.getDnsIp();
String reqType = AttaHelper.getReqType(statMerge.curNetStack);
Expand All @@ -198,7 +195,7 @@ private static void attaReportLookupEvent(String eventName, LookupResult lookupR
if (statMerge.restDnsStat.errorCode == 0) {
// 请求成功后将ErrorCount置为0
backupInfo.setErrorCount(0);
MAIN.execute(AttaHelper.report(carrierCode, statMerge.netType, sDnsConfig.lookupExtra.bizId,
MAIN.execute(AttaHelper.report(statMerge.netType, sDnsConfig.lookupExtra.bizId,
sDnsConfig.appId, sDnsConfig.channel, eventName, System.currentTimeMillis(), dnsIp,
statMerge.restDnsStat.costTimeMills, statMerge.localDnsStat.costTimeMills,
statMerge.requestHostname, reqType, sDnsConfig.timeoutMills, statMerge.restDnsStat.ttl,
Expand All @@ -212,7 +209,7 @@ private static void attaReportLookupEvent(String eventName, LookupResult lookupR
|| (Const.HTTPS_CHANNEL.equals(sDnsConfig.channel) && (statMerge.restDnsStat.errorCode == 1))) {
// 解析失败,仅当达到最大失败次数满足切换IP时候上报
if (backupInfo.getCanReport(backupInfo.getErrorCount() + 1)) {
MAIN.execute(AttaHelper.report(carrierCode, statMerge.netType, sDnsConfig.lookupExtra.bizId,
MAIN.execute(AttaHelper.report(statMerge.netType, sDnsConfig.lookupExtra.bizId,
sDnsConfig.appId, sDnsConfig.channel, eventName, System.currentTimeMillis(), dnsIp,
statMerge.restDnsStat.costTimeMills, statMerge.localDnsStat.costTimeMills,
statMerge.requestHostname, reqType, sDnsConfig.timeoutMills,
Expand All @@ -225,7 +222,7 @@ private static void attaReportLookupEvent(String eventName, LookupResult lookupR
backupInfo.incrementErrorCount();
DnsLog.d("dnsip连接失败, 当前失败次数:" + backupInfo.getErrorCount());
} else {
MAIN.execute(AttaHelper.report(carrierCode, statMerge.netType, sDnsConfig.lookupExtra.bizId,
MAIN.execute(AttaHelper.report(statMerge.netType, sDnsConfig.lookupExtra.bizId,
sDnsConfig.appId, sDnsConfig.channel, eventName, System.currentTimeMillis(), dnsIp,
statMerge.restDnsStat.costTimeMills, statMerge.localDnsStat.costTimeMills,
statMerge.requestHostname, reqType, sDnsConfig.timeoutMills, statMerge.restDnsStat.ttl,
Expand All @@ -249,20 +246,18 @@ private static void attaReportStatisticsEvent() {
int errCount = (int) temp[1];
int curCount = (int) temp[2];
int spendAvg = (int) temp[0] / (errCount + curCount);
// 获取手机卡运营商code
String carrierCode = AttaHelper.getSimOperator(DnsService.getAppContext());
// 获取当前dnsip
String dnsIp = BackupResolver.getInstance().getDnsIp();
if (errCount > 0) {
// 为空的缓存统计项上报,解析结果不上报
MAIN.execute(AttaHelper.report(carrierCode, "", sDnsConfig.lookupExtra.bizId, sDnsConfig.appId,
MAIN.execute(AttaHelper.report("", sDnsConfig.lookupExtra.bizId, sDnsConfig.appId,
sDnsConfig.channel, ReportConst.LOOKUP_FROM_CACHED_EVENT_NAME, System.currentTimeMillis(),
dnsIp, spendAvg, 0, item.getKey(), "", sDnsConfig.timeoutMills, null, 3, 0, true, errCount,
null, null));
}
if (curCount > 0) {
// 有值的缓存统计项上报,解析结果不上报
MAIN.execute(AttaHelper.report(carrierCode, "", sDnsConfig.lookupExtra.bizId, sDnsConfig.appId,
MAIN.execute(AttaHelper.report( "", sDnsConfig.lookupExtra.bizId, sDnsConfig.appId,
sDnsConfig.channel, ReportConst.LOOKUP_FROM_CACHED_EVENT_NAME, System.currentTimeMillis(),
dnsIp, spendAvg, 0, item.getKey(), "", sDnsConfig.timeoutMills, null, 0, 0, true, curCount,
null, null));
Expand Down

0 comments on commit 404dbfd

Please sign in to comment.