1 /*
2 * Copyright (c) 2025 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 #include "pasteboard_samgr_listener.h"
17
18 #include "pasteboard_client.h"
19 #include "pasteboard_hilog.h"
20 #include "pasteboard_service_loader.h"
21
22 namespace OHOS {
23 namespace MiscServices {
OnAddSystemAbility(int32_t systemAbilityId,const std::string & deviceId)24 void PasteboardSaMgrListener::OnAddSystemAbility(int32_t systemAbilityId,
25 const std::string &deviceId)
26 {
27 (void)deviceId;
28 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_CLIENT, "pasteboard service started");
29 PasteboardServiceLoader::GetInstance().ClearPasteboardServiceProxy();
30 if (hasDied_) {
31 PasteboardClient::GetInstance()->Resubscribe();
32 }
33 hasDied_ = false;
34 }
35
OnRemoveSystemAbility(int32_t systemAbilityId,const std::string & deviceId)36 void PasteboardSaMgrListener::OnRemoveSystemAbility(int32_t systemAbilityId,
37 const std::string &deviceId)
38 {
39 (void)deviceId;
40 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_CLIENT, "remove sa: %{public}d.", systemAbilityId);
41 hasDied_ = true;
42 }
43 } // namespace MiscServices
44 } // namespace OHOS