- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
94 lines
4.2 KiB
Java
94 lines
4.2 KiB
Java
package csdk.glucustomersupport.eventbus;
|
|
|
|
import android.text.TextUtils;
|
|
import com.facebook.share.internal.ShareConstants;
|
|
import com.mbridge.msdk.MBridgeConstans;
|
|
import csdk.glucustomersupport.eventbus.GluEventBus;
|
|
import csdk.glucustomersupport.util.ConfigUtil;
|
|
import csdk.glucustomersupport.util.GluUtil;
|
|
import csdk.glucustomersupport.util.IAction2;
|
|
import java.util.Collections;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public class GluConfigEventHandler implements GluEventBus.IEventHandler {
|
|
private static final String CHANNEL_SDK = "#csdk.gluCustomerSupport";
|
|
private static final String EVENT_SDK = "#csdk.gluCustomerSupport.evt";
|
|
private static final String ID_HANDLER = "@csdk.gluCustomerSupport.configGetter";
|
|
private final String mDefaultConfig;
|
|
private final GluEventBus mEventBus;
|
|
private final IAction2<String, String> mInitFn;
|
|
private Object mToken;
|
|
private boolean mut_initialized;
|
|
|
|
private GluConfigEventHandler(GluEventBus gluEventBus, IAction2<String, String> iAction2, String str) {
|
|
this.mEventBus = gluEventBus;
|
|
this.mInitFn = iAction2;
|
|
this.mDefaultConfig = str;
|
|
}
|
|
|
|
private static GluConfigEventHandler subscribe(GluEventBus gluEventBus, Object obj, IAction2<String, String> iAction2, String str) {
|
|
GluConfigEventHandler gluConfigEventHandler = new GluConfigEventHandler(gluEventBus, iAction2, str);
|
|
gluConfigEventHandler.mToken = gluEventBus.subscribe(obj, ID_HANDLER, Collections.singletonList(CHANNEL_SDK), gluConfigEventHandler);
|
|
return gluConfigEventHandler;
|
|
}
|
|
|
|
public static void request(String str, Map<String, Object> map, IAction2<String, String> iAction2) {
|
|
boolean z = ConfigUtil.getBoolean(map, "csdk.gluCustomerSupport.disabled.configUpdate", false);
|
|
long j = (long) (ConfigUtil.getDouble(map, "csdk.gluCustomerSupport.configUpdate.timeoutInSec", 5.0d) * 1000.0d);
|
|
GluEventBus gluEventBus = ConfigUtil.getBoolean(map, "csdk.gluCustomerSupport.disabled.eventBus", false) ? GluEventBus.DISCONNECTED : GluEventBus.SHARED;
|
|
if (gluEventBus.isConnected() && !z) {
|
|
subscribe(gluEventBus, GluEventBus.GLOBAL_TOKEN, iAction2, str).requestConfig(j);
|
|
} else {
|
|
iAction2.apply(str, "APP-NO-EB");
|
|
}
|
|
}
|
|
|
|
public void requestConfig(long j) {
|
|
this.mEventBus.publish(this.mToken, new GluEventBus.Event(EVENT_SDK, "configRequested", null, Collections.singletonMap("jsonConfig", this.mDefaultConfig)));
|
|
if (j > 0) {
|
|
GluUtil.runOnUIThreadDelayed(new Runnable() { // from class: csdk.glucustomersupport.eventbus.GluConfigEventHandler.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
GluConfigEventHandler gluConfigEventHandler = GluConfigEventHandler.this;
|
|
gluConfigEventHandler.initOnce(gluConfigEventHandler.mDefaultConfig, "app-timeout");
|
|
GluConfigEventHandler.this.onDestroy();
|
|
}
|
|
}, j);
|
|
}
|
|
}
|
|
|
|
public void onDestroy() {
|
|
this.mEventBus.unsubscribe(this.mToken);
|
|
}
|
|
|
|
@Override // csdk.glucustomersupport.eventbus.GluEventBus.IEventHandler
|
|
public void handleEvent(GluEventBus gluEventBus, Object obj, String str, GluEventBus.Event event) throws Exception {
|
|
String str2;
|
|
if (TextUtils.equals(event.channel, CHANNEL_SDK) && TextUtils.equals(event.action, "reconfigure")) {
|
|
String string = ConfigUtil.getString(event.data, "jsonConfig");
|
|
if (TextUtils.isEmpty(string)) {
|
|
string = this.mDefaultConfig;
|
|
str2 = MBridgeConstans.DYNAMIC_VIEW_WX_APP;
|
|
} else {
|
|
str2 = ConfigUtil.getString(event.data, ShareConstants.FEED_SOURCE_PARAM);
|
|
}
|
|
initOnce(string, str2);
|
|
gluEventBus.unsubscribe(obj);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void initOnce(String str, String str2) {
|
|
boolean z;
|
|
synchronized (this) {
|
|
z = this.mut_initialized;
|
|
this.mut_initialized = true;
|
|
}
|
|
if (z) {
|
|
return;
|
|
}
|
|
this.mInitFn.apply(str, str2);
|
|
}
|
|
}
|