Search in sources :

Example 1 with XposedProp

use of de.robv.android.xposed.installer.util.InstallZipUtil.XposedProp 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)

Example 2 with XposedProp

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

the class XposedApp method reloadXposedProp.

public void reloadXposedProp() {
    XposedProp prop = null;
    for (String path : XPOSED_PROP_FILES) {
        File file = new File(path);
        if (file.canRead()) {
            FileInputStream is = null;
            try {
                is = new FileInputStream(file);
                prop = InstallZipUtil.parseXposedProp(is);
                break;
            } catch (IOException e) {
                Log.e(XposedApp.TAG, "Could not read " + file.getPath(), e);
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (IOException ignored) {
                    }
                }
            }
        }
    }
    synchronized (this) {
        mXposedProp = prop;
    }
}
Also used : XposedProp(de.robv.android.xposed.installer.util.InstallZipUtil.XposedProp) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

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