鸠摩搜书官方正版 v1.7版本的 MD5 值为:01c9a20d2c415de3233d7f691829edf5

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


package net.youmi.android;

import android.content.Context;
import android.os.AsyncTask;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

public final class cz extends AsyncTask implements dj {

    private Context f564a;
    private DefaultHttpClient b;
    private da c;
    private long d;
    private long e;
    private String f;
    private String g;
    private boolean h;
    private String i;
    private String j;
    private long k;
    private long l;

    public cz(Context context, da daVar, ce ceVar) {
        this.h = false;
        this.f564a = context;
        this.c = daVar;
        if (ceVar == null) {
            this.h = false;
            return;
        }
        this.h = ceVar.s();
        ceVar.v();
        this.k = ceVar.I();
        this.l = ceVar.H();
        this.f = ceVar.g();
        this.g = ceVar.h();
        this.i = ceVar.o();
        this.j = ceVar.k();
    }

    private String a(String str, String str2) {
        InputStream inputStream;
        OutputStream outputStream;
        Throwable th;
        HttpGet httpGet;
        HttpResponse execute;
        HttpEntity entity;
        this.d = System.currentTimeMillis();
        ?? e = 0;
        e = 0;
        e = 0;
        e = 0;
        e = 0;
        ?? r0 = 0;
        OutputStream outputStream2 = null;
        try {
            try {
                if (this.b == null) {
                    this.b = aq.a(this.f564a, this);
                }
                httpGet = new HttpGet(str);
                httpGet.setHeader("Referer", "http://sdk.youmi.net/?p=3&app=" + f.a(this.f564a) + "&chn=" + f.e(this.f564a));
                execute = this.b.execute(httpGet);
            } catch (Throwable th2) {
                inputStream = null;
                outputStream = null;
                th = th2;
            }
        } catch (Exception e2) {
        }
        if (execute == null || (entity = execute.getEntity()) == null) {
            inputStream = null;
        } else {
            long contentLength = entity.getContentLength();
            r0 = this.f564a.openFileOutput(str2, 1);
            try {
                if (r0 == 0) {
                    httpGet.abort();
                    if (r0 != 0) {
                        try {
                            r0.close();
                        } catch (Exception e3) {
                        }
                    }
                    try {
                        if (this.b != null) {
                            this.b.getConnectionManager().shutdown();
                        }
                    } catch (Exception e4) {
                    }
                    r0 = 0;
                } else {
                    inputStream = entity.getContent();
                    outputStream2 = r0;
                    if (inputStream != null) {
                        try {
                            try {
                                byte[] bArr = new byte[1024];
                                int i = 0;
                                long j = 0;
                                while (true) {
                                    int read = inputStream.read(bArr);
                                    if (read <= 0) {
                                        break;
                                    }
                                    r0.write(bArr, 0, read);
                                    j += read;
                                    i++;
                                    if (i % 10 == 0) {
                                        if (contentLength > 0) {
                                            try {
                                                publishProgress(Integer.valueOf((int) ((100 * j) / contentLength)));
                                            } catch (Exception e5) {
                                            }
                                        } else {
                                            publishProgress(50);
                                        }
                                    }
                                }
                                int i2 = (j > 0L ? 1 : (j == 0L ? 0 : -1));
                                outputStream2 = r0;
                                e = i2;
                                if (i2 > 0) {
                                    try {
                                        r0.close();
                                        outputStream = null;
                                    } catch (Exception e6) {
                                        outputStream = r0;
                                    }
                                    try {
                                        File fileStreamPath = this.f564a.getFileStreamPath(str2);
                                        if (fileStreamPath == null || !fileStreamPath.exists()) {
                                            outputStream2 = outputStream;
                                            e = outputStream;
                                        } else {
                                            r0 = fileStreamPath.getPath();
                                            if (outputStream != null) {
                                                try {
                                                    outputStream.close();
                                                } catch (Exception e7) {
                                                }
                                            }
                                            if (inputStream != null) {
                                                try {
                                                    inputStream.close();
                                                } catch (Exception e8) {
                                                }
                                            }
                                            try {
                                                e = this.b;
                                                if (e != 0) {
                                                    e = this.b.getConnectionManager();
                                                    e.shutdown();
                                                }
                                            } catch (Exception e9) {
                                                e = e9;
                                            }
                                        }
                                    } catch (Exception e10) {
                                        r0 = outputStream;
                                        e = inputStream;
                                        if (r0 != 0) {
                                            try {
                                                r0.close();
                                            } catch (Exception e11) {
                                            }
                                        }
                                        if (e != 0) {
                                            try {
                                                e.close();
                                            } catch (Exception e12) {
                                            }
                                        }
                                        try {
                                            if (this.b != null) {
                                                this.b.getConnectionManager().shutdown();
                                            }
                                        } catch (Exception e13) {
                                        }
                                        r0 = 0;
                                        return r0;
                                    } catch (Throwable th3) {
                                        th = th3;
                                        if (outputStream != null) {
                                            try {
                                                outputStream.close();
                                            } catch (Exception e14) {
                                            }
                                        }
                                        if (inputStream != null) {
                                            try {
                                                inputStream.close();
                                            } catch (Exception e15) {
                                            }
                                        }
                                        try {
                                            if (this.b == null) {
                                                throw th;
                                            }
                                            this.b.getConnectionManager().shutdown();
                                            throw th;
                                        } catch (Exception e16) {
                                            throw th;
                                        }
                                    }
                                }
                            } catch (Exception e17) {
                                e = inputStream;
                            }
                        } catch (Throwable th4) {
                            outputStream = r0;
                            th = th4;
                        }
                    }
                }
                return r0;
            } catch (Throwable th5) {
                inputStream = e;
                outputStream = r0;
                th = th5;
            }
        }
        if (outputStream2 != null) {
            try {
                outputStream2.close();
            } catch (Exception e18) {
            }
        }
        if (inputStream != null) {
            try {
                inputStream.close();
            } catch (Exception e19) {
            }
        }
        if (this.b != null) {
            this.b.getConnectionManager().shutdown();
        }
        r0 = 0;
        return r0;
    }

