169570cc8Sopenharmony_ci/*
269570cc8Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
369570cc8Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
469570cc8Sopenharmony_ci * you may not use this file except in compliance with the License.
569570cc8Sopenharmony_ci * You may obtain a copy of the License at
669570cc8Sopenharmony_ci *
769570cc8Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
869570cc8Sopenharmony_ci *
969570cc8Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1069570cc8Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1169570cc8Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1269570cc8Sopenharmony_ci * See the License for the specific language governing permissions and
1369570cc8Sopenharmony_ci * limitations under the License.
1469570cc8Sopenharmony_ci */
1569570cc8Sopenharmony_ci
1669570cc8Sopenharmony_ci#ifndef HNP_INSTALLER_H
1769570cc8Sopenharmony_ci#define HNP_INSTALLER_H
1869570cc8Sopenharmony_ci
1969570cc8Sopenharmony_ci#include "hnp_base.h"
2069570cc8Sopenharmony_ci
2169570cc8Sopenharmony_ci#ifdef __cplusplus
2269570cc8Sopenharmony_ciextern "C" {
2369570cc8Sopenharmony_ci#endif
2469570cc8Sopenharmony_ci
2569570cc8Sopenharmony_ci// 0x801301 组装安装路径失败
2669570cc8Sopenharmony_ci#define HNP_ERRNO_INSTALLER_GET_HNP_PATH_FAILED            HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x1)
2769570cc8Sopenharmony_ci
2869570cc8Sopenharmony_ci// 0x801302 获取安装绝对路径失败
2969570cc8Sopenharmony_ci#define HNP_ERRNO_INSTALLER_GET_REALPATH_FAILED            HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x2)
3069570cc8Sopenharmony_ci
3169570cc8Sopenharmony_ci// 0x801303 ELF文件验签失败
3269570cc8Sopenharmony_ci#define HNP_ERRNO_INSTALLER_CODE_SIGN_APP_FAILED           HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x3)
3369570cc8Sopenharmony_ci
3469570cc8Sopenharmony_ci// 0x801304 安装的包已存在
3569570cc8Sopenharmony_ci#define HNP_ERRNO_INSTALLER_PATH_IS_EXIST                  HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x4)
3669570cc8Sopenharmony_ci
3769570cc8Sopenharmony_ci// 0x801305 获取卸载路径失败
3869570cc8Sopenharmony_ci#define HNP_ERRNO_UNINSTALLER_HNP_PATH_NOT_EXIST           HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x5)
3969570cc8Sopenharmony_ci
4069570cc8Sopenharmony_ci// 0x801306 安装命令参数uid错误
4169570cc8Sopenharmony_ci#define HNP_ERRNO_INSTALLER_ARGV_UID_INVALID               HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x6)
4269570cc8Sopenharmony_ci
4369570cc8Sopenharmony_ci// 0x801307 restorecon 安装目录失败
4469570cc8Sopenharmony_ci#define HNP_ERRNO_INSTALLER_RESTORECON_HNP_PATH_FAIL       HNP_ERRNO_COMMON(HNP_MID_INSTALLER, 0x7)
4569570cc8Sopenharmony_ci
4669570cc8Sopenharmony_ci#define HNP_DEFAULT_INSTALL_ROOT_PATH "/data/app/el1/bundle"
4769570cc8Sopenharmony_ci#define HNP_SANDBOX_BASE_PATH "/data/service/hnp"
4869570cc8Sopenharmony_ci
4969570cc8Sopenharmony_ci/* hap安装信息 */
5069570cc8Sopenharmony_citypedef struct HapInstallInfoStru {
5169570cc8Sopenharmony_ci    int uid;                                  // 用户id
5269570cc8Sopenharmony_ci    char *hapPackageName;                     // app名称
5369570cc8Sopenharmony_ci    char *hnpRootPath;                        // hnp安装目录
5469570cc8Sopenharmony_ci    char *hapPath;                            // hap目录
5569570cc8Sopenharmony_ci    char *abi;                                // 系统abi路径
5669570cc8Sopenharmony_ci    bool isForce;                             // 是否强制安装
5769570cc8Sopenharmony_ci} HapInstallInfo;
5869570cc8Sopenharmony_ci
5969570cc8Sopenharmony_ci/* hnp安装信息 */
6069570cc8Sopenharmony_citypedef struct HnpInstallInfoStru {
6169570cc8Sopenharmony_ci    HapInstallInfo *hapInstallInfo;           // hap安装信息
6269570cc8Sopenharmony_ci    bool isPublic;                            // 是否公有
6369570cc8Sopenharmony_ci    char hnpBasePath[MAX_FILE_PATH_LEN];      // hnp安装基础路径,public为 xxx/{uid}/hnppublic,private为xxx/{uid}/hnp/{hap}
6469570cc8Sopenharmony_ci    char hnpSoftwarePath[MAX_FILE_PATH_LEN];  // 软件安装路径,为hnpBasePath/{name}.org/
6569570cc8Sopenharmony_ci    char hnpVersionPath[MAX_FILE_PATH_LEN];   // 软件安装版本路径,为hnpBasePath/{name}.org/{name}_{version}
6669570cc8Sopenharmony_ci    char hnpSignKeyPrefix[MAX_FILE_PATH_LEN]; // hnp包验签前缀,hnp/{abi}/xxxx/xxx.hnp
6769570cc8Sopenharmony_ci} HnpInstallInfo;
6869570cc8Sopenharmony_ci
6969570cc8Sopenharmony_ciint HnpCmdInstall(int argc, char *argv[]);
7069570cc8Sopenharmony_ci
7169570cc8Sopenharmony_ciint HnpCmdUnInstall(int argc, char *argv[]);
7269570cc8Sopenharmony_ci
7369570cc8Sopenharmony_ci#ifdef __cplusplus
7469570cc8Sopenharmony_ci}
7569570cc8Sopenharmony_ci#endif
7669570cc8Sopenharmony_ci
7769570cc8Sopenharmony_ci#endif