package csdk.glucustomersupport.unity; import android.app.Activity; import android.text.TextUtils; import com.unity3d.player.UnityPlayer; import csdk.glucustomersupport.GluCustomerSupportSessionEndedEvent; import csdk.glucustomersupport.GluCustomerSupportSessionStartedEvent; import csdk.glucustomersupport.GluFactory; import csdk.glucustomersupport.IGluCustomerSupport; import csdk.glucustomersupport.IGluCustomerSupportListener; import csdk.glucustomersupport.NotificationCountEvent; import csdk.glucustomersupport.util.GluUtil; import csdk.glucustomersupport.util.JsonUtil; import java.util.Map; import java.util.concurrent.Callable; import org.json.JSONException; /* loaded from: classes4.dex */ public class UnityCustomerSupportFactory { public static class UnityCustomerSupportListener implements IGluCustomerSupportListener { private final String gameObject; public UnityCustomerSupportListener(String str) { this.gameObject = str; } @Override // csdk.glucustomersupport.IGluCustomerSupportListener public void onQueryNotificationCount(NotificationCountEvent notificationCountEvent) { UnityPlayer.UnitySendMessage(this.gameObject, "AndroidCustomerSupportOnQueryNotificationCount", JsonUtil.toJson(notificationCountEvent)); } @Override // csdk.glucustomersupport.IGluCustomerSupportListener public void onHelpshiftSessionStarted(GluCustomerSupportSessionStartedEvent gluCustomerSupportSessionStartedEvent) { UnityPlayer.UnitySendMessage(this.gameObject, "AndroidCustomerSupportOnHelpshiftSessionStarted", JsonUtil.toJson(gluCustomerSupportSessionStartedEvent)); } @Override // csdk.glucustomersupport.IGluCustomerSupportListener public void onHelpshiftSessionEnded(GluCustomerSupportSessionEndedEvent gluCustomerSupportSessionEndedEvent) { UnityPlayer.UnitySendMessage(this.gameObject, "AndroidCustomerSupportOnHelpshiftSessionEnded", JsonUtil.toJson(gluCustomerSupportSessionEndedEvent)); } } public IGluCustomerSupport createCustomerSupport(String str, String str2, String str3) { Map parseJsonObject; Callable callable = new Callable() { // from class: csdk.glucustomersupport.unity.UnityCustomerSupportFactory.1 /* JADX WARN: Can't rename method to resolve collision */ @Override // java.util.concurrent.Callable public Activity call() throws Exception { Activity activity = UnityPlayer.currentActivity; if (activity != null) { return activity; } throw new Error("Current activity is null."); } }; if (TextUtils.isEmpty(str3)) { parseJsonObject = null; } else { try { parseJsonObject = JsonUtil.parseJsonObject(str3); } catch (JSONException e) { throw GluUtil.propagate(e); } } IGluCustomerSupport createCustomerSupport = new GluFactory().createCustomerSupport(callable, GluUtil.emptyToNull(str2), parseJsonObject); createCustomerSupport.setListener(new UnityCustomerSupportListener(str)); return createCustomerSupport; } }