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_stub.h"
17
18 #include <string_ex.h>
19
20 #include "call_manager_errors.h"
21 #include "telephony_log_wrapper.h"
22
23 #include "message_option.h"
24 #include "message_parcel.h"
25
26 namespace OHOS {
27 namespace Telephony {
SpamCallStub()28 SpamCallStub::SpamCallStub() {}
29
~SpamCallStub()30 SpamCallStub::~SpamCallStub() {}
31
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)32 int32_t SpamCallStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
33 MessageOption &option)
34 {
35 std::u16string myDescriptor = SpamCallStub::GetDescriptor();
36 std::u16string remoteDescriptor = data.ReadInterfaceToken();
37 if (myDescriptor != remoteDescriptor) {
38 TELEPHONY_LOGE("descriptor checked fail !");
39 return TELEPHONY_ERR_DESCRIPTOR_MISMATCH;
40 }
41 int32_t errCodeVar = data.ReadInt32();
42 std::string resultVar = Str16ToStr8(data.ReadString16());
43 TELEPHONY_LOGI("OnReceived, cmd = %{public}u", code);
44 switch (code) {
45 case COMMAND_DETECT_SPAM_CALL_RESULT:
46 OnResult(errCodeVar, resultVar);
47 break;
48 default:
49 TELEPHONY_LOGE("callback failed, default = %d", code);
50 break;
51 }
52 return ERR_NONE;
53 }
54 } // namespace Telephony
55 } // namespace OHOS
56