!228 merge master into master

在AppVerifyBaseInfo结构中添加isPreinstalled字段

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!228
This commit is contained in:
openharmony_ci
2026-03-18 12:21:48 +08:00
8 changed files with 58 additions and 21 deletions
+17 -11
View File
@@ -184,22 +184,28 @@ bool BundleInfoQuery::IsPreInstalledApp(const std::string& bundleName)
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::vector<AppExecFwk::PreinstalledApplicationInfo> preinstalledApplicationInfos;
std::string identity = IPCSkeleton::ResetCallingIdentity();
auto ret = bundleMgrProxy->GetBundleInfoV9(bundleName,
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO), bundleInfo, userId);
APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MODULE_COMMON, "GetAllPreinstalledApplicationInfos called");
auto ret = bundleMgrProxy->GetAllPreinstalledApplicationInfos(preinstalledApplicationInfos);
APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MODULE_COMMON, "GetAllPreinstalledApplicationInfos called end");
IPCSkeleton::SetCallingIdentity(identity);
if (ret != ERR_OK) {
APP_DOMAIN_VERIFY_HILOGE(APP_DOMAIN_VERIFY_MODULE_COMMON, "GetBundleInfo failed, ret: %{public}d.", ret);
APP_DOMAIN_VERIFY_HILOGE(
APP_DOMAIN_VERIFY_MODULE_COMMON, "GetAllPreinstalledApplicationInfos failed, ret: %{public}d.", ret);
return false;
}
auto it = find_if(preinstalledApplicationInfos.begin(), preinstalledApplicationInfos.end(),
[&](const AppExecFwk::PreinstalledApplicationInfo& obj) { return obj.bundleName == bundleName; });
if (it != preinstalledApplicationInfos.end()) {
APP_DOMAIN_VERIFY_HILOGI(
APP_DOMAIN_VERIFY_MODULE_COMMON, "bundle:%{public}s isPreInstallApp:%{public}d", bundleName.c_str(), true);
return true;
} else {
APP_DOMAIN_VERIFY_HILOGI(
APP_DOMAIN_VERIFY_MODULE_COMMON, "bundle:%{public}s isPreInstallApp:%{public}d", bundleName.c_str(), false);
return false;
}
// Check if the app is pre-installed (system app)
return bundleInfo.isPreInstallApp;
}
}
}
+1 -10
View File
@@ -16,7 +16,6 @@
#include "domain_verifier.h"
#include "app_domain_verify_hilog.h"
#include "domain_json_util.h"
#include "bundle_info_query.h"
namespace OHOS {
namespace AppDomainVerify {
@@ -25,15 +24,7 @@ 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) {
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;
}
return GetVerifyStatusFromHttpError(responseCode);
}
AssetJsonObj assetJsonObj;
if (JsonUtil::Parse(assetJsonsStr, assetJsonObj)) {
+4
View File
@@ -27,6 +27,7 @@
#include "domain_url_util.h"
#include "app_domain_verify_task_mgr.h"
#include "verify_http_task.h"
#include "bundle_info_query.h"
namespace OHOS {
namespace AppDomainVerify {
@@ -43,6 +44,9 @@ void VerifyTask::OnPostVerify(const std::string& uri, const OHOS::NetStack::Http
(appVerifyBaseInfo_.priority < PRIORITY_MIN || appVerifyBaseInfo_.priority > PRIORITY_MAX)) {
status = InnerVerifyStatus::FAILURE_CLIENT_ERROR;
}
if (status == InnerVerifyStatus::FAILURE_HTTP_UNKNOWN && appVerifyBaseInfo_.isPreinstalled) {
status = InnerVerifyStatus::PRE_INSTALLED;
}
APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_AGENT_MODULE_SERVICE,
"OnPostVerify status %{public}d appId:%{public}s, priority:%{public}d", status,
appVerifyBaseInfo_.appIdentifier.c_str(), appVerifyBaseInfo_.priority);
@@ -24,6 +24,7 @@ struct AppVerifyBaseInfo : public Parcelable {
std::string bundleName{};
std::string fingerprint{};
int priority{};
bool isPreinstalled{};
AppVerifyBaseInfo();
AppVerifyBaseInfo(const AppVerifyBaseInfo &appVerifyBaseInfo);
@@ -25,6 +25,7 @@ AppVerifyBaseInfo::AppVerifyBaseInfo()
bundleName = "";
fingerprint = "";
priority = PRIORITY_UNSET;
isPreinstalled = false;
}
AppVerifyBaseInfo::AppVerifyBaseInfo(const AppVerifyBaseInfo &appVerifyBaseInfo)
@@ -33,6 +34,7 @@ AppVerifyBaseInfo::AppVerifyBaseInfo(const AppVerifyBaseInfo &appVerifyBaseInfo)
bundleName = appVerifyBaseInfo.bundleName;
fingerprint = appVerifyBaseInfo.fingerprint;
priority = appVerifyBaseInfo.priority;
isPreinstalled = appVerifyBaseInfo.isPreinstalled;
}
bool AppVerifyBaseInfo::Marshalling(Parcel &parcel) const
{
@@ -40,6 +42,7 @@ bool AppVerifyBaseInfo::Marshalling(Parcel &parcel) const
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, bundleName);
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fingerprint);
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, priority);
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isPreinstalled);
return true;
}
bool AppVerifyBaseInfo::ReadFromParcel(Parcel &parcel)
@@ -48,6 +51,7 @@ bool AppVerifyBaseInfo::ReadFromParcel(Parcel &parcel)
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, bundleName);
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fingerprint);
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, priority);
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isPreinstalled);
return true;
}
@@ -97,6 +97,10 @@ void AppDomainVerifyMgrService::VerifyDomain(const std::string& appIdentifier, c
VerifyResultInfo verifyResultInfo;
verifyResultInfo.appIdentifier = appIdentifier;
// Check if app is pre-installed
bool isPreInstalled = BundleInfoQuery::IsPreInstalledApp(bundleName);
appVerifyBaseInfo.isPreinstalled = isPreInstalled;
CollectDomains(skillUris, verifyResultInfo);
DelayedSingleton<AppDomainVerifyDataMgr>::GetInstance()->InsertVerifyStatus(bundleName, verifyResultInfo);
AppDomainVerifyAgentClient::GetInstance()->SingleVerify(appVerifyBaseInfo, verifyResultInfo);
@@ -23,6 +23,9 @@ bool g_mockWriteInt32 = true;
bool g_mockReadUint32 = true;
bool g_mockReadInt32 = true;
bool g_mockWriteBool = true;
bool g_mockReadBool = true;
bool g_mockWriteString = true;
bool g_mockWriteParcelable = true;
bool g_mockReadParcelable = true;
@@ -38,6 +41,11 @@ void MockWriteUint32(bool state)
g_mockWriteUint32 = state;
}
void MockWriteBool(bool state)
{
g_mockWriteBool = state;
}
void MockWriteInt32(bool state)
{
g_mockWriteInt32 = state;
@@ -48,6 +56,11 @@ void MockReadUint32(int state)
g_mockReadUint32 = state;
}
void MockReadBool(bool state)
{
g_mockReadBool = state;
}
void MockReadInt32(bool state)
{
g_mockReadInt32 = state;
@@ -138,5 +151,13 @@ bool Parcel::ReadInt32(int32_t& value)
{
return g_mockReadInt32;
}
bool Parcel::WriteBool(bool value)
{
return g_mockWriteBool;
}
bool Parcel::ReadBool(bool& value)
{
return g_mockReadBool;
}
} // namespace OHOS
@@ -21,8 +21,10 @@
namespace OHOS {
void MockWriteUint32(bool state);
void MockWriteInt32(bool state);
void MockWriteBool(bool state);
void MockReadUint32(int state);
void MockReadInt32(bool state);
void MockReadBool(bool state);
void MockWriteString(bool state, uint8_t count);
@@ -52,6 +54,10 @@ public:
bool ReadInt32(int32_t& value);
bool WriteBool(bool value);
bool ReadBool(bool& value);
bool WriteString(const std::string&) const;
bool ReadString(const std::string&);