/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  android.app.Service
 *  android.content.Intent
 *  android.os.Binder
 *  android.os.Handler
 *  android.os.IBinder
 *  android.os.Message
 *  android.util.Log
 *  java.lang.Exception
 *  java.lang.Object
 *  java.lang.Runnable
 *  java.lang.String
 *  java.util.ArrayList
 *  java.util.Date
 *  java.util.List
 *  org.apache.http.message.BasicNameValuePair
 */
package com.xinli.portalclient.service;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.util.Log;
import com.google.code.microlog4android.Logger;
import com.google.code.microlog4android.LoggerFactory;
import com.xinli.portalclient.util.HttpUtils;
import com.xinli.portalclient.util.Sim_NetKeeperClient;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.http.message.BasicNameValuePair;

public class OnlineHeartService
extends Service {
    private static String clientVersion;
    private static final Logger logger;
    private static String phoneIp;
    private static String sessionId;
    private static String url;
    private static String username;
    private Binder binder;
    private Handler handler;
    private Handler proxyHandler;
    private Runnable proxyRunnable;
    private Runnable runable;
    private boolean sendHeart = true;

    static {
        url = null;
        sessionId = null;
        phoneIp = null;
        clientVersion = null;
        username = null;
        logger = LoggerFactory.getLogger(OnlineHeartService.class);
    }

    public OnlineHeartService() {
        this.handler = new Handler(){

            public void handleMessage(Message message) {
                super.handleMessage(message);
            }
        };
        this.runable = new Runnable(){

            public void run() {
                OnlineHeartService.this.sendOnlineHeart();
                OnlineHeartService.this.handler.postDelayed(OnlineHeartService.this.runable, 120000);
            }
        };
        this.proxyHandler = new Handler();
        this.proxyRunnable = new Runnable(){

            public void run() {
            }
        };
        this.binder = new LocalBinder();
    }

    private void sendOnlineHeart() {
        ArrayList arrayList = new ArrayList();
        arrayList.add((Object)new BasicNameValuePair("username", username));
        try {
            logger.debug("\u5f00\u59cb\u53d1\u9001\u5728\u7ebf\u5fc3\u8df3\u62a5\u6587:" + url + "/wf.do?code=7  sessionId:" + sessionId + "time:" + (Object)new Date());
            String string2 = HttpUtils.sendContentByHttpClient(String.valueOf((Object)url) + "/wf.do?code=7", sessionId, (List)arrayList);
            logger.info("\u53d1\u9001\u5728\u7ebf\u5fc3\u8df3\u62a5\u6587\u7ed3\u679c\uff1a" + string2);
            return;
        }
        catch (Exception var3_3) {
            this.onlineHeartBroadcast();
            logger.error("\u53d1\u9001\u5728\u7ebf\u5fc3\u8df3\u62a5\u6587\u53d1\u751f\u5f02\u5e38" + (Object)var3_3);
            logger.error("\u53d1\u9001\u5728\u7ebf\u5fc3\u8df3\u62a5\u6587\u53d1\u751f\u5f02\u5e38message" + var3_3.getMessage());
            this.sendHeart = false;
            return;
        }
    }

    private void sendProxyHeart() {
        try {
            logger.debug("\u5f00\u59cb\u53d1\u9001\u9632\u4ee3\u7406\u5fc3\u8df3\u62a5\u6587: ip:" + phoneIp + ",version:" + clientVersion + "username:" + username);
            new Sim_NetKeeperClient().sendHeart(username, phoneIp, "android" + clientVersion);
            logger.info("\u53d1\u9001\u9632\u4ee3\u7406\u5fc3\u8df3\u62a5\u6587\u6210\u529f");
            return;
        }
        catch (Exception var1_1) {
            logger.error("\u53d1\u9001\u9632\u4ee3\u7406\u5fc3\u8df3\u53d1\u751f\u5f02\u5e38" + var1_1.getMessage());
            var1_1.printStackTrace();
            return;
        }
    }

    public int getResult() {
        if (this.sendHeart) {
            return 0;
        }
        return 1;
    }

    public IBinder onBind(Intent intent) {
        Log.i((String)"OnlineHeartService", (String)"onBind");
        url = intent.getStringExtra("url");
        sessionId = intent.getStringExtra("sessionId");
        phoneIp = intent.getStringExtra("phoneIp");
        clientVersion = intent.getStringExtra("clientVersion");
        username = intent.getStringExtra("username");
        return this.binder;
    }

    public void onCreate() {
        super.onCreate();
        Log.i((String)"OnlineHeartService", (String)"onCreate");
        this.handler.post(this.runable);
    }

    public void onDestroy() {
        super.onDestroy();
        Log.i((String)"OnlineHeartService", (String)"onDestroy");
    }

    public void onRebind(Intent intent) {
        super.onRebind(intent);
        Log.i((String)"OnlineHeartService", (String)"onRebind");
    }

    public boolean onUnbind(Intent intent) {
        Log.i((String)"OnlineHeartService", (String)"onUnbind");
        this.handler.removeCallbacks(this.runable);
        return super.onUnbind(intent);
    }

    public void onlineHeartBroadcast() {
        Intent intent = new Intent();
        intent.putExtra("onlineHeart", "Exception");
        intent.setAction("android.intent.onlineheart.exception");
        this.sendBroadcast(intent);
    }

    public class LocalBinder
    extends Binder {
        public OnlineHeartService getService() {
            return OnlineHeartService.this;
        }
    }

}

