1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "advanced_security_mode_manager.h"
17 
18 #include <string>
19 
20 #include "hilog_tag_wrapper.h"
21 #include "hitrace_meter.h"
22 #include "parameters.h"
23 #include "time_util.h"
24 
25 namespace OHOS {
26 namespace AppExecFwk {
27 namespace {
28 const std::string PARAM_GLOBAL_ADVANCED_MODE_STATE = "ohos.boot.advsecmode.state";
29 }
AdvancedSecurityModeManager()30 AdvancedSecurityModeManager::AdvancedSecurityModeManager()
31 {
32     TAG_LOGD(AAFwkTag::APPMGR, "ASMM constructor");
33 }
34 
~AdvancedSecurityModeManager()35 AdvancedSecurityModeManager::~AdvancedSecurityModeManager()
36 {
37     TAG_LOGD(AAFwkTag::APPMGR, "ASMM deconstructor");
38 }
39 
Init()40 void AdvancedSecurityModeManager::Init()
41 {
42     HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
43     int32_t state = OHOS::system::GetIntParameter<int32_t>(PARAM_GLOBAL_ADVANCED_MODE_STATE, 0);
44     isAdvSecModeEnabled_ = state > 0;
45     TAG_LOGI(AAFwkTag::APPMGR, "ASMM Init isAdvSecModeEnabled:%{public}d.", isAdvSecModeEnabled_);
46 }
47 
IsJITEnabled()48 bool AdvancedSecurityModeManager::IsJITEnabled()
49 {
50     HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
51     TAG_LOGD(AAFwkTag::APPMGR, "ASMM IsJITEnabled %{public}d", !isAdvSecModeEnabled_);
52     return !isAdvSecModeEnabled_;
53 }
54 }  // namespace AppExecFwk
55 }  // namespace OHOS
56