1/* 2 * Copyright (c) 2021 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 16import { paramMock } from "../utils" 17 18export const MessageParcelClass = class MessageParcel { 19 constructor() { 20 console.warn('rpc.MessageParcel.constructor interface mocked in the Previewer. How this interface works on the' + 21 ' Previewer may be different from that on a real device.'); 22 this.reclaim = function () { 23 console.warn("MessageParcel.reclaim interface mocked in the Previewer. How this interface works on the" + 24 " Previewer may be different from that on a real device.") 25 }; 26 this.writeRemoteObject = function (...args) { 27 console.warn("MessageParcel.writeRemoteObject interface mocked in the Previewer. How this interface works on the" + 28 " Previewer may be different from that on a real device.") 29 return paramMock.paramBooleanMock 30 }; 31 this.readRemoteObject = function () { 32 console.warn("MessageParcel.readRemoteObject interface mocked in the Previewer. How this interface works on the" + 33 " Previewer may be different from that on a real device.") 34 return IRemoteObjectMock 35 }; 36 this.writeInterfaceToken = function (...args) { 37 console.warn("MessageParcel.writeInterfaceToken interface mocked in the Previewer. How this interface works on the" + 38 " Previewer may be different from that on a real device.") 39 return paramMock.paramBooleanMock 40 }; 41 this.readInterfaceToken = function () { 42 console.warn("MessageParcel.readInterfaceToken interface mocked in the Previewer. How this interface works on the" + 43 " Previewer may be different from that on a real device.") 44 return paramMock.paramStringMock 45 }; 46 this.getSize = function () { 47 console.warn("MessageParcel.getSize interface mocked in the Previewer. How this interface works on the" + 48 " Previewer may be different from that on a real device.") 49 return paramMock.paramNumberMock 50 }; 51 this.getCapacity = function () { 52 console.warn("MessageParcel.getCapacity interface mocked in the Previewer. How this interface works on the" + 53 " Previewer may be different from that on a real device.") 54 return paramMock.paramNumberMock 55 }; 56 this.setSize = function (...args) { 57 console.warn("MessageParcel.setSize interface mocked in the Previewer. How this interface works on the" + 58 " Previewer may be different from that on a real device.") 59 return paramMock.paramBooleanMock 60 }; 61 this.setCapacity = function (...args) { 62 console.warn("MessageParcel.setCapacity interface mocked in the Previewer. How this interface works on the" + 63 " Previewer may be different from that on a real device.") 64 return paramMock.paramBooleanMock 65 }; 66 this.getWritableBytes = function () { 67 console.warn("MessageParcel.getWritableBytes interface mocked in the Previewer. How this interface works on the" + 68 " Previewer may be different from that on a real device.") 69 return paramMock.paramNumberMock 70 }; 71 this.getReadableBytes = function () { 72 console.warn("MessageParcel.getReadableBytes interface mocked in the Previewer. How this interface works on the" + 73 " Previewer may be different from that on a real device.") 74 return paramMock.paramNumberMock 75 }; 76 this.getReadPosition = function () { 77 console.warn("MessageParcel.getReadPosition interface mocked in the Previewer. How this interface works on the" + 78 " Previewer may be different from that on a real device.") 79 return paramMock.paramNumberMock 80 }; 81 this.getWritePosition = function () { 82 console.warn("MessageParcel.getWritePosition interface mocked in the Previewer. How this interface works on the" + 83 " Previewer may be different from that on a real device.") 84 return paramMock.paramNumberMock 85 }; 86 this.rewindRead = function (...args) { 87 console.warn("MessageParcel.rewindRead interface mocked in the Previewer. How this interface works on the" + 88 " Previewer may be different from that on a real device.") 89 return paramMock.paramBooleanMock 90 }; 91 this.rewindWrite = function (...args) { 92 console.warn("MessageParcel.rewindWrite interface mocked in the Previewer. How this interface works on the" + 93 " Previewer may be different from that on a real device.") 94 return paramMock.paramBooleanMock 95 }; 96 this.writeNoException = function () { 97 console.warn("MessageParcel.writeNoException interface mocked in the Previewer. How this interface works on the" + 98 " Previewer may be different from that on a real device.") 99 }; 100 this.readException = function () { 101 console.warn("MessageParcel.readException interface mocked in the Previewer. How this interface works on the" + 102 " Previewer may be different from that on a real device.") 103 }; 104 this.writeByte = function (...args) { 105 console.warn("MessageParcel.writeByte interface mocked in the Previewer. How this interface works on the" + 106 " Previewer may be different from that on a real device.") 107 return paramMock.paramBooleanMock 108 }; 109 this.writeShort = function (...args) { 110 console.warn("MessageParcel.writeShort interface mocked in the Previewer. How this interface works on the" + 111 " Previewer may be different from that on a real device.") 112 return paramMock.paramBooleanMock 113 }; 114 this.writeInt = function (...args) { 115 console.warn("MessageParcel.writeInt interface mocked in the Previewer. How this interface works on the" + 116 " Previewer may be different from that on a real device.") 117 return paramMock.paramBooleanMock 118 }; 119 this.writeLong = function (...args) { 120 console.warn("MessageParcel.writeLong interface mocked in the Previewer. How this interface works on the" + 121 " Previewer may be different from that on a real device.") 122 return paramMock.paramBooleanMock 123 }; 124 this.writeFloat = function (...args) { 125 console.warn("MessageParcel.writeFloat interface mocked in the Previewer. How this interface works on the" + 126 " Previewer may be different from that on a real device.") 127 return paramMock.paramBooleanMock 128 }; 129 this.writeDouble = function (...args) { 130 console.warn("MessageParcel.writeDouble interface mocked in the Previewer. How this interface works on the" + 131 " Previewer may be different from that on a real device.") 132 return paramMock.paramBooleanMock 133 }; 134 this.writeBoolean = function (...args) { 135 console.warn("MessageParcel.writeBoolean interface mocked in the Previewer. How this interface works on the" + 136 " Previewer may be different from that on a real device.") 137 return paramMock.paramBooleanMock 138 }; 139 this.writeChar = function (...args) { 140 console.warn("MessageParcel.writeChar interface mocked in the Previewer. How this interface works on the" + 141 " Previewer may be different from that on a real device.") 142 return paramMock.paramBooleanMock 143 }; 144 this.writeString = function (...args) { 145 console.warn("MessageParcel.writeString interface mocked in the Previewer. How this interface works on the" + 146 " Previewer may be different from that on a real device.") 147 return paramMock.paramBooleanMock 148 }; 149 this.writeSequenceable = function (...args) { 150 console.warn("MessageParcel.writeSequenceable interface mocked in the Previewer. How this interface works on the" + 151 " Previewer may be different from that on a real device.") 152 return paramMock.paramBooleanMock 153 }; 154 this.writeByteArray = function (...args) { 155 console.warn("MessageParcel.writeByteArray interface mocked in the Previewer. How this interface works on the" + 156 " Previewer may be different from that on a real device.") 157 return paramMock.paramBooleanMock 158 }; 159 this.writeShortArray = function (...args) { 160 console.warn("MessageParcel.writeShortArray interface mocked in the Previewer. How this interface works on the" + 161 " Previewer may be different from that on a real device.") 162 return paramMock.paramBooleanMock 163 }; 164 this.writeIntArray = function (...args) { 165 console.warn("MessageParcel.writeIntArray interface mocked in the Previewer. How this interface works on the" + 166 " Previewer may be different from that on a real device.") 167 return paramMock.paramBooleanMock 168 }; 169 this.writeLongArray = function (...args) { 170 console.warn("MessageParcel.writeLongArray interface mocked in the Previewer. How this interface works on the" + 171 " Previewer may be different from that on a real device.") 172 return paramMock.paramBooleanMock 173 }; 174 this.writeFloatArray = function (...args) { 175 console.warn("MessageParcel.writeFloatArray interface mocked in the Previewer. How this interface works on the" + 176 " Previewer may be different from that on a real device.") 177 return paramMock.paramBooleanMock 178 }; 179 this.writeDoubleArray = function (...args) { 180 console.warn("MessageParcel.writeDoubleArray interface mocked in the Previewer. How this interface works on the" + 181 " Previewer may be different from that on a real device.") 182 return paramMock.paramBooleanMock 183 }; 184 this.writeBooleanArray = function (...args) { 185 console.warn("MessageParcel.writeBooleanArray interface mocked in the Previewer. How this interface works on the" + 186 " Previewer may be different from that on a real device.") 187 return paramMock.paramBooleanMock 188 }; 189 this.writeCharArray = function (...args) { 190 console.warn("MessageParcel.writeCharArray interface mocked in the Previewer. How this interface works on the" + 191 " Previewer may be different from that on a real device.") 192 return paramMock.paramBooleanMock 193 }; 194 this.writeStringArray = function (...args) { 195 console.warn("MessageParcel.writeStringArray interface mocked in the Previewer. How this interface works on the" + 196 " Previewer may be different from that on a real device.") 197 return paramMock.paramBooleanMock 198 }; 199 this.writeSequenceableArray = function (...args) { 200 console.warn("MessageParcel.writeSequenceableArray interface mocked in the Previewer. How this interface works on the" + 201 " Previewer may be different from that on a real device.") 202 return paramMock.paramBooleanMock 203 }; 204 this.writeRemoteObjectArray = function (...args) { 205 console.warn("MessageParcel.writeRemoteObjectArray interface mocked in the Previewer. How this interface works on the" + 206 " Previewer may be different from that on a real device.") 207 return paramMock.paramBooleanMock 208 }; 209 this.readByte = function () { 210 console.warn("MessageParcel.readByte interface mocked in the Previewer. How this interface works on the" + 211 " Previewer may be different from that on a real device.") 212 return paramMock.paramNumberMock 213 }; 214 this.readShort = function () { 215 console.warn("MessageParcel.readShort interface mocked in the Previewer. How this interface works on the" + 216 " Previewer may be different from that on a real device.") 217 return paramMock.paramNumberMock 218 }; 219 this.readInt = function () { 220 console.warn("MessageParcel.readInt interface mocked in the Previewer. How this interface works on the" + 221 " Previewer may be different from that on a real device.") 222 return paramMock.paramNumberMock 223 }; 224 this.readLong = function () { 225 console.warn("MessageParcel.readLong interface mocked in the Previewer. How this interface works on the" + 226 " Previewer may be different from that on a real device.") 227 return paramMock.paramNumberMock 228 }; 229 this.readFloat = function () { 230 console.warn("MessageParcel.readFloat interface mocked in the Previewer. How this interface works on the" + 231 " Previewer may be different from that on a real device.") 232 return paramMock.paramNumberMock 233 }; 234 this.readDouble = function () { 235 console.warn("MessageParcel.readDouble interface mocked in the Previewer. How this interface works on the" + 236 " Previewer may be different from that on a real device.") 237 return paramMock.paramNumberMock 238 }; 239 this.readBoolean = function () { 240 console.warn("MessageParcel.readBoolean interface mocked in the Previewer. How this interface works on the" + 241 " Previewer may be different from that on a real device.") 242 return paramMock.paramBooleanMock 243 }; 244 this.readChar = function () { 245 console.warn("MessageParcel.readChar interface mocked in the Previewer. How this interface works on the" + 246 " Previewer may be different from that on a real device.") 247 return paramMock.paramNumberMock 248 }; 249 this.readString = function () { 250 console.warn("MessageParcel.readString interface mocked in the Previewer. How this interface works on the" + 251 " Previewer may be different from that on a real device.") 252 return paramMock.paramStringMock 253 }; 254 this.readSequenceable = function (...args) { 255 console.warn("MessageParcel.readSequenceable interface mocked in the Previewer. How this interface works on the" + 256 " Previewer may be different from that on a real device.") 257 return paramMock.paramBooleanMock 258 }; 259 this.readByteArray = function (...args) { 260 console.warn("MessageParcel.readByteArray interface mocked in the Previewer. How this interface works on the" + 261 " Previewer may be different from that on a real device.") 262 }; 263 this.readByteArray = function () { 264 console.warn("MessageParcel.readByteArray interface mocked in the Previewer. How this interface works on the" + 265 " Previewer may be different from that on a real device.") 266 return paramMock.paramArrayMock; 267 }; 268 this.readShortArray = function (...args) { 269 console.warn("MessageParcel.readShortArray interface mocked in the Previewer. How this interface works on the" + 270 " Previewer may be different from that on a real device.") 271 }; 272 this.readShortArray = function () { 273 console.warn("MessageParcel.readShortArray interface mocked in the Previewer. How this interface works on the" + 274 " Previewer may be different from that on a real device.") 275 return paramMock.paramArrayMock; 276 }; 277 this.readIntArray = function (...args) { 278 console.warn("MessageParcel.readIntArray interface mocked in the Previewer. How this interface works on the" + 279 " Previewer may be different from that on a real device.") 280 }; 281 this.readIntArray = function () { 282 console.warn("MessageParcel.readIntArray interface mocked in the Previewer. How this interface works on the" + 283 " Previewer may be different from that on a real device.") 284 return paramMock.paramArrayMock; 285 }; 286 this.readLongArray = function (...args) { 287 console.warn("MessageParcel.readLongArray interface mocked in the Previewer. How this interface works on the" + 288 " Previewer may be different from that on a real device.") 289 }; 290 this.readLongArray = function () { 291 console.warn("MessageParcel.readLongArray interface mocked in the Previewer. How this interface works on the" + 292 " Previewer may be different from that on a real device.") 293 return paramMock.paramArrayMock; 294 }; 295 this.readFloatArray = function (...args) { 296 console.warn("MessageParcel.readFloatArray interface mocked in the Previewer. How this interface works on the" + 297 " Previewer may be different from that on a real device.") 298 }; 299 this.readFloatArray = function () { 300 console.warn("MessageParcel.readFloatArray interface mocked in the Previewer. How this interface works on the" + 301 " Previewer may be different from that on a real device.") 302 return paramMock.paramArrayMock; 303 }; 304 this.readDoubleArray = function (...args) { 305 console.warn("MessageParcel.readDoubleArray interface mocked in the Previewer. How this interface works on the" + 306 " Previewer may be different from that on a real device.") 307 }; 308 this.readDoubleArray = function () { 309 console.warn("MessageParcel.readDoubleArray interface mocked in the Previewer. How this interface works on the" + 310 " Previewer may be different from that on a real device.") 311 return paramMock.paramArrayMock; 312 }; 313 this.readBooleanArray = function (...args) { 314 console.warn("MessageParcel.readBooleanArray interface mocked in the Previewer. How this interface works on the" + 315 " Previewer may be different from that on a real device.") 316 }; 317 this.readBooleanArray = function () { 318 console.warn("MessageParcel.readBooleanArray interface mocked in the Previewer. How this interface works on the" + 319 " Previewer may be different from that on a real device.") 320 return paramMock.paramArrayMock; 321 }; 322 this.readCharArray = function (...args) { 323 console.warn("MessageParcel.readCharArray interface mocked in the Previewer. How this interface works on the" + 324 " Previewer may be different from that on a real device.") 325 }; 326 this.readCharArray = function () { 327 console.warn("MessageParcel.readCharArray interface mocked in the Previewer. How this interface works on the" + 328 " Previewer may be different from that on a real device.") 329 return paramMock.paramArrayMock; 330 }; 331 this.readStringArray = function (...args) { 332 console.warn("MessageParcel.readStringArray interface mocked in the Previewer. How this interface works on the" + 333 " Previewer may be different from that on a real device.") 334 }; 335 this.readStringArray = function () { 336 console.warn("MessageParcel.readStringArray interface mocked in the Previewer. How this interface works on the" + 337 " Previewer may be different from that on a real device.") 338 return paramMock.paramArrayMock; 339 }; 340 this.readSequenceableArray = function (...args) { 341 console.warn("MessageParcel.readSequenceableArray interface mocked in the Previewer. How this interface works on the" + 342 " Previewer may be different from that on a real device.") 343 }; 344 this.readRemoteObjectArray = function (...args) { 345 console.warn("MessageParcel.readRemoteObjectArray interface mocked in the Previewer. How this interface works on the" + 346 " Previewer may be different from that on a real device.") 347 }; 348 this.readRemoteObjectArray = function () { 349 console.warn("MessageParcel.readRemoteObjectArray interface mocked in the Previewer. How this interface works on the" + 350 " Previewer may be different from that on a real device.") 351 return paramMock.paramArrayMock; 352 }; 353 this.containFileDescriptors = function () { 354 console.warn("MessageParcel.containFileDescriptors interface mocked in the Previewer. How this interface works on the" + 355 " Previewer may be different from that on a real device.") 356 return paramMock.paramBooleanMock; 357 }; 358 this.writeFileDescriptor = function (...args) { 359 console.warn("MessageParcel.writeFileDescriptor interface mocked in the Previewer. How this interface works on the" + 360 " Previewer may be different from that on a real device.") 361 return paramMock.paramBooleanMock; 362 }; 363 this.readFileDescriptor = function () { 364 console.warn("MessageParcel.readFileDescriptor interface mocked in the Previewer. How this interface works on the" + 365 " Previewer may be different from that on a real device.") 366 return paramMock.paramNumberMock; 367 }; 368 this.writeAshmem = function (...args) { 369 console.warn("MessageParcel.writeAshmem interface mocked in the Previewer. How this interface works on the" + 370 " Previewer may be different from that on a real device.") 371 return paramMock.paramBooleanMock; 372 }; 373 this.readAshmem = function () { 374 console.warn("MessageParcel.readAshmem interface mocked in the Previewer. How this interface works on the" + 375 " Previewer may be different from that on a real device.") 376 return new AshmemClass(); 377 }; 378 this.getRawDataCapacity = function () { 379 console.warn("MessageParcel.getRawDataCapacity interface mocked in the Previewer. How this interface works on the" + 380 " Previewer may be different from that on a real device.") 381 return paramMock.paramNumberMock; 382 }; 383 this.writeRawData = function (...args) { 384 console.warn("MessageParcel.writeRawData interface mocked in the Previewer. How this interface works on the" + 385 " Previewer may be different from that on a real device.") 386 return paramMock.paramBooleanMock; 387 }; 388 this.readRawData = function (...args) { 389 console.warn("MessageParcel.readRawData interface mocked in the Previewer. How this interface works on the" + 390 " Previewer may be different from that on a real device.") 391 return paramMock.paramArrayMock; 392 }; 393 } 394}; 395MessageParcelClass.create = function () { 396 console.warn("MessageParcel.create interface mocked in the Previewer. How this interface works on the" + 397 " Previewer may be different from that on a real device.") 398 return new MessageParcelClass() 399}; 400MessageParcelClass.closeFileDescriptor = function (...args) { 401 console.warn("MessageParcel.closeFileDescriptor interface mocked in the Previewer. How this interface works on the" + 402 " Previewer may be different from that on a real device.") 403}; 404MessageParcelClass.dupFileDescriptor = function (...args) { 405 console.warn("MessageParcel.dupFileDescriptor interface mocked in the Previewer. How this interface works on the" + 406 " Previewer may be different from that on a real device.") 407 return paramMock.paramNumberMock 408}; 409export const MessageOptionClass = class MessageOption { 410 constructor(...args) { 411 console.warn('rpc.MessageOption constructor interface mocked in the Previewer. How this interface works on the' + 412 ' Previewer may be different from that on a real device.') 413 this.getFlags = function () { 414 console.warn("MessageOption.getFlags interface mocked in the Previewer. How this interface works on the" + 415 " Previewer may be different from that on a real device.") 416 return paramMock.paramNumberMock 417 }; 418 this.setFlags = function (...args) { 419 console.warn("MessageOption.setFlags interface mocked in the Previewer. How this interface works on the" + 420 " Previewer may be different from that on a real device.") 421 }; 422 this.getWaitTime = function () { 423 console.warn("MessageOption.getWaitTime interface mocked in the Previewer. How this interface works on the" + 424 " Previewer may be different from that on a real device.") 425 return paramMock.paramNumberMock 426 }; 427 this.setWaitTime = function (...args) { 428 console.warn("MessageOption.setWaitTime interface mocked in the Previewer. How this interface works on the" + 429 " Previewer may be different from that on a real device.") 430 }; 431 } 432}; 433MessageOptionClass.TF_SYNC = '[PC preview] unknow TF_SYNC'; 434MessageOptionClass.TF_ASYNC = '[PC preview] unknow TF_ASYNC'; 435MessageOptionClass.TF_ACCEPT_FDS = '[PC preview] unknow TF_ACCEPT_FDS'; 436MessageOptionClass.TF_WAIT_TIME = '[PC preview] unknow TF_WAIT_TIME'; 437export const AshmemClass = class Ashmem { 438 constructor() { 439 console.warn('rpc.Ashmem constructor interface mocked in the Previewer. How this interface works on the' + 440 ' Previewer may be different from that on a real device.') 441 this.closeAshmem = function () { 442 console.warn('Ashmem.closeAshmem interface mocked in the Previewer. How this interface works on the' + 443 ' Previewer may be different from that on a real device.') 444 }; 445 this.unmapAshmem = function () { 446 console.warn('Ashmem.unmapAshmem interface mocked in the Previewer. How this interface works on the' + 447 ' Previewer may be different from that on a real device.') 448 }; 449 this.getAshmemSize = function () { 450 console.warn('Ashmem.getAshmemSize interface mocked in the Previewer. How this interface works on the' + 451 ' Previewer may be different from that on a real device.') 452 return paramMock.paramNumberMock 453 }; 454 this.mapAshmem = function (...args) { 455 console.warn('Ashmem.mapAshmem interface mocked in the Previewer. How this interface works on the' + 456 ' Previewer may be different from that on a real device.') 457 return paramMock.paramBooleanMock 458 }; 459 this.mapReadAndWriteAshmem = function () { 460 console.warn('Ashmem.mapReadAndWriteAshmem interface mocked in the Previewer. How this interface works on the' + 461 ' Previewer may be different from that on a real device.') 462 return paramMock.paramBooleanMock 463 }; 464 this.mapReadOnlyAshmem = function () { 465 console.warn('Ashmem.mapReadOnlyAshmem interface mocked in the Previewer. How this interface works on the' + 466 ' Previewer may be different from that on a real device.') 467 return paramMock.paramBooleanMock 468 }; 469 this.setProtection = function (...args) { 470 console.warn('Ashmem.setProtection interface mocked in the Previewer. How this interface works on the' + 471 ' Previewer may be different from that on a real device.') 472 return paramMock.paramBooleanMock 473 }; 474 this.writeToAshmem = function (...args) { 475 console.warn('Ashmem.writeToAshmem interface mocked in the Previewer. How this interface works on the' + 476 ' Previewer may be different from that on a real device.') 477 return paramMock.paramBooleanMock 478 }; 479 this.readFromAshmem = function (...args) { 480 console.warn('Ashmem.readFromAshmem interface mocked in the Previewer. How this interface works on the' + 481 ' Previewer may be different from that on a real device.') 482 return paramMock.paramArrayMock 483 }; 484 } 485}; 486AshmemClass.createAshmem = function (...args) { 487 console.warn('Ashmem.createAshmem interface mocked in the Previewer. How this interface works on the' + 488 ' Previewer may be different from that on a real device.') 489 return new AshmemClass() 490}; 491AshmemClass.createAshmemFromExisting = function (...args) { 492 console.warn('Ashmem.createAshmemFromExisting interface mocked in the Previewer. How this interface works on the' + 493 ' Previewer may be different from that on a real device.') 494 return new AshmemClass() 495}; 496AshmemClass.PROT_EXEC = '[PC preview] unknow PROT_EXEC'; 497AshmemClass.PROT_NONE = '[PC preview] unknow PROT_NONE'; 498AshmemClass.PROT_READ = '[PC preview] unknow PROT_READ'; 499AshmemClass.PROT_WRITE = '[PC preview] unknow PROT_WRITE'; 500export const RemoteObjectClass = class RemoteObject { 501 constructor(...args) { 502 console.warn("rpc.RemoteObject constructor interface mocked in the Previewer. How this interface works on the" + 503 " Previewer may be different from that on a real device.") 504 this.queryLocalInterface = function (...args) { 505 console.warn("RemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the" + 506 " Previewer may be different from that on a real device.") 507 return IRemoteBrokerMock 508 }; 509 this.getInterfaceDescriptor = function () { 510 console.warn("RemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the" + 511 " Previewer may be different from that on a real device.") 512 return paramMock.paramStringMock 513 }; 514 this.onRemoteRequest = function (...args) { 515 console.warn("RemoteObject.onRemoteRequest interface mocked in the Previewer. How this interface works on the" + 516 " Previewer may be different from that on a real device.") 517 return paramMock.paramBooleanMock 518 }; 519 this.sendRequest = function (...args) { 520 console.warn("RemoteObject.sendRequest interface mocked in the Previewer. How this interface works on the" + 521 " Previewer may be different from that on a real device.") 522 const len = args.length 523 if (len > 0 && typeof args[len - 1] === 'function') { 524 args[len - 1].call(this, SendRequestResultMock) 525 } else { 526 return new Promise((resolve, reject) => { 527 resolve(SendRequestResultMock) 528 }) 529 } 530 }; 531 this.getCallingPid = function () { 532 console.warn("RemoteObject.getCallingPid interface mocked in the Previewer. How this interface works on the" + 533 " Previewer may be different from that on a real device.") 534 return paramMock.paramNumberMock 535 }; 536 this.getCallingUid = function () { 537 console.warn("RemoteObject.getCallingUid interface mocked in the Previewer. How this interface works on the" + 538 " Previewer may be different from that on a real device.") 539 return paramMock.paramNumberMock 540 }; 541 this.attachLocalInterface = function (...args) { 542 console.warn("RemoteObject.attachLocalInterface interface mocked in the Previewer. How this interface works on the" + 543 " Previewer may be different from that on a real device.") 544 }; 545 this.addDeathRecipient = function (...args) { 546 console.warn("RemoteObject.addDeathRecipient interface mocked in the Previewer. How this interface works on the" + 547 " Previewer may be different from that on a real device.") 548 return paramMock.paramBooleanMock 549 }; 550 this.removeDeathRecipient = function (...args) { 551 console.warn("RemoteObject.removeDeathRecipient interface mocked in the Previewer. How this interface works on the" + 552 " Previewer may be different from that on a real device.") 553 return paramMock.paramBooleanMock 554 }; 555 this.isObjectDead = function () { 556 console.warn("RemoteObject.isObjectDead interface mocked in the Previewer. How this interface works on the" + 557 " Previewer may be different from that on a real device.") 558 return paramMock.paramBooleanMock 559 }; 560 } 561}; 562export const RemoteProxyClass = class RemoteProxy { 563 constructor() { 564 console.warn("rpc.RemoteProxy constructor interface mocked in the Previewer. How this interface works on the" + 565 " Previewer may be different from that on a real device.") 566 this.queryLocalInterface = function (...args) { 567 console.warn("RemoteProxy.queryLocalInterface interface mocked in the Previewer. How this interface works on the" + 568 " Previewer may be different from that on a real device.") 569 return IRemoteBrokerMock 570 }; 571 this.getInterfaceDescriptor = function () { 572 console.warn("RemoteProxy.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the" + 573 " Previewer may be different from that on a real device.") 574 return paramMock.paramStringMock 575 }; 576 this.addDeathRecipient = function (...args) { 577 console.warn("RemoteProxy.addDeathRecipient interface mocked in the Previewer. How this interface works on the" + 578 " Previewer may be different from that on a real device.") 579 return paramMock.paramBooleanMock 580 }; 581 this.removeDeathRecipient = function (...args) { 582 console.warn("RemoteProxy.removeDeathRecipient interface mocked in the Previewer. How this interface works on the" + 583 " Previewer may be different from that on a real device.") 584 return paramMock.paramBooleanMock 585 }; 586 this.isObjectDead = function () { 587 console.warn("RemoteProxy.isObjectDead interface mocked in the Previewer. How this interface works on the" + 588 " Previewer may be different from that on a real device.") 589 return paramMock.paramBooleanMock 590 }; 591 this.sendRequest = function (...args) { 592 console.warn("RemoteProxy.sendRequest mocked in the Previewer. How this interface works on the" + 593 " Previewer may be different from that on a real device.") 594 const len = args.length 595 if (len > 0 && typeof args[len - 1] === 'function') { 596 args[len - 1].call(this, SendRequestResultMock) 597 } else { 598 return new Promise((resolve, reject) => { 599 resolve(SendRequestResultMock) 600 }) 601 } 602 }; 603 } 604}; 605RemoteProxyClass.PING_TRANSACTION = '[PC preview] unknow PING_TRANSACTION'; 606RemoteProxyClass.DUMP_TRANSACTION = '[PC preview] unknow DUMP_TRANSACTION'; 607RemoteProxyClass.INTERFACE_TRANSACTION = '[PC preview] unknow INTERFACE_TRANSACTION'; 608RemoteProxyClass.MIN_TRANSACTION_ID = '[PC preview] unknow MIN_TRANSACTION_ID'; 609RemoteProxyClass.MAX_TRANSACTION_ID = '[PC preview] unknow MAX_TRANSACTION_ID'; 610export const IRemoteObjectMock = { 611 queryLocalInterface: function (...args) { 612 console.warn("IRemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the" + 613 " Previewer may be different from that on a real device.") 614 return IRemoteBrokerMock 615 }, 616 sendRequest: function (...args) { 617 console.warn("IRemoteObject.sendRequest interface mocked in the Previewer. How this interface works on the" + 618 " Previewer may be different from that on a real device.") 619 const len = args.length 620 if (len > 0 && typeof args[len - 1] === 'function') { 621 args[len - 1].call(this, SendRequestResultMock) 622 } else { 623 return new Promise((resolve, reject) => { 624 resolve(SendRequestResultMock) 625 }) 626 } 627 }, 628 addDeathRecipient: function (...args) { 629 console.warn("IRemoteObject.addDeathRecipient interface mocked in the Previewer. How this interface works on the" + 630 " Previewer may be different from that on a real device.") 631 return paramMock.paramBooleanMock 632 }, 633 removeDeathRecipient: function (...args) { 634 console.warn("IRemoteObject.removeDeathRecipient interface mocked in the Previewer. How this interface works on the" + 635 " Previewer may be different from that on a real device.") 636 return paramMock.paramBooleanMock 637 }, 638 getInterfaceDescriptor: function () { 639 console.warn("IRemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the" + 640 " Previewer may be different from that on a real device.") 641 return paramMock.paramStringMock 642 }, 643 isObjectDead: function () { 644 console.warn("IRemoteObject.isObjectDead interface mocked in the Previewer. How this interface works on the" + 645 " Previewer may be different from that on a real device.") 646 return paramMock.paramBooleanMock 647 } 648}; 649export const IRemoteBrokerMock = { 650 asObject: function () { 651 console.warn("IRemoteBroker.asObject interface mocked in the Previewer. How this interface works on the" + 652 " Previewer may be different from that on a real device.") 653 return IRemoteObjectMock 654 } 655}; 656export const SendRequestResultMock = { 657 errCode: "[PC Preview]: unknow errCode", 658 code: "[PC Preview]: unknow code", 659 data: "[PC Preview]: unknow data", 660 reply: "[PC Preview]: unknow reply", 661}; 662export const SequenceableMock = { 663 marshalling: function (...args) { 664 console.warn("Sequenceable.marshalling interface mocked in the Previewer. How this interface works on the" + 665 " Previewer may be different from that on a real device.") 666 return paramMock.paramBooleanMock 667 }, 668 669 unmarshalling: function (...args) { 670 console.warn("Sequenceable.unmarshalling interface mocked in the Previewer. How this interface works on the" + 671 " Previewer may be different from that on a real device.") 672 return paramMock.paramBooleanMock 673 } 674}; 675export const DeathRecipientMock = { 676 onRemoteDied: function () { 677 console.warn("DeathRecipient.onRemoteDied interface mocked in the Previewer. How this interface works on the" + 678 " Previewer may be different from that on a real device.") 679 } 680}; 681export const IPCSkeletonMock = { 682 getContextObject: function () { 683 console.warn("IPCSkeleton.getContextObject interface mocked in the Previewer. How this interface works on the" + 684 " Previewer may be different from that on a real device.") 685 return IRemoteObjectMock 686 }, 687 getCallingPid: function () { 688 console.warn("IPCSkeleton.getCallingPid interface mocked in the Previewer. How this interface works on the" + 689 " Previewer may be different from that on a real device.") 690 return paramMock.paramNumberMock 691 }, 692 getCallingUid: function () { 693 console.warn("IPCSkeleton.getCallingUid interface mocked in the Previewer. How this interface works on the" + 694 " Previewer may be different from that on a real device.") 695 return paramMock.paramNumberMock 696 }, 697 getCallingTokenId: function () { 698 console.warn("IPCSkeleton.getCallingTokenId interface mocked in the Previewer. How this interface works on the" + 699 " Previewer may be different from that on a real device.") 700 return paramMock.paramNumberMock 701 }, 702 getCallingDeviceID: function () { 703 console.warn("IPCSkeleton.getCallingDeviceID interface mocked in the Previewer. How this interface works on the" + 704 " Previewer may be different from that on a real device.") 705 return paramMock.paramStringMock 706 }, 707 getLocalDeviceID: function () { 708 console.warn("IPCSkeleton.getLocalDeviceID interface mocked in the Previewer. How this interface works on the" + 709 " Previewer may be different from that on a real device.") 710 return paramMock.paramStringMock 711 }, 712 isLocalCalling: function () { 713 console.warn("IPCSkeleton.isLocalCalling interface mocked in the Previewer. How this interface works on the" + 714 " Previewer may be different from that on a real device.") 715 return paramMock.paramBooleanMock 716 }, 717 flushCommands: function (...args) { 718 console.warn("IPCSkeleton.flushCommands interface mocked in the Previewer. How this interface works on the" + 719 " Previewer may be different from that on a real device.") 720 return paramMock.paramNumberMock 721 }, 722 resetCallingIdentity: function () { 723 console.warn("IPCSkeleton.resetCallingIdentity interface mocked in the Previewer. How this interface works on the" + 724 " Previewer may be different from that on a real device.") 725 return paramMock.paramStringMock 726 }, 727 setCallingIdentity: function (...args) { 728 console.warn("IPCSkeleton.setCallingIdentity interface mocked in the Previewer. How this interface works on the" + 729 " Previewer may be different from that on a real device.") 730 return paramMock.paramBooleanMock 731 } 732}; 733export function mockRpc() { 734 const rpcMock = { 735 IRemoteObject: IRemoteObjectMock, 736 IRemoteBroker: IRemoteBrokerMock, 737 SendRequestResult: SendRequestResultMock, 738 Sequenceable: SequenceableMock, 739 DeathRecipient: DeathRecipientMock, 740 IPCSkeleton: IPCSkeletonMock, 741 MessageParcel: MessageParcelClass, 742 MessageOption: MessageOptionClass, 743 Ashmem: AshmemClass, 744 RemoteObject: RemoteObjectClass, 745 RemoteProxy: RemoteProxyClass 746 }; 747 return rpcMock 748} 749