Sunbit v2.4.4版本的 MD5 值为:a5021e5e2a58eb1d6741b432fe7533c4

以下内容为反编译后的 Chat.java 源代码,内容仅作参考


package zendesk.chat;

import android.annotation.SuppressLint;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.zendesk.logger.Logger;
import com.zendesk.util.StringUtils;
public enum Chat {
    INSTANCE;
    
    private static final String BASE_URL = "https://widget-mediator.zopim.com";
    private static final String LOG_TAG = "Chat";
    static final String NOT_INITIALIZED_LOG = "Chat SDK needs to be initialized first. Call Chat.INSTANCE.init(...)";
    static final String SDK_VARIANT = "Chat";
    static final VisitorPath VISITOR_PATH = VisitorPath.create("Mobile Chat - Android", "Zendesk Chat SDK v2.0.0");
    private ChatProvidersComponent chatProvidersComponent;

    @SuppressLint({"RestrictedApi"})
    public void clearCache() {
        if (this.chatProvidersComponent == null) {
            Logger.e("Chat", NOT_INITIALIZED_LOG, new Object[0]);
            return;
        }
        Logger.d("Chat", "Clearing cache", new Object[0]);
        this.chatProvidersComponent.connectionProvider().disconnect();
        this.chatProvidersComponent.observableVisitorInfo().clearData();
        this.chatProvidersComponent.observableChatState().clearData();
        this.chatProvidersComponent.observableAccount().clearData();
        this.chatProvidersComponent.chatSessionManager().reset();
    }

    @Nullable
    public ChatProvidersComponent component() {
        ChatProvidersComponent chatProvidersComponent = this.chatProvidersComponent;
        if (chatProvidersComponent == null) {
            Logger.e("Chat", NOT_INITIALIZED_LOG, new Object[0]);
            return null;
        }
        return chatProvidersComponent;
    }

    @SuppressLint({"RestrictedApi"})
    public void init(@NonNull Context context, @NonNull String str) {
        if (context == null) {
            Logger.e("Chat", "Chat cannot be initialized without providing a context", new Object[0]);
        } else if (StringUtils.isEmpty(str)) {
            Logger.e("Chat", "Chat cannot be initialized without providing an account key", new Object[0]);
        } else {
            init(DaggerChatProvidersComponent.builder().chatConfig(new ChatConfig(str, VISITOR_PATH, BASE_URL)).context(context.getApplicationContext()).build());
        }
    }

    @Nullable
    public Providers providers() {
        return component();
    }

    @SuppressLint({"RestrictedApi"})
    public void resetIdentity() {
        if (this.chatProvidersComponent == null) {
            Logger.e("Chat", NOT_INITIALIZED_LOG, new Object[0]);
            return;
        }
        Logger.d("Chat", "Resetting user identity", new Object[0]);
        this.chatProvidersComponent.chatProviderStorage().clearMachineId();
        clearCache();
    }

    @VisibleForTesting
    void init(@NonNull ChatProvidersComponent chatProvidersComponent) {
        this.chatProvidersComponent = chatProvidersComponent;
    }
}