• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <string>
16 #include <vector>
17 #include "i18n_hilog.h"
18 #include "upgrade_utils.h"
19 
20 namespace OHOS {
21 namespace Global {
22 namespace I18n {
23 const std::string CFG_PATH =
24     "/data/service/el1/public/update/param_service/install/system/etc/TABOO/generic/";
25 const std::string LOCAL_VERSION_PATH = "/system/etc/TABOO/generic/version.txt";
26 const std::string VERSION_FILE = "version.txt";
27 const std::string PUBKEY_PATH = "/system/etc/i18n/upgrade/hota_i18n_upgrade_v1.pem";
28 const std::string SAFE_PATH = "/data/service/el1/public/i18n/taboo/";
29 const std::string MOUNT_DIR = "/system/etc/taboo_res/";
30 
UpdateTaboo()31 void UpdateTaboo()
32 {
33     std::vector<std::string> filesList;
34     if (!UpgradeUtils::CheckIfUpdateNecessary(CFG_PATH + VERSION_FILE, LOCAL_VERSION_PATH)) {
35         HILOG_ERROR_I18N("UpdateTaboo: CheckIfUpdateNecessary error, no need to update.");
36         return;
37     }
38 
39     if (!UpgradeUtils::CheckFileIntegrity(CFG_PATH, PUBKEY_PATH, filesList)) {
40         HILOG_ERROR_I18N("UpdateTaboo: CheckFileIntegrity error, no need to update.");
41         return;
42     }
43 
44     if (!UpgradeUtils::CopyDataFile(CFG_PATH, SAFE_PATH, filesList)) {
45         HILOG_ERROR_I18N("UpdateTaboo: Copy data file failed.");
46         return;
47     }
48 
49     if (!UpgradeUtils::FileDirMount(SAFE_PATH, MOUNT_DIR)) {
50         HILOG_ERROR_I18N("UpdateTaboo: Mount taboo_res error.");
51         return;
52     }
53 
54     HILOG_INFO_I18N("UpdateTaboo: Update success.");
55 }
56 }
57 }
58 }
59 
main(int argc,char * argv[])60 int main(int argc, char *argv[])
61 {
62     HILOG_INFO_I18N("hmos_taboo_mount: UpdateTaboo start.");
63     OHOS::Global::I18n::UpdateTaboo();
64     return 0;
65 }