APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:DroidCamX
版本号:6.11
包名称:com.dev47apps.droidcamx

MD5 校验值:254ed1e3048bfc7488132eab515957a9

反编译源代码说明

BMLfwsyqKU.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package com.dev47apps.droidcamx;

import android.content.Context;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import cd.dj;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.security.KeyStore;
import java.util.Arrays;
import java.util.LinkedList;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;

public class BMLfwsyqKU {

    public boolean f318mcZoNTjDX;

    public Context f319XznPeCSIAuY;

    public Handler f320XznPeCSIAuY;

    public com.dev47apps.droidcamx.xEgHObtapriRBML f321XznPeCSIAuY;

    public boolean f323XznPeCSIAuY = false;

    public GFdJxEgHObtapr f322XznPeCSIAuY = null;

    public class xEgHObtapriRBML {

        public int f324GFdJxEgHObtapr;

        public int f325mcZoNTjDX;

        public int f326XznPeCSIAuY;

        public Socket f327XznPeCSIAuY;

        public xEgHObtapriRBML(BMLfwsyqKU bMLfwsyqKU) {
        }
    }

    public class BMLfw {

        public int f328XznPeCSIAuY;

        public String f329XznPeCSIAuY;

        public BMLfw(BMLfwsyqKU bMLfwsyqKU, String str, int i) {
            this.f329XznPeCSIAuY = str;
            this.f328XznPeCSIAuY = i;
        }
    }

    public class GFdJxEgHObtapr extends Thread {

        public int f330mcZoNTjDX;

        public String f331mcZoNTjDX;

        public boolean f332mcZoNTjDX;

        public int f333XznPeCSIAuY;

        public XznPeCSIAuY f334XznPeCSIAuY;

        public String f336XznPeCSIAuY;

        public LinkedList<BMLfw> f337XznPeCSIAuY;

        public boolean f338XznPeCSIAuY;

        public byte[] f339XznPeCSIAuY;

        public String[] f340XznPeCSIAuY;

        public GFdJxEgHObtapr() {
        }

