SocketMgr.smali

.class public Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;
.super Ljava/lang/Object;


# static fields
.field private static INSTANCE:Lcom/cmcm/xiaobao/phone/commons/utils/Singleton;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Lcom/cmcm/xiaobao/phone/commons/utils/Singleton",
            "<",
            "Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;",
            ">;"
        }
    .end annotation
.end field

.field private static hasRegisterWifiChange:Z


# instance fields
.field private mSpeakerSocket:Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;

.field private mSpeakerSocketTransfer:Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/SpeakerSocketTransfer;

.field private mWiFiName:Ljava/lang/String;


# direct methods
.method static constructor <clinit>()V
    .registers 1

    new-instance v0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr$3;

    invoke-direct {v0}, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr$3;-><init>()V

    sput-object v0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->INSTANCE:Lcom/cmcm/xiaobao/phone/commons/utils/Singleton;

    return-void
.end method

.method private constructor <init>()V
    .registers 5

    const/4 v0, 0x0

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    iput-object v0, p0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->mSpeakerSocket:Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;

    iput-object v0, p0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->mWiFiName:Ljava/lang/String;

    new-instance v0, Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/SpeakerSocketTransfer;

    invoke-direct {v0}, Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/SpeakerSocketTransfer;-><init>()V

    iput-object v0, p0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->mSpeakerSocketTransfer:Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/SpeakerSocketTransfer;

    new-instance v0, Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;

    new-instance v1, Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PingSocketTransfer;

    iget-object v2, p0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->mSpeakerSocketTransfer:Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/SpeakerSocketTransfer;

    new-instance v3, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr$1;

    invoke-direct {v3, p0}, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr$1;-><init>(Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;)V

    invoke-direct {v1, v2, v3}, Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PingSocketTransfer;-><init>(Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/IDataTransfer;Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PingSocketTransfer$OnSignErrorListener;)V

    invoke-direct {v0, v1}, Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;-><init>(Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/IDataTransfer;)V

    iput-object v0, p0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->mSpeakerSocket:Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;

    return-void
.end method

.method synthetic constructor <init>(Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr$1;)V
    .registers 2

    invoke-direct {p0}, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;-><init>()V

    return-void
.end method

.method static synthetic access$000(Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;)Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;
    .registers 2

    iget-object v0, p0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->mSpeakerSocket:Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;

    return-object v0
.end method

.method static synthetic access$100(Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;)Ljava/lang/String;
    .registers 2

    iget-object v0, p0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->mWiFiName:Ljava/lang/String;

    return-object v0
.end method

.method static synthetic access$102(Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;Ljava/lang/String;)Ljava/lang/String;
    .registers 2

    iput-object p1, p0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->mWiFiName:Ljava/lang/String;

    return-object p1
.end method

.method public static getIns()Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;
    .registers 1

    sget-object v0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->INSTANCE:Lcom/cmcm/xiaobao/phone/commons/utils/Singleton;

    invoke-virtual {v0}, Lcom/cmcm/xiaobao/phone/commons/utils/Singleton;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;

    return-object v0
.end method


# virtual methods
.method public constructSocketAtStartup()V
    .registers 4

    iget-object v0, p0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->mSpeakerSocket:Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;

    invoke-virtual {v0}, Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;->createSocket()V

    invoke-static {}, Lcom/cmcm/xiaobao/phone/commons/utils/NetUtil;->getWiFiName()Ljava/lang/String;

    move-result-object v0

    iput-object v0, p0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->mWiFiName:Ljava/lang/String;

    sget-boolean v0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->hasRegisterWifiChange:Z

    if-eqz v0, :cond_10

    :goto_f
    return-void

    :cond_10
    new-instance v0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr$2;

    invoke-direct {v0, p0}, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr$2;-><init>(Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;)V

    new-instance v1, Landroid/content/IntentFilter;

    const-string/jumbo v2, "android.net.conn.CONNECTIVITY_CHANGE"

    invoke-direct {v1, v2}, Landroid/content/IntentFilter;-><init>(Ljava/lang/String;)V

    invoke-static {}, Lcom/cmcm/xiaobao/phone/smarthome/sdk/SmartHomeSDK;->getInstance()Lcom/cmcm/xiaobao/phone/smarthome/sdk/SmartHomeSDK;

    move-result-object v2

    invoke-virtual {v2}, Lcom/cmcm/xiaobao/phone/smarthome/sdk/SmartHomeSDK;->getAppContext()Landroid/content/Context;

    move-result-object v2

    invoke-virtual {v2, v0, v1}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    const/4 v0, 0x1

    sput-boolean v0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->hasRegisterWifiChange:Z

    goto :goto_f
