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 41 static std::mutex remoteMutex_; 42 static sptr<IRemoteObject> remote_; 43 static std::condition_variable remoteConVar_; 44 }; 45 46 class DistributedSchedLoadCallback : public SystemAbilityLoadCallbackStub { 47 public: 48 DistributedSchedLoadCallback() = default; 49 ~DistributedSchedLoadCallback() = default; 50 51 void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, 52 const sptr<IRemoteObject> &remoteObject) override; 53 void OnLoadSystemAbilityFail(int32_t systemAbilityId) override; 54 }; 55 } // namespace DistributedSchedule 56 } // namespace OHOS 57 #endif // DISTRIBUTED_SCHED_UTIL_H