        @Override
        public void run() {
            DatagramSocket datagramSocket;
            String str;
            String str2;
            String str3;
            String str4;
            int indexOf;
            String str5;
            String str6;
            String str7;
            String str8;
            this.f337XznPeCSIAuY = null;
            this.f334XznPeCSIAuY = null;
            this.f339XznPeCSIAuY = new byte[600];
            ServerSocket m1890XznPeCSIAuY = m1890XznPeCSIAuY();
            if (m1890XznPeCSIAuY == null) {
                BMLfwsyqKU.this.f323XznPeCSIAuY = false;
            } else {
                if (!BMLfwsyqKU.this.f318mcZoNTjDX) {
                    this.f334XznPeCSIAuY = m1888XznPeCSIAuY();
                }
                com.dev47apps.droidcamx.BMLfw.m1771XznPeCSIAuY("Server start..");
            }
            while (BMLfwsyqKU.this.f323XznPeCSIAuY) {
                this.f340XznPeCSIAuY = null;
                if (this.f334XznPeCSIAuY != null) {
                    m1891XznPeCSIAuY();
                }
                try {
                    Socket accept = m1890XznPeCSIAuY.accept();
                    accept.setSoTimeout(5000);
                    accept.setKeepAlive(true);
                    accept.setTcpNoDelay(true);
                    try {
                        int read = accept.getInputStream().read(this.f339XznPeCSIAuY);
                        if (read < 0) {
                            m1894XznPeCSIAuY(accept);
                        } else {
                            byte[] bArr = this.f339XznPeCSIAuY;
                            if (read > bArr.length) {
                                read = bArr.length;
                            }
                            String str9 = new String(this.f339XznPeCSIAuY, 0, read);
                            if (str9.contains("CMD /v1/video") || str9.contains("COMMAND /videre")) {
                                xEgHObtapriRBML xeghobtaprirbml = new xEgHObtapriRBML(BMLfwsyqKU.this);
                                xeghobtaprirbml.f327XznPeCSIAuY = accept;
                                m1892XznPeCSIAuY(3, xeghobtaprirbml);
                            } else if (str9.contains("CMD /v2/video")) {
                                xEgHObtapriRBML xeghobtaprirbml2 = new xEgHObtapriRBML(BMLfwsyqKU.this);
                                int[] m1772XznPeCSIAuY = com.dev47apps.droidcamx.BMLfw.m1772XznPeCSIAuY(str9, 640, 480);
                                xeghobtaprirbml2.f326XznPeCSIAuY = m1772XznPeCSIAuY[0];
                                xeghobtaprirbml2.f325mcZoNTjDX = m1772XznPeCSIAuY[1];
                                xeghobtaprirbml2.f327XznPeCSIAuY = accept;
                                try {
                                    accept.setSendBufferSize(262144);
                                } catch (Exception e) {
                                    com.dev47apps.droidcamx.BMLfw.m1765mcZoNTjDX(e.toString());
                                }
                                if (str9.contains("video.4") || str9.contains("video.3")) {
                                    xeghobtaprirbml2.f324GFdJxEgHObtapr = 2;
                                    m1892XznPeCSIAuY(22, xeghobtaprirbml2);
                                } else {
                                    m1892XznPeCSIAuY(3, xeghobtaprirbml2);
                                }
                            } else {
                                if (str9.startsWith("CMD /v3/video")) {
                                    xEgHObtapriRBML xeghobtaprirbml3 = new xEgHObtapriRBML(BMLfwsyqKU.this);
                                    int[] m1772XznPeCSIAuY2 = com.dev47apps.droidcamx.BMLfw.m1772XznPeCSIAuY(str9, 640, 480);
                                    xeghobtaprirbml3.f326XznPeCSIAuY = m1772XznPeCSIAuY2[0];
                                    xeghobtaprirbml3.f325mcZoNTjDX = m1772XznPeCSIAuY2[1];
                                    xeghobtaprirbml3.f327XznPeCSIAuY = accept;
                                    if (str9.contains("/jpg/")) {
                                        xeghobtaprirbml3.f324GFdJxEgHObtapr = 2;
                                    } else if (str9.contains("/avc/")) {
                                        xeghobtaprirbml3.f324GFdJxEgHObtapr = 3;
                                    } else {
                                        com.dev47apps.droidcamx.BMLfw.m1765mcZoNTjDX("invalid request:");
                                        com.dev47apps.droidcamx.BMLfw.m1765mcZoNTjDX(str9);
                                        xeghobtaprirbml3.f324GFdJxEgHObtapr = 0;
                                    }
                                    if (xeghobtaprirbml3.f324GFdJxEgHObtapr > 0) {
                                        try {
                                            accept.setSendBufferSize(262144);
                                        } catch (Exception e2) {
                                            com.dev47apps.droidcamx.BMLfw.m1765mcZoNTjDX(e2.toString());
                                        }
                                        m1892XznPeCSIAuY(22, xeghobtaprirbml3);
                                    }
                                } else if (str9.contains("COMMAND /audire")) {
                                    m1892XznPeCSIAuY(2, accept);
                                } else if (str9.contains("CMD /v1/audio")) {
                                    m1892XznPeCSIAuY(17, accept);
                                } else if (str9.contains("CMD /v2/audio")) {
                                    m1892XznPeCSIAuY(26, accept);
                                } else if (str9.contains("GET /battery")) {
                                    BMLfwsyqKU.this.f320XznPeCSIAuY.sendEmptyMessage(24);
                                    int i = this.f330mcZoNTjDX;
                                    if (i > 0) {
                                        BMLfwsyqKU.m1884XznPeCSIAuY((String) null, (String) null, Integer.toString(i), accept);
                                    }
                                    m1894XznPeCSIAuY(accept);
                                } else if (str9.startsWith("GET /v") && (str9.startsWith("GET /v1/video") || str9.startsWith("GET /v2/video") || str9.startsWith("GET /v3/video") || str9.startsWith("GET /v4/video"))) {
                                    BMLfwsyqKU.this.f320XznPeCSIAuY.sendEmptyMessage(40);
                                    m1894XznPeCSIAuY(accept);
                                } else if (str9.startsWith("CMD /v")) {
                                    com.dev47apps.droidcamx.BMLfw.m1771XznPeCSIAuY("invalid request: " + str9);
                                    m1894XznPeCSIAuY(accept);
                                }
                                if (this.f338XznPeCSIAuY) {
                                    m1894XznPeCSIAuY(accept);
                                } else {
                                    String str10 = this.f336XznPeCSIAuY;
                                    String str11 = "text/css";
                                    String str12 = "busy.htm";
                                    if (str10 == null || str10.length() <= 0 || str9.contains(this.f336XznPeCSIAuY)) {
                                        if (str9.contains("GET / ")) {
                                            if (!BMLfwsyqKU.this.f321XznPeCSIAuY.m1714BMLfw()) {
                                                str = BMLfwsyqKU.this.f319XznPeCSIAuY.getPackageName().contains("droidcamx") ? "droidcamx.htm" : "droidcam.htm";
                                                str2 = str;
                                            }
                                            str2 = str12;
                                        } else {
                                            if (str9.contains("GET /override")) {
                                                BMLfwsyqKU.this.f320XznPeCSIAuY.sendEmptyMessage(5);
                                                try {
                                                    Thread.sleep(1024L);
                                                } catch (InterruptedException unused) {
                                                }
                                                this.f340XznPeCSIAuY = r0;
                                                String[] strArr = {"Location: /"};
                                                str4 = "302 Moved Temporarily";
                                            } else {
                                                if (str9.contains("GET /cam/1/set_exposure_lock")) {
                                                    BMLfwsyqKU.this.f320XznPeCSIAuY.obtainMessage(20, 1, 0, null).sendToTarget();
                                                } else if (str9.contains("GET /cam/1/unset_exposure_lock")) {
                                                    BMLfwsyqKU.this.f320XznPeCSIAuY.obtainMessage(20, 0, 0, null).sendToTarget();
                                                } else if (str9.contains("GET /cam/1/set_wb/")) {
                                                    int indexOf2 = str9.indexOf("set_wb/") + 7;
                                                    if (indexOf2 > 0 && (indexOf = str9.indexOf(" ", indexOf2)) > 0) {
                                                        BMLfwsyqKU.this.f320XznPeCSIAuY.obtainMessage(9, com.dev47apps.droidcamx.GFdJxEgHObtapr.m1794XznPeCSIAuY(str9.substring(indexOf2, indexOf)), 0, null).sendToTarget();
                                                    }
                                                } else if (str9.contains("GET /cam/1/led_toggle")) {
                                                    BMLfwsyqKU.this.f320XznPeCSIAuY.sendEmptyMessage(14);
                                                } else if (str9.contains("GET /cam/1/af")) {
                                                    BMLfwsyqKU.this.f320XznPeCSIAuY.sendEmptyMessage(13);
                                                } else if (str9.contains("GET /cam/1/zoomin")) {
                                                    BMLfwsyqKU.this.f320XznPeCSIAuY.sendEmptyMessage(11);
                                                } else if (str9.contains("GET /cam/1/zoomout")) {
                                                    BMLfwsyqKU.this.f320XznPeCSIAuY.sendEmptyMessage(12);
                                                } else {
                                                    if (str9.contains("GET /cam/1/takepic")) {
                                                        BMLfwsyqKU bMLfwsyqKU = BMLfwsyqKU.this;
                                                        if (bMLfwsyqKU.f321XznPeCSIAuY.f177XznPeCSIAuY) {
                                                            bMLfwsyqKU.f320XznPeCSIAuY.sendEmptyMessage(15);
                                                            str3 = "200 OK";
                                                        } else {
                                                            str4 = "515 Permissions Error";
                                                        }
                                                    } else if (str9.contains("GET /cam/1/frame.jpg")) {
                                                        BMLfwsyqKU.this.f321XznPeCSIAuY.m1731XznPeCSIAuY(accept);
                                                    } else if (str9.contains("GET /cam/1/fpslimit")) {
                                                        BMLfwsyqKU.this.f321XznPeCSIAuY.m1710xEgHObtapriRBML();
                                                        str3 = "200 OK";
                                                    } else if (str9.contains("GET /video") || str9.contains("GET /mjpegfeed")) {
                                                        if (BMLfwsyqKU.this.f321XznPeCSIAuY.m1714BMLfw()) {
                                                            if (str9.contains("force")) {
                                                                BMLfwsyqKU.this.f320XznPeCSIAuY.sendEmptyMessage(5);
                                                                try {
                                                                    Thread.sleep(1024L);
                                                                } catch (Exception unused2) {
                                                                }
                                                            }
                                                            if (str12 != null) {
                                                                xEgHObtapriRBML xeghobtaprirbml4 = new xEgHObtapriRBML(BMLfwsyqKU.this);
                                                                int[] m1772XznPeCSIAuY3 = com.dev47apps.droidcamx.BMLfw.m1772XznPeCSIAuY(str9, 640, 480);
                                                                xeghobtaprirbml4.f326XznPeCSIAuY = m1772XznPeCSIAuY3[0];
                                                                xeghobtaprirbml4.f325mcZoNTjDX = m1772XznPeCSIAuY3[1];
                                                                xeghobtaprirbml4.f327XznPeCSIAuY = accept;
                                                                m1892XznPeCSIAuY(6, xeghobtaprirbml4);
                                                            } else {
                                                                str2 = str12;
                                                            }
                                                        }
                                                        str12 = null;
                                                        if (str12 != null) {
                                                        }
                                                    } else {
                                                        if (str9.contains("GET /favicon.ico")) {
                                                            str2 = "favicon.ico";
                                                            str11 = "image/ico";
                                                        } else if (str9.contains("GET /fullscreen.htm")) {
                                                            str = "fullscreen.htm";
                                                            str2 = str;
                                                        } else {
                                                            if (str9.contains("GET /css/bootstrap.min.css")) {
                                                                str8 = "css/bootstrap.3.3.5.min.css";
                                                            } else if (str9.contains("GET /css/bootstrap-theme.min.css")) {
                                                                str8 = "css/bootstrap-theme.3.3.5.min.css";
                                                            } else {
                                                                if (str9.contains("GET /fonts/glyphicons-halflings-regular.woff2")) {
                                                                    str7 = "fonts/glyphicons-halflings-regular.woff2";
                                                                } else if (str9.contains("GET /fonts/glyphicons-halflings-regular.woff")) {
                                                                    str7 = "fonts/glyphicons-halflings-regular.woff";
                                                                } else if (str9.contains("GET /fonts/glyphicons-halflings-regular.ttf")) {
                                                                    str7 = "fonts/glyphicons-halflings-regular.ttf";
                                                                } else {
                                                                    if (str9.contains("GET /js/jquery.min.js")) {
                                                                        str6 = "js/jquery-3.4.1.min.js";
                                                                    } else if (str9.contains("GET /js/bootstrap.min.js")) {
                                                                        str6 = "js/bootstrap.3.3.5.min.js";
                                                                    } else if (str9.contains("GET /js/ie10-viewport-bug-workaround.js")) {
                                                                        str6 = "js/ie10-viewport-bug-workaround.js";
                                                                    } else {
                                                                        if (str9.contains("GET /ic_expand.png")) {
                                                                            str5 = "ic_expand.png";
                                                                        } else if (str9.contains("GET /vlc-example.png")) {
                                                                            str5 = "vlc-example.png";
                                                                        } else {
                                                                            str4 = "400 Bad Request";
                                                                        }
                                                                        str2 = str5;
                                                                        str11 = "image/png";
                                                                    }
                                                                    str2 = str6;
                                                                    str3 = null;
                                                                    str11 = "application/javascript";
                                                                }
                                                                str2 = str7;
                                                                str3 = null;
                                                                str11 = "application/octet-stream";
                                                            }
                                                            str2 = str8;
                                                        }
                                                        str3 = null;
                                                    }
                                                    str11 = null;
                                                    str2 = "empty";
                                                }
                                                str3 = null;
                                                str11 = null;
                                                str2 = "empty";
                                            }
                                            str3 = str4;
                                            str11 = null;
                                            str2 = "empty";
                                        }
                                        str3 = null;
                                        str11 = null;
                                    } else {
                                        this.f340XznPeCSIAuY = r0;
                                        String[] strArr2 = {"WWW-Authenticate: Basic realm=\"DroidCam\""};
                                        str2 = "auth.htm";
                                        str3 = "401 Not Authorized";
                                        str11 = null;
                                    }
                                    m1893XznPeCSIAuY(str2, str3, str11, this.f340XznPeCSIAuY, accept);
                                    m1894XznPeCSIAuY(accept);
                                }
                            }
                        }
                    } catch (Exception e3) {
                        m1892XznPeCSIAuY(0, "Read Error: " + e3.getMessage());
                        m1894XznPeCSIAuY(accept);
                    }
                } catch (Exception unused3) {
                }
            }
            if (m1890XznPeCSIAuY != null) {
                try {
                    m1890XznPeCSIAuY.close();
                } catch (Exception unused4) {
                }
            }
            XznPeCSIAuY xznPeCSIAuY = this.f334XznPeCSIAuY;
            if (xznPeCSIAuY == null || (datagramSocket = xznPeCSIAuY.f343XznPeCSIAuY) == null) {
                return;
            }
            datagramSocket.close();
        }

