• 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 #ifndef FOUNDATION_DEFAULT_APPLICATION_FRAMEWORK_DEFAULT_APP_MGR
17 #define FOUNDATION_DEFAULT_APPLICATION_FRAMEWORK_DEFAULT_APP_MGR
18 
19 #include<set>
20 
21 #include "default_app_db_interface.h"
22 #include "nocopyable.h"
23 
24 namespace OHOS {
25 namespace AppExecFwk {
26 class DefaultAppMgr {
27 public:
28     static DefaultAppMgr& GetInstance();
29     static bool VerifyElementFormat(const Element& element);
30     ErrCode IsDefaultApplication(int32_t userId, const std::string& type, bool& isDefaultApp) const;
31     ErrCode GetDefaultApplication(int32_t userId, const std::string& type, BundleInfo& bundleInfo) const;
32     ErrCode SetDefaultApplication(int32_t userId, const std::string& type, const Element& element) const;
33     ErrCode ResetDefaultApplication(int32_t userId, const std::string& type) const;
34     void HandleUninstallBundle(int32_t userId, const std::string& bundleName) const;
35     void HandleCreateUser(int32_t userId) const;
36     void HandleRemoveUser(int32_t userId) const;
37 private:
38     DefaultAppMgr();
39     ~DefaultAppMgr();
40     DISALLOW_COPY_AND_MOVE(DefaultAppMgr);
41     void Init();
42     ErrCode GetBundleInfoByAppType(int32_t userId, const std::string& type, BundleInfo& bundleInfo) const;
43     ErrCode GetBundleInfoByFileType(int32_t userId, const std::string& type, BundleInfo& bundleInfo) const;
44     bool GetBundleInfo(int32_t userId, const std::string& type, const Element& element, BundleInfo& bundleInfo) const;
45     bool IsTypeValid(const std::string& type) const;
46     bool IsAppType(const std::string& type) const;
47     bool IsFileType(const std::string& type) const;
48     bool IsMatch(const std::string& type, const std::vector<Skill>& skills) const;
49     bool MatchAppType(const std::string& type, const std::vector<Skill>& skills) const;
50     bool MatchFileType(const std::string& type, const std::vector<Skill>& skills) const;
51     bool IsElementEmpty(const Element& element) const;
52     bool IsElementValid(int32_t userId, const std::string& type, const Element& element) const;
53     bool IsUserIdExist(int32_t userId) const;
54     ErrCode VerifyUserIdAndType(int32_t userId, const std::string& type) const;
55     bool IsBrowserSkillsValid(const std::vector<Skill>& skills) const;
56     bool IsImageSkillsValid(const std::vector<Skill>& skills) const;
57     bool IsAudioSkillsValid(const std::vector<Skill>& skills) const;
58     bool IsVideoSkillsValid(const std::vector<Skill>& skills) const;
59     bool IsPdfSkillsValid(const std::vector<Skill>& skills) const;
60     bool IsWordSkillsValid(const std::vector<Skill>& skills) const;
61     bool IsExcelSkillsValid(const std::vector<Skill>& skills) const;
62     bool IsPptSkillsValid(const std::vector<Skill>& skills) const;
63 
64     std::shared_ptr<IDefaultAppDb> defaultAppDb_;
65     static std::set<std::string> supportAppTypes;
66 };
67 }
68 }
69 #endif
70