1 /*
2 * Copyright (c) 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 #include "netsys_traffic_callback_proxy.h"
16 #include "netnative_log_wrapper.h"
17 #include "netsys_ipc_interface_code.h"
18
19 namespace OHOS {
20 namespace NetsysNative {
NetsysTrafficCallbackProxy(const sptr<IRemoteObject> & impl)21 NetsysTrafficCallbackProxy::NetsysTrafficCallbackProxy(const sptr<IRemoteObject> &impl)
22 : IRemoteProxy<INetsysTrafficCallback>(impl)
23 {}
24
OnExceedTrafficLimits(int8_t & flag)25 int32_t NetsysTrafficCallbackProxy::OnExceedTrafficLimits(int8_t &flag)
26 {
27 NETNATIVE_LOGI("Proxy OnExceedTrafficLimits");
28 MessageParcel data;
29 if (!data.WriteInterfaceToken(NetsysTrafficCallbackProxy::GetDescriptor())) {
30 NETNATIVE_LOGE("WriteInterfaceToken failed");
31 return ERR_NULL_OBJECT;
32 }
33 if (!data.WriteInt8(flag)) {
34 return ERR_NONE;
35 }
36 sptr<IRemoteObject> remote = Remote();
37 if (remote == nullptr) {
38 NETNATIVE_LOGE("Remote is null");
39 return ERR_NULL_OBJECT;
40 }
41 MessageParcel reply;
42 MessageOption option;
43 int32_t ret = remote->SendRequest(
44 static_cast<uint32_t>(NetsysTrafficfaceCode::NETSYS_TRAFFIC_STATUS_CHANGED), data, reply, option);
45 if (ret != ERR_NONE) {
46 NETNATIVE_LOGE("Proxy SendRequest failed, ret code:[%{public}d]", ret);
47 }
48 return ret;
49 }
50 } // namespace NetsysNative
51 } // namespace OHOS
52