1 /* 2 * Copyright (c) 2020 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 OHOS_ABILITY_SELF_CALLBACK_H 17 #define OHOS_ABILITY_SELF_CALLBACK_H 18 19 #include <algorithm> 20 #include <vector> 21 22 #include "ability_manager.h" 23 #include "ipc_skeleton.h" 24 #include "nocopyable.h" 25 26 namespace OHOS { 27 class AbilitySelfCallback { 28 public: GetInstance()29 static AbilitySelfCallback &GetInstance() 30 { 31 static AbilitySelfCallback instance; 32 return instance; 33 } 34 ~AbilitySelfCallback(); 35 const SvcIdentity *RegisterAbilitySelfCallback(IAbilityStartCallback &iAbilityStartCallback); 36 const IAbilityStartCallback GetCallback(); 37 private: 38 AbilitySelfCallback() = default; 39 static int32_t Callback(uint32_t code, IpcIo *data, IpcIo *reply, MessageOption option); 40 int32_t GenerateLocalServiceId(); 41 IAbilityStartCallback iAbilityStartCallback_ { nullptr }; 42 SvcIdentity *svcIdentity_ { nullptr }; 43 IpcObjectStub objectStub_; 44 45 DISALLOW_COPY_AND_MOVE(AbilitySelfCallback); 46 }; 47 } // namespace 48 #endif // OHOS_ABILITY_SELF_CALLBACK_H