        public XznPeCSIAuY m1888XznPeCSIAuY() {
            XznPeCSIAuY xznPeCSIAuY = new XznPeCSIAuY(BMLfwsyqKU.this);
            try {
                DatagramSocket datagramSocket = new DatagramSocket(this.f333XznPeCSIAuY + 1);
                xznPeCSIAuY.f343XznPeCSIAuY = datagramSocket;
                datagramSocket.setSoTimeout(50);
                xznPeCSIAuY.f342XznPeCSIAuY = new DatagramPacket(this.f339XznPeCSIAuY, this.f339XznPeCSIAuY.length);
                return xznPeCSIAuY;
            } catch (Exception e) {
                com.dev47apps.droidcamx.BMLfw.m1765mcZoNTjDX("error creating UDP server");
                com.dev47apps.droidcamx.BMLfw.m1765mcZoNTjDX(e.toString());
                return null;
            }
        }

        public final String m1889XznPeCSIAuY(StringBuilder sb) {
            if (this.f337XznPeCSIAuY == null) {
                LinkedList<BMLfw> linkedList = new LinkedList<>();
                this.f337XznPeCSIAuY = linkedList;
                linkedList.add(new BMLfw(BMLfwsyqKU.this, "#web_refresh_hint#", C0100riRBMLfwsyq.web_refresh_hint));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#web_req_sent#", C0100riRBMLfwsyq.web_req_sent));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#web_limit_fps#", C0100riRBMLfwsyq.web_limit_fps));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#web_save_photo_here#", C0100riRBMLfwsyq.web_save_photo_here));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#web_save_photo_there#", C0100riRBMLfwsyq.web_save_photo_there));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#web_dir_link_hint_1#", C0100riRBMLfwsyq.web_dir_link_hint_1));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#web_dir_link_hint_2#", C0100riRBMLfwsyq.web_dir_link_hint_2));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#fullscreen#", C0100riRBMLfwsyq.fullscreen));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#autofocus#", C0100riRBMLfwsyq.autofocus));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#toggle_led#", C0100riRBMLfwsyq.toggle_led));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#zoom_in#", C0100riRBMLfwsyq.zoom_in));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#zoom_out#", C0100riRBMLfwsyq.zoom_out));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#size#", C0100riRBMLfwsyq.size));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#help#", C0100riRBMLfwsyq.help));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#web_busy_hint_1#", C0100riRBMLfwsyq.web_busy_hint_1));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#web_busy_hint_2#", C0100riRBMLfwsyq.web_busy_hint_2));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#wb_auto#", C0100riRBMLfwsyq.opt_wb_auto));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#wb_incandescent#", C0100riRBMLfwsyq.opt_wb_incandescent));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#wb_fluorescent_warm#", C0100riRBMLfwsyq.opt_wb_fluorescent_warm));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#wb_twilight#", C0100riRBMLfwsyq.opt_wb_twilight));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#wb_fluorescent#", C0100riRBMLfwsyq.opt_wb_fluorescent));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#wb_daylight#", C0100riRBMLfwsyq.opt_wb_daylight));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#wb_daylight_cloudy#", C0100riRBMLfwsyq.opt_wb_daylight_cloudy));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#wb_shade#", C0100riRBMLfwsyq.opt_wb_shade));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#exposure_lock#", C0100riRBMLfwsyq.opt_exposure));
                this.f337XznPeCSIAuY.add(new BMLfw(BMLfwsyqKU.this, "#white_balance#", C0100riRBMLfwsyq.opt_wb));
            }
            int i = 5000;
            do {
                boolean z = false;
                for (int i2 = 0; i2 < this.f337XznPeCSIAuY.size(); i2++) {
                    BMLfw bMLfw = this.f337XznPeCSIAuY.get(i2);
                    int indexOf = sb.indexOf(bMLfw.f329XznPeCSIAuY);
                    while (indexOf > -1 && i - 1 > 0) {
                        sb.replace(indexOf, bMLfw.f329XznPeCSIAuY.length() + indexOf, BMLfwsyqKU.this.f319XznPeCSIAuY.getString(bMLfw.f328XznPeCSIAuY));
                        indexOf = sb.indexOf(bMLfw.f329XznPeCSIAuY);
                        z = true;
                    }
                }
                if (!z) {
                    break;
                }
                i--;
            } while (i > 0);
            return sb.toString();
        }