.end method

.method public destroySocket()V
    .registers 3

    const-string/jumbo v0, "XPhoneSocket"

    const-string/jumbo v1, "pdestroy socket"

    invoke-static {v0, v1}, Lcom/cmcm/xiaobao/phone/commons/log/LogUtil;->d(Ljava/lang/String;Ljava/lang/String;)V

    iget-object v0, p0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->mSpeakerSocket:Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;

    invoke-virtual {v0}, Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;->destroy()V

    return-void
.end method

.method public getSpeakerSocketTransfer()Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/SpeakerSocketTransfer;
    .registers 2

    iget-object v0, p0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->mSpeakerSocketTransfer:Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/SpeakerSocketTransfer;

    return-object v0
.end method

.method public isConnected()Z
    .registers 2

    iget-object v0, p0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->mSpeakerSocket:Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;

    invoke-virtual {v0}, Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;->isConnected()Z

    move-result v0

    return v0
.end method

.method public reconstructSocket()V
    .registers 2

    invoke-virtual {p0}, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->destroySocket()V

    iget-object v0, p0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->mSpeakerSocket:Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;

    invoke-virtual {v0}, Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;->createSocket()V

    return-void
.end method

.method public sendData(ILcom/cmcm/xiaobao/phone/smarthome/socket/transmission/OnSendCallBack;)Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/ResponseControl;
    .registers 4

    const/4 v0, 0x0

    invoke-virtual {p0, p1, v0, p2}, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->sendData(ILjava/lang/String;Lcom/cmcm/xiaobao/phone/smarthome/socket/transmission/OnSendCallBack;)Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/ResponseControl;

    move-result-object v0

    return-object v0
.end method

.method public sendData(ILjava/lang/Object;Lcom/cmcm/xiaobao/phone/smarthome/socket/transmission/OnSendCallBack;)Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/ResponseControl;
    .registers 5

    instance-of v0, p2, Ljava/lang/String;

    if-eqz v0, :cond_b

    check-cast p2, Ljava/lang/String;

    invoke-virtual {p0, p1, p2, p3}, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->sendData(ILjava/lang/String;Lcom/cmcm/xiaobao/phone/smarthome/socket/transmission/OnSendCallBack;)Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/ResponseControl;

    move-result-object v0

    :goto_a
    return-object v0

    :cond_b
    new-instance v0, Lcom/google/gson/Gson;

    invoke-direct {v0}, Lcom/google/gson/Gson;-><init>()V

    invoke-virtual {v0, p2}, Lcom/google/gson/Gson;->toJson(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v0

    invoke-virtual {p0, p1, v0, p3}, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->sendData(ILjava/lang/String;Lcom/cmcm/xiaobao/phone/smarthome/socket/transmission/OnSendCallBack;)Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/ResponseControl;

    move-result-object v0

    goto :goto_a
.end method

.method public sendData(ILjava/lang/String;Lcom/cmcm/xiaobao/phone/smarthome/socket/transmission/OnSendCallBack;)Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/ResponseControl;
    .registers 5

    iget-object v0, p0, Lcom/cmcm/xiaobao/phone/smarthome/socket/SocketMgr;->mSpeakerSocket:Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;

    invoke-virtual {v0, p1, p2, p3}, Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/PullIpTransfer;->send(ILjava/lang/String;Lcom/cmcm/xiaobao/phone/smarthome/socket/transmission/OnSendCallBack;)Lcom/cmcm/xiaobao/phone/smarthome/socket/protocol/ResponseControl;

    move-result-object v0

    return-object v0
.end method