TIM v2.3.1版本的 MD5 值为:d6957e3ee7ce901ccc491cefdea0da8c

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


package cooperation.qzone.webviewplugin;

import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.text.TextUtils;
import com.tencent.mobileqq.structmsg.StructMsgConstants;
import com.tencent.mobileqq.utils.JumpAction;
import com.tencent.mobileqq.webview.swift.JsBridgeListener;
import com.tencent.qphone.base.util.QLog;
import cooperation.peak.PeakConstants;
import cooperation.qzone.QZoneVideoCommonUtils;
import cooperation.qzone.QZoneVipInfoManager;
import cooperation.qzone.remote.logic.RemoteHandleConst;
import cooperation.qzone.remote.logic.RemoteHandleManager;
import cooperation.qzone.remote.logic.WebEventListener;
import java.util.Iterator;
import org.json.JSONException;
import org.json.JSONObject;
public class QzoneUiJsPlugin extends QzoneInternalWebViewPlugin implements WebEventListener {
    private static final String f98844a = "QzoneUiJsPlugin";
    private BroadcastReceiver f71001a = new yjo(this);
    private boolean f71002a;
    private String f98845b;
    private String f98846c;
    private String d;

    @Override
    public boolean a(JsBridgeListener jsBridgeListener, String str, String str2, String str3, String... strArr) {
        if (!QZoneJsConstants.f70926g.equals(str2) || this.f98823a == null) {
            return false;
        }
        if ("topicUploadVideo".equals(str3) && strArr != null && strArr.length > 0) {
            e(strArr[0]);
            return true;
        } else if ("getVideoFaceData".equals(str3) && strArr != null && strArr.length > 0) {
            RemoteHandleManager.a().a(this);
            d(strArr[0]);
            return true;
        } else if ("recordVideo".equals(str3) && strArr != null && strArr.length > 0) {
            a(strArr[0]);
            return true;
        } else if ("previewVideo".equals(str3) && strArr != null && strArr.length > 0) {
            b(strArr[0]);
            return true;
        } else if (!"uploadVideo".equals(str3) || strArr == null || strArr.length <= 0) {
            return false;
        } else {
            c(strArr[0]);
            return true;
        }
    }

    private void a(String str) {
        if (QLog.isDevelopLevel()) {
            QLog.d(f98844a, 4, "handleRecordVideo json=" + str);
        }
        b();
        try {
            JSONObject jSONObject = new JSONObject(str);
            String string = jSONObject.getString("callback");
            if (!TextUtils.isEmpty(string)) {
                this.d = string;
                String optString = jSONObject.optString("ptv_id");
                String optString2 = jSONObject.optString("confirm_btn_text");
                int optInt = jSONObject.optInt("need_input_text", 0);
                int optInt2 = optInt != 0 ? jSONObject.optInt("need_sync_qzone", 0) : 0;
                int optInt3 = jSONObject.optInt("is_original_video", 0);
                int optInt4 = jSONObject.optInt("need_edit_video", 0);
                JSONObject optJSONObject = jSONObject.optJSONObject("last_video");
                if (optJSONObject != null) {
                    String optString3 = optJSONObject.optString(JumpAction.dZ);
                    if (!TextUtils.isEmpty(optString3)) {
                        this.f98823a.mRuntime.m9632a().getHandler(QzoneVideoTabJsPlugin.class).post(new yjl(this, optString3));
                    }
                }
                QZoneVideoCommonUtils.a(this.f98823a.mRuntime.a(), QZoneVideoCommonUtils.f70248b, QZoneVipInfoManager.a().m10895a() > 0, optInt > 0, optInt4 > 0, optInt2 > 0, optInt3 > 0, optString, optString2, null);
            }
        } catch (JSONException e) {
            QLog.w(f98844a, 1, "handleRecordVideo error", e);
        }
    }

    private void b(String str) {
        if (QLog.isDevelopLevel()) {
            QLog.d(f98844a, 4, "handlePreviewVideo json=" + str);
        }
        try {
            JSONObject optJSONObject = new JSONObject(str).optJSONObject(StructMsgConstants.bO);
            if (optJSONObject == null) {
                QLog.e(f98844a, 1, "handlePreviewVideo video_info is empty");
                return;
            }
            String optString = optJSONObject.optString(JumpAction.dZ);
            int optInt = optJSONObject.optInt("videoType");
            long optLong = optJSONObject.optLong("duration");
            JSONObject optJSONObject2 = optJSONObject.optJSONObject("encodeExtras");
            Bundle bundle = new Bundle();
            if (optJSONObject2 != null) {
                Iterator<String> keys = optJSONObject2.keys();
                while (keys.hasNext()) {
                    String next = keys.next();
                    bundle.putInt(next, optJSONObject2.optInt(next));
                }
            }
            QZoneVideoCommonUtils.a(this.f98823a.mRuntime.a(), optInt, optString, optLong, bundle);
        } catch (JSONException e) {
            QLog.w(f98844a, 1, "handlePreviewVideo error", e);
        }
    }

    private void c(String str) {
        if (QLog.isDevelopLevel()) {
            QLog.d(f98844a, 4, "handleUploadVideo json=" + str);
        }
        try {
            if (new JSONObject(str).optJSONObject(StructMsgConstants.bO) == null) {
                QLog.e(f98844a, 1, "handleUploadVideo video_info is empty");
            } else {
                this.f98823a.mRuntime.m9632a().getHandler(QzoneVideoTabJsPlugin.class).post(new yjm(this, str));
            }
        } catch (JSONException e) {
            QLog.w(f98844a, 1, "handleUploadVideo error", e);
        }
    }