        public ServerSocket m1890XznPeCSIAuY() {
            ServerSocket serverSocket;
            try {
                InetAddress byName = InetAddress.getByName(BMLfwsyqKU.this.f318mcZoNTjDX ? "127.0.0.1" : "0.0.0.0");
                if (this.f332mcZoNTjDX) {
                    SSLContext sSLContext = SSLContext.getInstance("TLSv1.2");
                    com.dev47apps.droidcamx.BMLfw.m1771XznPeCSIAuY("TLS Server");
                    KeyStore keyStore = KeyStore.getInstance("PKCS12");
                    keyStore.load((this.f331mcZoNTjDX == null || this.f331mcZoNTjDX.equals("")) ? BMLfwsyqKU.this.f319XznPeCSIAuY.getAssets().open("server.p12") : BMLfwsyqKU.this.f319XznPeCSIAuY.getContentResolver().openInputStream(Uri.parse(this.f331mcZoNTjDX)), "3f:b5:c4:2a:81".toCharArray());
                    KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
                    keyManagerFactory.init(keyStore, "3f:b5:c4:2a:81".toCharArray());
                    sSLContext.init(keyManagerFactory.getKeyManagers(), null, null);
                    serverSocket = sSLContext.getServerSocketFactory().createServerSocket(this.f333XznPeCSIAuY, 8, byName);
                } else {
                    serverSocket = new ServerSocket(this.f333XznPeCSIAuY, 8, byName);
                }
                serverSocket.setSoTimeout(50);
                return serverSocket;
            } catch (Exception e) {
                com.dev47apps.droidcamx.BMLfw.m1765mcZoNTjDX("error creating server");
                com.dev47apps.droidcamx.BMLfw.m1765mcZoNTjDX(e.toString());
                m1892XznPeCSIAuY(0, "Server Error: " + e.getMessage());
                return null;
            }
        }

