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