1/* 2 * Copyright (c) 2021-2022 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 function mockOsAccount() { 19 const OsAccountInfoMock = { 20 localId: "[PC Preview] unknown localId", 21 localName: "[PC Preview] unknown localName", 22 type: "[PC Preview] unknown type", 23 constraints: "[PC Preview] unknown constraints", 24 isVerified: "[PC Preview] unknown isVerified", 25 photo: "[PC Preview] unknown photo", 26 createTime: "[PC Preview] unknown createTime", 27 lastLoginTime: "[PC Preview] unknown lastLoginTime", 28 serialNumber: "[PC Preview] unknown serialNumber", 29 isActived: "[PC Preview] unknown isActived", 30 isCreateCompleted: "[PC Preview] unknown isCreateCompleted", 31 domainInfo: "[PC Preview] unknown domainInfo", 32 distributedInfo: "[PC Preview] unknown distributedInfo" 33 }; 34 const DomainAccountInfoMock = { 35 domain: "[PC Preview] unknown domain", 36 accountName: "[PC Preview] unknown accountName" 37 }; 38 const ConstraintSourceTypeInfoMock = { 39 localId: "[PC Preview] unknown localId", 40 type: "[PC Preview] unknown type" 41 }; 42 const GetPropertyRequest = { 43 authType: "[PC Preview] unknown authType", 44 keys: "[PC Preview] unknown keys" 45 }; 46 const SetPropertyRequest = { 47 authType: "[PC Preview] unknown authType", 48 key: "[PC Preview] unknown key", 49 setInfo: "[PC Preview] unknown setInfo" 50 }; 51 const ExecutorProperty = { 52 result: "[PC Preview] unknown result", 53 authSubType: AuthSubType, 54 remainTimes: "[PC Preview] unknown remainTimes", 55 freezingTime: "[PC Preview] unknown freezingTime" 56 }; 57 const AuthResult = { 58 token: "[PC Preview] unknown token", 59 remainTimes: "[PC Preview] unknown remainTimes", 60 freezingTime: "[PC Preview] unknown freezingTime" 61 }; 62 const CredentialInfo = { 63 credType: "[PC Preview] unknown credType", 64 credSubType: "[PC Preview] unknown credSubType", 65 token: "[PC Preview] unknown token" 66 }; 67 const RequestResult = { 68 credentialId: "[PC Preview] unknown credentialId" 69 }; 70 const EnrolledCredInfo = { 71 credentialId: "[PC Preview] unknown credentialId", 72 authType: "[PC Preview] unknown authType", 73 authSubType: "[PC Preview] unknown authSubType", 74 templateId: "[PC Preview] unknown templateId" 75 }; 76 const OsAccountTypeMock = "[PC Preview] unknown type"; 77 const AccountManagerMock = { 78 activateOsAccount: function (...args) { 79 console.warn("AccountManager.activateOsAccount interface mocked in the Previewer. " + 80 "How this interface works on the Previewer may be different from that on a real device.") 81 const len = args.length 82 if (len > 0 && typeof args[len - 1] === 'function') { 83 args[len - 1].call(this, paramMock.businessErrorMock); 84 } else { 85 return new Promise((resolve, reject) => { 86 resolve(); 87 }) 88 } 89 }, 90 isMultiOsAccountEnable: function (...args) { 91 console.warn("AccountManager.isMultiOsAccountEnable interface mocked in the Previewer. " + 92 "How this interface works on the Previewer may be different from that on a real device.") 93 const len = args.length 94 if (len > 0 && typeof args[len - 1] === 'function') { 95 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); 96 } else { 97 return new Promise((resolve, reject) => { 98 resolve(paramMock.paramBooleanMock); 99 }) 100 } 101 }, 102 isOsAccountActived: function (...args) { 103 console.warn("AccountManager.isOsAccountActived interface mocked in the Previewer. " + 104 "How this interface works on the Previewer may be different from that on a real device.") 105 const len = args.length 106 if (len > 0 && typeof args[len - 1] === 'function') { 107 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); 108 } else { 109 return new Promise((resolve, reject) => { 110 resolve(paramMock.paramBooleanMock); 111 }) 112 } 113 }, 114 isOsAccountConstraintEnable: function (...args) { 115 console.warn("AccountManager.isOsAccountConstraintEnable interface mocked in the Previewer. " + 116 "How this interface works on the Previewer may be different from that on a real device.") 117 const len = args.length 118 if (len > 0 && typeof args[len - 1] === 'function') { 119 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); 120 } else { 121 return new Promise((resolve, reject) => { 122 resolve(paramMock.paramBooleanMock); 123 }) 124 } 125 }, 126 isTestOsAccount: function (...args) { 127 console.warn("AccountManager.isTestOsAccount interface mocked in the Previewer. " + 128 "How this interface works on the Previewer may be different from that on a real device.") 129 const len = args.length 130 if (len > 0 && typeof args[len - 1] === 'function') { 131 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); 132 } else { 133 return new Promise((resolve, reject) => { 134 resolve(paramMock.paramBooleanMock); 135 }) 136 } 137 }, 138 isOsAccountVerified: function (...args) { 139 console.warn("AccountManager.isOsAccountVerified interface mocked in the Previewer. " + 140 "How this interface works on the Previewer may be different from that on a real device.") 141 const len = args.length 142 if (len > 0 && typeof args[len - 1] === 'function') { 143 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); 144 } else { 145 return new Promise((resolve, reject) => { 146 resolve(paramMock.paramBooleanMock); 147 }) 148 } 149 }, 150 removeOsAccount: function (...args) { 151 console.warn("AccountManager.removeOsAccount interface mocked in the Previewer. " + 152 "How this interface works on the Previewer may be different from that on a real device.") 153 const len = args.length 154 if (len > 0 && typeof args[len - 1] === 'function') { 155 args[len - 1].call(this, paramMock.businessErrorMock); 156 } else { 157 return new Promise((resolve, reject) => { 158 resolve(); 159 }) 160 } 161 }, 162 setOsAccountConstraints: function (...args) { 163 console.warn("AccountManager.setOsAccountConstraints interface mocked in the Previewer. " + 164 "How this interface works on the Previewer may be different from that on a real device.") 165 const len = args.length 166 if (len > 0 && typeof args[len - 1] === 'function') { 167 args[len - 1].call(this, paramMock.businessErrorMock); 168 } else { 169 return new Promise((resolve, reject) => { 170 resolve(); 171 }) 172 } 173 }, 174 setOsAccountName: function (...args) { 175 console.warn("AccountManager.setOsAccountName interface mocked in the Previewer. " + 176 "How this interface works on the Previewer may be different from that on a real device.") 177 const len = args.length 178 if (len > 0 && typeof args[len - 1] === 'function') { 179 args[len - 1].call(this, paramMock.businessErrorMock); 180 } else { 181 return new Promise((resolve, reject) => { 182 resolve(); 183 }) 184 } 185 }, 186 getCreatedOsAccountsCount: function (...args) { 187 console.warn("AccountManager.getCreatedOsAccountsCount interface mocked in the Previewer. " + 188 "How this interface works on the Previewer may be different from that on a real device.") 189 const len = args.length 190 if (len > 0 && typeof args[len - 1] === 'function') { 191 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); 192 } else { 193 return new Promise((resolve, reject) => { 194 resolve(paramMock.paramNumberMock); 195 }) 196 } 197 }, 198 getOsAccountLocalIdFromProcess: function (...args) { 199 console.warn("AccountManager.getOsAccountLocalIdFromProcess interface mocked in the Previewer. " + 200 "How this interface works on the Previewer may be different from that on a real device.") 201 const len = args.length 202 if (len > 0 && typeof args[len - 1] === 'function') { 203 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); 204 } else { 205 return new Promise((resolve, reject) => { 206 resolve(paramMock.paramNumberMock); 207 }) 208 } 209 }, 210 getOsAccountLocalIdFromUid: function (...args) { 211 console.warn("AccountManager.getOsAccountLocalIdFromUid interface mocked in the Previewer. " + 212 "How this interface works on the Previewer may be different from that on a real device.") 213 const len = args.length 214 if (len > 0 && typeof args[len - 1] === 'function') { 215 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); 216 } else { 217 return new Promise((resolve, reject) => { 218 resolve(paramMock.paramNumberMock); 219 }) 220 } 221 }, 222 getOsAccountLocalIdFromDomain: function (...args) { 223 console.warn("AccountManager.getOsAccountLocalIdFromDomain interface mocked in the Previewer. " + 224 "How this interface works on the Previewer may be different from that on a real device.") 225 const len = args.length 226 if (len > 0 && typeof args[len - 1] === 'function') { 227 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); 228 } else { 229 return new Promise((resolve, reject) => { 230 resolve(paramMock.paramNumberMock); 231 }) 232 } 233 }, 234 queryMaxOsAccountNumber: function (...args) { 235 console.warn("AccountManager.queryMaxOsAccountNumber interface mocked in the Previewer. " + 236 "How this interface works on the Previewer may be different from that on a real device.") 237 const len = args.length 238 if (len > 0 && typeof args[len - 1] === 'function') { 239 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); 240 } else { 241 return new Promise((resolve, reject) => { 242 resolve(paramMock.paramNumberMock); 243 }) 244 } 245 }, 246 getOsAccountAllConstraints: function (...args) { 247 console.warn("AccountManager.getOsAccountAllConstraints interface mocked in the Previewer. " + 248 "How this interface works on the Previewer may be different from that on a real device.") 249 const len = args.length 250 if (len > 0 && typeof args[len - 1] === 'function') { 251 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); 252 } else { 253 return new Promise((resolve, reject) => { 254 resolve(paramMock.paramStringMock); 255 }) 256 } 257 }, 258 queryAllCreatedOsAccounts: function (...args) { 259 console.warn("AccountManager.queryAllCreatedOsAccounts interface mocked in the Previewer. " + 260 "How this interface works on the Previewer may be different from that on a real device.") 261 var osAccountInfoArrayMock = new Array(); 262 osAccountInfoArrayMock.push(OsAccountInfoMock); 263 const len = args.length 264 if (len > 0 && typeof args[len - 1] === 'function') { 265 args[len - 1].call(this, paramMock.businessErrorMock, osAccountInfoArrayMock); 266 } else { 267 return new Promise((resolve, reject) => { 268 resolve(osAccountInfoArrayMock); 269 }) 270 } 271 }, 272 queryActivatedOsAccountIds: function (...args) { 273 console.warn("AccountManager.queryActivatedOsAccountIds interface mocked in the Previewer. " + 274 "How this interface works on the Previewer may be different from that on a real device.") 275 var osAccountIdsArrayMock = new Array(); 276 osAccountIdsArrayMock.push(OsAccountInfoMock); 277 const len = args.length 278 if (len > 0 && typeof args[len - 1] === 'function') { 279 args[len - 1].call(this, paramMock.businessErrorMock, osAccountIdsArrayMock); 280 } else { 281 return new Promise((resolve, reject) => { 282 resolve(osAccountIdsArrayMock); 283 }) 284 } 285 }, 286 createOsAccount: function (...args) { 287 console.warn("AccountManager.createOsAccount interface mocked in the Previewer. " + 288 "How this interface works on the Previewer may be different from that on a real device.") 289 const len = args.length 290 if (len > 0 && typeof args[len - 1] === 'function') { 291 args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); 292 } else { 293 return new Promise((resolve, reject) => { 294 resolve(OsAccountInfoMock); 295 }) 296 } 297 }, 298 createOsAccountForDomain: function (...args) { 299 console.warn("AccountManager.createOsAccountForDomain interface mocked in the Previewer. " + 300 "How this interface works on the Previewer may be different from that on a real device.") 301 const len = args.length 302 if (len > 0 && typeof args[len - 1] === 'function') { 303 args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); 304 } else { 305 return new Promise((resolve, reject) => { 306 resolve(OsAccountInfoMock); 307 }) 308 } 309 }, 310 queryCurrentOsAccount: function (...args) { 311 console.warn("AccountManager.queryCurrentOsAccount interface mocked in the Previewer. " + 312 "How this interface works on the Previewer may be different from that on a real device.") 313 const len = args.length 314 if (len > 0 && typeof args[len - 1] === 'function') { 315 args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); 316 } else { 317 return new Promise((resolve, reject) => { 318 resolve(OsAccountInfoMock); 319 }) 320 } 321 }, 322 queryOsAccountById: function (...args) { 323 console.warn("AccountManager.queryOsAccountById interface mocked in the Previewer. " + 324 "How this interface works on the Previewer may be different from that on a real device.") 325 const len = args.length 326 if (len > 0 && typeof args[len - 1] === 'function') { 327 args[len - 1].call(this, paramMock.businessErrorMock, OsAccountInfoMock); 328 } else { 329 return new Promise((resolve, reject) => { 330 resolve(OsAccountInfoMock); 331 }) 332 } 333 }, 334 getOsAccountTypeFromProcess: function (...args) { 335 console.warn("AccountManager.getOsAccountTypeFromProcess interface mocked in the Previewer. " + 336 "How this interface works on the Previewer may be different from that on a real device.") 337 const len = args.length 338 if (len > 0 && typeof args[len - 1] === 'function') { 339 args[len - 1].call(this, paramMock.businessErrorMock, OsAccountTypeMock); 340 } else { 341 return new Promise((resolve, reject) => { 342 resolve(OsAccountTypeMock); 343 }) 344 } 345 }, 346 getDistributedVirtualDeviceId: function (...args) { 347 console.warn("AccountManager.getDistributedVirtualDeviceId interface mocked in the Previewer. " + 348 "How this interface works on the Previewer may be different from that on a real device.") 349 const len = args.length 350 if (len > 0 && typeof args[len - 1] === 'function') { 351 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); 352 } else { 353 return new Promise((resolve, reject) => { 354 resolve(paramMock.paramStringMock); 355 }) 356 } 357 }, 358 getOsAccountProfilePhoto: function (...args) { 359 console.warn("AccountManager.getOsAccountProfilePhoto interface mocked in the Previewer. " + 360 "How this interface works on the Previewer may be different from that on a real device.") 361 const len = args.length 362 if (len > 0 && typeof args[len - 1] === 'function') { 363 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); 364 } else { 365 return new Promise((resolve, reject) => { 366 resolve(paramMock.paramStringMock); 367 }) 368 } 369 }, 370 setOsAccountProfilePhoto: function (...args) { 371 console.warn("AccountManager.setOsAccountProfilePhoto interface mocked in the Previewer. " + 372 "How this interface works on the Previewer may be different from that on a real device.") 373 const len = args.length 374 if (len > 0 && typeof args[len - 1] === 'function') { 375 args[len - 1].call(this, paramMock.businessErrorMock); 376 } else { 377 return new Promise((resolve, reject) => { 378 resolve(); 379 }) 380 } 381 }, 382 getOsAccountLocalIdBySerialNumber: function (...args) { 383 console.warn("AccountManager.getOsAccountLocalIdBySerialNumber interface mocked in the Previewer. " + 384 "How this interface works on the Previewer may be different from that on a real device.") 385 const len = args.length 386 if (len > 0 && typeof args[len - 1] === 'function') { 387 args[len - 1].call(this, paramMock.businessErrorMock); 388 } else { 389 return new Promise((resolve, reject) => { 390 resolve(); 391 }) 392 } 393 }, 394 getSerialNumberByOsAccountLocalId: function (...args) { 395 console.warn("AccountManager.getSerialNumberByOsAccountLocalId interface mocked in the Previewer. " + 396 "How this interface works on the Previewer may be different from that on a real device.") 397 const len = args.length 398 if (len > 0 && typeof args[len - 1] === 'function') { 399 args[len - 1].call(this, paramMock.businessErrorMock); 400 } else { 401 return new Promise((resolve, reject) => { 402 resolve(); 403 }) 404 } 405 }, 406 on: function (...args) { 407 console.warn("AccountManager.on interface mocked in the Previewer. " + 408 "How this interface works on the Previewer may be different from that on a real device.") 409 const len = args.length 410 if (len > 0 && typeof args[len - 1] === 'function') { 411 args[len - 1].call(this, paramMock.paramNumberMock); 412 } else { 413 return new Promise((resolve, reject) => { 414 resolve(paramMock.paramNumberMock); 415 }) 416 } 417 }, 418 off: function (...args) { 419 console.warn("AccountManager.off interface mocked in the Previewer. " + 420 "How this interface works on the Previewer may be different from that on a real device.") 421 const len = args.length 422 if (len > 0 && typeof args[len - 1] === 'function') { 423 args[len - 1].call(this, paramMock.paramNumberMock); 424 } else { 425 return new Promise((resolve, reject) => { 426 resolve(paramMock.paramNumberMock); 427 }) 428 } 429 }, 430 isMainOsAccount: function (...args) { 431 console.warn("AccountManager.isMainOsAccount interface mocked in the Previewer. " + 432 "How this interface works on the Previewer may be different from that on a real device.") 433 const len = args.length 434 if (len > 0 && typeof args[len - 1] === 'function') { 435 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); 436 } else { 437 return new Promise((resolve, reject) => { 438 resolve(paramMock.paramBooleanMock); 439 }) 440 } 441 }, 442 getBundleIdFromUid: function (...args) { 443 console.warn("AccountManager.getBundleIdFromUid interface mocked in the Previewer. " + 444 "How this interface works on the Previewer may be different from that on a real device.") 445 const len = args.length 446 if (len > 0 && typeof args[len - 1] === 'function') { 447 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); 448 } else { 449 return new Promise((resolve, reject) => { 450 resolve(paramMock.paramNumberMock); 451 }) 452 } 453 }, 454 queryOsAccountConstraintSourceTypes: function (...args) { 455 console.warn("AccountManager.queryOsAccountConstraintSourceTypes interface mocked in the Previewer. " + 456 "How this interface works on the Previewer may be different from that on a real device.") 457 var constraintSourceTypeInfoArrayMock = new Array(); 458 constraintSourceTypeInfoArrayMock.push(ConstraintSourceTypeInfoMock); 459 const len = args.length 460 if (len > 0 && typeof args[len - 1] === 'function') { 461 args[len - 1].call(this, paramMock.businessErrorMock, constraintSourceTypeInfoArrayMock); 462 } else { 463 return new Promise((resolve, reject) => { 464 resolve(constraintSourceTypeInfoArrayMock); 465 }) 466 } 467 }, 468 }; 469 const UserAuthClass = class UserAuth { 470 constructor() { 471 console.warn("osAccount.UserAuth.constructor interface mocked in the Previewer. " + 472 "How this interface works on the Previewer may be different from that on a real device.") 473 this.getVersion = function (...args) { 474 console.warn("UserAuth.getVersion interface mocked in the Previewer. " + 475 "How this interface works on the Previewer may be different from that on a real device.") 476 return paramMock.paramNumberMock; 477 }; 478 this.getAvailableStatus = function (...args) { 479 console.warn("UserAuth.getAvailableStatus interface mocked in the Previewer. " + 480 "How this interface works on the Previewer may be different from that on a real device.") 481 return paramMock.paramNumberMock; 482 }; 483 this.getProperty = function (...args) { 484 console.warn("UserAuth.getProperty interface mocked in the Previewer. " + 485 "How this interface works on the Previewer may be different from that on a real device.") 486 const len = args.length 487 if (len > 0 && typeof args[len - 1] === 'function') { 488 args[len - 1].call(this, paramMock.businessErrorMock, ExecutorProperty); 489 } else { 490 return new Promise((resolve, reject) => { 491 resolve(ExecutorProperty); 492 }) 493 } 494 }; 495 this.setProperty = function (...args) { 496 console.warn("UserAuth.setProperty interface mocked in the Previewer. " + 497 "How this interface works on the Previewer may be different from that on a real device.") 498 const len = args.length 499 if (len > 0 && typeof args[len - 1] === 'function') { 500 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); 501 } else { 502 return new Promise((resolve, reject) => { 503 resolve(paramMock.paramNumberMock); 504 }) 505 } 506 }; 507 this.auth = function (...args) { 508 console.warn("UserAuth.auth interface mocked in the Previewer. " + 509 "How this interface works on the Previewer may be different from that on a real device.") 510 const len = args.length 511 if (len > 0 && typeof args[len - 1] === 'function') { 512 args[len - 1].call(this, paramMock.businessErrorMock, IUserAuthCallback); 513 } 514 return paramMock.paramArrayMock; 515 }; 516 this.authUser = function (...args) { 517 console.warn("UserAuth.authUser interface mocked in the Previewer. " + 518 "How this interface works on the Previewer may be different from that on a real device.") 519 const len = args.length 520 if (len > 0 && typeof args[len - 1] === 'function') { 521 args[len - 1].call(this, paramMock.businessErrorMock, IUserAuthCallback); 522 } 523 return paramMock.paramArrayMock; 524 }; 525 this.cancelAuth = function (...args) { 526 console.warn("UserAuth.cancelAuth interface mocked in the Previewer. " + 527 "How this interface works on the Previewer may be different from that on a real device.") 528 return paramMock.paramNumberMock; 529 }; 530 }; 531 }; 532 const PINAuthClass = class PINAuth { 533 constructor() { 534 console.warn("osAccount.PINA.constructor interface mocked in the Previewer. " + 535 "How this interface works on the Previewer may be different from that on a real device.") 536 this.registerInputer = function (...args) { 537 console.warn("PINAuth.registerInputer interface mocked in the Previewer. " + 538 "How this interface works on the Previewer may be different from that on a real device.") 539 return paramMock.paramBooleanMock; 540 }; 541 this.unregisterInputer = function (...args) { 542 console.warn("PINAuth.unregisterInputer interface mocked in the Previewer. " + 543 "How this interface works on the Previewer may be different from that on a real device.") 544 }; 545 }; 546 }; 547 const UserIdentityManagerClass = class UserIdentityManager { 548 constructor() { 549 console.warn("osAccount.getAccountManager.constructor interface mocked in the Previewer. " + 550 "How this interface works on the Previewer may be different from that on a real device.") 551 this.openSession = function (...args) { 552 console.warn("UserIdentityManager.openSession interface mocked in the Previewer. " + 553 "How this interface works on the Previewer may be different from that on a real device.") 554 const len = args.length 555 if (len > 0 && typeof args[len - 1] === 'function') { 556 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramArrayMock); 557 } else { 558 return new Promise((resolve, reject) => { 559 resolve(paramMock.paramArrayMock); 560 }) 561 } 562 }; 563 this.addCredential = function (...args) { 564 console.warn("AUserIdentityManager.addCredential interface mocked in the Previewer. " + 565 "How this interface works on the Previewer may be different from that on a real device.") 566 const len = args.length 567 if (len > 0 && typeof args[len - 1] === 'function') { 568 args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); 569 } 570 }; 571 this.updateCredential = function (...args) { 572 console.warn("AUserIdentityManager.updateCredential interface mocked in the Previewer. " + 573 "How this interface works on the Previewer may be different from that on a real device.") 574 const len = args.length 575 if (len > 0 && typeof args[len - 1] === 'function') { 576 args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); 577 } 578 }; 579 this.closeSession = function (...args) { 580 console.warn("AUserIdentityManager.closeSession interface mocked in the Previewer. " + 581 "How this interface works on the Previewer may be different from that on a real device.") 582 }; 583 this.cancel = function (...args) { 584 console.warn("AUserIdentityManager.cancel interface mocked in the Previewer. " + 585 "How this interface works on the Previewer may be different from that on a real device.") 586 return paramMock.paramNumberMock; 587 }; 588 this.delUser = function (...args) { 589 console.warn("AUserIdentityManager.delUser interface mocked in the Previewer. " + 590 "How this interface works on the Previewer may be different from that on a real device.") 591 const len = args.length 592 if (len > 0 && typeof args[len - 1] === 'function') { 593 args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); 594 } 595 }; 596 this.delCred = function (...args) { 597 console.warn("AUserIdentityManager.delCred interface mocked in the Previewer. " + 598 "How this interface works on the Previewer may be different from that on a real device.") 599 const len = args.length 600 if (len > 0 && typeof args[len - 1] === 'function') { 601 args[len - 1].call(this, paramMock.businessErrorMock, IIdmCallback); 602 } 603 }; 604 this.getAuthInfo = function (...args) { 605 console.warn("AUserIdentityManager.getAuthInfo interface mocked in the Previewer. " + 606 "How this interface works on the Previewer may be different from that on a real device.") 607 var EnrolledCredInfoMock = new Array(); 608 EnrolledCredInfoMock.push(EnrolledCredInfo); 609 const len = args.length 610 if (len > 0 && typeof args[len - 1] === 'function') { 611 args[len - 1].call(this, paramMock.businessErrorMock, EnrolledCredInfoMock); 612 } else { 613 return new Promise((resolve, reject) => { 614 resolve(EnrolledCredInfoMock) 615 }) 616 } 617 }; 618 }; 619 } 620 const IInputData = { 621 onSetData: function (...args) { 622 console.warn("IInputData.onSetData interface mocked in the Previewer. " + 623 "How this interface works on the Previewer may be different from that on a real device.") 624 }, 625 }; 626 const IInputer = { 627 onGetData: function (...args) { 628 console.warn("IInputer.onGetData interface mocked in the Previewer. " + 629 "How this interface works on the Previewer may be different from that on a real device.") 630 }, 631 }; 632 const IUserAuthCallback = { 633 onResult: function (...args) { 634 console.warn("IUserAuthCallback.onResult interface mocked in the Previewer. " + 635 "How this interface works on the Previewer may be different from that on a real device.") 636 }, 637 onAcquireInfo: function (...args) { 638 console.warn("IUserAuthCallback.onAcquireInfo interface mocked in the Previewer. " + 639 "How this interface works on the Previewer may be different from that on a real device.") 640 }, 641 }; 642 const IIdmCallback = { 643 onResult: function (...args) { 644 console.warn("IIdmCallback.onResult interface mocked in the Previewer. " + 645 "How this interface works on the Previewer may be different from that on a real device.") 646 }, 647 onAcquireInfo: function (...args) { 648 console.warn("IIdmCallback.onAcquireInfo interface mocked in the Previewer. " + 649 "How this interface works on the Previewer may be different from that on a real device.") 650 }, 651 }; 652 const ConstraintSourceType = { 653 CONSTRAINT_NOT_EXIST: 0, 654 CONSTRAINT_TYPE_BASE: 1, 655 CONSTRAINT_TYPE_DEVICE_OWNER: 2, 656 CONSTRAINT_TYPE_PROFILE_OWNER: 3 657 }; 658 const OsAccountType = { 659 ADMIN: 0, 660 NORMAL: 1, 661 GUEST: 2 662 }; 663 const FingerprintTips = { 664 FINGERPRINT_TIP_GOOD: 0, 665 FINGERPRINT_TIP_IMAGER_DIRTY: 1, 666 FINGERPRINT_TIP_INSUFFICIENT: 2, 667 FINGERPRINT_TIP_PARTIAL: 3, 668 FINGERPRINT_TIP_TOO_FAST: 4, 669 FINGERPRINT_TIP_TOO_SLOW: 5 670 }; 671 const FaceTipsCode = { 672 FACE_AUTH_TIP_TOO_BRIGHT: 1, 673 FACE_AUTH_TIP_TOO_DARK: 2, 674 FACE_AUTH_TIP_TOO_CLOSE: 3, 675 FACE_AUTH_TIP_TOO_FAR: 4, 676 FACE_AUTH_TIP_TOO_HIGH: 5, 677 FACE_AUTH_TIP_TOO_LOW: 6, 678 FACE_AUTH_TIP_TOO_RIGHT: 7, 679 FACE_AUTH_TIP_TOO_LEFT: 8, 680 FACE_AUTH_TIP_TOO_MUCH_MOTION: 9, 681 FACE_AUTH_TIP_POOR_GAZE: 10, 682 FACE_AUTH_TIP_NOT_DETECTED: 11 683 }; 684 const ResultCode = { 685 SUCCESS: 0, 686 FAIL: 1, 687 GENERAL_ERROR: 2, 688 CANCELED: 3, 689 TIMEOUT: 4, 690 TYPE_NOT_SUPPORT: 5, 691 TRUST_LEVEL_NOT_SUPPORT: 6, 692 BUSY: 7, 693 INVALID_PARAMETERS: 8, 694 LOCKED: 9, 695 NOT_ENROLLED: 10 696 }; 697 const Module = { 698 FACE_AUTH: 1 699 }; 700 const AuthTrustLevel = { 701 ATL1: 10000, 702 ATL2: 20000, 703 ATL3: 30000, 704 ATL4: 40000 705 }; 706 const AuthSubType = { 707 PIN_SIX: 10000, 708 PIN_NUMBER: 10001, 709 PIN_MIXED: 10002, 710 FACE_2D: 20000, 711 FACE_3D: 20001 712 }; 713 const GetPropertyType = { 714 AUTH_SUB_TYPE: 1, 715 REMAIN_TIMES: 2, 716 FREEZING_TIME: 3 717 }; 718 const SetPropertyType = { 719 INIT_ALGORITHM: 1 720 }; 721 const AuthType = { 722 PIN: 1, 723 FACE: 2 724 }; 725 const osAccount = { 726 getAccountManager: function (...args) { 727 console.warn("osAccount.getAccountManager interface mocked in the Previewer. " + 728 "How this interface works on the Previewer may be different from that on a real device.") 729 return AccountManagerMock; 730 }, 731 UserAuth: UserAuthClass, 732 PINAuth: PINAuthClass, 733 UserIdentityManager: UserIdentityManagerClass, 734 ConstraintSourceType, 735 OsAccountType, 736 FingerprintTips, 737 FaceTipsCode, 738 ResultCode, 739 Module, 740 AuthTrustLevel, 741 AuthSubType, 742 GetPropertyType, 743 SetPropertyType, 744 AuthType, 745 } 746 return osAccount 747} 748