        public void m1891XznPeCSIAuY() {
            try {
                this.f334XznPeCSIAuY.f343XznPeCSIAuY.receive(this.f334XznPeCSIAuY.f342XznPeCSIAuY);
                if (this.f334XznPeCSIAuY.f342XznPeCSIAuY.getLength() < 8) {
                    return;
                }
                byte[] bArr = this.f339XznPeCSIAuY;
                if (bArr[0] == 67 && bArr[1] == 77 && bArr[2] == 68 && bArr[5] == 118) {
                    if (bArr[6] == 49 && bArr[8] == 97 && bArr[9] == 117 && bArr[10] == 100) {
                        m1892XznPeCSIAuY(16, this.f334XznPeCSIAuY);
                    } else {
                        byte[] bArr2 = this.f339XznPeCSIAuY;
                        if (bArr2[6] == 50 && bArr2[8] == 97 && bArr2[9] == 117 && bArr2[10] == 100) {
                            m1892XznPeCSIAuY(27, this.f334XznPeCSIAuY);
                        } else {
                            byte[] bArr3 = this.f339XznPeCSIAuY;
                            if (bArr3[8] == 115 && bArr3[9] == 116 && bArr3[10] == 111) {
                                BMLfwsyqKU.this.f320XznPeCSIAuY.sendEmptyMessage(5);
                            }
                        }
                    }
                }
                Arrays.fill(this.f339XznPeCSIAuY, 0, 32, (byte) 0);
            } catch (Exception unused) {
            }
        }

