1 /*
2 * Copyright (C) 2024-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 "spam_call_connection.h"
17
18 #include "telephony_log_wrapper.h"
19 #include "spam_call_proxy.h"
20
21 namespace OHOS {
22 namespace Telephony {
23 constexpr int32_t PARAM_NUM = 3;
24
OnAbilityConnectDone(const AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int32_t resultCode)25 void SpamCallConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &element,
26 const sptr<IRemoteObject> &remoteObject, int32_t resultCode)
27 {
28 TELEPHONY_LOGI("OnAbilityConnectDone, resultCode = %{public}d", resultCode);
29 if (remoteObject == nullptr) {
30 TELEPHONY_LOGE("Connected service is invalid!");
31 return;
32 }
33 remoteObject_ = remoteObject;
34 SpamCallProxy service(remoteObject);
35 int32_t ret = service.DetectSpamCall(phoneNumber_, slotId_, spamCallAdapter_);
36 TELEPHONY_LOGI("SpamCallProxy DetectSpamCall ret = %{public}d", ret);
37 }
38
OnAbilityDisconnectDone(const AppExecFwk::ElementName & element,int32_t resultCode)39 void SpamCallConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element,
40 int32_t resultCode)
41 {
42 remoteObject_ = nullptr;
43 TELEPHONY_LOGI("OnAbilityDisconnectDone, resultCode = %{public}d", resultCode);
44 }
45
RequireCallReminder()46 void SpamCallConnection::RequireCallReminder()
47 {
48 TELEPHONY_LOGI("DetectNeedNotify start.");
49 if (remoteObject_ == nullptr) {
50 TELEPHONY_LOGE("remoteObject_ is nullptr");
51 return;
52 }
53 SpamCallProxy service(remoteObject_);
54 int32_t ret = service.RequireCallReminder(slotId_, spamCallAdapter_);
55 TELEPHONY_LOGI("SpamCallProxy DetectNeedNotify ret = %{public}d", ret);
56 }
57 } // namespace Telephony
58 } // namespace OHOS
59