Java Code Examples for com.android.utils.ILogger#info()

The following examples show how to use com.android.utils.ILogger#info() . 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: PreProcessCache.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
public synchronized void clear(@Nullable File itemStorage, @Nullable ILogger logger) throws
        IOException {
    if (!mMap.isEmpty()) {
        if (itemStorage != null) {
            saveItems(itemStorage);
        }

        if (logger != null) {
            logger.info("PREDEX CACHE HITS:   " + mHits);
            logger.info("PREDEX CACHE MISSES: " + mMisses);
        }
    }

    mMap.clear();
    mStoredItems.clear();
    mHits = 0;
    mMisses = 0;
}
 
Example 2
Source File: BuildToolsServiceLoader.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Return the first service instance for the requested service type or
 * {@link Optional#absent()} if none exist.
 *
 * @param logger      to log resolution.
 * @param serviceType the requested service type encapsulation.
 * @param <T>         the requested service class type.
 * @return the instance of T or null of none exist in this context.
 * @throws ClassNotFoundException
 */
@NonNull
public synchronized <T> Optional<T> getSingleService(
        ILogger logger,
        Service<T> serviceType) throws ClassNotFoundException {
    logger.verbose("Looking for %1$s", serviceType);
    ServiceLoader<T> serviceLoader = getServiceLoader(serviceType);
    logger.verbose("Got a serviceLoader %1$d",
            Integer.toHexString(System.identityHashCode(serviceLoader)));
    Iterator<T> serviceIterator = serviceLoader.iterator();
    logger.verbose("Service Iterator =  %1$s ", serviceIterator);
    if (serviceIterator.hasNext()) {
        T service = serviceIterator.next();
        logger.verbose("Got it from %1$s, loaded service = %2$s, type = %3$s",
                serviceIterator, service, service.getClass());
        return Optional.of(service);
    } else {
        logger.info("Cannot find service implementation %1$s" + serviceType);
        return Optional.absent();
    }
}
 
Example 3
Source File: AvdManager.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Updates an AVD with new path to the system image folders.
 * @param avd the AVD to update.
 * @param log the log object to receive action logs. Cannot be null.
 * @throws IOException
 */
public AvdInfo updateAvd(AvdInfo avd, ILogger log) throws IOException {
    // get the properties. This is a unmodifiable Map.
    Map<String, String> oldProperties = avd.getProperties();

    // create a new map
    Map<String, String> properties = new HashMap<String, String>();
    if (oldProperties != null) {
        properties.putAll(oldProperties);
    }

    AvdStatus status;

    // create the path to the new system images.
    if (setImagePathProperties(avd.getTarget(),
                               avd.getTag(),
                               avd.getAbiType(),
                               properties,
                               log)) {
        if (properties.containsKey(AVD_INI_IMAGES_1)) {
            log.info("Updated '%1$s' with value '%2$s'\n", AVD_INI_IMAGES_1,
                    properties.get(AVD_INI_IMAGES_1));
        }

        if (properties.containsKey(AVD_INI_IMAGES_2)) {
            log.info("Updated '%1$s' with value '%2$s'\n", AVD_INI_IMAGES_2,
                    properties.get(AVD_INI_IMAGES_2));
        }

        status = AvdStatus.OK;
    } else {
        log.error(null, "Unable to find non empty system images folders for %1$s",
                avd.getName());
        //FIXME: display paths to empty image folders?
        status = AvdStatus.ERROR_IMAGE_DIR;
    }

    return updateAvd(avd, properties, status, log);
}
 
Example 4
Source File: QueuedCruncher.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new {@link QueuedCruncher} or return an existing one
 * based on the underlying AAPT executable location.
 * @param aaptLocation the APPT executable location.
 * @param logger the logger to use
 * @return a new of existing instance of the {@link QueuedCruncher}
 */
public QueuedCruncher newCruncher(
        @NonNull String aaptLocation,
        @NonNull ILogger logger) {
    synchronized (sLock) {
        logger.info("QueuedCruncher is using %1$s", aaptLocation);
        if (!sInstances.containsKey(aaptLocation)) {
            QueuedCruncher queuedCruncher = new QueuedCruncher(aaptLocation, logger);
            sInstances.put(aaptLocation, queuedCruncher);
        }
        return sInstances.get(aaptLocation);
    }
}
 
Example 5
Source File: PatchFileBuilder.java    From atlas with Apache License 2.0 4 votes vote down vote up
/**
 * create patch for target version
 *
 * @param targetVersion
 */
private PatchInfo createHisTPatch(String targetVersion, ILogger logger) throws IOException, PatchException {
    PatchInfo hisPatchInfo = hisPatchInfos.get(targetVersion);
    String patchName = "patch-" + currentBuildPatchInfo.getPatchVersion() + "@" + hisPatchInfo.getPatchVersion();
    File destTPathTmpFolder = new File(tPatchTmpFolder, patchName);
    destTPathTmpFolder.mkdirs();
    File infoFile = new File(destTPathTmpFolder, "patchInfo");
    FileUtils.writeStringToFile(infoFile, patchName);
    File curTPatchUnzipFolder = unzipCurTPatchFolder(patchName);
    // 处理awb的更新
    List<BundlePatch> bundlePatches = diffPatch(hisPatchInfo, currentBuildPatchInfo);
    PatchInfo newPatchInfo = processBundlePatch(hisPatchInfo, bundlePatches, curTPatchUnzipFolder);

    // 比对主bundle的信息
    PatchBundleInfo curMainBundleInfo = getMainBundleInfo(currentBuildPatchInfo);
    PatchBundleInfo mainBundleInfo = new PatchBundleInfo();
    mainBundleInfo.setMainBundle(true);
    mainBundleInfo.setNewBundle(false);
    if (null != curMainBundleInfo) {
        File mainBundleFile = new File(curTPatchUnzipFolder, curMainBundleInfo.getName() + ".so");
        FileUtils.copyFileToDirectory(mainBundleFile, destTPathTmpFolder);
        mainBundleInfo.setVersion(curMainBundleInfo.getVersion());
        mainBundleInfo.setPkgName(curMainBundleInfo.getPkgName());
        mainBundleInfo.setBaseVersion(curMainBundleInfo.getBaseVersion());
        mainBundleInfo.setUnitTag(curMainBundleInfo.getUnitTag());
        mainBundleInfo.setSrcUnitTag(curMainBundleInfo.getSrcUnitTag());
        mainBundleInfo.setName(curMainBundleInfo.getName());
        mainBundleInfo.setPkgName(curMainBundleInfo.getPkgName());
        mainBundleInfo.setApplicationName(curMainBundleInfo.getApplicationName());
        newPatchInfo.getBundles().add(mainBundleInfo);
    }

    // 生成tpatch文件
    for (PatchBundleInfo bundleInfo : newPatchInfo.getBundles()) {
        if (bundleInfo.getMainBundle() || bundleInfo.getNewBundle() || noPatchBundles.contains(
                bundleInfo.getPkgName())) {
            File bundleFolder = new File(destTPathTmpFolder, bundleInfo.getName());
            File soFile = new File(destTPathTmpFolder, bundleInfo.getName() + ".so");
            if (soFile.exists() || bundleInfo.getVersion().equals(ROLLBACK_VERSION)) {
                continue;
            }
            CommandUtils.exec(bundleFolder, "zip -r " + soFile.getAbsolutePath() + " . -x */ -x .*");
            //                zipBunldeSo(bundleFolder, soFile);
            FileUtils.deleteDirectory(bundleFolder);
        }
    }
    File tPatchFile = new File(patchsFolder, newPatchInfo.getFileName());
    if (tPatchFile.exists()) {
        FileUtils.deleteQuietly(tPatchFile);
    }
    CommandUtils.exec(destTPathTmpFolder, "zip -r " + tPatchFile.getAbsolutePath() + " . -x */ -x .*");
    if (null != logger) {
        logger.info("[TPatchFile]" + tPatchFile.getAbsolutePath());
    }
    return newPatchInfo;
}
 
Example 6
Source File: DependencyManager.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Normalize a path to remove all illegal characters for all supported operating systems.
 * {@see http://en.wikipedia.org/wiki/Filename#Comparison%5Fof%5Ffile%5Fname%5Flimitations}
 *
 * @param id   the module coordinates that generated this path
 * @param path the proposed path name
 * @return the normalized path name
 */
static String normalize(ILogger logger, ModuleVersionIdentifier id, String path) {
    if (path == null || path.isEmpty()) {
        logger.info(String.format(
                "When unzipping library '%s:%s:%s, either group, name or version is empty",
                id.getGroup(), id.getName(), id.getVersion()));
        return path;
    }
    // list of illegal characters
    String normalizedPath = path.replaceAll("[%<>:\"/?*\\\\]", "@");
    if (normalizedPath == null || normalizedPath.isEmpty()) {
        // if the path normalization failed, return the original path.
        logger.info(String.format(
                "When unzipping library '%s:%s:%s, the normalized '%s' is empty",
                id.getGroup(), id.getName(), id.getVersion(), path));
        return path;
    }
    try {
        int pathPointer = normalizedPath.length() - 1;
        // do not end your path with either a dot or a space.
        String suffix = "";
        while (pathPointer >= 0 && (normalizedPath.charAt(pathPointer) == '.'
                || normalizedPath.charAt(pathPointer) == ' ')) {
            pathPointer--;
            suffix += "@";
        }
        if (pathPointer < 0) {
            throw new RuntimeException(String.format(
                    "When unzipping library '%s:%s:%s, " +
                            "the path '%s' cannot be transformed into a valid directory name",
                    id.getGroup(), id.getName(), id.getVersion(), path));
        }
        return normalizedPath.substring(0, pathPointer + 1) + suffix;
    } catch (Exception e) {
        logger.error(e, String.format(
                "When unzipping library '%s:%s:%s', " +
                        "Path normalization failed for input %s",
                id.getGroup(), id.getName(), id.getVersion(), path));
        return path;
    }
}