• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
35 #ifndef UPDATER_UT
SetDevItem(const char * key,const char * value)36     bool SetDevItem(const char *key, const char *value)
37     {
38         bool ret = true;
39         ret = SetParameter(key, value) == 0;
40         return ret;
41     }
42 
GetDevItem(const char * key,string & out,const char * preDefine)43     bool GetDevItem(const char *key, string &out, const char *preDefine)
44     {
45         char tmpStringBuf[BUF_SIZE_MEDIUM] = "";
46         auto res = GetParameter(key, preDefine, tmpStringBuf, BUF_SIZE_MEDIUM);
47         if (res <= 0) {
48             return false;
49         }
50         out = tmpStringBuf;
51         return true;
52     }
53 
RebootDevice(const string & cmd)54     bool RebootDevice(const string &cmd)
55     {
56         FLASHD_LOGE("Flashd RebootDevice cmd is %s", cmd.c_str());
57         Updater::PostUpdater(true);
58         Updater::Utils::UpdaterDoReboot("", "Updater flashd reboot command");
59         return true;
60     }
61 #endif
62 }
63 }  // namespace Hdc
64