        public void m1892XznPeCSIAuY(int i, Object obj) {
            Message obtain = Message.obtain();
            obtain.what = i;
            obtain.obj = obj;
            BMLfwsyqKU.this.f320XznPeCSIAuY.sendMessage(obtain);
        }

        public void m1893XznPeCSIAuY(String str, String str2, String str3, String[] strArr, Socket socket) {
            InputStream inputStream;
            int read;
            try {
                inputStream = BMLfwsyqKU.this.f319XznPeCSIAuY.getAssets().open("www/" + str);
            } catch (Exception unused) {
                inputStream = null;
                com.dev47apps.droidcamx.BMLfw.m1765mcZoNTjDX("File not found: www/" + str);
            }
            StringBuilder sb = new StringBuilder();
            sb.append("HTTP/1.1 ");
            if (str2 != null) {
                sb.append(str2);
            } else if (inputStream != null) {
                sb.append("200 OK");
            } else {
                sb.append("404 Not Found");
            }
            if (strArr != null) {
                for (String str4 : strArr) {
                    sb.append("\r\n");
                    sb.append(str4);
                }
            }
            sb.append("\r\nTransfer-Encoding: chunked\r\nConnection: close\r\nContent-Type: ");
            if (str3 != null) {
                sb.append(str3);
            } else {
                sb.append("text/html");
            }
            sb.append("\r\n\r\n");
            try {
                OutputStream outputStream = socket.getOutputStream();
                outputStream.write(sb.toString().getBytes());
                StringBuilder sb2 = new StringBuilder();
                boolean endsWith = str.endsWith(".htm");
                while (inputStream != null && inputStream.available() > 0 && (read = inputStream.read(this.f339XznPeCSIAuY, 0, this.f339XznPeCSIAuY.length - 2)) > 0) {
                    if (endsWith) {
                        sb2.append(new String(this.f339XznPeCSIAuY, 0, read));
                    } else {
                        outputStream.write(String.format("%x\r\n", Integer.valueOf(read)).getBytes());
                        int i = read + 1;
                        this.f339XznPeCSIAuY[read] = 13;
                        this.f339XznPeCSIAuY[i] = 10;
                        outputStream.write(this.f339XznPeCSIAuY, 0, i + 1);
                    }
                }
                if (endsWith) {
                    byte[] bytes = m1889XznPeCSIAuY(sb2).getBytes();
                    outputStream.write(String.format("%x\r\n", Integer.valueOf(bytes.length)).getBytes());
                    outputStream.write(bytes);
                    this.f339XznPeCSIAuY[0] = 13;
                    this.f339XznPeCSIAuY[1] = 10;
                    outputStream.write(this.f339XznPeCSIAuY, 0, 2);
                }
                this.f339XznPeCSIAuY[0] = 48;
                this.f339XznPeCSIAuY[1] = 13;
                this.f339XznPeCSIAuY[2] = 10;
                this.f339XznPeCSIAuY[3] = 13;
                this.f339XznPeCSIAuY[4] = 10;
                outputStream.write(this.f339XznPeCSIAuY, 0, 5);
            } catch (Exception e) {
                m1892XznPeCSIAuY(0, "Error: " + e.toString());
            }
        }