    private void d(String str) {
        if (QLog.isDevelopLevel()) {
            QLog.d(f98844a, 4, "handleGetVideoCover json=" + str);
        }
        try {
            JSONObject jSONObject = new JSONObject(str);
            String string = jSONObject.getString("callback");
            if (!TextUtils.isEmpty(string)) {
                this.f98846c = string;
                String string2 = jSONObject.getString("timestamp");
                if (!TextUtils.isEmpty(string2)) {
                    this.f98823a.mRuntime.m9632a().getHandler(QzoneVideoTabJsPlugin.class).post(new yjn(this, string2));
                }
            }
        } catch (JSONException e) {
            QLog.w(f98844a, 1, "handleGetVideoCover error", e);
        }
    }

    private void e(String str) {
        if (QLog.isDevelopLevel()) {
            QLog.d(f98844a, 4, "handleTopicUploadVideo json=" + str);
        }
        b();
        try {
            JSONObject jSONObject = new JSONObject(str);
            String string = jSONObject.getString("callback");
            if (!TextUtils.isEmpty(string)) {
                this.f98845b = string;
            }
            String string2 = jSONObject.getString("topicId");
            if (!TextUtils.isEmpty(string2)) {
                QZoneVideoCommonUtils.a(0L, this.f98823a.mRuntime.a(), true, true, PeakConstants.bS, QZoneVipInfoManager.a().m10895a() > 0, true, string2, "ptucamera".equals(jSONObject.optString("shoot")), null, null, null);
            }
        } catch (JSONException e) {
            QLog.w(f98844a, 1, "topicUploadVideo error", e);
        }
    }

    @Override
    public void mo11113a() {
        if (this.f71002a) {
            this.f98823a.mRuntime.a().unregisterReceiver(this.f71001a);
            this.f71002a = false;
        }
        RemoteHandleManager.a().b(this);
        super.mo11113a();
    }

    private void b() {
        if (!this.f71002a) {
            IntentFilter intentFilter = new IntentFilter();
            intentFilter.addAction(PeakConstants.bV);
            intentFilter.addAction(PeakConstants.bW);
            intentFilter.addAction(PeakConstants.bU);
            this.f98823a.mRuntime.a().registerReceiver(this.f71001a, intentFilter);
            this.f71002a = true;
        }
    }

    public JSONObject a(Intent intent) {
        String stringExtra = intent.getStringExtra(RemoteHandleConst.aF);
        int intExtra = intent.getIntExtra(RemoteHandleConst.aH, 0);
        String stringExtra2 = intent.getStringExtra("param.content");
        long longExtra = intent.getLongExtra(RemoteHandleConst.aG, 0L);
        String stringExtra3 = intent.getStringExtra(RemoteHandleConst.aI);
        long longExtra2 = intent.getLongExtra("param.duration", 0L);
        long longExtra3 = intent.getLongExtra(RemoteHandleConst.aN, 0L);
        boolean booleanExtra = intent.getBooleanExtra(RemoteHandleConst.aO, true);
        boolean booleanExtra2 = intent.getBooleanExtra(RemoteHandleConst.aS, false);
        String stringExtra4 = intent.getStringExtra(RemoteHandleConst.aT);
        Bundle bundleExtra = intent.getBundleExtra(RemoteHandleConst.aQ);
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put(JumpAction.dZ, stringExtra);
            jSONObject.put("videoType", intExtra);
            jSONObject.put("content", stringExtra2);
            jSONObject.put("videoSize", longExtra);
            jSONObject.put("thumbnailPath", stringExtra3);
            jSONObject.put("duration", longExtra2);
            jSONObject.put("totalDuration", longExtra3);
            jSONObject.put("needProcess", booleanExtra);
            jSONObject.put("syncQzone", booleanExtra2);
            jSONObject.put("fakeVid", stringExtra4);
            JSONObject jSONObject2 = new JSONObject();
            if (bundleExtra != null) {
                for (String str : bundleExtra.keySet()) {
                    jSONObject2.put(str, bundleExtra.getInt(str));
                }
            }
            jSONObject.put("encodeExtras", jSONObject2);
        } catch (JSONException e) {
            QLog.w(f98844a, 1, "convertVideoInfoToJson error", e);
        }
        return jSONObject;
    }

    @Override
    public void onWebEvent(String str, Bundle bundle) {
        if (bundle != null && bundle.containsKey("data")) {
            Bundle bundle2 = bundle.getBundle("data");
            if (bundle2 == null) {
                QLog.e(f98844a, 1, "call js function,bundle is empty");
            } else if (RemoteHandleConst.bt.equals(str) && !TextUtils.isEmpty(this.f98846c)) {
                String string = bundle2.getString(RemoteHandleConst.bv);
                int i = bundle2.getInt(RemoteHandleConst.bw, 0);
                int i2 = bundle2.getInt(RemoteHandleConst.bx, 0);
                String string2 = bundle2.getString(RemoteHandleConst.bu);
                String a2 = TextUtils.isEmpty(string) ? "" : QzoneDynamicAlbumPlugin.a(string, i, i2);
                JSONObject jSONObject = new JSONObject();
                try {
                    jSONObject.put("code", 0);
                    JSONObject jSONObject2 = new JSONObject();
                    jSONObject2.put("msg", "");
                    jSONObject2.put("base64", "data:image/jpg;base64," + a2);
                    jSONObject2.put("timestamp", string2);
                    jSONObject2.put("isFakeFeed", true);
                    jSONObject.put("data", jSONObject2);
                    this.f98823a.callJs(this.f98846c, jSONObject.toString());
                } catch (JSONException e) {
                    QLog.w(f98844a, 1, "topicUploadVideo fake feed  callback error", e);
                }
            }
        }
    }
}