package com.huawei.hms.hatool; import java.util.Iterator; import java.util.List; import org.bouncycastle.asn1.cmp.PKIFailureInfo; import org.json.JSONArray; import org.json.JSONException; /* loaded from: classes2.dex */ public class d1 implements g { private String a; private String b; private String c; private List d; @Override // java.lang.Runnable public void run() { List list = this.d; if (list == null || list.size() == 0) { v.d("hmsSdk", "failed events is empty"); return; } if (c0.a(q0.i(), "cached_v2_1", q0.k() * PKIFailureInfo.badCertTemplate)) { StringBuilder sb = new StringBuilder("The cacheFile is full,Can not writing data! reqID:"); sb.append(this.b); v.e("hmsSdk", sb.toString()); return; } String a = n1.a(this.a, this.c); List list2 = c1.b(q0.i(), "cached_v2_1", a).get(a); if (list2 != null && list2.size() != 0) { this.d.addAll(list2); } JSONArray jSONArray = new JSONArray(); Iterator it = this.d.iterator(); while (it.hasNext()) { try { jSONArray.put(it.next().d()); } catch (JSONException unused) { v.e("hmsSdk", "event to json error"); } } String jSONArray2 = jSONArray.toString(); if (jSONArray2.length() > q0.h() * PKIFailureInfo.badCertTemplate) { v.e("hmsSdk", "this failed data is too long,can not writing it"); this.d = null; return; } StringBuilder sb2 = new StringBuilder("data send failed, write to cache file...reqID:"); sb2.append(this.b); v.d("hmsSdk", sb2.toString()); d.b(q0.i(), "cached_v2_1", a, jSONArray2); a(); } private void a() { d.a(q0.i(), "backup_event", n1.a(this.a, this.c, this.b)); } public d1(List list, String str, String str2, String str3) { this.a = str; this.b = str2; this.c = str3; this.d = list; } }