1 /*
2 * Copyright (c) 2021-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 "test_audio_ability_stub.h"
17
18 #include "errors.h"
19 #include "ipc_object_stub.h"
20 #include "ipc_types.h"
21 #include "message_option.h"
22 #include "message_parcel.h"
23
24 using namespace OHOS::HiviewDFX;
25
26 namespace OHOS {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)27 int32_t TestAudioAbilityStub::OnRemoteRequest(uint32_t code,
28 MessageParcel& data, MessageParcel& reply, MessageOption& option)
29 {
30 HiLog::Info(label_, "TestAudioAbilityStub::OnReceived, code = %{public}u, flags= %{public}d",
31 code, option.GetFlags());
32
33 switch (code) {
34 case ADD_VOLUME: {
35 bool ret = reply.WriteInt32(AddVolume(data.ReadInt32()));
36 return (ret ? ERR_OK : ERR_FLATTEN_OBJECT);
37 }
38
39 case REDUCE_VOLUME: {
40 bool ret = reply.WriteInt32(ReduceVolume(data.ReadInt32()));
41 return (ret ? ERR_OK : ERR_FLATTEN_OBJECT);
42 }
43
44 case TEST_RPCINT32: {
45 bool ret = reply.WriteInt32(TestRpcInt32(data.ReadInt32()));
46 return (ret ? ERR_OK : ERR_FLATTEN_OBJECT);
47 }
48
49 case TEST_RPCUINT32: {
50 bool ret = reply.WriteUint32(TestRpcUInt32(data.ReadUint32()));
51 return (ret ? ERR_OK : ERR_FLATTEN_OBJECT);
52 }
53
54 case TEST_RPCINT64: {
55 bool ret = reply.WriteInt64(TestRpcInt64(data.ReadInt64()));
56 return (ret ? ERR_OK : ERR_FLATTEN_OBJECT);
57 }
58
59 case TEST_RPCUINT64: {
60 bool ret = reply.WriteUint64(TestRpcUInt64(data.ReadUint64()));
61 return (ret ? ERR_OK : ERR_FLATTEN_OBJECT);
62 }
63
64 case TEST_RPCFLOAT: {
65 bool ret = reply.WriteFloat(TestRpcFloat(data.ReadFloat()));
66 return (ret ? ERR_OK : ERR_FLATTEN_OBJECT);
67 }
68
69 case TEST_RPCDOUBLE: {
70 bool ret = reply.WriteDouble(TestRpcDouble(data.ReadDouble()));
71 return (ret ? ERR_OK : ERR_FLATTEN_OBJECT);
72 }
73
74 case TEST_RPCSTRING16: {
75 std::u16string strTmp = TestRpcString16(data.ReadString16());
76 bool ret = reply.WriteString16(strTmp.c_str());
77 return (ret ? ERR_OK : ERR_FLATTEN_OBJECT);
78 }
79
80 default:
81 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
82 }
83 }
84 }
85