1 /*
2  * Copyright (C) 2022 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 ############
17 This file is used to support compatibility between platforms, differences between old and new projects and
18 compilation platforms
19 
20 defined __MUSL__ Has migrated to the latest version of harmony project
21 
22 defined HARMONY_PROJECT
23 With openharmony toolchains suport. If not defined, it should be [device]buildroot or [PC]msys64(...)/ubuntu-apt(...)
24 envirments
25 ############
26 */
27 #include "system_depend.h"
28 #include "parameter.h"
29 #include "utils.h"
30 #include "flashd_define.h"
31 #include "updater/updater.h"
32 
33 namespace Hdc {
34 namespace SystemDepend {
SetDevItem(const char * key,const char * value)35     bool SetDevItem(const char *key, const char *value)
36     {
37         bool ret = true;
38         ret = SetParameter(key, value) == 0;
39         return ret;
40     }
41 
GetDevItem(const char * key,string & out,const char * preDefine)42     bool GetDevItem(const char *key, string &out, const char *preDefine)
43     {
44         char tmpStringBuf[BUF_SIZE_MEDIUM] = "";
45         auto res = GetParameter(key, preDefine, tmpStringBuf, BUF_SIZE_MEDIUM);
46         if (res <= 0) {
47             return false;
48         }
49         out = tmpStringBuf;
50         return true;
51     }
52 
RebootDevice(const string & cmd)53     bool RebootDevice(const string &cmd)
54     {
55         FLASHD_LOGE("Flashd RebootDevice cmd is %s", cmd.c_str());
56         Updater::PostUpdater(true);
57         Updater::Utils::UpdaterDoReboot("");
58         return true;
59     }
60 }
61 }  // namespace Hdc
62