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
16 #include "fence_extension_stub.h"
17 #include "ipc_types.h"
18 #include "location_log.h"
19
20 namespace OHOS {
21 namespace Location {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)22 int FenceExtensionStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
23 {
24 LBSLOGI(FENCE_EXTENSION, "stub on message:%{public}d", code);
25 if (data.ReadInterfaceToken() != GetDescriptor()) {
26 return ERR_TRANSACTION_FAILED;
27 }
28
29 switch (code) {
30 case ON_FENCE_STATUS_CHANGE: {
31 std::vector<std::string> dataKeys;
32 data.ReadStringVector(&dataKeys);
33 std::vector<std::string> dataValues;
34 data.ReadStringVector(&dataValues);
35 std::map<std::string, std::string> extraData;
36 auto keysItr = dataKeys.begin();
37 auto valuesItr = dataValues.begin();
38 while (keysItr != dataKeys.end() && valuesItr != dataValues.end()) {
39 extraData[*keysItr] = *valuesItr;
40 keysItr++;
41 valuesItr++;
42 }
43 FenceExtensionErrCode result = OnFenceStatusChange(extraData);
44 LBSLOGI(FENCE_EXTENSION, "stub on message end:%{public}d", result);
45 if (result != FenceExtensionErrCode::EXTENSION_SUCCESS) {
46 return ERR_TRANSACTION_FAILED;
47 }
48 return ERR_NONE;
49 }
50 default:
51 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
52 }
53 LBSLOGE(FENCE_EXTENSION, "stub on message trans failed");
54 return ERR_TRANSACTION_FAILED;
55 }
56 } // namespace Location
57 } // namespace OHOS