• 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 #ifndef TEST_WUKONG_APP_MANAGER_H
16 #define TEST_WUKONG_APP_MANAGER_H
17 
18 #include "ability_controller_stub.h"
19 #include "appexecfwk_errors.h"
20 #include "singleton.h"
21 
22 namespace OHOS {
23 namespace WuKong {
24 class AppManager : public DelayedSingleton<AppManager> {
25 public:
26     /**
27      * @brief start ability by bundleInfo's entryHapName and entryHap->mainAbility
28      * @param abilityName ability name
29      * @param bundleName bundle name
30      * @return Returns ERR_OK on success, others on failure.
31      */
32     ErrCode StartAbilityByBundleInfo(std::string abilityName, std::string bundleName);
33     void SetAbilityController();
34 
35 private:
36     class BlockAbilityController : public OHOS::AppExecFwk::AbilityControllerStub {
37     public:
38         /**
39          * @brief cold start.
40          * @param want want information
41          * @param bundleName bundle name
42          * @return whether this function is realize or not.
43          */
44         virtual bool AllowAbilityStart(const AAFwk::Want &want, const std::string &bundleName) override;
45 
46         /**
47          * @brief turn to background.
48          * @param bundleName bundle name
49          * @return whether this function is realize or not.
50          */
51         virtual bool AllowAbilityBackground(const std::string &bundleName) override;
52 
53     private:
54         std::vector<std::string> AllowBundleList;
55     };
56 
57     // block ability controller
58     sptr<BlockAbilityController> abilityController_;
59 };
60 }  // namespace WuKong
61 }  // namespace OHOS
62 #endif  // TEST_WUKONG_APP_MANAGER_H
63