1 /*
2 * Copyright (C) 2022 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 "geo_convert_skeleton.h"
17 #include "common_utils.h"
18 #include "ipc_skeleton.h"
19 #include "location_log.h"
20
21 namespace OHOS {
22 namespace Location {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)23 int GeoConvertServiceStub::OnRemoteRequest(uint32_t code,
24 MessageParcel &data, MessageParcel &reply, MessageOption &option)
25 {
26 pid_t callingPid = IPCSkeleton::GetCallingPid();
27 pid_t callingUid = IPCSkeleton::GetCallingUid();
28 LBSLOGI(GEO_CONVERT, "OnRemoteRequest cmd = %{public}u, flags= %{public}d, pid= %{public}d, uid= %{public}d",
29 code, option.GetFlags(), callingPid, callingUid);
30 if (callingUid > SYSTEM_UID) {
31 LBSLOGE(GEO_CONVERT, "this remote request is not allowed");
32 return -1;
33 }
34 if (data.ReadInterfaceToken() != GetDescriptor()) {
35 LBSLOGE(PASSIVE, "invalid token.");
36 return EXCEPTION;
37 }
38
39 int ret = REPLY_NO_EXCEPTION;
40 switch (code) {
41 case IS_AVAILABLE: {
42 ret = IsGeoConvertAvailable(data, reply);
43 break;
44 }
45 case GET_FROM_COORDINATE: {
46 ret = GetAddressByCoordinate(data, reply);
47 break;
48 }
49 case GET_FROM_LOCATION_NAME_BY_BOUNDARY: {
50 ret = GetAddressByLocationName(data, reply);
51 break;
52 }
53 default:
54 ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option);
55 }
56 return ret;
57 }
58 } // namespace Location
59 } // namespace OHOS
60