1 /*
2 * Copyright (c) 2021 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 "start_via_asan.h"
17 #include "properties.h"
18 #include "app_log_wrapper.h"
19
20 namespace OHOS {
21 namespace AppExecFwk {
StartViaAsan()22 StartViaAsan::StartViaAsan()
23 {}
24
~StartViaAsan()25 StartViaAsan::~StartViaAsan()
26 {}
27
IsAsanVersion(const std::string & name) const28 bool StartViaAsan::IsAsanVersion(const std::string &name) const
29 {
30 if (name.empty()) {
31 return false;
32 }
33
34 std::string defaultWrapValue = "";
35 std::string wrapAppName = "wrap." + name;
36 std::string propValue = GetProperty(wrapAppName, defaultWrapValue);
37 if (propValue != defaultWrapValue) {
38 APP_LOGI("%{public}s system prop set, value is %{public}s", wrapAppName.c_str(), propValue.c_str());
39 return true;
40 }
41 APP_LOGI("%{public}s system prop not set", wrapAppName.c_str());
42 return false;
43 }
44
GetAsanStartMsg(AppSpawnStartMsg & startMsg) const45 void StartViaAsan::GetAsanStartMsg(AppSpawnStartMsg &startMsg) const
46 {
47 if (startMsg.arg.empty()) {
48 startMsg.arg = "wrap." + startMsg.procName;
49 } else {
50 startMsg.arg += " wrap." + startMsg.procName;
51 }
52 startMsg.argsNum++;
53 }
54 } // namespace AppExecFwk
55 } // namespace OHOS