Java Code Examples for com.android.SdkConstants#FN_SOURCE_PROP

The following examples show how to use com.android.SdkConstants#FN_SOURCE_PROP . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalDirInfo.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new immutable {@link LocalDirInfo}.
 *
 * @param fileOp The {@link FileOp} to use for all file-based interactions.
 * @param dir The platform/addon directory of the target. It should be a directory.
 */
public LocalDirInfo(@NonNull IFileOp fileOp, @NonNull File dir) {
    mFileOp = fileOp;
    mDir = dir;
    mDirModifiedTS = mFileOp.lastModified(dir);

    // Capture some info about the source.properties file if it exists.
    // We use propsModifiedTS == 0 to mean there is no props file.
    long propsChecksum = 0;
    long propsModifiedTS = 0;
    File props = new File(dir, SdkConstants.FN_SOURCE_PROP);
    if (mFileOp.isFile(props)) {
        propsModifiedTS = mFileOp.lastModified(props);
        propsChecksum = getFileChecksum(props);
    }
    mPropsModifiedTS = propsModifiedTS;
    mPropsChecksum = propsChecksum;
    mDirChecksum = getDirChecksum(mDir);
}
 
Example 2
Source File: DeviceManager.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
private boolean isDevicesExtra(@NonNull File item) {
    File properties = new File(item, SdkConstants.FN_SOURCE_PROP);
    try {
        BufferedReader propertiesReader = new BufferedReader(new FileReader(properties));
        try {
            String line;
            while ((line = propertiesReader.readLine()) != null) {
                Matcher m = PATH_PROPERTY_PATTERN.matcher(line);
                if (m.matches()) {
                    return true;
                }
            }
        } finally {
            propertiesReader.close();
        }
    } catch (IOException ignore) {
    }
    return false;
}
 
Example 3
Source File: LocalDirInfo.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new immutable {@link LocalDirInfo}.
 *
 * @param fileOp The {@link FileOp} to use for all file-based interactions.
 * @param dir The platform/addon directory of the target. It should be a directory.
 */
public LocalDirInfo(@NonNull IFileOp fileOp, @NonNull File dir) {
    mFileOp = fileOp;
    mDir = dir;
    mDirModifiedTS = mFileOp.lastModified(dir);

    // Capture some info about the source.properties file if it exists.
    // We use propsModifiedTS == 0 to mean there is no props file.
    long propsChecksum = 0;
    long propsModifiedTS = 0;
    File props = new File(dir, SdkConstants.FN_SOURCE_PROP);
    if (mFileOp.isFile(props)) {
        propsModifiedTS = mFileOp.lastModified(props);
        propsChecksum = getFileChecksum(props);
    }
    mPropsModifiedTS = propsModifiedTS;
    mPropsChecksum = propsChecksum;
    mDirChecksum = getDirChecksum(mDir);
}
 
Example 4
Source File: DeviceManager.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private boolean isDevicesExtra(@NonNull File item) {
    File properties = new File(item, SdkConstants.FN_SOURCE_PROP);
    try {
        BufferedReader propertiesReader = new BufferedReader(new FileReader(properties));
        try {
            String line;
            while ((line = propertiesReader.readLine()) != null) {
                Matcher m = PATH_PROPERTY_PATTERN.matcher(line);
                if (m.matches()) {
                    return true;
                }
            }
        } finally {
            propertiesReader.close();
        }
    } catch (IOException ignore) {
    }
    return false;
}
 
Example 5
Source File: LocalDirInfo.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Checks whether the directory/source.properties attributes have changed.
 *
 * @return True if the directory modified timestamp or
 *  its source.property files have changed.
 */
public boolean hasChanged() {
    // Does platform directory still exist?
    if (!mFileOp.isDirectory(mDir)) {
        return true;
    }
    // Has platform directory modified-timestamp changed?
    if (mDirModifiedTS != mFileOp.lastModified(mDir)) {
        return true;
    }

    File props = new File(mDir, SdkConstants.FN_SOURCE_PROP);

    // The directory did not have a props file if target was null or
    // if mPropsModifiedTS is 0.
    boolean hadProps = mPropsModifiedTS != 0;

    // Was there a props file and it vanished, or there wasn't and there's one now?
    if (hadProps != mFileOp.isFile(props)) {
        return true;
    }

    if (hadProps) {
        // Has source.props file modified-timestamp changed?
        if (mPropsModifiedTS != mFileOp.lastModified(props)) {
            return true;
        }
        // Had the content of source.props changed?
        if (mPropsChecksum != getFileChecksum(props)) {
            return true;
        }
    }

    // Has the deep directory checksum changed?
    if (mDirChecksum != getDirChecksum(mDir)) {
        return true;
    }

    return false;
}
 
Example 6
Source File: LocalDirInfo.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Checks whether the directory/source.properties attributes have changed.
 *
 * @return True if the directory modified timestamp or
 *  its source.property files have changed.
 */
