mirror of
https://github.com/openharmony/bundlemanager_app_domain_verify.git
synced 2026-07-01 22:34:03 -04:00
!224 merge master into master
新增预装应用类别
Created-by: zhangrn98
Commit-by: zhangrn98
Merged-by: openharmony_ci
Description: ### 一、内容说明(相关的Issue)
### 二、建议测试周期和提测地址
建议测试完成时间:xxxx.xx.xx
投产上线时间:xxxx.xx.xx
提测地址:CI环境/压测环境
测试账号:
### 三、变更内容
* 3.1 关联PR列表
* 3.2 数据库和部署说明
1. 常规更新
2. 重启unicorn
3. 重启sidekiq
4. 迁移任务:是否有迁移任务,没有写 "无"
5. rake脚本:`bundle exec xxx RAILS_ENV = production`;没有写 "无"
* 3.4 其他技术优化内容(做了什么,变更了什么)
- 重构了 xxxx 代码
- xxxx 算法优化
* 3.5 废弃通知(什么字段、方法弃用?)
* 3.6 后向不兼容变更(是否有无法向后兼容的变更?)
### 四、研发自测点(自测哪些?冒烟用例全部自测?)
自测测试结论:
### 五、测试关注点(需要提醒QA重点关注的、可能会忽略的地方)
检查点:
| 需求名称 | 是否影响xx公共模块 | 是否需要xx功能 | 需求升级是否依赖其他子产品 |
|------|------------|----------|---------------|
| xxx | 否 | 需要 | 不需要 |
| | | | |
接口测试:
性能测试:
并发测试:
其他:
See merge request: openharmony/bundlemanager_app_domain_verify!224
This commit is contained in:
@@ -30,6 +30,7 @@ public:
|
||||
static bool GetBundleAbilityInfos(const std::string& bundleName, std::vector<AbilityInfo>& abilityInfos);
|
||||
static bool QueryAbilityInfos(
|
||||
const std::string& url, bool withDefault, std::vector<AbilityInfo>& abilityInfos, bool& findDefaultApp);
|
||||
static bool IsPreInstalledApp(const std::string& bundleName);
|
||||
|
||||
private:
|
||||
static sptr<AppExecFwk::IBundleMgr> GetBundleMgrProxy();
|
||||
|
||||
@@ -175,5 +175,31 @@ bool BundleInfoQuery::QueryAbilityInfos(
|
||||
abilityInfos.size(), findDefaultApp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool BundleInfoQuery::IsPreInstalledApp(const std::string& bundleName)
|
||||
{
|
||||
APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MODULE_COMMON, "called");
|
||||
sptr<AppExecFwk::IBundleMgr> bundleMgrProxy = BundleInfoQuery::GetBundleMgrProxy();
|
||||
if (bundleMgrProxy == nullptr) {
|
||||
APP_DOMAIN_VERIFY_HILOGE(APP_DOMAIN_VERIFY_MODULE_COMMON, "bundleMgrProxy is nullptr.");
|
||||
return false;
|
||||
}
|
||||
int32_t userId = BundleInfoQuery::GetCurrentAccountId();
|
||||
if (userId < 0) {
|
||||
return false;
|
||||
}
|
||||
OHOS::AppExecFwk::BundleInfo bundleInfo;
|
||||
// use sa identity
|
||||
std::string identity = IPCSkeleton::ResetCallingIdentity();
|
||||
auto ret = bundleMgrProxy->GetBundleInfoV9(bundleName,
|
||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO), bundleInfo, userId);
|
||||
IPCSkeleton::SetCallingIdentity(identity);
|
||||
if (ret != ERR_OK) {
|
||||
APP_DOMAIN_VERIFY_HILOGE(APP_DOMAIN_VERIFY_MODULE_COMMON, "GetBundleInfo failed, ret: %{public}d.", ret);
|
||||
return false;
|
||||
}
|
||||
// Check if the app is pre-installed (system app)
|
||||
return bundleInfo.isPreInstallApp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,14 +26,14 @@ namespace AppDomainVerify {
|
||||
class DomainVerifier {
|
||||
public:
|
||||
static InnerVerifyStatus VerifyHost(OHOS::NetStack::HttpClient::ResponseCode responseCode,
|
||||
const std::string &assetJsonsStr, AppVerifyBaseInfo &appVerifyBaseInfo);
|
||||
const std::string& assetJsonsStr, AppVerifyBaseInfo& appVerifyBaseInfo);
|
||||
|
||||
private:
|
||||
static InnerVerifyStatus GetVerifyStatusFromHttpError(OHOS::NetStack::HttpClient::ResponseCode responseCode);
|
||||
static InnerVerifyStatus VerifyHostWithAppIdentifier(const AssetJsonObj &assetJsonObj,
|
||||
AppVerifyBaseInfo &appVerifyBaseInfo);
|
||||
static InnerVerifyStatus VerifyHostWithBundleName(const AssetJsonObj &assetJsonObj,
|
||||
AppVerifyBaseInfo &appVerifyBaseInfo);
|
||||
static InnerVerifyStatus VerifyHostWithAppIdentifier(
|
||||
const AssetJsonObj& assetJsonObj, AppVerifyBaseInfo& appVerifyBaseInfo);
|
||||
static InnerVerifyStatus VerifyHostWithBundleName(
|
||||
const AssetJsonObj& assetJsonObj, AppVerifyBaseInfo& appVerifyBaseInfo);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "domain_verifier.h"
|
||||
#include "app_domain_verify_hilog.h"
|
||||
#include "domain_json_util.h"
|
||||
#include "bundle_info_query.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppDomainVerify {
|
||||
@@ -24,7 +25,15 @@ InnerVerifyStatus DomainVerifier::VerifyHost(OHOS::NetStack::HttpClient::Respons
|
||||
{
|
||||
APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_AGENT_MODULE_SERVICE, "called");
|
||||
if (responseCode != OHOS::NetStack::HttpClient::ResponseCode::OK) {
|
||||
return GetVerifyStatusFromHttpError(responseCode);
|
||||
InnerVerifyStatus status = GetVerifyStatusFromHttpError(responseCode);
|
||||
if (status == InnerVerifyStatus::FAILURE_HTTP_UNKNOWN &&
|
||||
BundleInfoQuery::IsPreInstalledApp(appVerifyBaseInfo.bundleName)) {
|
||||
APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_AGENT_MODULE_SERVICE,
|
||||
"pre installed app, bundleName: %{public}s", appVerifyBaseInfo.bundleName.c_str());
|
||||
return InnerVerifyStatus::PRE_INSTALLED;
|
||||
} else {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
AssetJsonObj assetJsonObj;
|
||||
if (JsonUtil::Parse(assetJsonsStr, assetJsonObj)) {
|
||||
|
||||
@@ -76,13 +76,14 @@ private:
|
||||
// with check caller's bundleName and appIdentifier
|
||||
int QueryVerifiedBundleWithDomains(std::string& bundleName, std::vector<std::string>& domains);
|
||||
void SendVerifiedEvent(const std::string& bundleName, const VerifyResultInfo& verifyResultInfo);
|
||||
int QueryVerifiedBundleWithDomainsByAppIdentifer(const std::string& appIdentifer,
|
||||
std::string& bundleName, std::vector<std::string>& domains);
|
||||
int QueryVerifiedBundleWithDomainsByAppIdentifer(
|
||||
const std::string& appIdentifer, std::string& bundleName, std::vector<std::string>& domains);
|
||||
void FilterAbilitiesInner(std::string hostVerifyKey,
|
||||
const std::vector<OHOS::AppExecFwk::AbilityInfo>& originAbilityInfos,
|
||||
std::vector<OHOS::AppExecFwk::AbilityInfo>& filteredAbilityInfos);
|
||||
bool ResetDBSecurityByPath();
|
||||
bool IsExistDir(const std::string& dirPath);
|
||||
|
||||
private:
|
||||
std::shared_ptr<AppDetailsDataMgr> appDetailsDataMgr_ = nullptr;
|
||||
bool InitConfigMgr();
|
||||
|
||||
@@ -39,7 +39,9 @@ enum InnerVerifyStatus {
|
||||
|
||||
FAILURE_CONFIG = 8,
|
||||
|
||||
FORBIDDEN_FOREVER = 9
|
||||
FORBIDDEN_FOREVER = 9,
|
||||
|
||||
PRE_INSTALLED = 10
|
||||
};
|
||||
|
||||
static std::unordered_map<InnerVerifyStatus, std::string> InnerVerifyStatusMap = {
|
||||
@@ -52,7 +54,8 @@ static std::unordered_map<InnerVerifyStatus, std::string> InnerVerifyStatusMap =
|
||||
{ FAILURE_HTTP_UNKNOWN, "http_unknown" },
|
||||
{ FAILURE_TIMEOUT, "timeout" },
|
||||
{ FAILURE_CONFIG, "config_error" },
|
||||
{ FORBIDDEN_FOREVER, "forbidden_forever" }
|
||||
{ FORBIDDEN_FOREVER, "forbidden_forever" },
|
||||
{ PRE_INSTALLED, "pre_installed" }
|
||||
};
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -132,7 +132,8 @@ void AppDomainVerifyMgrService::FilterAbilitiesInner(std::string hostVerifyKey,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itr->second.status == InnerVerifyStatus::STATE_SUCCESS) {
|
||||
if (itr->second.status == InnerVerifyStatus::STATE_SUCCESS ||
|
||||
itr->second.status == InnerVerifyStatus::PRE_INSTALLED) {
|
||||
auto ability = *it;
|
||||
auto priority = itr->second.priority;
|
||||
auto tuple = std::make_tuple(ability, priority);
|
||||
|
||||
Reference in New Issue
Block a user