360手机助手 v3.3.0版本的 MD5 值为:127c345ad16bbebee6e347381328afd0

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


package com.qihoo.appstore.video;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.ClipboardManager;
import android.text.TextUtils;
import android.util.Pair;
import android.view.View;
import android.widget.Toast;
import com.qihoo.appstore.activities.MainActivity;
import com.qihoo.appstore.resource.app.App;
import com.qihoo.appstore.ui.ScrollScreenLayout;
import com.qihoo.appstore.utils.bk;
import com.qihoo.appstore.utils.de;
import com.qihoo.freewifi.push.R;
import com.qihoo.speedometer.Config;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class VideoJavaScriptinterface implements com.qihoo.appstore.video.a.a.x {
    private static final String JS_METHOD_DOWNLOAD_MULTIPLE = "multipleDownload";
    private static final String JS_METHOD_DOWNLOAD_SINGLE = "singleDownload";
    private static final String JS_METHOD_DOWNLOAD_STATE = "changeDownloadState";
    private static final int OP_DOWNLOAD_VIDEO = 5;
    private static final int OP_DOWNLOAD_VIDEO_WITHOUT_PLAY = 9;
    private static final int OP_GO_APP_INFO_ACCTIVITY = 6;
    private static final int OP_JS_GO_APP_INFO_ACCTIVITY = 8;
    private static final int OP_OPEN_PAGE = 1;
    private static final int OP_RESET_SEARCH_CONDITION = 4;
    private static final int OP_RETRIVE_VIDEO_STATUS = 3;
    private static final int OP_SHARE = 7;
    private static final int OP_UPDATE_BOTTOM_BAR = 2;
    public static final int PAGE_TYPE_CATEGORY = 2;
    public static final int PAGE_TYPE_DETAIL = 3;
    public static final int PAGE_TYPE_FILE_REVIEW = 4;
    public static final int PAGE_TYPE_MAIN = 1;
    public static final int PAGE_TYPE_SEARCH_CONTENT = 6;
    public static final int PAGE_TYPE_SEARCH_INDEX = 5;
    private static final String TAG = VideoJavaScriptinterface.class.getSimpleName();
    static com.qihoo.appstore.d.n sld;
    private au mCallback;
    private Context mContext;
    private VideoWebView mWebView;
    private View mloadingView;
    ConditionSearchLayout mResetConditionCallback = null;
    private at mUpdate = null;
    private AsyncTask mVideoStatusChecker = null;
    com.qihoo.appstore.http.netconfig.a netApnConfig = com.qihoo.appstore.http.netconfig.c.b().a();
    private final Handler mHandler = new Handler(new al(this));

    public VideoJavaScriptinterface(Context context, VideoWebView videoWebView, View view) {
        this.mContext = context;
        this.mWebView = videoWebView;
        this.mloadingView = view;
        com.qihoo.appstore.video.a.a.d.a(this);
    }

    private void callWebViewJs(String str) {
        this.mWebView.loadUrl("javascript:" + str);
    }

    private String getInfoForWeb() {
        JSONObject jSONObject = new JSONObject();
        if (this.netApnConfig.a() == 1) {
            jSONObject.put("net", "wifi");
        } else {
            jSONObject.put("net", "2g");
        }
        jSONObject.put("screen", Config.INVALID_IP + de.b().widthPixels + "," + de.b().heightPixels);
        jSONObject.put("version", de.c(this.mContext, this.mContext.getPackageName()));
        return jSONObject.toString();
    }

    private void retriveVideoStatus(String[] strArr) {
        if (this.mVideoStatusChecker != null && !this.mVideoStatusChecker.getStatus().equals(AsyncTask.Status.RUNNING)) {
            this.mVideoStatusChecker = null;
        }
        if (this.mVideoStatusChecker == null) {
            this.mVideoStatusChecker = new ak(this, strArr);
        }
        if (this.mVideoStatusChecker.getStatus().equals(AsyncTask.Status.RUNNING)) {
            return;
        }
        this.mVideoStatusChecker.execute(strArr);
    }

    public void share(Object obj) {
        try {
            JSONObject jSONObject = (JSONObject) obj;
            String optString = jSONObject.optString("content");
            String optString2 = jSONObject.optString("img");
            if (this.mContext instanceof Activity) {
                com.qihoo.appstore.share.a.a((Activity) this.mContext, optString + this.mContext.getResources().getString(R.string.video_share_tail), optString2);
            }
        } catch (Exception e) {
            bk.e(TAG, e.getMessage());
        }
    }

    public void startDownload(JSONArray jSONArray) {
        int length;
        if (jSONArray == null || (length = jSONArray.length()) <= 0) {
            return;
        }
        try {
            ArrayList arrayList = new ArrayList();
            for (int i = 0; i < length; i++) {
                JSONObject optJSONObject = jSONArray.optJSONObject(i);
                String optString = optJSONObject.optString("id");
                String optString2 = optJSONObject.optString("url");
                String optString3 = optJSONObject.optString("name");
                String optString4 = optJSONObject.optString("cid");
                String optString5 = optJSONObject.optString("from");
                String optString6 = optJSONObject.optString("cover_url");
                String optString7 = optJSONObject.optString("url_list");
                Video video = new Video();
                video.n(optString);
                video.A(optString);
                video.o(optString3);
                if (optString7 == null || optString7.length() <= 0) {
                    optString7 = optString2;
                }
                video.q(optString7);
                video.m(optString);
                video.y(optString4);
                video.z(optString5);
                video.B(optString6);
                video.g(false);
                arrayList.add(video);
                if (length == 1) {
                    boolean a2 = com.qihoo.appstore.video.a.a.d.a(video);
                    boolean b2 = com.qihoo.appstore.video.a.a.d.b(video);
                    if (!a2 || b2) {
                        com.qihoo.appstore.video.a.a.d.a((com.qihoo.appstore.e.a.b) video, true);
                    } else {
                        this.mHandler.post(new am(this));
                    }
                }
            }
            if (length > 1) {
                com.qihoo.appstore.video.a.a.d.a((List) arrayList, true);
            }
        } catch (Exception e) {
            bk.e(TAG, e.getMessage());
        }
    }

    public void startDownloadWithoutPlay(JSONArray jSONArray) {
        int length;
        de.l(MainActivity.e(), Video.ac);
        if (jSONArray == null || (length = jSONArray.length()) <= 0) {
            return;
        }
        try {
            ArrayList arrayList = new ArrayList();
            for (int i = 0; i < length; i++) {
                JSONObject optJSONObject = jSONArray.optJSONObject(i);
                String optString = optJSONObject.optString("id");
                String optString2 = optJSONObject.optString("url");
                String optString3 = optJSONObject.optString("name");
                String optString4 = optJSONObject.optString("cid");
                String optString5 = optJSONObject.optString("from");
                String optString6 = optJSONObject.optString("cover_url");
                String optString7 = optJSONObject.optString("url_list");
                Video video = new Video();
                video.n(optString);
                video.A(optString);
                video.o(optString3);
                if (optString7 == null || optString7.length() <= 0) {
                    optString7 = optString2;
                }
                video.q(optString7);
                video.m(optString);
                video.y(optString4);
                video.z(optString5);
                video.B(optString6);
                video.g(false);
                arrayList.add(video);
            }
            if (length > 0) {
                if (com.qihoo.appstore.video.a.a.d.a(arrayList)) {
                    this.mHandler.post(new an(this));
                    com.qihoo.appstore.video.a.a.d.a((List) arrayList, true);
                } else {
                    if (length > 1) {
                        this.mHandler.post(new ao(this));
                        return;
                    }
                    if (!(this.mContext instanceof VideoDetailActivity ? ((VideoDetailActivity) this.mContext).a() : false)) {
                        this.mHandler.post(new aq(this));
                    } else if (com.qihoo.appstore.video.a.a.d.b((Video) arrayList.get(0))) {
                        com.qihoo.appstore.video.a.a.d.a((com.qihoo.appstore.e.a.b) arrayList.get(0), true);
                    } else {
                        this.mHandler.post(new ap(this));
                    }
                }
            }
        } catch (Exception e) {
            bk.e(TAG, e.getMessage());
        }
    }

    public boolean bCanBeUpdate(String str) {
        return com.qihoo.appstore.l.d.e(str);
    }

    public void callWebViewJsDownloadSingle(String str) {
        this.mWebView.loadUrl("javascript:singleDownload(" + str + ")");
    }

    public void clear() {
        com.qihoo.appstore.video.a.a.d.b(this);
        this.mloadingView = null;
        this.mWebView = null;
        this.mContext = null;
        sld = null;
    }

    public void clientInit(String str) {
        String str2 = Config.INVALID_IP;
        try {
            str2 = getInfoForWeb();
        } catch (JSONException e) {
            bk.e(TAG, e.getMessage());
        }
        if (TextUtils.isEmpty(str2)) {
            return;
        }
        setClientInfo(str2);
    }

    public void copyToClipboard(String str) {
        if (com.qihoo360.mobilesafe.a.a.f5313a) {
            bk.b(TAG, "copyToClipboard" + str);
        }
        ((ClipboardManager) this.mContext.getSystemService("clipboard")).setText(str);
    }

    public void download(String str) {
        de.l(MainActivity.e(), Video.ac);
        bk.c(TAG, "download=" + str);
        if (TextUtils.isEmpty(str)) {
            return;
        }
        try {
            JSONArray jSONArray = new JSONArray(str);
            Message obtain = Message.obtain();
            obtain.what = 5;
            obtain.obj = jSONArray;
            this.mHandler.sendMessage(obtain);
        } catch (JSONException e) {
            bk.e(TAG, e.getMessage());
        }
    }

    public void downloadWithoutPlay(String str) {
        bk.c(TAG, "download=" + str);
        if (TextUtils.isEmpty(str)) {
            return;
        }
        try {
            JSONArray jSONArray = new JSONArray(str);
            Message obtain = Message.obtain();
            obtain.what = 9;
            obtain.obj = jSONArray;
            this.mHandler.sendMessage(obtain);
        } catch (JSONException e) {
            bk.e(TAG, e.getMessage());
        }
    }

    public void filterList(String str) {
        if (str == null || TextUtils.isEmpty(str)) {
            return;
        }
        if (com.qihoo360.mobilesafe.a.a.f5313a) {
            bk.b(TAG, str);
        }
        this.mWebView.loadUrl("javascript:AndroidWebview_filterList(" + str + ")");
    }

    public int getApkVersionCode() {
        try {
            int i = this.mContext.getPackageManager().getPackageInfo(this.mContext.getPackageName(), 16384).versionCode;
            if (!com.qihoo360.mobilesafe.a.a.f5313a) {
                return i;
            }
            bk.b(TAG, "getVersionCode = " + i);
            return i;
        } catch (Exception e) {
            if (com.qihoo360.mobilesafe.a.a.f5313a) {
                bk.b(TAG, "getVersionCode error packagename not found");
            }
            return -1;
        }
    }

    public void getAppStatus(String str, String str2) {
        if (com.qihoo360.mobilesafe.a.a.f5313a) {
            bk.b(TAG, "getAppStatus" + str);
        }
        StringBuffer stringBuffer = new StringBuffer("{");
        try {
            JSONArray jSONArray = new JSONArray(str);
            for (int i = 0; i < jSONArray.length(); i++) {
                JSONObject jSONObject = (JSONObject) jSONArray.opt(i);
                String optString = jSONObject.optString("pkgName");
                jSONObject.optInt("version", 0);
                stringBuffer.append("\"").append(optString).append("\":{\"status\":\"").append(isInstalled(optString) ? bCanBeUpdate(optString) ? 2 : 1 : 0);
            }
            stringBuffer.append("\"}");
            String str3 = str2 + "('" + stringBuffer.toString() + "')";
            bk.b(TAG, "getappStatus = " + str3);
            callWebViewJs(str3);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    public void getInstatllApp(String str) {
        if (com.qihoo360.mobilesafe.a.a.f5313a) {
            bk.b(TAG, "getInstatllApp" + str);
        }
        StringBuffer stringBuffer = new StringBuffer();
        List<PackageInfo> installedPackages = this.mContext.getPackageManager().getInstalledPackages(0);
        stringBuffer.append("{");
        for (PackageInfo packageInfo : installedPackages) {
            if (stringBuffer.length() > 1) {
                stringBuffer.append(",");
            }
            stringBuffer.append("\"").append(packageInfo.packageName).append("\"").append(":");
            stringBuffer.append("\"").append(packageInfo.versionCode).append("\"");
        }
        stringBuffer.append("}");
        bk.b(TAG, "getinstallapp = " + stringBuffer.toString());
        if (str != null) {
            callWebViewJs("setAppStatus(" + stringBuffer.toString() + ")");
        }
    }

    public String getVideoStatus(String str) {
        if (com.qihoo360.mobilesafe.a.a.f5313a) {
            bk.b(TAG, "getVideoStatus =" + str);
        }
        if (TextUtils.isEmpty(str)) {
            return Config.INVALID_IP;
        }
        String[] split = str.split(",");
        Message message = new Message();
        message.what = 2;
        message.obj = split;
        this.mHandler.sendMessage(message);
        retriveVideoStatus(split);
        return Config.INVALID_IP;
    }

    public boolean gotoPage(String str) {
        boolean z = false;
        if (com.qihoo360.mobilesafe.a.a.f5313a) {
            bk.b(TAG, "gotoAppInfo " + str);
        }
        if (str == null) {
            return false;
        }
        try {
            JSONObject jSONObject = new JSONObject(str);
            if (!"detail".equals(jSONObject.optString("page"))) {
                return false;
            }
            Message message = new Message();
            Bundle bundle = new Bundle();
            App app = new App();
            app.m(jSONObject.optString("apkid"));
            app.o(jSONObject.optString("name"));
            app.s(jSONObject.optString("logo_url"));
            app.p(jSONObject.optInt("version_code"));
            app.q(jSONObject.optString("down_url"));
            app.D("soft");
            com.qihoo.appstore.f.f j = com.qihoo.appstore.f.g.j(app.W());
            if (j == null) {
                app.c(-2);
            } else {
                app.c(j.c());
                app.e(j.e());
            }
            bundle.putParcelable("com.qihoo.appstore.App", app);
            message.setData(bundle);
            message.what = 8;
            z = this.mHandler.sendMessage(message);
            return z;
        } catch (JSONException e) {
            e.printStackTrace();
            return z;
        }
    }

    public boolean isInstalled(String str) {
        if (com.qihoo360.mobilesafe.a.a.f5313a) {
            bk.b(TAG, "isInstalled" + str);
        }
        return com.qihoo.appstore.l.d.c(str);
    }

    public boolean launchApp(String str) {
        if (com.qihoo360.mobilesafe.a.a.f5313a) {
            bk.b(TAG, "launchApp" + str);
        }
        PackageManager packageManager = this.mContext.getPackageManager();
        new Intent();
        try {
            Intent launchIntentForPackage = packageManager.getLaunchIntentForPackage(new JSONObject(str).optString("apkid"));
            if (launchIntentForPackage != null) {
                this.mContext.startActivity(launchIntentForPackage);
                return true;
            }
        } catch (Exception e) {
            bk.c(TAG, e.toString());
        }
        return false;
    }

    public void notifyCurrentPageState(String str) {
        if (TextUtils.isEmpty(str) || this.mUpdate == null) {
            return;
        }
        this.mUpdate.b(str);
    }

    @Override
    public void onLocalCacheInitFinished() {
    }

    @Override
    public boolean onNotifyDataChanged(com.qihoo.appstore.video.a.a.c cVar, boolean z) {
        if (cVar != null && this.mWebView.getIfKnowDownloadStatus()) {
            if (cVar.e() == 190 && com.qihoo360.mobilesafe.a.a.f5313a) {
                bk.b(TAG, "Downloads.STATUS_PENDING");
            }
            String b2 = com.qihoo.appstore.video.a.a.d.b(cVar);
            callWebViewJs("AndroidWebview_setVideoStatus(" + b2 + ")");
            if (com.qihoo360.mobilesafe.a.a.f5313a) {
                bk.b(TAG, "AndroidWebview_setVideoStatus(" + b2 + ")");
            }
        }
        return false;
    }

    public void openPage(String str) {
        if (str == null) {
            return;
        }
        bk.c(TAG, "openPage jsonString=" + str);
        try {
            JSONObject jSONObject = new JSONObject(str);
            String optString = jSONObject.optString("url");
            int i = jSONObject.getInt("pageType");
            String optString2 = jSONObject.optString("title");
            String optString3 = jSONObject.optString("extra");
            String optString4 = jSONObject.optString("cid");
            ArrayList arrayList = new ArrayList();
            Pair pair = new Pair("title", optString2);
            Pair pair2 = new Pair("extra", optString3);
            Pair pair3 = new Pair("media_type", optString4);
            Pair pair4 = new Pair("url", optString);
            arrayList.add(pair);
            arrayList.add(pair2);
            arrayList.add(pair3);
            arrayList.add(pair4);
            Message obtain = Message.obtain();
            obtain.what = 1;
            obtain.arg1 = i;
            obtain.obj = arrayList;
            this.mHandler.sendMessage(obtain);
        } catch (JSONException e) {
            bk.e(TAG, e.getMessage());
        }
    }

    public void pageFinish() {
        if (this.mloadingView != null) {
            this.mHandler.post(new as(this));
        }
        if (com.qihoo360.mobilesafe.a.a.f5313a) {
            bk.b(TAG, "pageLoadFinished " + (this.mloadingView != null));
        }
    }

    public void pageStart() {
        if (this.mloadingView != null) {
            this.mHandler.post(new ar(this));
        }
        if (com.qihoo360.mobilesafe.a.a.f5313a) {
            bk.b(TAG, "pageLoadStarted " + (this.mloadingView != null));
        }
    }

    public void reload() {
        if (this.mWebView != null) {
            if (com.qihoo360.mobilesafe.a.a.f5313a) {
                bk.b(TAG, "reload");
            }
            this.mWebView.a();
        }
    }

    public void request(String str) {
        if (this.mWebView != null) {
            this.mWebView.loadUrl(str);
        }
    }

    public void resetSearchCondition(String str, String str2) {
        if (this.mResetConditionCallback != null) {
            Message message = new Message();
            message.what = 4;
            message.obj = new Object[]{str, str2};
            this.mHandler.sendMessage(message);
        }
    }

    public void setBannerOnTouch(int i) {
        bk.b(TAG, "setBannerOnTouch " + i);
        ScrollScreenLayout.setScrollable(i != 1);
    }

    public void setBottomBarStateUpdate(at atVar) {
        this.mUpdate = atVar;
    }

    public void setClientInfo(String str) {
        this.mWebView.loadUrl("javascript:setClientInfo(" + str + ")");
    }

    public void setLoadingView(View view) {
        this.mloadingView = view;
    }

    public void setPageTypeChangeCallback(au auVar) {
        this.mCallback = auVar;
    }

    public void setSearchConditionCallback(ConditionSearchLayout conditionSearchLayout) {
        this.mResetConditionCallback = conditionSearchLayout;
    }

    public void shareToSNS(String str) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        try {
            JSONObject jSONObject = new JSONObject(str);
            Message obtain = Message.obtain();
            obtain.obj = jSONObject;
            obtain.what = 7;
            this.mHandler.sendMessage(obtain);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    public void showMessage(String str) {
        if (MainActivity.e() != null) {
            Toast.makeText(MainActivity.e(), str, 0).show();
        }
    }
}