diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index e38f8109..8d5da916 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -26,7 +26,6 @@ import { mockDataAbility } from './dataAbility' import { mockStorage } from './storage' import { mockRdb } from './rdb' import { mockInputDevice } from './inputDevice' -import { mockLight } from './light' import { mockVibrator } from './vibrator' import { mockSensor } from './sensor' @@ -89,8 +88,6 @@ export function mockRequireNapiFun() { return mockDataAbility(); case "multimodalInput.inputDevice": return mockInputDevice(); - case "light": - return mockLight(); case "vibrator": return mockVibrator(); case "sensor": diff --git a/runtime/main/extend/systemplugin/napi/light.js b/runtime/main/extend/systemplugin/napi/light.js deleted file mode 100644 index 221ff220..00000000 --- a/runtime/main/extend/systemplugin/napi/light.js +++ /dev/null @@ -1,93 +0,0 @@ -import { paramMock } from "../utils" - -export function mockLight() { - const LightId = { - LIGHT_ID_LED: 0, - LIGHT_ID_KEYBOARD: 1, - LIGHT_ID_BUTTONS: 2, - LIGHT_ID_BELT: 3, - UNKNOWN: 4 - } - const LightEffectId = { - LIGHT_ID_LED: "0", - LIGHT_ID_KEYBOARD: "1", - LIGHT_ID_BUTTONS: "2", - LIGHT_ID_BELT: "3", - UNKNOWN: "4" - } - const LightBrightness = { - redBrightness: "[PC preview] unknown redBrightness", - greenBrightness: "[PC preview] unknown greenBrightness", - blueBrightness: "[PC preview] unknown blueBrightness" - } - const LightEffect = { - lightBrightness: "[PC preview] unknown lightBrightness", - onDuration: "[PC preview] unknown onDuration", - offDuration: "[PC preview] unknown offDuration" - } - const light = { - turnOn: function (...args) { - console.warn("light.turnOn 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.businessErrorMock); - } else { - return new Promise((resolve) => { - resolve(); - }) - } - }, - turnOff: function (...args) { - console.warn("light.turnOff 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.businessErrorMock); - } else { - return new Promise((resolve) => { - resolve(); - }) - } - }, - getLightIdList: function (...args) { - console.warn("light.getLightIdList interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - var lightIdArray = new Array(); - lightIdArray.push(paramMock.paramNumberMock); - const len = args.length - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, lightIdArray); - } else { - return new Promise((resolve) => { - resolve(lightIdArray); - }) - } - }, - isSupport: function (...args) { - console.warn("light.isSupport 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.businessErrorMock, paramMock.paramBooleanMock); - } else { - return new Promise((resolve) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - isEffectSupport: function (...args) { - console.warn("light.isEffectSupport 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.businessErrorMock, paramMock.paramBooleanMock); - } else { - return new Promise((resolve) => { - resolve(paramMock.paramBooleanMock); - }) - } - } - } - return light -} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/sensor.js b/runtime/main/extend/systemplugin/napi/sensor.js index 73b2f4c6..88674e6c 100644 --- a/runtime/main/extend/systemplugin/napi/sensor.js +++ b/runtime/main/extend/systemplugin/napi/sensor.js @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { paramMock } from "../utils" export function mockSensor() { @@ -109,10 +124,6 @@ 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, @@ -251,90 +262,6 @@ 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 diff --git a/runtime/main/extend/systemplugin/napi/vibrator.js b/runtime/main/extend/systemplugin/napi/vibrator.js index d0eac90f..3968b60a 100644 --- a/runtime/main/extend/systemplugin/napi/vibrator.js +++ b/runtime/main/extend/systemplugin/napi/vibrator.js @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import { paramMock } from "../utils" export function mockVibrator() {