mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 23:30:44 +00:00
Description:Split big func.
Sig:SIG_ApplicationFramework Feature or BugFix: Feature Binary Source: No Signed-off-by: zhangyafei.echo <zhangyafei12@huawei.com> Change-Id: I12505b2af15f1b3484cac3d7583f2ff6850ee435
This commit is contained in:
parent
19c273bdc7
commit
5c53493c0d
@ -114,6 +114,7 @@ private:
|
||||
bool ParseAbilityInfo(const std::string &abilitySrcPath);
|
||||
bool LoadRuntimeEnv(napi_env env, napi_value globalObject);
|
||||
static napi_value RequireNapi(napi_env env, napi_callback_info info);
|
||||
inline void SetHostResolveBufferTracker();
|
||||
|
||||
panda::ecmascript::EcmaVM *CreateJSVM();
|
||||
Options options_;
|
||||
@ -661,24 +662,7 @@ bool SimulatorImpl::OnInit()
|
||||
return false;
|
||||
}
|
||||
|
||||
panda::JSNApi::SetHostResolveBufferTracker(vm_,
|
||||
[](const std::string &inputPath, uint8_t **buff, size_t *buffSize) -> bool {
|
||||
if (inputPath.empty() || buff == nullptr || buffSize == nullptr) {
|
||||
HILOG_ERROR("Param invalid.");
|
||||
return false;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Get module buffer, input path: %{public}s.", inputPath.c_str());
|
||||
auto data = Ide::StageContext::GetInstance().GetModuleBuffer(inputPath);
|
||||
if (data == nullptr) {
|
||||
HILOG_ERROR("Get module buffer failed, input path: %{public}s.", inputPath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
*buff = data->data();
|
||||
*buffSize = data->size();
|
||||
return true;
|
||||
});
|
||||
SetHostResolveBufferTracker();
|
||||
panda::JSNApi::DebugOption debugOption = {ARK_DEBUGGER_LIB_PATH, (options_.debugPort != 0), options_.debugPort};
|
||||
panda::JSNApi::StartDebugger(vm_, debugOption, 0,
|
||||
std::bind(&DebuggerTask::OnPostTask, &debuggerTask_, std::placeholders::_1));
|
||||
@ -798,5 +782,27 @@ std::unique_ptr<Simulator> Simulator::Create(const Options &options)
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SimulatorImpl::SetHostResolveBufferTracker()
|
||||
{
|
||||
panda::JSNApi::SetHostResolveBufferTracker(vm_,
|
||||
[](const std::string &inputPath, uint8_t **buff, size_t *buffSize) -> bool {
|
||||
if (inputPath.empty() || buff == nullptr || buffSize == nullptr) {
|
||||
HILOG_ERROR("Param invalid.");
|
||||
return false;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Get module buffer, input path: %{public}s.", inputPath.c_str());
|
||||
auto data = Ide::StageContext::GetInstance().GetModuleBuffer(inputPath);
|
||||
if (data == nullptr) {
|
||||
HILOG_ERROR("Get module buffer failed, input path: %{public}s.", inputPath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
*buff = data->data();
|
||||
*buffSize = data->size();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -81,6 +81,7 @@ public:
|
||||
private:
|
||||
bool CheckTaskRunningState(const std::string &bundleName);
|
||||
void AddApplyTask(std::shared_ptr<QuickFixManagerApplyTask> applyTask);
|
||||
int32_t GetQuickFixInfo(const std::string &bundleName, bool &patchExists, bool &isSoContained);
|
||||
|
||||
static std::mutex mutex_;
|
||||
static sptr<QuickFixManagerService> instance_;
|
||||
|
@ -140,30 +140,11 @@ int32_t QuickFixManagerService::RevokeQuickFix(const std::string &bundleName)
|
||||
return QUICK_FIX_DEPLOYING_TASK;
|
||||
}
|
||||
|
||||
auto bundleMgrHelper = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("Failed to get bundle manager helper.");
|
||||
return QUICK_FIX_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
if (!bundleMgrHelper->GetBundleInfo(bundleName, AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo,
|
||||
AppExecFwk::Constants::ANY_USERID)) {
|
||||
HILOG_ERROR("Get bundle info failed.");
|
||||
return QUICK_FIX_GET_BUNDLE_INFO_FAILED;
|
||||
}
|
||||
|
||||
auto isSoContained = !bundleInfo.applicationInfo.appQuickFix.deployedAppqfInfo.nativeLibraryPath.empty();
|
||||
auto patchExists = true;
|
||||
for (auto &item : bundleInfo.hapModuleInfos) {
|
||||
if (!item.hqfInfo.moduleName.empty()) {
|
||||
patchExists = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (patchExists) {
|
||||
HILOG_ERROR("Patch does not exist.");
|
||||
auto patchExists = false;
|
||||
auto isSoContained = false;
|
||||
auto ret = GetQuickFixInfo(bundleName, patchExists, isSoContained);
|
||||
if (ret != QUICK_FIX_OK || !patchExists) {
|
||||
HILOG_ERROR("Get bundle info failed or patch does not exist.");
|
||||
return QUICK_FIX_GET_BUNDLE_INFO_FAILED;
|
||||
}
|
||||
|
||||
@ -222,5 +203,31 @@ bool QuickFixManagerService::CheckTaskRunningState(const std::string &bundleName
|
||||
HILOG_DEBUG("bundleName %{public}s not found in tasks.", bundleName.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t QuickFixManagerService::GetQuickFixInfo(const std::string &bundleName, bool &patchExists, bool &isSoContained)
|
||||
{
|
||||
auto bundleMgrHelper = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("Failed to get bundle manager helper.");
|
||||
return QUICK_FIX_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
if (!bundleMgrHelper->GetBundleInfo(bundleName, AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo,
|
||||
AppExecFwk::Constants::ANY_USERID)) {
|
||||
HILOG_ERROR("Get bundle info failed.");
|
||||
return QUICK_FIX_GET_BUNDLE_INFO_FAILED;
|
||||
}
|
||||
|
||||
for (auto &item : bundleInfo.hapModuleInfos) {
|
||||
if (!item.hqfInfo.moduleName.empty()) {
|
||||
patchExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
isSoContained = !bundleInfo.applicationInfo.appQuickFix.deployedAppqfInfo.nativeLibraryPath.empty();
|
||||
return QUICK_FIX_OK;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -221,5 +221,28 @@ HWTEST_F(QuickFixManagerServiceTest, RevokeQuickFix_0300, TestSize.Level1)
|
||||
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetQuickFixInfo_0100
|
||||
* @tc.desc: RevokeQuickFix GetQuickFixInfo
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(QuickFixManagerServiceTest, GetQuickFixInfo_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("GetQuickFixInfo_0100 start.");
|
||||
|
||||
auto mockGetBundleInstaller = []() { return mockBundleInstaller; };
|
||||
EXPECT_CALL(*mockBundleMgr, GetBundleInstaller()).WillOnce(testing::Invoke(mockGetBundleInstaller));
|
||||
|
||||
std::string bundleName = "com.ohos.quickfix";
|
||||
auto patchExists = false;
|
||||
auto isSoContained = false;
|
||||
auto ret = quickFixMs_->GetQuickFixInfo(bundleName, patchExists, isSoContained);
|
||||
EXPECT_EQ(ret, QUICK_FIX_OK);
|
||||
EXPECT_EQ(patchExists, true);
|
||||
EXPECT_EQ(isSoContained, true);
|
||||
|
||||
HILOG_INFO("GetQuickFixInfo_0100 end.");
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
Loading…
Reference in New Issue
Block a user