public boolean hasChanged() {
    // Does platform directory still exist?
    if (!mFileOp.isDirectory(mDir)) {
        return true;
    }
    // Has platform directory modified-timestamp changed?
    if (mDirModifiedTS != mFileOp.lastModified(mDir)) {
        return true;
    }

    File props = new File(mDir, SdkConstants.FN_SOURCE_PROP);

    // The directory did not have a props file if target was null or
    // if mPropsModifiedTS is 0.
    boolean hadProps = mPropsModifiedTS != 0;

    // Was there a props file and it vanished, or there wasn't and there's one now?
    if (hadProps != mFileOp.isFile(props)) {
        return true;
    }

    if (hadProps) {
        // Has source.props file modified-timestamp changed?
        if (mPropsModifiedTS != mFileOp.lastModified(props)) {
            return true;
        }
        // Had the content of source.props changed?
        if (mPropsChecksum != getFileChecksum(props)) {
            return true;
        }
    }

    // Has the deep directory checksum changed?
    if (mDirChecksum != getDirChecksum(mDir)) {
        return true;
    }

    return false;
}
 
Example 7
Source File: LocalSdkParser.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * The sdk manager only lists valid system image via its addons or platform targets.
 * However here we also want to find "broken" system images, that is system images
 * that are located in the sdk/system-images folder but somehow not loaded properly.
 */
private void scanMissingSystemImages(SdkManager sdkManager,
        HashSet<File> visited,
        ArrayList<Package> packages,
        ILogger log) {
    File siRoot = new File(sdkManager.getLocation(), SdkConstants.FD_SYSTEM_IMAGES);

    // The system-images folder contains a list of platform folders.
    for (File platformDir : listFilesNonNull(siRoot)) {
        if (platformDir.isDirectory() && !visited.contains(platformDir)) {
            visited.add(platformDir);

            // In the platform directory, we expect a list of abi folders
            // or a list of tag/abi folders. Basically parse any folder that has
            // a source.prop file within 2 levels.
            List<File> propFiles = Lists.newArrayList();

            for (File dir1 : listFilesNonNull(platformDir)) {
                if (dir1.isDirectory() && !visited.contains(dir1)) {
                    visited.add(dir1);
                    File prop1 = new File(dir1, SdkConstants.FN_SOURCE_PROP);
                    if (prop1.isFile()) {
                        propFiles.add(prop1);
                    } else {
                        for (File dir2 : listFilesNonNull(dir1)) {
                            if (dir2.isDirectory() && !visited.contains(dir2)) {
                                visited.add(dir2);
                                File prop2 = new File(dir2, SdkConstants.FN_SOURCE_PROP);
                                if (prop2.isFile()) {
                                    propFiles.add(prop2);
                                }
                            }
                        }
                    }
                }
            }

            for (File propFile : propFiles) {
                Properties props = parseProperties(propFile);
                try {
                    Package pkg = SystemImagePackage.createBroken(propFile.getParentFile(),
                                                                  props);
                    packages.add(pkg);
                } catch (Exception e) {
                    log.error(e, null);
                }
            }
        }
    }
}
 
Example 8
Source File: LocalSdkParser.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * The sdk manager only lists valid system image via its addons or platform targets.
 * However here we also want to find "broken" system images, that is system images
 * that are located in the sdk/system-images folder but somehow not loaded properly.
 */
private void scanMissingSystemImages(SdkManager sdkManager,
        HashSet<File> visited,
        ArrayList<Package> packages,
        ILogger log) {
    File siRoot = new File(sdkManager.getLocation(), SdkConstants.FD_SYSTEM_IMAGES);

    // The system-images folder contains a list of platform folders.
    for (File platformDir : listFilesNonNull(siRoot)) {
        if (platformDir.isDirectory() && !visited.contains(platformDir)) {
            visited.add(platformDir);

            // In the platform directory, we expect a list of abi folders
            // or a list of tag/abi folders. Basically parse any folder that has
            // a source.prop file within 2 levels.
            List<File> propFiles = Lists.newArrayList();

            for (File dir1 : listFilesNonNull(platformDir)) {
                if (dir1.isDirectory() && !visited.contains(dir1)) {
                    visited.add(dir1);
                    File prop1 = new File(dir1, SdkConstants.FN_SOURCE_PROP);
                    if (prop1.isFile()) {
                        propFiles.add(prop1);
                    } else {
                        for (File dir2 : listFilesNonNull(dir1)) {
                            if (dir2.isDirectory() && !visited.contains(dir2)) {
                                visited.add(dir2);
                                File prop2 = new File(dir2, SdkConstants.FN_SOURCE_PROP);
                                if (prop2.isFile()) {
                                    propFiles.add(prop2);
                                }
                            }
                        }
                    }
                }
            }

            for (File propFile : propFiles) {
                Properties props = parseProperties(propFile);
                try {
                    Package pkg = SystemImagePackage.createBroken(propFile.getParentFile(),
                                                                  props);
                    packages.add(pkg);
                } catch (Exception e) {
                    log.error(e, null);
                }
            }
        }
    }
}