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 #include "message_parcel_mock.h" 16 17 #include "iremote_broker.h" 18 19 #include "bytrace_adapter.h" 20 21 namespace OHOS { 22 using namespace OHOS::MMI; 23 Parcelable()24Parcelable::Parcelable() : Parcelable(false) 25 {} 26 Parcelable(bool asRemote)27Parcelable::Parcelable(bool asRemote) 28 { 29 asRemote_ = asRemote; 30 behavior_ = 0; 31 } 32 GetTokenType()33int32_t PermissionHelper::GetTokenType() 34 { 35 return 0; 36 } 37 StartIpcServer(uint32_t code)38void BytraceAdapter::StartIpcServer(uint32_t code) {} 39 StopIpcServer()40void BytraceAdapter::StopIpcServer() {} 41 WriteInterfaceToken(std::u16string name)42bool MessageParcel::WriteInterfaceToken(std::u16string name) 43 { 44 if (DfsMessageParcel::messageParcel == nullptr) { 45 return false; 46 } 47 return DfsMessageParcel::messageParcel->WriteInterfaceToken(name); 48 } 49 ReadInterfaceToken()50std::u16string MessageParcel::ReadInterfaceToken() 51 { 52 if (DfsMessageParcel::messageParcel == nullptr) { 53 return u""; 54 } 55 return DfsMessageParcel::messageParcel->ReadInterfaceToken(); 56 } 57 WriteInt32(int32_t value)58bool Parcel::WriteInt32(int32_t value) 59 { 60 if (DfsMessageParcel::messageParcel == nullptr) { 61 return false; 62 } 63 return DfsMessageParcel::messageParcel->WriteInt32(value); 64 } 65 ReadInt32()66int32_t Parcel::ReadInt32() 67 { 68 if (DfsMessageParcel::messageParcel == nullptr) { 69 return 0; 70 } 71 return DfsMessageParcel::messageParcel->ReadInt32(); 72 } 73 ReadInt32(int32_t & value)74bool Parcel::ReadInt32(int32_t &value) 75 { 76 if (DfsMessageParcel::messageParcel == nullptr) { 77 return false; 78 } 79 return DfsMessageParcel::messageParcel->ReadInt32(value); 80 } 81 WriteRemoteObject(const Parcelable * object)82bool Parcel::WriteRemoteObject(const Parcelable *object) 83 { 84 if (DfsMessageParcel::messageParcel == nullptr) { 85 return false; 86 } 87 return DfsMessageParcel::messageParcel->WriteRemoteObject(object); 88 } 89 WriteRemoteObject(const sptr<IRemoteObject> & object)90bool MessageParcel::WriteRemoteObject(const sptr<IRemoteObject> &object) 91 { 92 if (DfsMessageParcel::messageParcel == nullptr) { 93 return false; 94 } 95 return DfsMessageParcel::messageParcel->WriteRemoteObject(object); 96 } 97 ReadRemoteObject()98sptr<IRemoteObject> MessageParcel::ReadRemoteObject() 99 { 100 if (DfsMessageParcel::messageParcel == nullptr) { 101 return nullptr; 102 } 103 return DfsMessageParcel::messageParcel->ReadRemoteObject(); 104 } 105 ReadBool()106bool Parcel::ReadBool() 107 { 108 if (DfsMessageParcel::messageParcel == nullptr) { 109 return false; 110 } 111 return DfsMessageParcel::messageParcel->ReadBool(); 112 } 113 ReadBool(bool & value)114bool Parcel::ReadBool(bool &value) 115 { 116 if (DfsMessageParcel::messageParcel == nullptr) { 117 return false; 118 } 119 return DfsMessageParcel::messageParcel->ReadBool(value); 120 } 121 WriteBool(bool value)122bool Parcel::WriteBool(bool value) 123 { 124 if (DfsMessageParcel::messageParcel == nullptr) { 125 return false; 126 } 127 return DfsMessageParcel::messageParcel->WriteBool(value); 128 } 129 WriteString(const std::string & value)130bool Parcel::WriteString(const std::string &value) 131 { 132 if (DfsMessageParcel::messageParcel == nullptr) { 133 return false; 134 } 135 return DfsMessageParcel::messageParcel->WriteString(value); 136 } 137 WriteCString(const char * value)138bool Parcel::WriteCString(const char *value) 139 { 140 if (DfsMessageParcel::messageParcel == nullptr) { 141 return false; 142 } 143 return DfsMessageParcel::messageParcel->WriteCString(value); 144 } 145 ReadString()146const std::string Parcel::ReadString() 147 { 148 if (DfsMessageParcel::messageParcel == nullptr) { 149 return ""; 150 } 151 return DfsMessageParcel::messageParcel->ReadString(); 152 } 153 ReadString(std::string & value)154bool Parcel::ReadString(std::string &value) 155 { 156 if (DfsMessageParcel::messageParcel == nullptr) { 157 return false; 158 } 159 return DfsMessageParcel::messageParcel->ReadString(value); 160 } 161 ReadStringVector(std::vector<std::string> * value)162bool Parcel::ReadStringVector(std::vector<std::string> *value) 163 { 164 if (DfsMessageParcel::messageParcel == nullptr) { 165 return false; 166 } 167 return DfsMessageParcel::messageParcel->ReadStringVector(value); 168 } 169 WriteFileDescriptor(int fd)170bool MessageParcel::WriteFileDescriptor(int fd) 171 { 172 if (DfsMessageParcel::messageParcel == nullptr) { 173 return false; 174 } 175 return DfsMessageParcel::messageParcel->WriteFileDescriptor(fd); 176 } 177 ReadFileDescriptor()178int MessageParcel::ReadFileDescriptor() 179 { 180 if (DfsMessageParcel::messageParcel == nullptr) { 181 return 0; 182 } 183 return DfsMessageParcel::messageParcel->ReadFileDescriptor(); 184 } 185 ReadUint32(uint32_t & value)186bool Parcel::ReadUint32(uint32_t &value) 187 { 188 if (DfsMessageParcel::messageParcel == nullptr) { 189 return false; 190 } 191 return DfsMessageParcel::messageParcel->ReadUint32(value); 192 } 193 WriteUint64(uint64_t value)194bool Parcel::WriteUint64(uint64_t value) 195 { 196 if (DfsMessageParcel::messageParcel == nullptr) { 197 return false; 198 } 199 return DfsMessageParcel::messageParcel->WriteUint64(value); 200 } 201 WriteUint16(uint16_t value)202bool Parcel::WriteUint16(uint16_t value) 203 { 204 if (DfsMessageParcel::messageParcel == nullptr) { 205 return false; 206 } 207 return DfsMessageParcel::messageParcel->WriteUint16(value); 208 } 209 WriteUint32(uint32_t value)210bool Parcel::WriteUint32(uint32_t value) 211 { 212 if (DfsMessageParcel::messageParcel == nullptr) { 213 return false; 214 } 215 return DfsMessageParcel::messageParcel->WriteUint32(value); 216 } 217 ReadUint64(uint64_t & value)218bool Parcel::ReadUint64(uint64_t &value) 219 { 220 if (DfsMessageParcel::messageParcel == nullptr) { 221 return false; 222 } 223 return DfsMessageParcel::messageParcel->ReadUint64(value); 224 } 225 VerifySystemApp()226bool PermissionHelper::VerifySystemApp() 227 { 228 if (DfsMessageParcel::messageParcel == nullptr) { 229 return false; 230 } 231 return DfsMessageParcel::messageParcel->VerifySystemApp(); 232 } 233 CheckMouseCursor()234bool PermissionHelper::CheckMouseCursor() 235 { 236 if (DfsMessageParcel::messageParcel == nullptr) { 237 return false; 238 } 239 return DfsMessageParcel::messageParcel->CheckMouseCursor(); 240 } 241 CheckInputEventFilter()242bool PermissionHelper::CheckInputEventFilter() 243 { 244 if (DfsMessageParcel::messageParcel == nullptr) { 245 return false; 246 } 247 return DfsMessageParcel::messageParcel->CheckInputEventFilter(); 248 } 249 CheckInjectPermission()250bool PermissionHelper::CheckInjectPermission() 251 { 252 return DfsMessageParcel::messageParcel->CheckInjectPermission(); 253 } 254 CheckInterceptor()255bool PermissionHelper::CheckInterceptor() 256 { 257 if (DfsMessageParcel::messageParcel == nullptr) { 258 return false; 259 } 260 return DfsMessageParcel::messageParcel->CheckInterceptor(); 261 } 262 CheckMonitor()263bool PermissionHelper::CheckMonitor() 264 { 265 if (DfsMessageParcel::messageParcel == nullptr) { 266 return false; 267 } 268 return DfsMessageParcel::messageParcel->CheckMonitor(); 269 } 270 CheckDispatchControl()271bool PermissionHelper::CheckDispatchControl() 272 { 273 if (DfsMessageParcel::messageParcel == nullptr) { 274 return false; 275 } 276 return DfsMessageParcel::messageParcel->CheckDispatchControl(); 277 } 278 CheckInfraredEmmit()279bool PermissionHelper::CheckInfraredEmmit() 280 { 281 if (DfsMessageParcel::messageParcel == nullptr) { 282 return false; 283 } 284 return DfsMessageParcel::messageParcel->CheckInfraredEmmit(); 285 } 286 CheckAuthorize()287bool PermissionHelper::CheckAuthorize() 288 { 289 if (DfsMessageParcel::messageParcel == nullptr) { 290 return false; 291 } 292 return DfsMessageParcel::messageParcel->CheckAuthorize(); 293 } 294 WriteBoolVector(const std::vector<bool> & val)295bool Parcel::WriteBoolVector(const std::vector<bool> &val) 296 { 297 if (DfsMessageParcel::messageParcel == nullptr) { 298 return false; 299 } 300 return DfsMessageParcel::messageParcel->WriteBoolVector(val); 301 } 302 WriteInt32Vector(const std::vector<int32_t> & val)303bool Parcel::WriteInt32Vector(const std::vector<int32_t> &val) 304 { 305 if (DfsMessageParcel::messageParcel == nullptr) { 306 return false; 307 } 308 return DfsMessageParcel::messageParcel->WriteInt32Vector(val); 309 } 310 ReadInt64()311int64_t Parcel::ReadInt64() 312 { 313 if (DfsMessageParcel::messageParcel == nullptr) { 314 return 0; 315 } 316 return DfsMessageParcel::messageParcel->ReadInt64(); 317 } 318 ReadInt64(int64_t & value)319bool Parcel::ReadInt64(int64_t &value) 320 { 321 if (DfsMessageParcel::messageParcel == nullptr) { 322 return false; 323 } 324 return DfsMessageParcel::messageParcel->ReadInt64(value); 325 } 326 ReadFloat()327float Parcel::ReadFloat() 328 { 329 if (DfsMessageParcel::messageParcel == nullptr) { 330 return 0.0f; 331 } 332 return DfsMessageParcel::messageParcel->ReadFloat(); 333 } 334 ReadFloat(float & value)335bool Parcel::ReadFloat(float &value) 336 { 337 if (DfsMessageParcel::messageParcel == nullptr) { 338 return false; 339 } 340 return DfsMessageParcel::messageParcel->ReadFloat(value); 341 } 342 ReadDouble()343double Parcel::ReadDouble() 344 { 345 if (DfsMessageParcel::messageParcel == nullptr) { 346 return 0.0; 347 } 348 return DfsMessageParcel::messageParcel->ReadDouble(); 349 } 350 ReadDouble(double & value)351bool Parcel::ReadDouble(double &value) 352 { 353 if (DfsMessageParcel::messageParcel == nullptr) { 354 return false; 355 } 356 return DfsMessageParcel::messageParcel->ReadDouble(value); 357 } 358 Unmarshalling(Parcel & parcel)359Media::PixelMap *Media::PixelMap::Unmarshalling(Parcel &parcel) 360 { 361 if (DfsMessageParcel::messageParcel == nullptr) { 362 return nullptr; 363 } 364 return DfsMessageParcel::messageParcel->Unmarshalling(parcel); 365 } 366 } // namespace OHOS