/** * Execute the zipalign for a certain apk * * @param apk */ public static void zipAlign(File apk) { // String zipAlign = SdkUtils.getSdkToolsPath(); String zipAlign = AndroidUtils.getSDKPathByPreference() + IPath.SEPARATOR + IAndroidConstants.FD_TOOLS; try { File tempFile = File.createTempFile("_tozipalign", ".apk"); FileUtil.copyFile(apk, tempFile); if (!zipAlign.endsWith(File.separator)) { zipAlign += File.separator; } zipAlign += Platform.getOS().equals(Platform.OS_WIN32) ? "zipalign.exe" : "zipalign"; String[] command = new String[] { zipAlign, "-f", "-v", "4", tempFile.getAbsolutePath(), apk.getAbsolutePath() }; StringBuilder commandLine = new StringBuilder(); for (String commandPart : command) { commandLine.append(commandPart); commandLine.append(" "); } AndmoreLogger.info(PackageFile.class, "Zipaligning package: " + commandLine.toString()); Runtime.getRuntime().exec(command); } catch (IOException e) { AndmoreLogger.error(PackageFile.class, "Error while zipaligning package", e); } catch (Exception e) { AndmoreLogger.error( PackageFile.class, "Zipalign application cannot be executed - insuficient permissions", e); } }
/** * Loads a new screen image to the currentSkin attribute. This action updates the skin image that * is drawn as skin * * @param imageToSet The new skin pixel data, as retrieved from the skin plugin * @param changedKey The key that has changed, if any. If one if provided, only the key area * should be redrawn. Can be <code>null</code>. * @param forceDraw true if a draw is needed after setting the new image; false if replacing skin * image only will be performed. */ private void setSkinImage(ImageData imageToSet, IAndroidKey changedKey, boolean forceDraw) { recalculateZoomFactor(); if (imageToSet != null) { if (currentSkinImage != null) { currentSkinImage.dispose(); } // Scales the chosen image and sets to currentSkin attribute // // NOTE: width and height cannot be equal to MINIMUM_ZOOM_FACTOR, // because this // will raise an IllegalArgumentException when constructing the // Image object int width = (zoomFactor == MINIMUM_ZOOM_FACTOR ? 1 : (int) (imageToSet.width * zoomFactor)); int height = (zoomFactor == MINIMUM_ZOOM_FACTOR ? 1 : (int) (imageToSet.height * zoomFactor)); currentSkinImage = new Image(getDisplay(), imageToSet.scaledTo(width, height)); // It only makes sense to reset the translation if the skin image is // really being changed // It will happen if we set a image data without specifying a // changed key if (changedKey == null) { displayRectangle.x = 0; displayRectangle.y = 0; } if (forceDraw) { layout(); GC gc = new GC(this); drawSkin(gc, changedKey); gc.dispose(); } } else { info("It was requested to set a skin image that was null. Operation aborted."); } }