Lines Matching refs:utility

254      * parse file size limit from utility.
256 * @param utility Indicates the utility.
258 public void parseFileSizeLimit(Utility utility) throws BundleException {
260 String totalLimit = utility.getTotalLimit();
273 String normalLimit = utility.getNormalModuleLimit();
287 String mainLimit = utility.getMainModuleLimit();
327 * @param utility common data
330 public boolean compressProcess(Utility utility) {
331 switch (utility.getMode()) {
333 versionNormalize(utility);
336 hapAddition(utility);
339 return PackageNormalize.normalize(utility);
341 return defaultProcess(utility);
345 private boolean defaultProcess(Utility utility) {
346 File destFile = new File(utility.getOutPath());
362 zipOut.setLevel(utility.getCompressLevel());
363 compressExcute(utility);
377 if (compressResult && !checkAppAtomicServiceCompressedSizeValid(utility)) {
392 private void compressExcute(Utility utility) throws BundleException {
393 switch (utility.getMode()) {
395 compressHap(utility);
398 compressHarMode(utility);
401 compressAppMode(utility);
404 compressFastAppMode(utility);
407 compressAppModeForMultiProject(utility);
410 compressHQFMode(utility);
413 compressAPPQFMode(utility);
416 compressHsp(utility);
419 compressPackResMode(utility);
423 private void compressHsp(Utility utility) throws BundleException {
424 setGenerateBuildHash(utility);
425 if (isModuleJSON(utility.getJsonPath())) {
426 Optional<String> optional = FileUtils.getFileContent(utility.getJsonPath());
460 compressHSPMode(utility);
461 buildHash(utility);
464 private void compressHap(Utility utility) throws BundleException {
465 if (utility.getJsonPath().isEmpty() && !utility.getBinPath().isEmpty()) {
467 compressHapMode(utility);
470 setGenerateBuildHash(utility);
471 if (isModuleJSON(utility.getJsonPath())) {
472 if (!checkStageHap(utility)) {
476 Optional<String> optional = FileUtils.getFileContent(utility.getJsonPath());
486 compressHapModeForModule(utility);
487 buildHash(utility);
489 compressHapMode(utility);
490 buildHash(utility);
494 private static boolean hasGenerateBuildHash(Utility utility) throws BundleException {
495 File file = new File(utility.getJsonPath());
527 private static void setGenerateBuildHash(Utility utility) throws BundleException {
528 if (utility.isBuildHashFinish() || !hasGenerateBuildHash(utility)) {
531 copyFileToTempDir(utility);
532 File file = new File(utility.getJsonPath());
549 utility.setGenerateBuildHash(true);
552 utility.setGenerateBuildHash(true);
561 new FileOutputStream(utility.getJsonPath()), StandardCharsets.UTF_8));
583 private static void copyFileToTempDir(Utility utility) throws BundleException {
584 String jsonPath = utility.getJsonPath();
594 if (isModuleJSON(utility.getJsonPath())) {
608 utility.setJsonPath(tempPath);
622 private static void buildHash(Utility utility) throws BundleException {
623 if (utility.isBuildHashFinish() || (!utility.getGenerateBuildHash())) {
626 String filePath = utility.getOutPath();
629 putBuildHash(utility, hash);
669 private static void putBuildHash(Utility utility, String hash) throws BundleException, IOException {
670 if (utility.isBuildHashFinish()) {
673 String jsonPath = utility.getJsonPath();
703 utility.setBuildHashFinish(true);
706 private boolean checkAppAtomicServiceCompressedSizeValid(Utility utility) {
707 if (!utility.getMode().equals(Utility.MODE_APP) &&
708 !utility.getMode().equals(Utility.MODE_FAST_APP)) {
712 File destFile = new File(utility.getOutPath());
748 private static boolean checkStageHap(Utility utility) throws BundleException {
749 Optional<String> optional = FileUtils.getFileContent(utility.getJsonPath());
904 private static boolean checkFAHap(Utility utility) throws BundleException {
905 Optional<String> optional = FileUtils.getFileContent(utility.getJsonPath());
923 * @param utility common data
926 private void compressHapMode(Utility utility) throws BundleException {
927 pathToFile(utility, utility.getJsonPath(), NULL_DIR_NAME, false);
929 pathToFile(utility, utility.getProfilePath(), NULL_DIR_NAME, false);
931 if (!utility.getIndexPath().isEmpty() && !utility.getModuleName().isEmpty()) {
932 String assetsPath = ASSETS_DIR_NAME + utility.getModuleName() + LINUX_FILE_SEPARATOR;
933 pathToFile(utility, utility.getIndexPath(), assetsPath, false);
936 if (!utility.getLibPath().isEmpty()) {
937 pathToFile(utility, utility.getLibPath(), LIBS_DIR_NAME, utility.isCompressNativeLibs());
940 if (!utility.getFilePath().isEmpty()) {
941 pathToFile(utility, utility.getFilePath(), NULL_DIR_NAME, false);
944 if (!utility.getResPath().isEmpty() && !utility.getModuleName().isEmpty()) {
945 String resPath = ASSETS_DIR_NAME + utility.getModuleName() + LINUX_FILE_SEPARATOR
947 String deviceTypes = utility.getDeviceType().replace("\"", "").trim();
952 pathToFile(utility, utility.getResPath(), resPath, false);
955 if (!utility.getResourcesPath().isEmpty() && !utility.getModuleName().isEmpty()) {
956 String resourcesPath = ASSETS_DIR_NAME + utility.getModuleName() + LINUX_FILE_SEPARATOR
958 pathToFile(utility, utility.getResourcesPath(), resourcesPath, false);
961 if (!utility.getRpcidPath().isEmpty()) {
963 pathToFile(utility, utility.getRpcidPath(), rpcidPath, false);
966 if (!utility.getPackInfoPath().isEmpty()) {
968 pathToFile(utility, utility.getPackInfoPath(), packInfoPath, false);
971 if (!utility.getAssetsPath().isEmpty()) {
972 pathToFile(utility, utility.getAssetsPath(), ASSETS_DIR_NAME, false);
975 if (!utility.getBinPath().isEmpty()) {
976 pathToFile(utility, utility.getBinPath(), NULL_DIR_NAME, false);
979 if (!utility.getFormatedDirList().isEmpty()) {
980 for (int i = 0; i < utility.getFormatedDirList().size(); ++i) {
981 String baseDir = new File(utility.getFormatedDirList().get(i)).getName() + File.separator;
982 pathToFile(utility, utility.getFormatedDirList().get(i), baseDir, false);
986 compressHapModeMultiple(utility);
992 * @param utility common data
995 private void compressHapModeForModule(Utility utility) throws BundleException {
996 pathToFile(utility, utility.getJsonPath(), NULL_DIR_NAME, false);
998 pathToFile(utility, utility.getProfilePath(), NULL_DIR_NAME, false);
1000 if (!utility.getIndexPath().isEmpty() && isModuleJSON(utility.getJsonPath())) {
1002 pathToFile(utility, utility.getIndexPath(), assetsPath, false);
1005 if (!utility.getLibPath().isEmpty()) {
1006 pathToFile(utility, utility.getLibPath(), LIBS_DIR_NAME, utility.isCompressNativeLibs());
1009 if (!utility.getANPath().isEmpty()) {
1010 pathToFile(utility, utility.getANPath(), AN_DIR_NAME, false);
1013 if (!utility.getAPPath().isEmpty()) {
1014 pathToFile(utility, utility.getAPPath(), AP_PATH_NAME, false);
1017 if (!utility.getFilePath().isEmpty()) {
1018 pathToFile(utility, utility.getFilePath(), NULL_DIR_NAME, false);
1021 if (!utility.getResPath().isEmpty() && !utility.getModuleName().isEmpty()) {
1022 String resPath = ASSETS_DIR_NAME + utility.getModuleName() + LINUX_FILE_SEPARATOR
1024 String deviceTypes = utility.getDeviceType().replace("\"", "").trim();
1029 pathToFile(utility, utility.getResPath(), resPath, false);
1032 if (!utility.getResourcesPath().isEmpty() && isModuleJSON(utility.getJsonPath())) {
1034 pathToFile(utility, utility.getResourcesPath(), resourcesPath, false);
1036 if (!utility.getJsPath().isEmpty() && isModuleJSON(utility.getJsonPath())) {
1038 pathToFile(utility, utility.getJsPath(), jsPath, false);
1041 if (!utility.getEtsPath().isEmpty() && isModuleJSON(utility.getJsonPath())) {
1043 pathToFile(utility, utility.getEtsPath(), etsPath, false);
1046 if (!utility.getHnpPath().isEmpty() && isModuleJSON(utility.getJsonPath())) {
1048 pathToFile(utility, utility.getHnpPath(), hnpPath, false);
1051 if (!utility.getRpcidPath().isEmpty()) {
1053 pathToFile(utility, utility.getRpcidPath(), rpcidPath, false);
1056 if (!utility.getAssetsPath().isEmpty()) {
1057 pathToFile(utility, utility.getAssetsPath(), ASSETS_DIR_NAME, false);
1060 if (!utility.getBinPath().isEmpty()) {
1061 pathToFile(utility, utility.getBinPath(), NULL_DIR_NAME, false);
1064 if (!utility.getPackInfoPath().isEmpty()) {
1065 pathToFile(utility, utility.getPackInfoPath(), NULL_DIR_NAME, false);
1069 if (!utility.getFormatedDirList().isEmpty()) {
1070 for (int i = 0; i < utility.getFormatedDirList().size(); ++i) {
1071 String baseDir = new File(utility.getFormatedDirList().get(i)).getName() + File.separator;
1072 pathToFile(utility, utility.getFormatedDirList().get(i), baseDir, false);
1075 if (!utility.getPkgContextPath().isEmpty()) {
1076 pathToFile(utility, utility.getPkgContextPath(), NULL_DIR_NAME, false);
1079 compressHapModeMultiple(utility);
1085 * @param utility common data
1088 private void compressHapModeMultiple(Utility utility) throws BundleException {
1089 for (String soPathItem : utility.getFormattedSoPathList()) {
1090 pathToFile(utility, soPathItem, SO_ARM64_DIR_NAME, false);
1093 if (utility.getFormattedSoPathList().size() == 0 && !utility.getSoDir().isEmpty()) {
1094 pathToFile(utility, utility.getSoDir(), SO_DIR_NAME, false);
1097 for (String soPathItem : utility.getFormattedAbilitySoPathList()) {
1098 pathToFile(utility, soPathItem, NULL_DIR_NAME, false);
1101 for (String dexPathItem : utility.getFormattedDexPathList()) {
1102 pathToFile(utility, dexPathItem, NULL_DIR_NAME, false);
1105 for (String abcPathItem : utility.getFormattedAbcPathList()) {
1106 pathToFile(utility, abcPathItem, NULL_DIR_NAME, false);
1109 for (String apkPathItem : utility.getFormattedApkPathList()) {
1110 pathToFile(utility, apkPathItem, NULL_DIR_NAME, false);
1113 for (String jarPathItem : utility.getFormattedJarPathList()) {
1114 pathToFile(utility, jarPathItem, NULL_DIR_NAME, false);
1117 for (String txtPathItem : utility.getFormattedTxtPathList()) {
1118 pathToFile(utility, txtPathItem, NULL_DIR_NAME, false);
1121 if (!utility.getSharedLibsPath().isEmpty()) {
1122 pathToFile(utility, utility.getSharedLibsPath(), SHARED_LIBS_DIR_NAME, utility.isCompressNativeLibs());
1129 * @param utility common data
1132 private void compressHarMode(Utility utility) throws BundleException {
1133 pathToFile(utility, utility.getJsonPath(), NULL_DIR_NAME, false);
1135 if (!utility.getLibPath().isEmpty()) {
1136 pathToFile(utility, utility.getLibPath(), LIBS_DIR_NAME, utility.isCompressNativeLibs());
1139 if (!utility.getResPath().isEmpty()) {
1140 pathToFile(utility, utility.getResPath(), RESOURCES_DIR_NAME, false);
1143 if (!utility.getResourcesPath().isEmpty()) {
1144 pathToFile(utility, utility.getResourcesPath(), RESOURCES_DIR_NAME, false);
1147 if (!utility.getAssetsPath().isEmpty()) {
1148 pathToFile(utility, utility.getAssetsPath(), ASSETS_DIR_NAME, false);
1151 for (String jarPathItem : utility.getFormattedJarPathList()) {
1152 pathToFile(utility, jarPathItem, NULL_DIR_NAME, false);
1155 for (String txtPathItem : utility.getFormattedTxtPathList()) {
1156 pathToFile(utility, txtPathItem, NULL_DIR_NAME, false);
1163 * @param utility common data
1166 private void compressAppMode(Utility utility) throws BundleException {
1168 File appOutputFile = new File(utility.getOutPath().trim());
1172 pathToFile(utility, utility.getJsonPath(), NULL_DIR_NAME, false);
1174 if (!utility.getCertificatePath().isEmpty()) {
1175 pathToFile(utility, utility.getCertificatePath(), NULL_DIR_NAME, false);
1178 if (!utility.getSignaturePath().isEmpty()) {
1179 pathToFile(utility, utility.getSignaturePath(), NULL_DIR_NAME, false);
1187 for (String hapPathItem : utility.getFormattedHapPathList()) {
1192 compressPackinfoIntoHap(hapPathItem, hapTempPath, utility.getPackInfoPath(),
1193 utility.getCompressLevel());
1204 for (String hspPathItem : utility.getFormattedHspPathList()) {
1209 compressPackinfoIntoHap(hspPathItem, hspTempPath, utility.getPackInfoPath(),
1210 utility.getCompressLevel());
1217 if (!checkHapIsValid(fileList, utility.getSharedApp())) {
1227 pathToFile(utility, hapPath, NULL_DIR_NAME, true);
1229 pathToFile(utility, hapPath, NULL_DIR_NAME, false);
1233 if (!utility.getEntryCardPath().isEmpty()) {
1234 String entryCardPath = ENTRYCARD_NAME + utility.getModuleName() + LINUX_FILE_SEPARATOR
1236 for (String entryCardPathItem : utility.getformattedEntryCardPathList()) {
1237 pathToFile(utility, entryCardPathItem, entryCardPath, true);
1241 if (!utility.getPackResPath().isEmpty()) {
1242 pathToFile(utility, utility.getPackResPath(), NULL_DIR_NAME, false);
1244 File file = new File(utility.getPackInfoPath());
1245 compressFile(utility, file, NULL_DIR_NAME, false);
1247 packEncryptJsonFile(utility);
1261 private void compressFastAppMode(Utility utility) throws BundleException {
1262 Path appOutPath = Paths.get(utility.getOutPath().trim());
1266 Path appPackInfo = Paths.get(utility.getPackInfoPath());
1268 for (String hapPath : utility.getFormattedHapPathList()) {
1270 Path hap = PackageUtil.pack(path, appPackInfo, tmpDir, utility.getCompressLevel());
1275 for (String hspPath : utility.getFormattedHspPathList()) {
1277 Path hsp = PackageUtil.pack(path, appPackInfo, tmpDir, utility.getCompressLevel());
1283 if (!checkHapIsValid(fileList, utility.getSharedApp())) {
1290 packFastApp(utility, fileList);
1301 private void packFastApp(Utility utility, List<String> fileList) throws BundleException {
1303 pathToFile(utility, utility.getPackInfoPath(), NULL_DIR_NAME, false);
1305 packEncryptJsonFile(utility);
1310 pathToFile(utility, hapPath, NULL_DIR_NAME, true);
1312 pathToFile(utility, hapPath, NULL_DIR_NAME, false);
1316 if (!utility.getEntryCardPath().isEmpty()) {
1317 String entryCardPath = ENTRYCARD_NAME + utility.getModuleName() + LINUX_FILE_SEPARATOR
1319 for (String entryCardPathItem : utility.getformattedEntryCardPathList()) {
1320 pathToFile(utility, entryCardPathItem, entryCardPath, true);
1323 if (!utility.getPackResPath().isEmpty()) {
1324 pathToFile(utility, utility.getPackResPath(), NULL_DIR_NAME, false);
1327 if (!utility.getCertificatePath().isEmpty()) {
1328 pathToFile(utility, utility.getCertificatePath(), NULL_DIR_NAME, false);
1330 if (!utility.getSignaturePath().isEmpty()) {
1331 pathToFile(utility, utility.getSignaturePath(), NULL_DIR_NAME, false);
1338 * @param utility common data
1341 private void compressAppModeForMultiProject(Utility utility) throws BundleException {
1343 File appOutputFile = new File(utility.getOutPath().trim());
1354 String finalPackInfoStr = disposeApp(utility, seletedHaps, tempSelectedHapPath);
1356 finalPackInfoStr = disposeHap(utility, seletedHaps, tempSelectedHapPath, finalPackInfoStr);
1367 compressPackinfoIntoHap(hapPathItem, hapTempPath, finalPackInfoPath, utility.getCompressLevel());
1376 pathToFile(utility, hapPath, NULL_DIR_NAME, false);
1379 compressFile(utility, file, NULL_DIR_NAME, false);
1381 packEncryptJsonFile(utility);
1395 * @param utility common data
1397 private void hapAddition(Utility utility) {
1398 File hapPath = new File(utility.getAbsoluteHapPath());
1401 File destFile = new File(utility.getOutPath() + LINUX_FILE_SEPARATOR + hapFileName);
1413 String hapPathOri = utility.getHapPath();
1415 copyHapFile(utility, backName);
1420 compressHapAddition(utility, hapAdditionPath);
1435 private void copyHapFile(Utility utility, String backName) throws IOException, BundleException {
1436 File hapFile = new File(utility.getAbsoluteHapPath());
1441 utility.setHapPath(backName);
1483 private static void setUtilityParameter(String hapAdditionPath, Utility utility) throws IOException {
1491 utility.setEtsPath(filePath);
1494 utility.setLibPath(filePath);
1497 utility.setANPath(filePath);
1500 utility.setAPPath(filePath);
1503 utility.setResourcesPath(filePath);
1506 utility.setJsPath(filePath);
1509 utility.setAssetsPath(filePath);
1512 utility.setSoDir(filePath);
1515 utility.setSharedLibsPath(filePath);
1518 utility.setJsonPath(filePath);
1521 utility.setIndexPath(filePath);
1524 utility.setPackInfoPath(filePath);
1531 private void compressHapAddition(Utility utility, String hapAdditionPath) throws BundleException {
1534 unpackHap(utility.getHapPath(), hapAdditionPath);
1538 String data = readerFile(utility.getJsonPath());
1557 setUtilityParameter(hapAdditionPath, utility);
1563 if (utility.getHapPath().endsWith(HAP_SUFFIX)) {
1564 compressHap(utility);
1565 } else if (utility.getHapPath().endsWith(HSP_SUFFIX)) {
1566 compressHsp(utility);
1577 * @param utility is common data
1582 private static String disposeApp(Utility utility, List<String> seletedHaps,
1585 if (utility.getFormattedAppList().isEmpty()) {
1590 for (String appPath : utility.getFormattedAppList()) {
1711 * @param utility is common data
1717 private static String disposeHap(Utility utility, List<String> seletedHaps, String tempDir,
1720 if (utility.getFormattedHapList().isEmpty()) {
1723 for (String hapPath : utility.getFormattedHapList()) {
1845 * @param utility common data
1848 private void compressPackResMode(Utility utility) throws BundleException {
1849 if (!utility.getPackInfoPath().isEmpty()) {
1850 parsePackInfoJsonFile(utility, utility.getPackInfoPath());
1851 File file = new File(utility.getPackInfoPath());
1852 infoSpecialProcess(utility, file);
1854 if (!utility.getEntryCardPath().isEmpty()) {
1855 getFileList(utility.getEntryCardPath());
1874 if (!isPicturing(filePicturingName, utility)) {
1899 pathToFileResMode(utility, utility.getEntryCardPath(), ENTRYCARD_NAME, false);
2062 * @param utility common data
2065 private boolean isPicturing(String name, Utility utility) {
2080 if (!utility.getFormNameList().contains(formName)) {
2082 utility.getFormNameList().toString() + ".");
2159 * @param utility common data
2165 private void pathToFile(Utility utility, String path, String baseDir, boolean isCompression)
2171 compressNativeLibsParallel(path, baseDir, utility.getCompressLevel());
2182 compressDirectory(utility, file, baseDir, isCompression);
2184 compressFile(utility, file, baseDir, isCompression);
2186 compressFile(utility, file, baseDir, isCompression);
2190 compressFile(utility, fileItem, baseDir, isCompression);
2251 * @param utility common data
2257 private void pathToFileResMode(Utility utility, String path, String baseDir, boolean isCompression)
2274 compressDirectory(utility, file, baseDir, isCompression);
2276 compressFile(utility, file, baseDir, isCompression);
2278 compressFile(utility, file, baseDir, isCompression);
2282 compressFile(utility, fileItem, baseDir, isCompression);
2289 * @param utility common data
2295 private void compressDirectory(Utility utility, File dir, String baseDir, boolean isCompression)
2303 compressDirectory(utility, file, baseDir + dir.getName() + File.separator, isCompression);
2305 compressFile(utility, file, baseDir + dir.getName() + File.separator, isCompression);
2418 * @param utility common data
2424 private void compressFile(Utility utility, File srcFile, String baseDir, boolean isCompression)
2437 if (jsonSpecialProcess(utility, srcFile, zipEntry)) {
2452 CRC32 crc = getCrcFromFile(utility, srcFile);
2513 * @param utility common data
2518 private CRC32 getCrcFromFile(Utility utility, File file) throws BundleException {
2542 private void parsePackInfoJsonFile(Utility utility, String jsonPath)
2554 utility.addFormNameList(formName);
2562 private void infoSpecialProcess(Utility utility, File srcFile)
2574 parsePackModuleName(bufferedReader, utility);
2576 parseDeviceType(bufferedReader, utility);
2601 * @param utility common data
2606 private boolean jsonSpecialProcess(Utility utility, File srcFile, ZipArchiveEntry entry) {
2617 Optional<String> optional = FileUtils.getFileContent(utility.getJsonPath());
2619 String jsonName = new File(utility.getJsonPath()).getName().toLowerCase(Locale.ENGLISH);
2621 parseCompressNativeLibs(bufferedReader, utility);
2622 utility.setModuleName(ModuleJsonUtil.parseFaModuleName(jsonString));
2624 utility.setIsCompressNativeLibs(ModuleJsonUtil.stageIsCompressNativeLibs(jsonString));
2625 utility.setModuleName(ModuleJsonUtil.parseStageModuleName(jsonString));
2627 utility.setModuleName(ModuleJsonUtil.parsePatchModuleName(jsonString));
2630 parseDeviceType(bufferedReader, utility);
2674 * @param utility common data
2677 private void parsePackModuleName(BufferedReader bufferedReader, Utility utility) throws BundleException {
2688 getModuleNameFromString(lineStr, utility);
2701 * @param utility common data
2704 private void parsePackFormName(BufferedReader bufferedReader, Utility utility) throws BundleException {
2718 getNameFromString(lineStr, utility);
2732 * @param utility common data
2735 private void getNameFromString(String lineStr, Utility utility) throws BundleException {
2751 utility.addFormNameList(formName);
2763 * @param utility common data
2766 private void getModuleNameFromString(String lineStr, Utility utility) throws BundleException {
2780 utility.setModuleName(moduleName);
2787 private void parseCompressNativeLibs(BufferedReader bufferedReader, Utility utility) throws BundleException {
2793 utility.setIsCompressNativeLibs(true);
2835 * @param utility common data
2838 private void parseDeviceType(BufferedReader bufferedReader, Utility utility) throws BundleException {
2852 utility.setDeviceType(lineStr);
3017 * @param utility common data
3020 private void compressHQFMode(Utility utility) throws BundleException {
3021 pathToFile(utility, utility.getJsonPath(), NULL_DIR_NAME, false);
3023 if (!utility.getEtsPath().isEmpty()) {
3024 pathToFile(utility, utility.getEtsPath(), ETS_PATH, false);
3026 if (!utility.getLibPath().isEmpty()) {
3027 pathToFile(utility, utility.getLibPath(), LIBS_DIR_NAME, false);
3029 if (!utility.getResourcesPath().isEmpty()) {
3030 pathToFile(utility, utility.getResourcesPath(), RESOURCES_DIR_NAME, false);
3037 * @param utility common data
3040 private void compressAPPQFMode(Utility utility) throws BundleException {
3041 List<String> fileList = utility.getFormatedHQFList();
3047 pathToFile(utility, hapPath, NULL_DIR_NAME, false);
3069 private void compressHSPMode(Utility utility) throws BundleException {
3070 pathToFile(utility, utility.getJsonPath(), NULL_DIR_NAME, false);
3072 pathToFile(utility, utility.getProfilePath(), NULL_DIR_NAME, false);
3074 if (!utility.getIndexPath().isEmpty() && isModuleJSON(utility.getJsonPath())) {
3076 pathToFile(utility, utility.getIndexPath(), assetsPath, false);
3079 if (!utility.getLibPath().isEmpty()) {
3080 pathToFile(utility, utility.getLibPath(), LIBS_DIR_NAME, utility.isCompressNativeLibs());
3083 if (!utility.getANPath().isEmpty()) {
3084 pathToFile(utility, utility.getANPath(), AN_DIR_NAME, false);
3087 if (!utility.getAPPath().isEmpty()) {
3088 pathToFile(utility, utility.getAPPath(), AP_PATH_NAME, false);
3091 if (!utility.getFilePath().isEmpty()) {
3092 pathToFile(utility, utility.getFilePath(), NULL_DIR_NAME, false);
3095 if (!utility.getResPath().isEmpty() && !utility.getModuleName().isEmpty()) {
3096 String resPath = ASSETS_DIR_NAME + utility.getModuleName() + LINUX_FILE_SEPARATOR
3099 utility.getDeviceType().replace(SEMICOLON, EMPTY_STRING).trim()) ||
3101 utility.getDeviceType().replace(SEMICOLON, EMPTY_STRING).trim())) {
3104 pathToFile(utility, utility.getResPath(), resPath, false);
3107 if (!utility.getResourcesPath().isEmpty() && isModuleJSON(utility.getJsonPath())) {
3109 pathToFile(utility, utility.getResourcesPath(), resourcesPath, false);
3111 if (!utility.getJsPath().isEmpty() && isModuleJSON(utility.getJsonPath())) {
3113 pathToFile(utility, utility.getJsPath(), jsPath, false);
3116 if (!utility.getEtsPath().isEmpty() && isModuleJSON(utility.getJsonPath())) {
3118 pathToFile(utility, utility.getEtsPath(), etsPath, false);
3121 if (!utility.getRpcidPath().isEmpty()) {
3123 pathToFile(utility, utility.getRpcidPath(), rpcidPath, false);
3126 if (!utility.getAssetsPath().isEmpty()) {
3127 pathToFile(utility, utility.getAssetsPath(), ASSETS_DIR_NAME, false);
3130 if (!utility.getBinPath().isEmpty()) {
3131 pathToFile(utility, utility.getBinPath(), NULL_DIR_NAME, false);
3134 if (!utility.getPackInfoPath().isEmpty()) {
3135 pathToFile(utility, utility.getPackInfoPath(), NULL_DIR_NAME, false);
3139 if (!utility.getFormatedDirList().isEmpty()) {
3140 for (int i = 0; i < utility.getFormatedDirList().size(); ++i) {
3141 String baseDir = new File(utility.getFormatedDirList().get(i)).getName() + File.separator;
3142 pathToFile(utility, utility.getFormatedDirList().get(i), baseDir, false);
3145 if (!utility.getPkgContextPath().isEmpty()) {
3146 pathToFile(utility, utility.getPkgContextPath(), NULL_DIR_NAME, false);
3149 compressHapModeMultiple(utility);
3170 private void versionNormalize(Utility utility) {
3173 for (String hapPath : utility.getFormattedHapList()) {
3175 tempDir = Files.createTempDirectory(Paths.get(utility.getOutPath()), "temp");
3192 util = parseAndModifyModuleJson(moduleJsonPath, utility);
3195 util = parseAndModifyConfigJson(configJsonPath, utility);
3202 parseAndModifyPackInfo(packInfoPath, utility);
3205 verifyModuleVersion(util, utility);
3208 String modifiedHapPath = Paths.get(utility.getOutPath()) +
3219 writeVersionRecord(utils, utility.getOutPath());
3222 private VersionNormalizeUtil parseAndModifyModuleJson(String jsonFilePath, Utility utility)
3249 appObject.put(VERSION_CODE, utility.getVersionCode());
3250 appObject.put(VERSION_NAME, utility.getVersionName());
3259 private void parseAndModifyPackInfo(String packInfoPath, Utility utility)
3282 versionObject.put(CODE, utility.getVersionCode());
3283 versionObject.put(NAME, utility.getVersionName());
3309 private VersionNormalizeUtil parseAndModifyConfigJson(String jsonFilePath, Utility utility)
3342 versionObj.put(CODE, utility.getVersionCode());
3343 versionObj.put(NAME, utility.getVersionName());
3354 Utility utility = new Utility();
3355 utility.setOutPath(zipFilePath);
3357 utility.setMode(Utility.MODE_HAP);
3359 utility.setMode(Utility.MODE_HSP);
3368 utility.setEtsPath(filePath);
3371 utility.setHnpPath(filePath);
3374 utility.setLibPath(filePath);
3377 utility.setANPath(filePath);
3380 utility.setAPPath(filePath);
3383 utility.setResourcesPath(filePath);
3386 utility.setJsPath(filePath);
3389 utility.setAssetsPath(filePath);
3392 utility.setSoDir(filePath);
3395 utility.setSharedLibsPath(filePath);
3398 utility.setJsonPath(filePath);
3401 utility.setJsonPath(filePath);
3404 utility.setIndexPath(filePath);
3407 utility.setPackInfoPath(filePath);
3410 utility.setRpcid(filePath);
3413 utility.setPkgContextPath(filePath);
3418 compressProcess(utility);
3442 private static void verifyModuleVersion(VersionNormalizeUtil versionNormalizeUtil, Utility utility)
3444 if (versionNormalizeUtil.getOriginVersionCode() > utility.getVersionCode()) {
3449 } else if (versionNormalizeUtil.getOriginVersionCode() == utility.getVersionCode()) {
3453 if (versionNormalizeUtil.getOriginVersionName().equals(utility.getVersionName())) {
3507 private void packEncryptJsonFile(Utility utility) throws BundleException {
3508 if (!utility.getEncryptPath().isEmpty()) {
3509 pathToFile(utility, utility.getEncryptPath(), NULL_DIR_NAME, false);