package csdk.glucustomersupport; import android.app.Activity; import csdk.glucustomersupport.util.GluUtil; import java.lang.ref.WeakReference; import java.util.Map; import java.util.concurrent.Callable; /* loaded from: classes4.dex */ public class NativeBridge implements IGluCustomerSupportListener { private WeakReference mActivity; private long mNativeData; private static native void destroy(long j); /* JADX INFO: Access modifiers changed from: private */ public static native Activity getCurrentActivity(long j); private static native void onHelpshiftSessionEnded(long j, String str); private static native void onHelpshiftSessionStarted(long j, String str); private static native void onQueryNotificationCount(long j, long j2, String str); public NativeBridge(long j) { this.mNativeData = j; this.mActivity = new WeakReference<>(getCurrentActivity(this.mNativeData)); } public void destroy() { synchronized (this) { try { long j = this.mNativeData; this.mNativeData = 0L; if (j != 0) { destroy(j); } } catch (Throwable th) { throw th; } } } public IGluCustomerSupport createCustomerSupport(String str, Map map) { IGluCustomerSupport createCustomerSupport = new GluFactory().createCustomerSupport(new Callable() { // from class: csdk.glucustomersupport.NativeBridge.1 /* JADX WARN: Can't rename method to resolve collision */ @Override // java.util.concurrent.Callable public Activity call() throws Exception { Activity activity; synchronized (NativeBridge.this) { try { if (NativeBridge.this.mNativeData != 0) { NativeBridge.this.mActivity = new WeakReference(NativeBridge.getCurrentActivity(NativeBridge.this.mNativeData)); } activity = (Activity) NativeBridge.this.mActivity.get(); } catch (Throwable th) { throw th; } } return activity; } }, GluUtil.emptyToNull(str), map); createCustomerSupport.setListener(this); return createCustomerSupport; } @Override // csdk.glucustomersupport.IGluCustomerSupportListener public void onQueryNotificationCount(NotificationCountEvent notificationCountEvent) { synchronized (this) { try { long j = this.mNativeData; long j2 = notificationCountEvent.count; Throwable th = notificationCountEvent.error; onQueryNotificationCount(j, j2, th != null ? th.getMessage() : null); } catch (Throwable th2) { throw th2; } } } @Override // csdk.glucustomersupport.IGluCustomerSupportListener public void onHelpshiftSessionStarted(GluCustomerSupportSessionStartedEvent gluCustomerSupportSessionStartedEvent) { synchronized (this) { try { long j = this.mNativeData; Throwable th = gluCustomerSupportSessionStartedEvent.error; onHelpshiftSessionStarted(j, th != null ? th.getMessage() : null); } catch (Throwable th2) { throw th2; } } } @Override // csdk.glucustomersupport.IGluCustomerSupportListener public void onHelpshiftSessionEnded(GluCustomerSupportSessionEndedEvent gluCustomerSupportSessionEndedEvent) { synchronized (this) { try { long j = this.mNativeData; Throwable th = gluCustomerSupportSessionEndedEvent.error; onHelpshiftSessionEnded(j, th != null ? th.getMessage() : null); } catch (Throwable th2) { throw th2; } } } }