1 /*
2 * Copyright (c) 2021 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 "watcher_proxy.h"
17
18 #include <string_ex.h>
19 #include "parcel.h"
20 #include "message_parcel.h"
21 #include "watcher_utils.h"
22 #include "securec.h"
23
24 namespace OHOS {
25 namespace init_param {
OnParamerterChange(const std::string & name,const std::string & value)26 void WatcherProxy::OnParamerterChange(const std::string &name, const std::string &value)
27 {
28 WATCHER_LOGV("WatcherProxy::OnParamerterChange %s %s", name.c_str(), value.c_str());
29 MessageParcel data;
30 MessageParcel reply;
31 MessageOption option { MessageOption::TF_ASYNC };
32 auto remote = Remote();
33 WATCHER_CHECK(remote != nullptr, return, "Can not get remote");
34
35 data.WriteInterfaceToken(WatcherProxy::GetDescriptor());
36 data.WriteString(name);
37 data.WriteString(value);
38 int ret = remote->SendRequest(PARAM_CHANGE, data, reply, option);
39 WATCHER_CHECK(ret == ERR_OK, return, "Can not SendRequest for name %s", name.c_str());
40 return;
41 }
42 }
43 } // namespace OHOS
44