• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 "form_refresh/check_mgr/calling_bundle_checker.h"
17 
18 #include "bms_mgr/form_bms_helper.h"
19 
20 namespace OHOS {
21 namespace AppExecFwk {
22 
CallingBundleChecker()23 CallingBundleChecker::CallingBundleChecker() {}
~CallingBundleChecker()24 CallingBundleChecker::~CallingBundleChecker() {}
25 
CheckValid(const CheckValidFactor & factor)26 int CallingBundleChecker::CheckValid(const CheckValidFactor &factor)
27 {
28     std::string bundleName;
29     auto ret = FormBmsHelper::GetInstance().GetCallerBundleName(bundleName);
30     if (ret != ERR_OK) {
31         HILOG_ERROR("get bundleName failed, formId:%{public}" PRId64, factor.record.formId);
32         return ERR_APPEXECFWK_FORM_GET_BUNDLE_FAILED;
33     }
34 
35     if (bundleName != factor.record.bundleName) {
36         HILOG_ERROR("not match caller bundleName:%{public}s, formId:%{public}" PRId64,
37             bundleName.c_str(), factor.record.formId);
38         return ERR_APPEXECFWK_FORM_OPERATION_NOT_SELF;
39     }
40     return ERR_OK;
41 }
42 } // namespace AppExecFwk
43 } // namespace OHOS