From 21074fc8c5ced5dee963d3014b2f1e4b72e62a4c Mon Sep 17 00:00:00 2001 From: SUE Date: Wed, 12 Jan 2022 14:26:29 +0000 Subject: [PATCH] Signed-off-by:hellohyh001 --- .../main/extend/systemplugin/napi/sensor.js | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/sensor.js b/runtime/main/extend/systemplugin/napi/sensor.js index 88674e6c..bf3725fe 100644 --- a/runtime/main/extend/systemplugin/napi/sensor.js +++ b/runtime/main/extend/systemplugin/napi/sensor.js @@ -124,6 +124,10 @@ export function mockSensor() { longitude: "[PC preview] unknown longitude", altitude: "[PC preview] unknown altitude", } + const CoordinatesOptions = { + x: "[PC preview] unknown x", + y: "[PC preview] unknown y" + } const SensorType = { SENSOR_TYPE_ID_ACCELEROMETER: 1, SENSOR_TYPE_ID_GYROSCOPE: 2, @@ -262,6 +266,90 @@ export function mockSensor() { resolve(GeomagneticResponse); }) } + }, + getAltitude: function (...args) { + console.warn("sensor.getAltitude interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + getGeomagneticDip: function (...args) { + console.warn("sensor.getGeomagneticDip interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramNumberMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + getAngleModifiy: function (...args) { + console.warn("sensor.getAngleModifiy interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }, + createRotationMatrix: function (...args) { + console.warn("sensor.createRotationMatrix interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }, + transformCoordinateSystem: function (...args) { + console.warn("sensor.transformCoordinateSystem interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }, + createQuaternion: function (...args) { + console.warn("sensor.createQuaternion interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }, + getDirection: function (...args) { + console.warn("sensor.getDirection interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMoc, paramMock.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } } } return sensor