        public void m1894XznPeCSIAuY(Socket socket) {
            try {
                socket.close();
            } catch (Exception unused) {
            }
        }
    }

    public static class mcZoNTjDX extends Thread {

        public Socket f341XznPeCSIAuY;

        @Override
        public void run() {
            try {
                this.f341XznPeCSIAuY.close();
            } catch (Exception unused) {
            }
            this.f341XznPeCSIAuY = null;
        }
    }

    public class XznPeCSIAuY {

        public DatagramPacket f342XznPeCSIAuY;

        public DatagramSocket f343XznPeCSIAuY;

        public XznPeCSIAuY(BMLfwsyqKU bMLfwsyqKU) {
        }
    }

    public BMLfwsyqKU(Context context, Handler handler, boolean z) {
        this.f319XznPeCSIAuY = context;
        this.f320XznPeCSIAuY = handler;
        this.f318mcZoNTjDX = z;
    }

    public static void m1884XznPeCSIAuY(String str, String str2, String str3, Socket socket) {
        StringBuilder sb = new StringBuilder();
        sb.append("HTTP/1.1 ");
        if (str != null) {
            sb.append(str);
        } else if (str3 != null) {
            sb.append("200 OK");
        } else {
            sb.append("404 Not Found");
        }
        sb.append("\r\nConnection: close\r\nContent-Type: ");
        if (str2 != null) {
            sb.append(str2);
        } else {
            sb.append(dj.d);
        }
        sb.append("\r\nContent-length: ");
        if (str3 != null) {
            sb.append(str3.length());
        } else {
            sb.append(0);
        }
        sb.append("\r\n\r\n");
        try {
            OutputStream outputStream = socket.getOutputStream();
            outputStream.write(sb.toString().getBytes());
            if (str3 != null) {
                outputStream.write(str3.getBytes());
            }
        } catch (Exception unused) {
        }
    }

