1 /*
2 * Copyright (c) 2022-2024 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 "dscreen_source_load_callback.h"
17
18 #include "dscreen_constants.h"
19 #include "dscreen_errcode.h"
20 #include "dscreen_hisysevent.h"
21 #include "dscreen_log.h"
22 #include "dscreen_source_handler.h"
23
24 namespace OHOS { class IRemoteObject; }
25 namespace OHOS {
26 namespace DistributedHardware {
OnLoadSystemAbilitySuccess(int32_t systemAbilityId,const sptr<IRemoteObject> & remoteObject)27 void DScreenSourceLoadCallback::OnLoadSystemAbilitySuccess(
28 int32_t systemAbilityId, const sptr<IRemoteObject> &remoteObject)
29 {
30 DHLOGI("load screen SA success, systemAbilityId:%{public}" PRId32 ", remoteObject result:%{public}s",
31 systemAbilityId, (remoteObject != nullptr) ? "true" : "false");
32 if (systemAbilityId != DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID) {
33 DHLOGE("start systemabilityId is not sourceSAId!");
34 return;
35 }
36 if (remoteObject == nullptr) {
37 DHLOGE("remoteObject is nullptr");
38 return;
39 }
40 DScreenSourceHandler::GetInstance().FinishStartSA(params_, remoteObject);
41 }
42
OnLoadSystemAbilityFail(int32_t systemAbilityId)43 void DScreenSourceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
44 {
45 DHLOGE("load screen SA failed, systemAbilityId:%{public}" PRId32, systemAbilityId);
46 ReportSaFail(DSCREEN_INIT_FAIL, ERR_DH_SCREEN_SA_SOURCEPROXY_NOT_INIT, systemAbilityId,
47 "dscreen source OnLoadSystemAbilityFail.");
48 }
49 } // namespace DistributedHardware
50 } // namespace OHOS
51