1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef HNP_INSTALLER_H
17#define HNP_INSTALLER_H
18
19#include "hnp_base.h"
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25// 0x801301 组装安装路径失败
26#define HNP_ERRNO_INSTALLER_GET_HNP_PATH_FAILED            HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x1)
27
28// 0x801302 获取安装绝对路径失败
29#define HNP_ERRNO_INSTALLER_GET_REALPATH_FAILED            HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x2)
30
31// 0x801303 ELF文件验签失败
32#define HNP_ERRNO_INSTALLER_CODE_SIGN_APP_FAILED           HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x3)
33
34// 0x801304 安装的包已存在
35#define HNP_ERRNO_INSTALLER_PATH_IS_EXIST                  HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x4)
36
37// 0x801305 获取卸载路径失败
38#define HNP_ERRNO_UNINSTALLER_HNP_PATH_NOT_EXIST           HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x5)
39
40// 0x801306 安装命令参数uid错误
41#define HNP_ERRNO_INSTALLER_ARGV_UID_INVALID               HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x6)
42
43// 0x801307 restorecon 安装目录失败
44#define HNP_ERRNO_INSTALLER_RESTORECON_HNP_PATH_FAIL       HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x7)
45
46#define HNP_DEFAULT_INSTALL_ROOT_PATH "/data/app/el1/bundle"
47#define HNP_SANDBOX_BASE_PATH "/data/service/hnp"
48
49/* hap安装信息 */
50typedef struct HapInstallInfoStru {
51    int uid;                                  // 用户id
52    char *hapPackageName;                     // app名称
53    char *hnpRootPath;                        // hnp安装目录
54    char *hapPath;                            // hap目录
55    char *abi;                                // 系统abi路径
56    bool isForce;                             // 是否强制安装
57} HapInstallInfo;
58
59/* hnp安装信息 */
60typedef struct HnpInstallInfoStru {
61    HapInstallInfo *hapInstallInfo;           // hap安装信息
62    bool isPublic;                            // 是否公有
63    char hnpBasePath[MAX_FILE_PATH_LEN];      // hnp安装基础路径,public为 xxx/{uid}/hnppublic,private为xxx/{uid}/hnp/{hap}
64    char hnpSoftwarePath[MAX_FILE_PATH_LEN];  // 软件安装路径,为hnpBasePath/{name}.org/
65    char hnpVersionPath[MAX_FILE_PATH_LEN];   // 软件安装版本路径,为hnpBasePath/{name}.org/{name}_{version}
66    char hnpSignKeyPrefix[MAX_FILE_PATH_LEN]; // hnp包验签前缀,hnp/{abi}/xxxx/xxx.hnp
67} HnpInstallInfo;
68
69int HnpCmdInstall(int argc, char *argv[]);
70
71int HnpCmdUnInstall(int argc, char *argv[]);
72
73#ifdef __cplusplus
74}
75#endif
76
77#endif