93 lines
2.6 KiB
Java
93 lines
2.6 KiB
Java
package com.huawei.hms.hatool;
|
|
|
|
import android.text.TextUtils;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class h1 implements o1 {
|
|
private List<b1> a;
|
|
private k0 b;
|
|
private t0 c;
|
|
private o1 d;
|
|
private String e = "";
|
|
private String f;
|
|
|
|
public void a(List<b1> list) {
|
|
this.a = list;
|
|
}
|
|
|
|
public void a(String str) {
|
|
if (str != null) {
|
|
this.e = str;
|
|
}
|
|
}
|
|
|
|
public void a(t0 t0Var) {
|
|
this.c = t0Var;
|
|
}
|
|
|
|
public void a(l lVar) {
|
|
this.d = lVar;
|
|
}
|
|
|
|
public void a(k0 k0Var) {
|
|
this.b = k0Var;
|
|
}
|
|
|
|
@Override // com.huawei.hms.hatool.o1
|
|
public JSONObject a() {
|
|
String str;
|
|
List<b1> list = this.a;
|
|
if (list == null || list.size() == 0) {
|
|
str = "Not have actionEvent to send";
|
|
} else if (this.b == null || this.c == null || this.d == null) {
|
|
str = "model in wrong format";
|
|
} else {
|
|
JSONObject jSONObject = new JSONObject();
|
|
jSONObject.put("header", this.b.a());
|
|
JSONObject jSONObject2 = new JSONObject();
|
|
JSONObject a = this.d.a();
|
|
a.put("properties", this.c.a());
|
|
try {
|
|
a.put("events_global_properties", new JSONObject(this.e));
|
|
} catch (JSONException unused) {
|
|
a.put("events_global_properties", this.e);
|
|
}
|
|
jSONObject2.put("events_common", a);
|
|
JSONArray jSONArray = new JSONArray();
|
|
Iterator<b1> it = this.a.iterator();
|
|
while (it.hasNext()) {
|
|
JSONObject a2 = it.next().a();
|
|
if (a2 != null) {
|
|
jSONArray.put(a2);
|
|
} else {
|
|
v.e("hmsSdk", "custom event is empty,delete this event");
|
|
}
|
|
}
|
|
jSONObject2.put("events", jSONArray);
|
|
try {
|
|
String a3 = n.a(k1.a(jSONObject2.toString().getBytes("UTF-8")), this.f);
|
|
if (TextUtils.isEmpty(a3)) {
|
|
v.e("hmsSdk", "eventInfo encrypt failed,report over!");
|
|
return null;
|
|
}
|
|
jSONObject.put("event", a3);
|
|
return jSONObject;
|
|
} catch (UnsupportedEncodingException unused2) {
|
|
str = "getBitZip(): Unsupported coding : utf-8";
|
|
}
|
|
}
|
|
v.e("hmsSdk", str);
|
|
return null;
|
|
}
|
|
|
|
public h1(String str) {
|
|
this.f = str;
|
|
}
|
|
}
|