baiduad测试 v0.0.0版本的 MD5 值为:ef50fc8b78044be49b08cff701993fe5

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


package com.uzmap.pkg.uzkit;

import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.text.format.Formatter;
import com.baidu.mobads.sdk.api.IAdInterListener;
import com.deepe.c.a.j;
import com.deepe.c.c.t;
import com.deepe.c.i.d;
import com.deepe.c.i.g;
import com.deepe.d.a;
import com.uzmap.pkg.b.e.c;
import com.uzmap.pkg.uzapp.DataProvider;
import com.uzmap.pkg.uzcore.UZCoreUtil;
import com.uzmap.pkg.uzcore.e;
import com.uzmap.pkg.uzcore.x;
import com.uzmap.pkg.uzkit.data.UZWidgetInfo;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.json.JSONException;
import org.json.JSONObject;
public class UZUtility {
    public static boolean SDCardOnWork() {
        return j.b().equals("mounted");
    }

    public static boolean assetFileExists(String str) {
        return g.k(str);
    }

    public static String bitmapToBase64(Bitmap bitmap) {
        return t.a(bitmap);
    }

    public static String bitmapToBase64(String str) {
        try {
            return t.a(g.a(str));
        } catch (Exception unused) {
            a.e("UZUtility.bitmapToBase64: " + str + " Exception!");
            return "data:image/jpeg;base64,";
        }
    }

    private static int computeInitialSampleSize(BitmapFactory.Options options, int i, int i2) {
        int ceil;
        int min;
        double d = options.outWidth;
        double d2 = options.outHeight;
        if (i2 < 0) {
            ceil = 1;
        } else {
            Double.isNaN(d);
            Double.isNaN(d2);
            double d3 = i2;
            Double.isNaN(d3);
            ceil = (int) Math.ceil(Math.sqrt((d * d2) / d3));
        }
        if (i < 0) {
            min = 128;
        } else {
            double d4 = i;
            Double.isNaN(d);
            Double.isNaN(d4);
            double floor = Math.floor(d / d4);
            Double.isNaN(d2);
            Double.isNaN(d4);
            min = (int) Math.min(floor, Math.floor(d2 / d4));
        }
        if (min < ceil) {
            return ceil;
        }
        if (i2 >= 0 || i >= 0) {
            return i < 0 ? ceil : min;
        }
        return 1;
    }

    public static int computeSampleSize(BitmapFactory.Options options, int i, int i2) {
        int computeInitialSampleSize = computeInitialSampleSize(options, i, i2);
        if (computeInitialSampleSize <= 8) {
            int i3 = 1;
            while (i3 < computeInitialSampleSize) {
                i3 <<= 1;
            }
            return i3;
        }
        return ((computeInitialSampleSize + 7) / 8) * 8;
    }

    public static int dipToPix(int i) {
        return UZCoreUtil.dipToPix(i);
    }

    public static String formatFileSize(long j) {
        return Formatter.formatFileSize(e.a().b(), j);
    }

    public static int getAppVersionCode() {
        return UZCoreUtil.getAppVersionCode();
    }

    public static String getAppVersionName() {
        return UZCoreUtil.getAppVersionName();
    }

    public static Context getBaseContext() {
        return e.a().b();
    }

    public static String getCameraStoragePath() {
        return j.b((String) null);
    }

    public static String getCameraStoragePath(String str) {
        return j.b(str);
    }

    public static String getDefaultUseragent() {
        return UZCoreUtil.getDefaultUserAgent();
    }

    public static String getDeviceId() {
        return UZCoreUtil.getDeviceId();
    }

    public static String getExternaDownloadDir() {
        return j.e();
    }

    @Deprecated
    public static String getExternaStoragePath() {
        return j.d();
    }

    public static String getExternaStoragePath(Context context) {
        return UZCoreUtil.getExternaStoragePath(context);
    }

    public static String getExternalCacheDir() {
        return j.c(e.a().b());
    }

    public static Bitmap getLocalImage(String str) {
        return c.a(str);
    }

    public static Uri getUriForFile(Context context, File file) {
        return DataProvider.a(context, file);
    }

    public static InputStream guessInputStream(String str) throws IOException {
        if (d.a((CharSequence) str)) {
            return null;
        }
        return g.c(str);
    }

    public static int guessVideoDuration(String str) {
        int i = 0;
        if (d.a((CharSequence) str)) {
            return 0;
        }
        Uri parse = Uri.parse(str);
        String scheme = parse.getScheme();
        Context b = e.a().b();
        if (IAdInterListener.AdProdType.PRODUCT_CONTENT.equals(scheme)) {
            try {
                Cursor query = b.getContentResolver().query(parse, new String[]{"duration"}, null, null, null);
                if (query != null) {
                    int columnIndexOrThrow = query.getColumnIndexOrThrow("duration");
                    query.moveToFirst();
                    i = query.getInt(columnIndexOrThrow);
                    query.close();
                    String authority = parse.getAuthority();
                    return authority != null ? authority.contains("miui") ? i * 1000 : i : i;
                }
                return 0;
            } catch (Exception unused) {
                return i;
            }
        }
        return 0;
    }

