• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 import { paramMock } from "../utils"
17 
18 export 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 };
395 MessageParcelClass.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 };
400 MessageParcelClass.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 };
404 MessageParcelClass.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 };
409 export 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     this.TF_SYNC = 0;
432     this.TF_ASYNC = 1;
433     this.TF_ACCEPT_FDS = 0x10;
434     this.TF_WAIT_TIME = 4;
435   }
436 };
437 export 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     this.PROT_EXEC = 4;
485     this.PROT_NONE = 0;
486     this.PROT_READ = 1;
487     this.PROT_WRITE = 2;
488   }
489 };
490 AshmemClass.createAshmem = function (...args) {
491   console.warn('Ashmem.createAshmem interface mocked in the Previewer. How this interface works on the' +
492     ' Previewer may be different from that on a real device.')
493   return new AshmemClass()
494 };
495 AshmemClass.createAshmemFromExisting = function (...args) {
496   console.warn('Ashmem.createAshmemFromExisting interface mocked in the Previewer. How this interface works on the' +
497     ' Previewer may be different from that on a real device.')
498   return new AshmemClass()
499 };
500 export 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 };
562 export 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     this.PING_TRANSACTION = ('_'.charCodeAt(0) << 24) | ('P'.charCodeAt(0) << 16) |
604         ('N'.charCodeAt(0) << 8) | 'G'.charCodeAt(0);
605     this.DUMP_TRANSACTION = ('_'.charCodeAt(0) << 24) | ('D'.charCodeAt(0) << 16) |
606         ('M'.charCodeAt(0) << 8) | 'P'.charCodeAt(0);
607     this.INTERFACE_TRANSACTION = ('_'.charCodeAt(0) << 24) | ('N'.charCodeAt(0) << 16) |
608         ('T'.charCodeAt(0) << 8) | 'F'.charCodeAt(0);
609     this.MIN_TRANSACTION_ID = 0x1;
610     this.MAX_TRANSACTION_ID = 0x00FFFFFF;
611   }
612 };
613 export const IRemoteObjectMock = {
614   queryLocalInterface: function (...args) {
615     console.warn("IRemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the" +
616       " Previewer may be different from that on a real device.")
617     return IRemoteBrokerMock
618   },
619   sendRequest: function (...args) {
620     console.warn("IRemoteObject.sendRequest interface mocked in the Previewer. How this interface works on the" +
621       " Previewer may be different from that on a real device.")
622     const len = args.length
623     if (len > 0 && typeof args[len - 1] === 'function') {
624       args[len - 1].call(this, SendRequestResultMock)
625     } else {
626       return new Promise((resolve, reject) => {
627         resolve(SendRequestResultMock)
628       })
629     }
630   },
631   addDeathRecipient: function (...args) {
632     console.warn("IRemoteObject.addDeathRecipient interface mocked in the Previewer. How this interface works on the" +
633       " Previewer may be different from that on a real device.")
634     return paramMock.paramBooleanMock
635   },
636   removeDeathRecipient: function (...args) {
637     console.warn("IRemoteObject.removeDeathRecipient interface mocked in the Previewer. How this interface works on the" +
638       " Previewer may be different from that on a real device.")
639     return paramMock.paramBooleanMock
640   },
641   getInterfaceDescriptor: function () {
642     console.warn("IRemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the" +
643       " Previewer may be different from that on a real device.")
644     return paramMock.paramStringMock
645   },
646   isObjectDead: function () {
647     console.warn("IRemoteObject.isObjectDead interface mocked in the Previewer. How this interface works on the" +
648       " Previewer may be different from that on a real device.")
649     return paramMock.paramBooleanMock
650   }
651 };
652 export const IRemoteBrokerMock = {
653   asObject: function () {
654     console.warn("IRemoteBroker.asObject interface mocked in the Previewer. How this interface works on the" +
655       " Previewer may be different from that on a real device.")
656     return IRemoteObjectMock
657   }
658 };
659 export const SendRequestResultMock = {
660   errCode: "[PC Preview]: unknow errCode",
661   code: "[PC Preview]: unknow code",
662   data: "[PC Preview]: unknow data",
663   reply: "[PC Preview]: unknow reply",
664 };
665 export const SequenceableMock = {
666   marshalling: function (...args) {
667     console.warn("Sequenceable.marshalling interface mocked in the Previewer. How this interface works on the" +
668       " Previewer may be different from that on a real device.")
669     return paramMock.paramBooleanMock
670   },
671 
672   unmarshalling: function (...args) {
673     console.warn("Sequenceable.unmarshalling interface mocked in the Previewer. How this interface works on the" +
674       " Previewer may be different from that on a real device.")
675     return paramMock.paramBooleanMock
676   }
677 };
678 export const DeathRecipientMock = {
679   onRemoteDied: function () {
680     console.warn("DeathRecipient.onRemoteDied interface mocked in the Previewer. How this interface works on the" +
681       " Previewer may be different from that on a real device.")
682   }
683 };
684 export const IPCSkeletonMock = {
685   getContextObject: function () {
686     console.warn("IPCSkeleton.getContextObject interface mocked in the Previewer. How this interface works on the" +
687       " Previewer may be different from that on a real device.")
688     return IRemoteObjectMock
689   },
690   getCallingPid: function () {
691     console.warn("IPCSkeleton.getCallingPid interface mocked in the Previewer. How this interface works on the" +
692       " Previewer may be different from that on a real device.")
693     return paramMock.paramNumberMock
694   },
695   getCallingUid: function () {
696     console.warn("IPCSkeleton.getCallingUid interface mocked in the Previewer. How this interface works on the" +
697       " Previewer may be different from that on a real device.")
698     return paramMock.paramNumberMock
699   },
700   getCallingTokenId: function () {
701     console.warn("IPCSkeleton.getCallingTokenId interface mocked in the Previewer. How this interface works on the" +
702       " Previewer may be different from that on a real device.")
703     return paramMock.paramNumberMock
704   },
705   getCallingDeviceID: function () {
706     console.warn("IPCSkeleton.getCallingDeviceID interface mocked in the Previewer. How this interface works on the" +
707       " Previewer may be different from that on a real device.")
708     return paramMock.paramStringMock
709   },
710   getLocalDeviceID: function () {
711     console.warn("IPCSkeleton.getLocalDeviceID interface mocked in the Previewer. How this interface works on the" +
712       " Previewer may be different from that on a real device.")
713     return paramMock.paramStringMock
714   },
715   isLocalCalling: function () {
716     console.warn("IPCSkeleton.isLocalCalling interface mocked in the Previewer. How this interface works on the" +
717       " Previewer may be different from that on a real device.")
718     return paramMock.paramBooleanMock
719   },
720   flushCommands: function (...args) {
721     console.warn("IPCSkeleton.flushCommands interface mocked in the Previewer. How this interface works on the" +
722       " Previewer may be different from that on a real device.")
723     return paramMock.paramNumberMock
724   },
725   resetCallingIdentity: function () {
726     console.warn("IPCSkeleton.resetCallingIdentity interface mocked in the Previewer. How this interface works on the" +
727       " Previewer may be different from that on a real device.")
728     return paramMock.paramStringMock
729   },
730   setCallingIdentity: function (...args) {
731     console.warn("IPCSkeleton.setCallingIdentity interface mocked in the Previewer. How this interface works on the" +
732       " Previewer may be different from that on a real device.")
733     return paramMock.paramBooleanMock
734   }
735 };
736 export function mockRpc() {
737   const rpcMock = {
738     IRemoteObject: IRemoteObjectMock,
739     IRemoteBroker: IRemoteBrokerMock,
740     SendRequestResult: SendRequestResultMock,
741     Sequenceable: SequenceableMock,
742     DeathRecipient: DeathRecipientMock,
743     IPCSkeleton: IPCSkeletonMock,
744     MessageParcel: MessageParcelClass,
745     MessageOption: MessageOptionClass,
746     Ashmem: AshmemClass,
747     RemoteObject: RemoteObjectClass,
748     RemoteProxy: RemoteProxyClass
749   };
750   return rpcMock
751 }
752