• 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 "app_details_filter.h"
16 #include "skill.h"
17 #include "want.h"
18 #include "app_domain_verify_hilog.h"
19 
20 namespace OHOS {
21 namespace AppDomainVerify {
22 constexpr const static char *ENTITY_SYSTEM_BROWSABLE = "entity.system.browsable";
23 constexpr const static char *WANT_ACTION_VIEWDATA = "ohos.want.action.viewData";
Filter(const std::vector<AppDetailInfo> & input,std::vector<AppDetailInfo> & dest,const std::string & url)24 bool AppDetailsFilter::Filter(
25     const std::vector<AppDetailInfo>& input, std::vector<AppDetailInfo>& dest, const std::string& url)
26 {
27     APP_DOMAIN_VERIFY_HILOGI(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "call.");
28     AAFwk::Want want;
29     want.SetAction(WANT_ACTION_VIEWDATA);
30     want.SetEntities({ENTITY_SYSTEM_BROWSABLE});
31     want.SetUri(url);
32     AppExecFwk::Skill skill;
33     skill.actions.push_back(WANT_ACTION_VIEWDATA);
34     skill.entities.push_back(ENTITY_SYSTEM_BROWSABLE);
35     for (auto& info : input) {
36         skill.uris.push_back(info.skillUri);
37     }
38     size_t index = 0;
39     bool ret = skill.Match(want, index);
40     if (!ret) {
41         APP_DOMAIN_VERIFY_HILOGW(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "skill match fail.");
42         return false;
43     }
44     dest.clear();
45     dest.push_back(input[index]);
46     return true;
47 }
48 }
49 }
50