• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "idl_test_service_stub.h"
17 
18 namespace OHOS {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)19 int IdlTestServiceStub::OnRemoteRequest(uint32_t code, MessageParcel& data,
20     MessageParcel& reply, MessageOption& option)
21 {
22     if (data.ReadInterfaceToken() != GetDescriptor()) {
23         return ERR_TRANSACTION_FAILED;
24     }
25     switch (code) {
26         case COMMAND_TEST_INT_TRANSACTION: {
27             int _data = data.ReadInt32();
28             int result;
29             ErrCode ec = TestIntTransaction(_data, result);
30             reply.WriteInt32(ec);
31             if (SUCCEEDED(ec)) {
32                 reply.WriteInt32(result);
33             }
34             return ERR_NONE;
35         }
36         case COMMAND_TEST_STRING_TRANSACTION: {
37             std::string _data = Str16ToStr8(data.ReadString16());
38             ErrCode ec = TestStringTransaction(_data);
39             reply.WriteInt32(ec);
40             return ERR_NONE;
41         }
42         default:
43             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
44     }
45 
46     return ERR_TRANSACTION_FAILED;
47 }
48 } // namespace OHOS
49