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 #include "sysparam_errno.h"
24
25 namespace OHOS {
26 namespace init_param {
OnParameterChange(const std::string & prefix,const std::string & name,const std::string & value)27 void WatcherProxy::OnParameterChange(const std::string &prefix, const std::string &name, const std::string &value)
28 {
29 MessageParcel data;
30 MessageParcel reply;
31 MessageOption option { MessageOption::TF_ASYNC };
32
33 data.WriteInterfaceToken(WatcherProxy::GetDescriptor());
34 data.WriteString(prefix);
35 data.WriteString(name);
36 data.WriteString(value);
37 auto remote = Remote();
38 #ifdef STARTUP_INIT_TEST
39 int ret = 0;
40 #else
41 int ret = SYSPARAM_SYSTEM_ERROR;
42 #endif
43 if (remote != nullptr) {
44 ret = remote->SendRequest(PARAM_CHANGE, data, reply, option);
45 }
46 WATCHER_CHECK(ret == ERR_OK, return, "Can not SendRequest for name %s err:%d", name.c_str(), ret);
47 return;
48 }
49 }
50 } // namespace OHOS
51