1 /*
2 * Copyright (c) 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 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED
16 #include "swing_callback_proxy.h"
17
18 #include "ans_log_wrapper.h"
19 #include "event_handler.h"
20 #include "ipc_types.h"
21 #include "message_parcel.h"
22 #include "singleton.h"
23 #include "ans_inner_errors.h"
24
25 namespace OHOS {
26 namespace Notification {
OnUpdateStatus(bool isEnable,int triggerMode)27 int32_t SwingCallBackProxy::OnUpdateStatus(bool isEnable, int triggerMode)
28 {
29 MessageParcel data;
30 MessageParcel reply;
31 MessageOption option;
32 if (!data.WriteInterfaceToken(SwingCallBackProxy::GetDescriptor())) {
33 ANS_LOGE("Write interface token failed.");
34 return false;
35 }
36
37 if (!data.WriteInt8(static_cast<int8_t>(isEnable))) {
38 ANS_LOGE("Connect done element error.");
39 return false;
40 }
41
42 if (!data.WriteInt32(static_cast<int32_t>(triggerMode))) {
43 ANS_LOGE("Connect done element error.");
44 return false;
45 }
46
47 auto remote = Remote();
48 if (remote == nullptr) {
49 ANS_LOGE("Get Remote fail.");
50 return false;
51 }
52 int error = remote->SendRequest(static_cast<uint32_t>(NotificationInterfaceCode::ON_UPDATE_STATUS),
53 data, reply, option);
54 if (error != NO_ERROR) {
55 ANS_LOGE("Connect done fail, error: %{public}d", error);
56 return false;
57 }
58 return reply.ReadInt32();
59 }
60 }
61 }
62 #endif