• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "stub_common.h"
17 #include <iostream>
18 
19 namespace OHOS {
20 namespace Media {
GetSubSystemAbility(IStandardMediaService::MediaSystemAbility subSystemId,const sptr<IRemoteObject> & listener)21 sptr<IRemoteObject> MediaServiceProxyFuzzer::GetSubSystemAbility(IStandardMediaService::MediaSystemAbility subSystemId,
22     const sptr<IRemoteObject> &listener)
23 {
24     MessageParcel data;
25     MessageParcel reply;
26     MessageOption option;
27 
28     bool token = data.WriteInterfaceToken(MediaServiceProxyFuzzer::GetDescriptor());
29     if (!token) {
30         std::cout << "Failed to write descriptor!" << std::endl;
31         return nullptr;
32     }
33     (void)data.WriteInt32(static_cast<int32_t>(subSystemId));
34     (void)data.WriteRemoteObject(listener);
35     if (Remote()->SendRequest(MediaServiceMsg::GET_SUBSYSTEM, data, reply, option) != 0) {
36         std::cout << "Failed to SendRequest" << std::endl;
37         return nullptr;
38     }
39     return reply.ReadRemoteObject();
40 }
41 
GetSubSystemAbilityWithTimeOut(IStandardMediaService::MediaSystemAbility subSystemId,const sptr<IRemoteObject> & listener,uint32_t timeoutMs)42 sptr<IRemoteObject> MediaServiceProxyFuzzer::GetSubSystemAbilityWithTimeOut(
43     IStandardMediaService::MediaSystemAbility subSystemId, const sptr<IRemoteObject> &listener, uint32_t timeoutMs)
44 {
45     (void) timeoutMs;
46     return GetSubSystemAbility(subSystemId, listener);
47 }
48 
ReleaseClientListener()49 void MediaServiceProxyFuzzer::ReleaseClientListener()
50 {
51     MessageParcel data;
52     MessageParcel reply;
53     MessageOption option;
54     (void)Remote()->SendRequest(MediaServiceMsg::RELEASE_CLIENT_LISTENER, data, reply, option);
55 }
56 
CanKillMediaService()57 bool MediaServiceProxyFuzzer::CanKillMediaService()
58 {
59     MessageParcel data;
60     MessageParcel reply;
61     MessageOption option;
62     (void)Remote()->SendRequest(MediaServiceMsg::CAN_KILL_MEDIA_SERVICE, data, reply, option);
63     return reply.ReadBool();
64 }
65 
GetPlayerPids()66 std::vector<pid_t> MediaServiceProxyFuzzer::GetPlayerPids()
67 {
68     MessageParcel data;
69     MessageParcel reply;
70     MessageOption option;
71     (void)Remote()->SendRequest(MediaServiceMsg::GET_PLAYER_PIDS, data, reply, option);
72     std::vector<pid_t> res;
73     return res;
74 }
75 
FreezeStubForPids(const std::set<int32_t> & pidList,bool isProxy)76 int32_t MediaServiceProxyFuzzer::FreezeStubForPids(const std::set<int32_t> &pidList, bool isProxy)
77 {
78     (void) pidList;
79     (void) isProxy;
80     return 0;
81 }
82 
ResetAllProxy()83 int32_t MediaServiceProxyFuzzer::ResetAllProxy()
84 {
85     return 0;
86 }
87 }
88 }