mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 12:43:16 -04:00
fix db in bopd
Signed-off-by: xuzheheng <xuzheheng2@h-partners.com> 🤖 AI[0%] 🔧 Human Fixed[0%] 🧑 Human[100%] 👌 AI Adopted[0%] Change-Id: Ied3a46f5904bfb6611bf6c43ade291cfa400ee09
This commit is contained in:
@@ -97,6 +97,10 @@ AgentManagerService::~AgentManagerService()
|
||||
void AgentManagerService::OnStart() noexcept
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::SER_ROUTER, "agentmgr start");
|
||||
if (AgentRuntime::IsBopdOrRescueMode()) {
|
||||
TAG_LOGW(AAFwkTag::SER_ROUTER, "Skip init agentmgr in bopd or rescue mode");
|
||||
return;
|
||||
}
|
||||
Init();
|
||||
if (!Publish(AgentManagerService::GetInstance())) {
|
||||
TAG_LOGE(AAFwkTag::SER_ROUTER, "Publish failed");
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace AgentRuntime {
|
||||
int64_t GenerateVerificationNonce();
|
||||
bool IsMatchedAgentCardTarget(const AAFwk::Want &want, const AgentCard &card);
|
||||
void NormalizeAgentConnectWant(AAFwk::Want &connectWant, const AgentCard &card);
|
||||
bool IsBopdOrRescueMode();
|
||||
bool IsBopdMode();
|
||||
} // namespace AgentRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
|
||||
@@ -18,9 +18,13 @@
|
||||
#include <cerrno>
|
||||
#include <cstddef>
|
||||
#include <limits>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <sys/random.h>
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "parameters.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AgentRuntime {
|
||||
namespace {
|
||||
@@ -80,5 +84,27 @@ void NormalizeAgentConnectWant(AAFwk::Want &connectWant, const AgentCard &card)
|
||||
connectWant.SetElement(element);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsBopdMode()
|
||||
{
|
||||
const std::unordered_set<std::string> bopdModeSet = {
|
||||
"0x2",
|
||||
"0x3",
|
||||
"0x6",
|
||||
"0x7",
|
||||
"0xa",
|
||||
"0xe",
|
||||
"0xf",
|
||||
};
|
||||
auto mode = system::GetParameter("ohos.boot.bopd.mode", "NA");
|
||||
return bopdModeSet.find(mode) != bopdModeSet.end();
|
||||
}
|
||||
|
||||
bool IsBopdOrRescueMode()
|
||||
{
|
||||
bool isBopdOrRescue = (IsBopdMode() || system::GetParameter("soc.boot.mode", "") == "rescue");
|
||||
TAG_LOGD(AAFwkTag::SER_ROUTER, "IsBopdOrRescueMode: %{public}d", isBopdOrRescue);
|
||||
return isBopdOrRescue;
|
||||
}
|
||||
} // namespace AgentRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "ability_manager_errors.h"
|
||||
#include "accesstoken_kit.h"
|
||||
#include "app_utils.h"
|
||||
#include "exit_info_data_manager.h"
|
||||
#include "ffrt.h"
|
||||
#include "hitrace_meter.h"
|
||||
@@ -87,6 +88,10 @@ bool AppExitReasonDataManager::CheckKvStore()
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
AAFwk::RecordCostTimeUtil timeRecord("CheckKvStore");
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "AppExitReasonDataManager::CheckKvStore start");
|
||||
if (AAFwk::AppUtils::GetInstance().IsBopdOrRescueMode()) {
|
||||
TAG_LOGW(AAFwkTag::SER_ROUTER, "Skip KvStore operation in bopd or rescue mode");
|
||||
return false;
|
||||
}
|
||||
if (kvStorePtr_ != nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -381,6 +381,13 @@ public:
|
||||
bool IsSupportNativeUIAbility();
|
||||
|
||||
bool IsSupportDelayedProcessExit();
|
||||
|
||||
/**
|
||||
* IsBopdOrRescueMode, check if system is in bopd or rescue mode.
|
||||
*
|
||||
* @return Whether system is in bopd or rescue mode.
|
||||
*/
|
||||
bool IsBopdOrRescueMode();
|
||||
private:
|
||||
/**
|
||||
* LoadResidentProcessInExtremeMemory, load resident process in extreme low memory.
|
||||
@@ -436,6 +443,12 @@ private:
|
||||
*/
|
||||
void LoadOnNewProcessEnableList();
|
||||
|
||||
/**
|
||||
* IsBopdMode, check bopd mode.
|
||||
*
|
||||
*/
|
||||
bool IsBopdMode();
|
||||
|
||||
/**
|
||||
* AppUtils, private constructor.
|
||||
*
|
||||
@@ -475,6 +488,7 @@ private:
|
||||
volatile DeviceConfiguration<bool> isHybridSpawnUnified_ = {false, false};
|
||||
volatile DeviceConfiguration<bool> isSupportNativeUIAbility_ = {false, false};
|
||||
volatile DeviceConfiguration<bool> isSupportDelayedProcessExit_ = {false, false};
|
||||
volatile DeviceConfiguration<bool> isBopdOrRescueMode_ = {false, false};
|
||||
DeviceConfiguration<std::vector<std::pair<std::string, std::string>>>
|
||||
residentProcessInExtremeMemory_ = {false, {}};
|
||||
std::mutex residentProcessInExtremeMemoryMutex_;
|
||||
|
||||
@@ -990,5 +990,30 @@ bool AppUtils::IsSupportNativeUIAbility()
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "IsSupportNativeUIAbility: %{public}d", isSupportNativeUIAbility_.value);
|
||||
return isSupportNativeUIAbility_.value;
|
||||
}
|
||||
|
||||
bool AppUtils::IsBopdMode()
|
||||
{
|
||||
const std::unordered_set<std::string> bopdModeSet = {
|
||||
"0x2",
|
||||
"0x3",
|
||||
"0x6",
|
||||
"0x7",
|
||||
"0xa",
|
||||
"0xe",
|
||||
"0xf",
|
||||
};
|
||||
auto mode = system::GetParameter("ohos.boot.bopd.mode", "NA");
|
||||
return bopdModeSet.find(mode) != bopdModeSet.end();
|
||||
}
|
||||
|
||||
bool AppUtils::IsBopdOrRescueMode()
|
||||
{
|
||||
if (!isBopdOrRescueMode_.isLoaded) {
|
||||
isBopdOrRescueMode_.value = (IsBopdMode() || system::GetParameter("soc.boot.mode", "") == "rescue");
|
||||
isBopdOrRescueMode_.isLoaded = true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "IsBopdOrRescueMode: %{public}d", isBopdOrRescueMode_.value);
|
||||
return isBopdOrRescueMode_.value;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -80,6 +80,7 @@ ohos_unittest("agent_host_connection_test") {
|
||||
"googletest:gtest_main",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"json:nlohmann_json_static",
|
||||
"kv_store:distributeddata_inner",
|
||||
|
||||
@@ -81,6 +81,7 @@ ohos_unittest("agent_manager_service_test") {
|
||||
"googletest:gtest_main",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"json:nlohmann_json_static",
|
||||
"kv_store:distributeddata_inner",
|
||||
|
||||
@@ -80,6 +80,7 @@ ohos_unittest("agent_service_connection_test") {
|
||||
"googletest:gtest_main",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"json:nlohmann_json_static",
|
||||
"kv_store:distributeddata_inner",
|
||||
|
||||
@@ -49,6 +49,7 @@ ohos_unittest("agent_utils_test") {
|
||||
"c_utils:utils",
|
||||
"googletest:gtest_main",
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"json:nlohmann_json_static",
|
||||
]
|
||||
|
||||
@@ -1136,5 +1136,33 @@ HWTEST_F(AppUtilsTest, IsSupportDelayedProcessExit_0300, TestSize.Level2)
|
||||
appUtils.isSupportDelayedProcessExit_.value = false;
|
||||
EXPECT_FALSE(appUtils.IsSupportDelayedProcessExit());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: IsBopdOrRescueMode_0100
|
||||
* @tc.desc: Test IsBopdOrRescueMode when already loaded with true
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppUtilsTest, IsBopdOrRescueMode_0100, TestSize.Level2)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsBopdOrRescueMode_0100 called.");
|
||||
auto &appUtils = AAFwk::AppUtils::GetInstance();
|
||||
appUtils.isBopdOrRescueMode_.isLoaded = true;
|
||||
appUtils.isBopdOrRescueMode_.value = true;
|
||||
EXPECT_TRUE(appUtils.IsBopdOrRescueMode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: IsBopdOrRescueMode_0200
|
||||
* @tc.desc: Test IsBopdOrRescueMode when already loaded with false
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppUtilsTest, IsBopdOrRescueMode_0200, TestSize.Level2)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsBopdOrRescueMode_0200 called.");
|
||||
auto &appUtils = AAFwk::AppUtils::GetInstance();
|
||||
appUtils.isBopdOrRescueMode_.isLoaded = true;
|
||||
appUtils.isBopdOrRescueMode_.value = false;
|
||||
EXPECT_FALSE(appUtils.IsBopdOrRescueMode());
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
bool InOnNewProcessEnableList(const std::string &bundleName);
|
||||
bool IsProductAppbootSettingEnabled();
|
||||
bool IsAutoStartupSupported();
|
||||
bool IsBopdOrRescueMode();
|
||||
|
||||
private:
|
||||
AppUtils();
|
||||
|
||||
@@ -63,5 +63,10 @@ bool AppUtils::IsAutoStartupSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AppUtils::IsBopdOrRescueMode()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
bool InOnNewProcessEnableList(const std::string &bundleName);
|
||||
bool IsProductAppbootSettingEnabled();
|
||||
bool IsAutoStartupSupported();
|
||||
bool IsBopdOrRescueMode();
|
||||
|
||||
private:
|
||||
AppUtils();
|
||||
|
||||
@@ -65,5 +65,10 @@ bool AppUtils::IsAutoStartupSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AppUtils::IsBopdOrRescueMode()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
Reference in New Issue
Block a user