Search in sources :

Example 1 with ZipCheckResult

use of de.robv.android.xposed.installer.util.InstallZipUtil.ZipCheckResult in project XposedInstaller by rovo89.

the class FrameworkZips method analyze.

@WorkerThread
private static LocalFrameworkZip analyze(File file) {
    String filename = file.getName();
    ZipFile zipFile = null;
    try {
        zipFile = new ZipFile(file);
        ZipCheckResult zcr = InstallZipUtil.checkZip(zipFile);
        if (!zcr.isValidZip()) {
            return null;
        }
        LocalFrameworkZip zip = new LocalFrameworkZip();
        ZipEntry entry;
        if ((entry = zipFile.getEntry("system/xposed.prop")) != null) {
            XposedProp prop = InstallZipUtil.parseXposedProp(zipFile.getInputStream(entry));
            if (prop == null || !prop.isCompatible()) {
                Log.w(XposedApp.TAG, "ZIP file is not compatible: " + file);
                return null;
            }
            zip.title = "Version " + prop.getVersion();
        } else if (filename.startsWith("xposed-uninstaller-")) {
            // TODO provide more information inside uninstaller ZIPs
            zip.type = Type.UNINSTALLER;
            zip.title = "Uninstaller";
            int start = "xposed-uninstaller-".length();
            int end = filename.lastIndexOf('-');
            if (start < end) {
                zip.title += " (" + filename.substring(start, end) + ")";
            }
        } else {
            return null;
        }
        zip.path = file;
        return zip;
    } catch (IOException e) {
        Log.e(XposedApp.TAG, "Errors while checking " + file, e);
        return null;
    } finally {
        if (zipFile != null) {
            InstallZipUtil.closeSilently(zipFile);
        }
    }
}
Also used : XposedProp(de.robv.android.xposed.installer.util.InstallZipUtil.XposedProp) ZipFile(java.util.zip.ZipFile) ZipCheckResult(de.robv.android.xposed.installer.util.InstallZipUtil.ZipCheckResult) ZipEntry(java.util.zip.ZipEntry) IOException(java.io.IOException) WorkerThread(android.support.annotation.WorkerThread)

Aggregations

WorkerThread (android.support.annotation.WorkerThread)1 XposedProp (de.robv.android.xposed.installer.util.InstallZipUtil.XposedProp)1 ZipCheckResult (de.robv.android.xposed.installer.util.InstallZipUtil.ZipCheckResult)1 IOException (java.io.IOException)1 ZipEntry (java.util.zip.ZipEntry)1 ZipFile (java.util.zip.ZipFile)1