From df3b38af819ca8506235bae039442ae9639dddcb Mon Sep 17 00:00:00 2001 From: "fenghao (P)" Date: Sat, 18 Sep 2021 17:14:19 +0800 Subject: [PATCH] =?UTF-8?q?IssueNo:#I4AW6K=20Description:=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E6=8B=86=E8=A7=A3=E5=8D=95=E4=B8=AAhap=E5=8C=85?= =?UTF-8?q?=E7=9A=84=E6=8E=A5=E5=8F=A3unpackHap=20Sig:aafwk=20Feature=20or?= =?UTF-8?q?=20Bugfix:=20Bugfig=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fenghao (P) --- adapter/ohos/UncompressEntrance.java | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/adapter/ohos/UncompressEntrance.java b/adapter/ohos/UncompressEntrance.java index fa15679b..2318bfcf 100644 --- a/adapter/ohos/UncompressEntrance.java +++ b/adapter/ohos/UncompressEntrance.java @@ -132,6 +132,47 @@ public class UncompressEntrance { return true; } + /** + * Unpack the hap. + * + * @param hapPath Indicates the hap path. + * @param outPath Indicates the out path. + * @param unpackApk Indicates whether to decompress the apk file in the hap.The default value is {@code false}, + * not unpack the apk file. + * @return Return the unpack result. + */ + public static boolean unpackHap(String hapPath, String outPath, boolean unpackApk) { + if (hapPath == null || hapPath.isEmpty()) { + LOG.error("UncompressEntrance::unpackHap hapPath is invalid!"); + return false; + } + + if (outPath == null || outPath.isEmpty()) { + LOG.error("UncompressEntrance::unpackHap outPath is invalid!"); + return false; + } + + Utility utility = new Utility(); + utility.setMode(Utility.MODE_HAP); + utility.setHapPath(hapPath); + utility.setDeviceType(""); + utility.setOutPath(outPath); + utility.setUnpackApk(String.valueOf(unpackApk)); + utility.setForceRewrite("true"); + + if (!UncompressVerify.commandVerify(utility)) { + LOG.error("CompressEntrance::unpackHap verity failed"); + return false; + } + + if (!Uncompress.unpackageProcess(utility)) { + LOG.error("UncompressEntrance::unpackageProcess failed"); + return false; + } + + return true; + } + /** * Parse the app. * -- Gitee