    public static void m1885XznPeCSIAuY(Socket socket) {
        mcZoNTjDX mczontjdx = new mcZoNTjDX();
        mczontjdx.f341XznPeCSIAuY = socket;
        mczontjdx.start();
    }

    public void m1886XznPeCSIAuY() {
        this.f323XznPeCSIAuY = false;
        GFdJxEgHObtapr gFdJxEgHObtapr = this.f322XznPeCSIAuY;
        if (gFdJxEgHObtapr == null || !gFdJxEgHObtapr.isAlive()) {
            return;
        }
        this.f322XznPeCSIAuY.interrupt();
    }

    public void m1887XznPeCSIAuY(int i, boolean z, String str, String str2) {
        if (this.f323XznPeCSIAuY) {
            return;
        }
        GFdJxEgHObtapr gFdJxEgHObtapr = new GFdJxEgHObtapr();
        this.f322XznPeCSIAuY = gFdJxEgHObtapr;
        gFdJxEgHObtapr.f332mcZoNTjDX = z;
        gFdJxEgHObtapr.f338XznPeCSIAuY = false;
        gFdJxEgHObtapr.f333XznPeCSIAuY = i;
        gFdJxEgHObtapr.f330mcZoNTjDX = 0;
        gFdJxEgHObtapr.f336XznPeCSIAuY = str;
        gFdJxEgHObtapr.f331mcZoNTjDX = str2;
        gFdJxEgHObtapr.start();
        this.f323XznPeCSIAuY = true;
    }
}