    public static boolean isHtmlColor(String str) {
        return UZCoreUtil.isHtmlColor(str);
    }

    public static String makeAbsUrl(String str, String str2) {
        return x.a(str, str2);
    }

    public static Bitmap makeBitmap(String str, int i) {
        try {
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapFactory.decodeFile(str, options);
            if (!options.mCancel && options.outWidth != -1 && options.outHeight != -1) {
                options.inSampleSize = computeSampleSize(options, -1, i);
                options.inJustDecodeBounds = false;
                options.inDither = false;
                if (options.outMimeType != null && options.outMimeType.contains("jpeg")) {
                    options.inPreferredConfig = Bitmap.Config.RGB_565;
                }
                return BitmapFactory.decodeFile(str, options);
            }
            return null;
        } catch (OutOfMemoryError e) {
            e.printStackTrace();
            return null;
        }
    }

    public static Drawable makeDrawable(String str, UZWidgetInfo uZWidgetInfo) {
        return str != null ? isHtmlColor(str) ? new ColorDrawable(UZCoreUtil.parseColor(str)) : c.a(makeRealPath(str, uZWidgetInfo), e.a().b()) : new ColorDrawable(com.deepe.c.b.a.a);
    }

    public static String makeRealPath(String str, UZWidgetInfo uZWidgetInfo) {
        return x.a(str, uZWidgetInfo);
    }

    public static final int parseCssColor(String str) {
        return UZCoreUtil.parseColor(str);
    }

    public static final int parseCssPixel(String str) {
        if (str == null) {
            return 0;
        }
        if ("auto".equals(str)) {
            return -1;
        }
        return parseInt(str.replace("px", ""));
    }

    public static int parseInt(String str) {
        try {
            return Integer.parseInt(str);
        } catch (Exception unused) {
            return 0;
        }
    }

    public static void setGlobalLocation(double d, double d2, String str) {
    }

    public static String toMd5(String str) {
        return UZCoreUtil.toMD5(str);
    }

    public static String transcoding(String str) {
        return d.a(str);
    }

    public static boolean unzip(String str, String str2) {
        File file = new File(str);
        if (file.exists()) {
            ZipFile zipFile = null;
            try {
                zipFile = new ZipFile(file);
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (zipFile == null) {
                return false;
            }
            Enumeration<? extends ZipEntry> entries = zipFile.entries();
            while (entries.hasMoreElements()) {
                ZipEntry nextElement = entries.nextElement();
                String name = nextElement.getName();
                String str3 = String.valueOf(str2) + File.separator + name;
                if (nextElement.isDirectory()) {
                    File file2 = new File(str3);
                    if (!file2.exists()) {
                        file2.mkdirs();
                    }
                } else {
                    File file3 = new File(str3.substring(0, str3.lastIndexOf(File.separator)));
                    if (!file3.exists()) {
                        file3.mkdirs();
                    }
                    try {
                        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(String.valueOf(str2) + File.separator + name));
                        BufferedInputStream bufferedInputStream = new BufferedInputStream(zipFile.getInputStream(nextElement));
                        byte[] bArr = new byte[4096];
                        while (true) {
                            int read = bufferedInputStream.read(bArr);
                            if (read == -1) {
                                break;
                            }
                            bufferedOutputStream.write(bArr, 0, read);
                        }
                        bufferedOutputStream.close();
                    } catch (Exception e2) {
                        e2.printStackTrace();
                        return false;
                    }
                }
            }
            try {
                zipFile.close();
                return true;
            } catch (IOException e3) {
                e3.printStackTrace();
                return true;
            }
        }
        return false;
    }

    public static JSONObject xmlToJsonObject(String str) {
        try {
            return com.uzmap.pkg.uzkit.a.a.b(str);
        } catch (JSONException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static JSONObject xmlToJsonObject(String str, String str2) {
        try {
            if (!d.a((CharSequence) str2)) {
                com.uzmap.pkg.uzkit.a.a.a = str2;
            }
            JSONObject b = com.uzmap.pkg.uzkit.a.a.b(str);
            com.uzmap.pkg.uzkit.a.a.a();
            return b;
        } catch (JSONException e) {
            e.printStackTrace();
            com.uzmap.pkg.uzkit.a.a.a();
            return null;
        }
    }
}