    private static boolean a(InputStream inputStream, OutputStream outputStream) {
        if (inputStream == null || outputStream == null) {
            return false;
        }
        try {
            byte[] bArr = new byte[1024];
            while (true) {
                int read = inputStream.read(bArr);
                if (read <= 0) {
                    return true;
                }
                outputStream.write(bArr, 0, read);
            }
        } catch (Exception e) {
            return false;
        }
    }

    private static boolean a(HttpResponse httpResponse, File file) {
        InputStream inputStream;
        FileOutputStream fileOutputStream;
        FileOutputStream fileOutputStream2 = null;
        fileOutputStream2 = null;
        fileOutputStream2 = null;
        r1 = null;
        FileOutputStream fileOutputStream3 = null;
        InputStream inputStream2 = null;
        try {
            HttpEntity entity = httpResponse.getEntity();
            if (entity == null || file == null) {
                inputStream = null;
            } else {
                inputStream = entity.getContent();
                if (inputStream != null) {
                    try {
                        try {
                            fileOutputStream = new FileOutputStream(file);
                            try {
                                try {
                                    if (a(inputStream, fileOutputStream)) {
                                        try {
                                            fileOutputStream.close();
                                        } catch (Exception e) {
                                            fileOutputStream2 = fileOutputStream;
                                        }
                                        try {
                                            boolean exists = file.exists();
                                            if (fileOutputStream2 != null) {
                                                try {
                                                    fileOutputStream2.close();
                                                } catch (Exception e2) {
                                                }
                                            }
                                            if (inputStream == null) {
                                                return exists;
                                            }
                                            try {
                                                inputStream.close();
                                                return exists;
                                            } catch (Exception e3) {
                                                return exists;
                                            }
                                        } catch (Exception e4) {
                                            fileOutputStream = fileOutputStream2;
                                            inputStream2 = inputStream;
                                            if (fileOutputStream != null) {
                                                try {
                                                    fileOutputStream.close();
                                                } catch (Exception e5) {
                                                }
                                            }
                                            if (inputStream2 != null) {
                                                try {
                                                    inputStream2.close();
                                                } catch (Exception e6) {
                                                }
                                            }
                                            return false;
                                        }
                                    }
                                    fileOutputStream3 = fileOutputStream;
                                } catch (Throwable th) {
                                    fileOutputStream2 = fileOutputStream;
                                    th = th;
                                    if (fileOutputStream2 != null) {
                                        try {
                                            fileOutputStream2.close();
                                        } catch (Exception e7) {
                                        }
                                    }
                                    if (inputStream == null) {
                                        throw th;
                                    }
                                    try {
                                        inputStream.close();
                                        throw th;
                                    } catch (Exception e8) {
                                        throw th;
                                    }
                                }
                            } catch (Exception e9) {
                                inputStream2 = inputStream;
                            }
                        } catch (Exception e10) {
                            fileOutputStream = null;
                            inputStream2 = inputStream;
                        }
                    } catch (Throwable th2) {
                        th = th2;
                    }
                }
            }
            if (fileOutputStream3 != null) {
                try {
                    fileOutputStream3.close();
                } catch (Exception e11) {
                }
            }
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (Exception e12) {
                }
            }
        } catch (Exception e13) {
            fileOutputStream = null;
        } catch (Throwable th3) {
            th = th3;
            inputStream = null;
        }
        return false;
    }

    private String[] a(String[] strArr) {
        HttpGet httpGet;
        HttpGet httpGet2;
        String str;
        HttpResponse execute;
        long j;
        String value;
        if (strArr == null) {
            try {
                if (this.b != null) {
                    this.b.getConnectionManager().shutdown();
                }
            } catch (Exception e) {
            }
            return null;
        }
        try {
            try {
                if (strArr.length > 0) {
                    ArrayList arrayList = new ArrayList(strArr.length);
                    for (int i = 0; i < strArr.length; i++) {
                        try {
                            str = strArr[i];
                        } catch (Exception e2) {
                            httpGet2 = null;
                        } catch (Throwable th) {
                            th = th;
                            httpGet = null;
                        }
                        if (str != null) {
                            String trim = str.trim();
                            if (trim.length() > 0) {
                                trim.length();
                                if (this.b == null) {
                                    this.b = aq.a(this.f564a, this);
                                }
                                httpGet2 = new HttpGet(trim);
                                try {
                                    try {
                                        httpGet2.setHeader("Referer", "http://sdk.youmi.net/?p=3&app=" + f.a(this.f564a) + "&chn=" + f.e(this.f564a));
                                        execute = this.b.execute(httpGet2);
                                    } catch (Throwable th2) {
                                        httpGet = httpGet2;
                                        th = th2;
                                        if (httpGet != null) {
                                            try {
                                                httpGet.abort();
                                            } catch (Exception e3) {
                                            }
                                        }
                                        try {
                                            publishProgress(Integer.valueOf(((i + 1) * 100) / strArr.length));
                                            throw th;
                                        } catch (Exception e4) {
                                            throw th;
                                        }
                                    }
                                } catch (Exception e5) {
                                    if (httpGet2 != null) {
                                        try {
                                            httpGet2.abort();
                                        } catch (Exception e6) {
                                        }
                                    }
                                    try {
                                        publishProgress(Integer.valueOf(((i + 1) * 100) / strArr.length));
                                    } catch (Exception e7) {
                                    }
                                }
                                if (execute != null) {
                                    try {
                                        value = execute.getLastHeader("Last-Modified").getValue();
                                    } catch (Exception e8) {
                                    }
                                    if (value != null) {
                                        String trim2 = value.trim();
                                        if (trim2.length() > 0) {
                                            j = new Date(trim2).getTime();
                                            File c = aj.d().c(trim);
                                            if (j > 0) {
                                                if (c.exists()) {
                                                    arrayList.add(c.getPath());
                                                } else if (a(execute, c)) {
                                                    arrayList.add(c.getPath());
                                                }
                                            } else if (c.exists()) {
                                                if (c.lastModified() == j) {
                                                    arrayList.add(c.getPath());
                                                    httpGet2.abort();
                                                    httpGet2 = null;
                                                } else {
                                                    try {
                                                        c.deleteOnExit();
                                                    } catch (Exception e9) {
                                                    }
                                                    if (a(execute, c)) {
                                                        try {
                                                            c.setLastModified(j);
                                                        } catch (Exception e10) {
                                                        }
                                                        arrayList.add(c.getPath());
                                                    }
                                                }
                                            } else if (a(execute, c)) {
                                                try {
                                                    c.setLastModified(j);
                                                } catch (Exception e11) {
                                                }
                                                arrayList.add(c.getPath());
                                            }
                                            if (httpGet2 != null) {
                                                try {
                                                    httpGet2.abort();
                                                } catch (Exception e12) {
                                                }
                                            }
                                            publishProgress(Integer.valueOf(((i + 1) * 100) / strArr.length));
                                        }
                                    }
                                    j = 0;
                                    File c2 = aj.d().c(trim);
                                    if (j > 0) {
                                    }
                                    if (httpGet2 != null) {
                                    }
                                    publishProgress(Integer.valueOf(((i + 1) * 100) / strArr.length));
                                }
                                if (httpGet2 != null) {
                                    try {
                                        httpGet2.abort();
                                    } catch (Exception e13) {
                                    }
                                }
                                publishProgress(Integer.valueOf(((i + 1) * 100) / strArr.length));
                            }
                        }
                        httpGet2 = null;
                        if (httpGet2 != null) {
                        }
                        publishProgress(Integer.valueOf(((i + 1) * 100) / strArr.length));
                    }
                    if (arrayList.size() > 0) {
                        String[] strArr2 = new String[arrayList.size()];
                        for (int i2 = 0; i2 < arrayList.size(); i2++) {
                            strArr2[i2] = (String) arrayList.get(i2);
                        }
                        try {
                            if (this.b != null) {
                                this.b.getConnectionManager().shutdown();
                            }
                        } catch (Exception e14) {
                        }
                        return strArr2;
                    }
                }
                try {
                    if (this.b != null) {
                        this.b.getConnectionManager().shutdown();
                    }
                } catch (Exception e15) {
                }
            } catch (Throwable th3) {
                try {
                    if (this.b != null) {
                        this.b.getConnectionManager().shutdown();
                    }
                } catch (Exception e16) {
                }
                throw th3;
            }
        } catch (Exception e17) {
            try {
                if (this.b != null) {
                    this.b.getConnectionManager().shutdown();
                }
            } catch (Exception e18) {
            }
        }
        return null;
    }

    @Override
    public String[] doInBackground(String[]... strArr) {
        String[] strArr2;
        String[] strArr3;
        File file;
        ?? e = 0;
        e = 0;
        e = 0;
        e = 0;
        try {
            try {
                publishProgress(1);
            } catch (Throwable th) {
                try {
                    if (this.b != null) {
                        this.b.getConnectionManager().shutdown();
                    }
                } catch (Exception e2) {
                }
                throw th;
            }
        } catch (Exception e3) {
            try {
                if (this.b != null) {
                    this.b.getConnectionManager().shutdown();
                }
            } catch (Exception e4) {
            }
        }
        if (strArr != null && strArr.length > 0 && (strArr3 = strArr[0]) != null && strArr3.length > 0) {
            if (ba.a(this.f564a)) {
                strArr2 = a(strArr3);
                try {
                    e = this.b;
                    if (e != 0) {
                        e = this.b.getConnectionManager();
                        e.shutdown();
                    }
                } catch (Exception e5) {
                    e = e5;
                }
            } else {
                String str = strArr3[0];
                if (str != null) {
                    String trim = str.trim();
                    if (trim.length() > 0) {
                        String b = l.b(trim);
                        try {
                            file = this.f564a.getFileStreamPath(b);
                        } catch (Exception e6) {
                            file = null;
                        }
                        if (file == null || !file.exists()) {
                            String a2 = a(trim, b);
                            if (a2 != null) {
                                strArr2 = new String[]{a2};
                                try {
                                    e = this.b;
                                    if (e != 0) {
                                        e = this.b.getConnectionManager();
                                        e.shutdown();
                                    }
                                } catch (Exception e7) {
                                    e = e7;
                                }
                            }
                        } else {
                            strArr2 = new String[]{file.getPath()};
                            try {
                                e = this.b;
                                if (e != 0) {
                                    e = this.b.getConnectionManager();
                                    e.shutdown();
                                }
                            } catch (Exception e8) {
                                e = e8;
                            }
                        }
                    }
                }
            }
            return strArr2;
        }
        if (this.b != null) {
            this.b.getConnectionManager().shutdown();
        }
        strArr2 = e;
        return strArr2;
    }

    public final long a() {
        return this.e - this.d;
    }

    @Override
    public final void a(String str) {
    }

    public final boolean b() {
        return this.h;
    }

    public final long c() {
        return this.k;
    }

    public final long d() {
        return this.d - this.l;
    }

    public final String e() {
        return this.f;
    }

    public final String f() {
        return this.g;
    }

    public final String g() {
        return this.i;
    }

    public final String h() {
        return this.j;
    }

    @Override
    protected final void onPostExecute(java.lang.Object r3) {
        throw new UnsupportedOperationException("Method not decompiled: net.youmi.android.cz.onPostExecute(java.lang.Object):void");
    }

    @Override
    protected final void onProgressUpdate(Object... objArr) {
        Integer[] numArr = (Integer[]) objArr;
        super.onProgressUpdate(numArr);
        try {
            if (this.c == null || numArr == null || numArr.length <= 0) {
                return;
            }
            this.c.b(numArr[0].intValue());
        } catch (Exception e) {
        }
    }
}