1a69a01cdSopenharmony_ci/*
2a69a01cdSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
3a69a01cdSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4a69a01cdSopenharmony_ci * you may not use this file except in compliance with the License.
5a69a01cdSopenharmony_ci * You may obtain a copy of the License at
6a69a01cdSopenharmony_ci *
7a69a01cdSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8a69a01cdSopenharmony_ci *
9a69a01cdSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10a69a01cdSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11a69a01cdSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12a69a01cdSopenharmony_ci * See the License for the specific language governing permissions and
13a69a01cdSopenharmony_ci * limitations under the License.
14a69a01cdSopenharmony_ci */
15a69a01cdSopenharmony_ci#ifndef TEST_WUKONG_APP_MANAGER_H
16a69a01cdSopenharmony_ci#define TEST_WUKONG_APP_MANAGER_H
17a69a01cdSopenharmony_ci
18a69a01cdSopenharmony_ci#include "ability_controller_stub.h"
19a69a01cdSopenharmony_ci#include "appexecfwk_errors.h"
20a69a01cdSopenharmony_ci#include "singleton.h"
21a69a01cdSopenharmony_ci
22a69a01cdSopenharmony_cinamespace OHOS {
23a69a01cdSopenharmony_cinamespace WuKong {
24a69a01cdSopenharmony_ciclass AppManager : public DelayedSingleton<AppManager> {
25a69a01cdSopenharmony_cipublic:
26a69a01cdSopenharmony_ci    /**
27a69a01cdSopenharmony_ci     * @brief start ability by bundleInfo's entryHapName and entryHap->mainAbility
28a69a01cdSopenharmony_ci     * @param abilityName ability name
29a69a01cdSopenharmony_ci     * @param bundleName bundle name
30a69a01cdSopenharmony_ci     * @return Returns ERR_OK on success, others on failure.
31a69a01cdSopenharmony_ci     */
32a69a01cdSopenharmony_ci    ErrCode StartAbilityByBundleInfo(std::string abilityName, std::string bundleName);
33a69a01cdSopenharmony_ci
34a69a01cdSopenharmony_ci    /**
35a69a01cdSopenharmony_ci     * @brief start ability by uri name and typeVal name
36a69a01cdSopenharmony_ci     * @param uriname uri name
37a69a01cdSopenharmony_ci     * @param typeVal uritype name
38a69a01cdSopenharmony_ci     * @return Returns ERR_OK on success, others on failure.
39a69a01cdSopenharmony_ci     */
40a69a01cdSopenharmony_ci    ErrCode StartAbilityByUriAndType(const std::string uri, const std::string typeVal);
41a69a01cdSopenharmony_ci
42a69a01cdSopenharmony_ci    /**
43a69a01cdSopenharmony_ci     * @brief start ability by uri name and ability name
44a69a01cdSopenharmony_ci     * @param uriname uri name
45a69a01cdSopenharmony_ci     * @param abilityName ability name
46a69a01cdSopenharmony_ci     * @return Returns ERR_OK on success, others on failure.
47a69a01cdSopenharmony_ci     */
48a69a01cdSopenharmony_ci    ErrCode StartAbilityByAbilityAndUri(const std::string uri, const std::vector<std::string> &abilityName);
49a69a01cdSopenharmony_ci
50a69a01cdSopenharmony_ci    void SetAbilityController();
51a69a01cdSopenharmony_ci
52a69a01cdSopenharmony_ciprivate:
53a69a01cdSopenharmony_ci    class BlockAbilityController : public OHOS::AppExecFwk::AbilityControllerStub {
54a69a01cdSopenharmony_ci    public:
55a69a01cdSopenharmony_ci        /**
56a69a01cdSopenharmony_ci         * @brief cold start.
57a69a01cdSopenharmony_ci         * @param want want information
58a69a01cdSopenharmony_ci         * @param bundleName bundle name
59a69a01cdSopenharmony_ci         * @return whether this function is realize or not.
60a69a01cdSopenharmony_ci         */
61a69a01cdSopenharmony_ci        virtual bool AllowAbilityStart(const AAFwk::Want &want, const std::string &bundleName) override;
62a69a01cdSopenharmony_ci
63a69a01cdSopenharmony_ci        /**
64a69a01cdSopenharmony_ci         * @brief turn to background.
65a69a01cdSopenharmony_ci         * @param bundleName bundle name
66a69a01cdSopenharmony_ci         * @return whether this function is realize or not.
67a69a01cdSopenharmony_ci         */
68a69a01cdSopenharmony_ci        virtual bool AllowAbilityBackground(const std::string &bundleName) override;
69a69a01cdSopenharmony_ci
70a69a01cdSopenharmony_ci    private:
71a69a01cdSopenharmony_ci        std::vector<std::string> AllowBundleList;
72a69a01cdSopenharmony_ci    };
73a69a01cdSopenharmony_ci
74a69a01cdSopenharmony_ci    // block ability controller
75a69a01cdSopenharmony_ci    sptr<BlockAbilityController> abilityController_;
76a69a01cdSopenharmony_ci};
77a69a01cdSopenharmony_ci}  // namespace WuKong
78a69a01cdSopenharmony_ci}  // namespace OHOS
79a69a01cdSopenharmony_ci#endif  // TEST_WUKONG_APP_MANAGER_H
80