package com.mbridge.msdk.newreward.function.g; import android.text.TextUtils; import com.facebook.appevents.internal.ViewHierarchyConstants; import com.mbridge.msdk.MBridgeConstans; import com.mbridge.msdk.newreward.function.common.MBridgeSharedPreferenceModel; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /* loaded from: classes4.dex */ public final class a { public static c a() { JSONObject jSONObject; int optInt; c cVar = new c(); String string = MBridgeSharedPreferenceModel.getInstance().getString(MBridgeConstans.SP_DYNAMIC_METRICS_REPORT, ""); if (TextUtils.isEmpty(string)) { return cVar; } try { jSONObject = new JSONObject(string); optInt = jSONObject.optInt("version", -1); } catch (JSONException e) { if (MBridgeConstans.DEBUG) { e.printStackTrace(); } } if (optInt == -1) { return cVar; } String optString = jSONObject.optString("name", ""); JSONArray jSONArray = jSONObject.getJSONArray("report"); d[] dVarArr = new d[jSONArray.length()]; for (int i = 0; i < jSONArray.length(); i++) { try { JSONObject jSONObject2 = jSONArray.getJSONObject(i); if (jSONObject2 != null) { String optString2 = jSONObject2.optString("key", ""); String optString3 = jSONObject2.optString(ViewHierarchyConstants.CLASS_NAME_KEY, ""); String optString4 = jSONObject2.optString("method", ""); if (!TextUtils.isEmpty(optString2)) { dVarArr[i] = new d(optString3, optString4, optString2); } } } catch (JSONException e2) { if (MBridgeConstans.DEBUG) { e2.printStackTrace(); } } } cVar.a(optString); cVar.a(optInt); cVar.a(dVarArr); return cVar; } }