• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 DISTRIBUTED_SCHED_UTIL_H
17 #define DISTRIBUTED_SCHED_UTIL_H
18 
19 #include <cstdint>
20 #include <mutex>
21 
22 #include "bundle_mgr_interface.h"
23 #include "iremote_object.h"
24 #include "system_ability_load_callback_stub.h"
25 
26 namespace OHOS {
27 namespace DistributedSchedule {
28 class DistributedSchedUtil {
29 public:
30     static void MockPermission();
31     static void MockBundlePermission();
32     static void MockManageMissions();
33     static void MockProcess(const char* processName);
34     static void MockProcessAndPermission(const char* processName,
35         const char *perms[] = nullptr, int32_t permsNum = 0);
36     static bool LoadDistributedSchedService();
37     static void LoadSystemAbilitySuccessNotify(const sptr<IRemoteObject>& remoteObject);
38     static void LoadSystemAbilityFailNotify();
39     static sptr<AppExecFwk::IBundleMgr> GetBundleManager();
40     static int32_t InstallThirdPartyHap();
41 
42     static std::mutex remoteMutex_;
43     static sptr<IRemoteObject> remote_;
44     static std::condition_variable remoteConVar_;
45 };
46 
47 class DistributedSchedLoadCallback : public SystemAbilityLoadCallbackStub {
48 public:
49     DistributedSchedLoadCallback() = default;
50     ~DistributedSchedLoadCallback() = default;
51 
52     void OnLoadSystemAbilitySuccess(int32_t systemAbilityId,
53         const sptr<IRemoteObject> &remoteObject) override;
54     void OnLoadSystemAbilityFail(int32_t systemAbilityId) override;
55 };
56 } // namespace DistributedSchedule
57 } // namespace OHOS
58 #endif // DISTRIBUTED_SCHED_UTIL_H