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 "load_d_input_source_callback.h"
17
18 #include "dinput_log.h"
19 #include "distributed_input_source_handler.h"
20 #include "hisysevent_util.h"
21
22 namespace OHOS {
23 namespace DistributedHardware {
24 namespace DistributedInput {
LoadDInputSourceCallback(const std::string & params)25 LoadDInputSourceCallback::LoadDInputSourceCallback(const std::string ¶ms) : params_(params) {}
26
OnLoadSystemAbilitySuccess(int32_t systemAbilityId,const sptr<IRemoteObject> & remoteObject)27 void LoadDInputSourceCallback::OnLoadSystemAbilitySuccess(
28 int32_t systemAbilityId, const sptr<IRemoteObject> &remoteObject)
29 {
30 DHLOGI("load dinput SA success, systemAbilityId:%{public}d, remoteObject result:%{public}s",
31 systemAbilityId, (remoteObject != nullptr) ? "true" : "false");
32 if (remoteObject == nullptr) {
33 DHLOGE("remoteObject is nullptr");
34 return;
35 }
36 DistributedInputSourceHandler::GetInstance().FinishStartSA(params_, remoteObject);
37 }
38
OnLoadSystemAbilityFail(int32_t systemAbilityId)39 void LoadDInputSourceCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
40 {
41 DHLOGE("load dinput SA failed, systemAbilityId:%{public}d", systemAbilityId);
42 HisyseventUtil::GetInstance().SysEventWriteFault(DINPUT_INIT_FAIL,
43 "dinput source LoadSystemAbility call failed.");
44 }
45 } // namespace DistributedInput
46 } // namespace DistributedHardware
47 } // namespace OHOS