UCam Driving recorder v3.2.5版本的 MD5 值为:80b4271bc5ccc520b2146c142992977d

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


package com.sicadroid.carcamera.utils;

import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.storage.StorageManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.sicadroid.carcamera.ucamservice.Log;
import com.sicadroid.ucam_car.R;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Formatter;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class UCamUtils {
    public static final String SICADOGNAME = "sicadog.mdb";
    public static final String SICADOGZIPNAME = "sicadog.zip";
    public static final String TAG = "Hz";
    public static final String UCAMNAME = "elene";
    public static final String UPDATE_CHECK_CARAPP = "http://up.cndik.com/update/ucamera/checknew/ucamcar.html";
    public static final String UPDATE_CHECK_CARDOG = "http://up.cndik.com/update/ucamera/checknew/sicadog.html";
    public static final String UPDATE_DOWN_CARAPP = "http://up.cndik.com/update/ucamera/ucamcar/";
    public static final String UPDATE_DOWN_CARDOG = "http://up.cndik.com/update/ucamera/ucamdog/";
    public static boolean DEBUG = false;
    public static String sAppData = "";
    public static String sUserData = "";
    private static StringBuffer Lonsb = new StringBuffer();
    private static StringBuffer Latsb = new StringBuffer();
    private static StringBuilder sFormatBuilder = new StringBuilder();
    private static Formatter sFormatter = new Formatter(sFormatBuilder, Locale.getDefault());
    private static final Object[] sTimeArgs = new Object[5];

    public static class UpdateInfo {
        public boolean bforce;
        public String downpath;
        public String downurl;
        public String filename;
        public String md5;
        public String updateinfo;
        public int vercode;
    }

    public static String getAppDataPath(Context context) {
        if (!TextUtils.isEmpty(sAppData)) {
            return sAppData;
        }
        sAppData = context.getFilesDir().getAbsolutePath();
        return sAppData;
    }

    public static String getDataPath(Context context) {
        if (!TextUtils.isEmpty(sUserData)) {
            return sUserData;
        }
        File file = context.getApplicationContext().getExternalFilesDir(null);
        if (file != null) {
            sUserData = file.getAbsolutePath();
        } else {
            sUserData = String.valueOf(Environment.getExternalStorageDirectory().getAbsolutePath()) + "/UCamCar";
        }
        return sUserData;
    }

    public static String getDownLoadPath(Context context) {
        return String.valueOf(getDataPath(context)) + File.separator + "download";
    }

    public static String getUpdatePath(Context context) {
        return String.valueOf(getDataPath(context)) + File.separator + "updata";
    }

    public static String getDeviceFile(Context context) {
        return String.valueOf(getDataPath(context)) + File.separator + "device";
    }

    public static String getNetParamFile(Context context) {
        return String.valueOf(getDataPath(context)) + File.separator + "netparam";
    }

    public static String getSuperDogPath(Context context) {
        return String.valueOf(getAppDataPath(context)) + File.separator + "sicadog";
    }

    public static boolean isServiceWorked(Context context, String serviceName) {
        ActivityManager myManager = (ActivityManager) context.getSystemService("activity");
        try {
            ArrayList<ActivityManager.RunningServiceInfo> runningService = (ArrayList) myManager.getRunningServices(Integer.MAX_VALUE);
            if (runningService != null) {
                for (int i = 0; i < runningService.size(); i++) {
                    if (runningService.get(i).service.getClassName().toString().equals(serviceName)) {
                        return true;
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    public boolean isTablet(Context context) {
        return (context.getResources().getConfiguration().screenLayout & 15) >= 3;
    }

    public boolean hasIMEI(Context context) {
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
        String imei = telephonyManager.getDeviceId();
        return !TextUtils.isEmpty(imei);
    }

    public static boolean hasSIMCard(Context context) {
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
        return (telephonyManager.getSimState() == 1 || telephonyManager.getSimState() == 0) ? false : true;
    }

    public static String getDeviceId(Context context) {
        String deviceid = getSN(context);
        if (TextUtils.isEmpty(deviceid)) {
            deviceid = getIMEI(context);
        }
        if (TextUtils.isEmpty(deviceid)) {
            return getUUID8(context);
        }
        return deviceid;
    }

    public static String getSN(Context context) {
        TelephonyManager tm = (TelephonyManager) context.getSystemService("phone");
        String sn = tm.getSimSerialNumber();
        if (TextUtils.isEmpty(sn)) {
            return Build.SERIAL;
        }
        return sn;
    }

    public static String getIMEI(Context context) {
        TelephonyManager tm = (TelephonyManager) context.getSystemService("phone");
        return tm.getDeviceId();
    }

    public static String getUUID(Context context) {
        UCamIniUtils inifile = new UCamIniUtils(getDeviceFile(context));
        String uuid = (String) inifile.get("sys", "uuid16", "");
        if (TextUtils.isEmpty(uuid)) {
            String[] idd = UUID.randomUUID().toString().split("-");
            String uuid2 = String.valueOf(idd[0]) + idd[1] + idd[2];
            inifile.set("sys", "uuid16", uuid2);
            inifile.save();
            return uuid2;
        }
        return uuid;
    }

    public static String getUUID8(Context context) {
        UCamIniUtils inifile = new UCamIniUtils(getDeviceFile(context));
        String uuid = (String) inifile.get("sys", "uuid8", "");
        if (TextUtils.isEmpty(uuid)) {
            String[] idd = UUID.randomUUID().toString().split("-");
            String uuid2 = idd[0];
            inifile.set("sys", "uuid8", uuid2);
            inifile.save();
            return uuid2;
        }
        return uuid;
    }

    public static String getUUID4(Context context) {
        UCamIniUtils inifile = new UCamIniUtils(getDeviceFile(context));
        String uuid = (String) inifile.get("sys", "uuid4", "");
        if (TextUtils.isEmpty(uuid)) {
            String[] idd = UUID.randomUUID().toString().split("-");
            String uuid2 = idd[2];
            inifile.set("sys", "uuid4", uuid2);
            inifile.save();
            return uuid2;
        }
        return uuid;
    }

    public static String getVersion(Context context) {
        try {
            PackageManager manager = context.getPackageManager();
            PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
            return info.versionName;
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    public static int getVersionCode(Context context) {
        try {
            PackageManager manager = context.getPackageManager();
            PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
            return info.versionCode;
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
        }
    }

    public static String getDeviceFilePath(Context context) {
        String campath = null;
        StorageManager storageManager = (StorageManager) context.getSystemService("storage");
        try {
            Class[] paramClasses = new Class[0];
            Method getVolumeList = StorageManager.class.getMethod("getVolumeList", paramClasses);
            Object[] params = new Object[0];
            Object[] invokes = (Object[]) getVolumeList.invoke(storageManager, params);
            if (invokes != null) {
                int i = 0;
                while (true) {
                    if (i >= invokes.length) {
                        break;
                    }
                    Object obj = invokes[i];
                    Method getPath = obj.getClass().getMethod("getPath", new Class[0]);
                    String path = (String) getPath.invoke(obj, new Object[0]);
                    Method getVolumeState = StorageManager.class.getMethod("getVolumeState", String.class);
                    String state = (String) getVolumeState.invoke(storageManager, path);
                    Method isRemovable = obj.getClass().getMethod("isRemovable", new Class[0]);
                    boolean isRemoveable = ((Boolean) isRemovable.invoke(obj, new Object[0])).booleanValue();
                    if (DEBUG) {
                        Log.e(TAG, "path = " + path + " isRemovable = " + isRemoveable + " state " + state);
                    }
                    File file = new File(path);
                    if (DEBUG) {
                        Log.e(TAG, "file  " + file.exists() + "  " + file.isDirectory() + "  " + file.canRead());
                    }
                    if (isRemoveable && "mounted".equals(state) && file.exists() && file.isDirectory() && file.canRead()) {
                        File ucamfile = new File(String.valueOf(file.getAbsolutePath()) + File.separator + UCAMNAME);
                        if (ucamfile.exists() && ucamfile.canRead()) {
                            break;
                        }
                        Log.e(TAG, "ucamfile not exist! " + ucamfile.getAbsolutePath());
                    }
                    i++;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return campath;
    }

    public static String getMountedPath() {
        String ucampath = null;
        BufferedReader reader = null;
        try {
            try {
                BufferedReader reader2 = new BufferedReader(new FileReader("/proc/mounts"));
                while (true) {
                    try {
                        String strLine = reader2.readLine();
                        if (strLine == null) {
                            break;
                        }
                        if (DEBUG) {
                            Log.e(TAG, strLine);
                        }
                        String[] list = strLine.split(" ");
                        File ucamfile = new File(String.valueOf(list[1]) + File.separator + UCAMNAME);
                        if (ucamfile.exists() && ucamfile.canRead()) {
                            break;
                        }
                    } catch (Exception e) {
                        e = e;
                        reader = reader2;
                        e.printStackTrace();
                        if (reader != null) {
                            try {
                                reader.close();
                            } catch (IOException e2) {
                                e2.printStackTrace();
                            }
                        }
                        return ucampath;
                    } catch (Throwable th) {
                        th = th;
                        reader = reader2;
                        if (reader != null) {
                            try {
                                reader.close();
                            } catch (IOException e3) {
                                e3.printStackTrace();
                            }
                        }
                        throw th;
                    }
                }
                if (reader2 != null) {
                    try {
                        reader2.close();
                    } catch (IOException e4) {
                        e4.printStackTrace();
                    }
                }
            } catch (Exception e5) {
                e = e5;
            }
            return ucampath;
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public static String changeLon(double value) {
        Lonsb.delete(0, Lonsb.length());
        if (value > 0.0d) {
            Lonsb.append("E");
        } else {
            Lonsb.append("W");
        }
        double value2 = Math.abs(value);
        int zhengshu = (int) value2;
        double xiaoshu = (value2 - zhengshu) * 60.0d;
        int xiaoshuZhengshu = (int) xiaoshu;
        int xiaoshuXiaoshu = (int) Math.floor((xiaoshu - xiaoshuZhengshu) * 60.0d);
        if (zhengshu < 10) {
            Lonsb.append("00" + zhengshu + ".");
        } else if (zhengshu > 9 && zhengshu < 100) {
            Lonsb.append("0" + zhengshu + ".");
        } else {
            Lonsb.append(String.valueOf(zhengshu) + ".");
        }
        if (xiaoshuZhengshu < 10) {
            Lonsb.append("0" + xiaoshuZhengshu + ".");
        } else {
            Lonsb.append(String.valueOf(xiaoshuZhengshu) + ".");
        }
        if (xiaoshuXiaoshu < 10) {
            Lonsb.append("0" + xiaoshuXiaoshu);
        } else {
            Lonsb.append(xiaoshuXiaoshu);
        }
        return Lonsb.toString();
    }

    public static String changeLat(double value) {
        Latsb.delete(0, Latsb.length());
        if (value > 0.0d) {
            Latsb.append("N");
        } else {
            Latsb.append("S");
        }
        double value2 = Math.abs(value);
        int zhengshu = (int) value2;
        double xiaoshu = (value2 - zhengshu) * 60.0d;
        int xiaoshuZhengshu = (int) xiaoshu;
        int xiaoshuXiaoshu = (int) Math.floor((xiaoshu - xiaoshuZhengshu) * 60.0d);
        if (zhengshu < 10) {
            Latsb.append("0" + zhengshu + ".");
        } else {
            Latsb.append(String.valueOf(zhengshu) + ".");
        }
        if (xiaoshuZhengshu < 10) {
            Latsb.append("0" + xiaoshuZhengshu + ".");
        } else {
            Latsb.append(String.valueOf(xiaoshuZhengshu) + ".");
        }
        if (xiaoshuXiaoshu < 10) {
            Latsb.append("0" + xiaoshuXiaoshu);
        } else {
            Latsb.append(xiaoshuXiaoshu);
        }
        return Latsb.toString();
    }

    public static long getRomAvailableSize(Context context) {
        ActivityManager actMgr = (ActivityManager) context.getSystemService("activity");
        ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
        actMgr.getMemoryInfo(memoryInfo);
        return memoryInfo.availMem >> 20;
    }

    public static String makeTimeString(Context context, long secs) {
        String durationformat = context.getString(secs < 3600 ? R.string.durationformatshort : R.string.durationformatlong);
        sFormatBuilder.setLength(0);
        Object[] timeArgs = sTimeArgs;
        timeArgs[0] = Long.valueOf(secs / 3600);
        timeArgs[1] = Long.valueOf(secs / 60);
        timeArgs[2] = Long.valueOf((secs / 60) % 60);
        timeArgs[3] = Long.valueOf(secs);
        timeArgs[4] = Long.valueOf(secs % 60);
        return sFormatter.format(durationformat, timeArgs).toString();
    }

    public static String getYear() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        return sdf.format(new Date());
    }

    public static boolean isZh(Context context) {
        Locale locale = context.getResources().getConfiguration().locale;
        String language = locale.getLanguage();
        return language.endsWith("zh");
    }

    public static UpdateInfo getUpdateInfoFromUrl(Context context, String url) {
        UpdateInfo info = null;
        if (UCamWiFiManager.isNetworkAvailable(context)) {
            String strtext = getHtmlFormUrl(url);
            if (!TextUtils.isEmpty(strtext)) {
                info = new UpdateInfo();
                int start = strtext.indexOf("VERCODE=");
                int end = strtext.indexOf("#", start + 8);
                if (start > -1 && end > 0 && end > start) {
                    String vercode = strtext.substring(start + 8, end);
                    info.vercode = Integer.valueOf(vercode).intValue();
                }
                int start2 = strtext.indexOf("VER=");
                int end2 = strtext.indexOf("#", start2 + 4);
                if (start2 > -1 && end2 > 0 && end2 > start2) {
                    info.filename = strtext.substring(start2 + 4, end2);
                }
                int start3 = strtext.indexOf("MD5=");
                int end3 = strtext.indexOf("#", start3 + 4);
                if (start3 > -1 && end3 > 0 && end3 > start3) {
                    info.md5 = strtext.substring(start3 + 4, end3);
                }
                int start4 = strtext.indexOf("FROCE=");
                int end4 = strtext.indexOf("#", start4 + 6);
                if (start4 > -1 && end4 > 0 && end4 > start4) {
                    String force = strtext.substring(start4 + 6, end4);
                    info.bforce = "1".equals(force);
                }
                int start5 = strtext.indexOf("URL=");
                int end5 = strtext.indexOf("#", start5 + 4);
                if (start5 > -1 && end5 > 0 && end5 > start5) {
                    info.downurl = strtext.substring(start5 + 4, end5);
                }
                int start6 = strtext.indexOf("INFO=");
                int end6 = strtext.indexOf("#", start6 + 5);
                if (start6 > -1 && end6 > 0 && end6 > start6) {
                    info.updateinfo = strtext.substring(start6 + 5, end6);
                }
            }
        }
        return info;
    }

    public static String getHtmlFormUrl(String strurl) {
        InputStream inputStream;
        String str = null;
        if (TextUtils.isEmpty(strurl)) {
            return null;
        }
        try {
            URL url = new URL(strurl);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setConnectTimeout(3000);
            conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
            if (conn.getResponseCode() != 200 || (inputStream = conn.getInputStream()) == null) {
                return null;
            }
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
            StringBuilder sb = new StringBuilder();
            while (true) {
                String line = reader.readLine();
                if (line != null) {
                    sb.append(String.valueOf(line) + "\n");
                } else {
                    inputStream.close();
                    str = sb.toString();
                    return str;
                }
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
            return str;
        } catch (IOException e2) {
            e2.printStackTrace();
            return str;
        }
    }

    public static boolean downLoadFromUrl(String urlStr, String fileName, String filePath) {
        boolean z = false;
        File fileDir = new File(filePath);
        if (!fileDir.exists()) {
            fileDir.mkdirs();
        }
        File file = new File(fileDir + File.separator + fileName);
        if (file.exists()) {
            file.delete();
        }
        try {
            URL url = new URL(urlStr);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setConnectTimeout(3000);
            conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
            InputStream inputStream = conn.getInputStream();
            if (inputStream == null) {
                return false;
            }
            byte[] buffer = new byte[1024];
            FileOutputStream fos = new FileOutputStream(file);
            while (true) {
                int len = inputStream.read(buffer);
                if (len == -1) {
                    break;
                }
                fos.write(buffer, 0, len);
            }
            if (fos != null) {
                fos.close();
            }
            inputStream.close();
            z = true;
            return true;
        } catch (MalformedURLException e) {
            e.printStackTrace();
            return z;
        } catch (IOException e2) {
            e2.printStackTrace();
            return z;
        }
    }

    public static String getVersionNameFromApk(Context context, String archiveFilePath, String packagename) {
        if (TextUtils.isEmpty(archiveFilePath) || TextUtils.isEmpty(packagename)) {
            return "";
        }
        PackageManager pm = context.getPackageManager();
        PackageInfo packInfo = pm.getPackageArchiveInfo(archiveFilePath, 1);
        return (packInfo == null || !packInfo.packageName.equals(packagename)) ? "" : packInfo.versionName;
    }

    public static int getVersionCodeFromApk(Context context, String archiveFilePath, String packagename) {
        if (TextUtils.isEmpty(archiveFilePath) || TextUtils.isEmpty(packagename)) {
            return 0;
        }
        PackageManager pm = context.getPackageManager();
        PackageInfo packInfo = pm.getPackageArchiveInfo(archiveFilePath, 1);
        if (packInfo == null || !packInfo.packageName.equals(packagename)) {
            return 0;
        }
        return packInfo.versionCode;
    }

    public static boolean install(String apkPath) {
        BufferedReader errorStream;
        boolean result = false;
        DataOutputStream dataOutputStream = null;
        BufferedReader errorStream2 = null;
        try {
            try {
                Process process = Runtime.getRuntime().exec("su");
                DataOutputStream dataOutputStream2 = new DataOutputStream(process.getOutputStream());
                try {
                    String command = "pm install -r " + apkPath + "\n";
                    dataOutputStream2.write(command.getBytes(Charset.forName("utf-8")));
                    dataOutputStream2.flush();
                    dataOutputStream2.writeBytes("exit\n");
                    dataOutputStream2.flush();
                    process.waitFor();
                    errorStream = new BufferedReader(new InputStreamReader(process.getErrorStream()));
                    String msg = "";
                    while (true) {
                        try {
                            String line = errorStream.readLine();
                            if (line == null) {
                                break;
                            }
                            msg = String.valueOf(msg) + line;
                        } catch (Exception e) {
                            e = e;
                            errorStream2 = errorStream;
                            dataOutputStream = dataOutputStream2;
                            e.printStackTrace();
                            if (dataOutputStream != null) {
                                try {
                                    dataOutputStream.close();
                                } catch (IOException e2) {
                                    e2.printStackTrace();
                                }
                            }
                            if (errorStream2 != null) {
                                errorStream2.close();
                            }
                            return result;
                        } catch (Throwable th) {
                            th = th;
                            errorStream2 = errorStream;
                            dataOutputStream = dataOutputStream2;
                            if (dataOutputStream != null) {
                                try {
                                    dataOutputStream.close();
                                } catch (IOException e3) {
                                    e3.printStackTrace();
                                    throw th;
                                }
                            }
                            if (errorStream2 != null) {
                                errorStream2.close();
                            }
                            throw th;
                        }
                    }
                    Log.d("TAG", "install msg is " + msg);
                    if (!msg.contains("Failure")) {
                        result = true;
                    }
                    if (dataOutputStream2 != null) {
                        try {
                            dataOutputStream2.close();
                        } catch (IOException e4) {
                            e4.printStackTrace();
                        }
                    }
                } catch (Exception e5) {
                    e = e5;
                    dataOutputStream = dataOutputStream2;
                } catch (Throwable th2) {
                    th = th2;
                    dataOutputStream = dataOutputStream2;
                }
            } catch (Exception e6) {
                e = e6;
            }
            if (errorStream != null) {
                errorStream.close();
                return result;
            }
            return result;
        } catch (Throwable th3) {
            th = th3;
        }
    }

    public static void installApk(Context context, String apkPath) {
        Intent intent = new Intent();
        intent.setAction("android.intent.action.VIEW");
        intent.addFlags(268435456);
        intent.setDataAndType(Uri.parse("file://" + apkPath), "application/vnd.android.package-archive");
        try {
            context.startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static boolean verifyInstallPackage(String packagePath, String crc) {
        try {
            MessageDigest sig = MessageDigest.getInstance("MD5");
            File packageFile = new File(packagePath);
            InputStream signedData = new FileInputStream(packageFile);
            byte[] buffer = new byte[4096];
            long toRead = packageFile.length();
            long soFar = 0;
            while (soFar < toRead) {
                boolean interrupted = Thread.interrupted();
                if (interrupted) {
                    break;
                }
                int read = signedData.read(buffer);
                soFar += read;
                sig.update(buffer, 0, read);
            }
            byte[] digest = sig.digest();
            String digestStr = bytesToHexString(digest);
            if (digestStr.toLowerCase().equals(crc.toLowerCase())) {
                return true;
            }
            return false;
        } catch (Exception e) {
            return false;
        }
    }

    public static String bytesToHexString(byte[] src) {
        StringBuilder stringBuilder = new StringBuilder("");
        if (src == null || src.length <= 0) {
            return null;
        }
        for (int i = 0; i < src.length; i++) {
            int v = (src[i] >> 4) & 15;
            String hv = Integer.toHexString(v);
            stringBuilder.append(hv);
            int v2 = src[i] & 15;
            String hv2 = Integer.toHexString(v2);
            stringBuilder.append(hv2);
        }
        return stringBuilder.toString();
    }

    public static boolean copyFile(String fromFile, String toFile) {
        boolean z = false;
        try {
            FileInputStream fosfrom = new FileInputStream(fromFile);
            FileOutputStream fosto = new FileOutputStream(toFile);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte[] buffer = new byte[1024];
            while (true) {
                int len = fosfrom.read(buffer);
                if (len != -1) {
                    baos.write(buffer, 0, len);
                } else {
                    fosto.write(baos.toByteArray());
                    baos.close();
                    fosto.close();
                    fosfrom.close();
                    z = true;
                    return true;
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            return z;
        }
    }

    public static boolean unzip(String zipFileName, String outputDirectory) {
        boolean z = false;
        File zipfile = new File(zipFileName);
        if (!zipfile.exists()) {
            return false;
        }
        try {
            ZipInputStream in = new ZipInputStream(new FileInputStream(zipfile));
            while (true) {
                ZipEntry z2 = in.getNextEntry();
                if (z2 != null) {
                    String name = z2.getName();
                    if (z2.isDirectory()) {
                        File folder = new File(String.valueOf(outputDirectory) + File.separator + name.substring(0, name.length() - 1));
                        folder.mkdirs();
                    } else {
                        File file = new File(String.valueOf(outputDirectory) + File.separator + name);
                        file.createNewFile();
                        FileOutputStream out = new FileOutputStream(file);
                        byte[] buffer = new byte[1024];
                        while (true) {
                            int ch = in.read(buffer);
                            if (ch == -1) {
                                break;
                            }
                            out.write(buffer, 0, ch);
                            out.flush();
                        }
                        out.close();
                    }
                } else {
                    in.close();
                    z = true;
                    return true;
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            return z;
        }
    }

    public static void deepFile(Context context, String assectpath, String dstpath) {
        try {
            String[] str = context.getAssets().list(assectpath);
            if (str.length > 0) {
                File file = new File(dstpath);
                file.mkdirs();
                for (String string : str) {
                    deepFile(context, String.valueOf(assectpath) + File.separator + string, String.valueOf(dstpath) + File.separator + string);
                }
                return;
            }
            InputStream is = context.getAssets().open(assectpath);
            FileOutputStream fos = new FileOutputStream(new File(dstpath));
            byte[] buffer = new byte[1024];
            while (true) {
                int len = is.read(buffer);
                if (len != -1) {
                    fos.write(buffer, 0, len);
                } else {
                    is.close();
                    fos.close();
                    return;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getProperty(String key, String defaultValue) {
        String value = defaultValue;
        try {
            try {
                Class<?> c = Class.forName("android.os.SystemProperties");
                Method get = c.getMethod("get", String.class, String.class);
                value = (String) get.invoke(c, key, defaultValue);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } catch (Throwable th) {
        }
        return value;
    }

    public static Bitmap generateBitmap(String content, int width, int height) {
        QRCodeWriter qrCodeWriter = new QRCodeWriter();
        Map<EncodeHintType, String> hints = new HashMap<>();
        hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
        try {
            BitMatrix encode = qrCodeWriter.encode(content, BarcodeFormat.QR_CODE, width, height, hints);
            int[] pixels = new int[width * height];
            boolean isFirstBlackPoint = false;
            int startX = 0;
            int startY = 0;
            for (int i = 0; i < height; i++) {
                for (int j = 0; j < width; j++) {
                    if (encode.get(j, i)) {
                        pixels[(i * width) + j] = 0;
                        if (!isFirstBlackPoint) {
                            isFirstBlackPoint = true;
                            startX = j;
                            startY = i;
                        }
                    } else {
                        pixels[(i * width) + j] = -1;
                    }
                }
            }
            Bitmap bitmap = Bitmap.createBitmap(pixels, 0, width, width, height, Bitmap.Config.RGB_565);
            if (startX > 20) {
                int x1 = startX - 20;
                int y1 = startY - 20;
                if (x1 >= 0 && y1 >= 0) {
                    int w1 = width - (x1 * 2);
                    int h1 = height - (y1 * 2);
                    return Bitmap.createBitmap(bitmap, x1, y1, w1, h1);
                }
                return bitmap;
            }
            return bitmap;
        } catch (WriterException e) {
            e.printStackTrace();
            return null;
        }
    }
}