diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index aecc8f7a..cee8d33b 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -65,6 +65,7 @@ import { mockHilog } from './ohos_hilog' import { mockHiSysEvent } from './ohos_hiSysEvent' import { mockHiTraceChain } from './ohos_hiTraceChain' import { mockHiTraceMeter } from './ohos_hiTraceMeter' +import { mockHidebug } from './ohos_hidebug' import { mockFaultLogger } from './ohos_faultLogger' import { mockTv } from './tv' import { mockDtv } from './dtv' @@ -391,6 +392,8 @@ export function mockRequireNapiFun() { return mockHilog(); case "hiSysEvent": return mockHiSysEvent(); + case "hidebug": + return mockHidebug(); case "hiTraceChain": return mockHiTraceChain(); case "hiTraceMeter": diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js index 5a0aedb5..3f7f3a92 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_AbilityConstant.js @@ -33,12 +33,20 @@ export const OnContinueResult = { REJECT: 1, MISMATCH: 2, } +export const WindowMode = { + WINDOW_MODE_UNDEFINED: 0, + WINDOW_MODE_FULLSCREEN: 1, + WINDOW_MODE_SPLIT_PRIMARY: 100, + WINDOW_MODE_SPLIT_SECONDARY: 101, + WINDOW_MODE_FLOATING: 102, +} export function mockAbilityConstant() { const AbilityConstant = { LaunchParam, LaunchReason, LastExitReason, - OnContinueResult + OnContinueResult, + WindowMode } return AbilityConstant; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_hidebug.js b/runtime/main/extend/systemplugin/napi/ohos_hidebug.js new file mode 100644 index 00000000..c1fd2a4a --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_hidebug.js @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2022 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 mockHidebug() { + const hidebug = { + getNativeHeapSize: function () { + console.warn("hidebug.getNativeHeapSize interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getNativeHeapAllocatedSize: function () { + console.warn("hidebug.getNativeHeapAllocatedSize interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getNativeHeapFreeSize: function () { + console.warn("hidebug.getNativeHeapFreeSize interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getPss: function () { + console.warn("hidebug.getPss interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getSharedDirty: function () { + console.warn("hidebug.getSharedDirty interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getPrivateDirty: function () { + console.warn("hidebug.getPrivateDirty interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getCpuUsage: function () { + console.warn("hidebug.getCpuUsage interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + startProfiling: function (...args) { + console.warn("hidebug.startProfiling interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + stopProfiling: function () { + console.warn("hidebug.stopProfiling interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + dumpHeapData: function (...args) { + console.warn("hidebug.dumpHeapData interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + getServiceDump: function (...args) { + console.warn("hidebug.getServiceDump interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + return paramMock.paramStringMock; + }, + } + return hidebug +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_update.js b/runtime/main/extend/systemplugin/napi/ohos_update.js index deba644b..1e45391f 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_update.js +++ b/runtime/main/extend/systemplugin/napi/ohos_update.js @@ -41,6 +41,18 @@ export function mockUpdate() { }) } }, + getNewVersionDescription: function (...args) { + console.warn("Updater.getNewVersionDescription 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 (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [ComponentDescription]); + } else { + return new Promise((resolve, reject) => { + resolve([ComponentDescription]); + }) + } + }, getCurrentVersionInfo: function (...args) { console.warn("Updater.getCurrentVersionInfo interface mocked in the Previewer. How this interface works" + " on the Previewer may be different from that on a real device.") @@ -53,6 +65,18 @@ export function mockUpdate() { }) } }, + getCurrentVersionDescription: function (...args) { + console.warn("Updater.getCurrentVersionDescription 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 (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [ComponentDescription]); + } else { + return new Promise((resolve, reject) => { + resolve([ComponentDescription]); + }) + } + }, getTaskInfo: function (...args) { console.warn("Updater.getTaskInfo interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") @@ -255,6 +279,8 @@ export function mockUpdate() { ClearOptions, EventClassifyInfo, UpgradeFile, + DescriptionOptions, + DescriptionFormat, getOnlineUpdater: function (...args) { console.warn("update.getOnlineUpdater interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") @@ -365,6 +391,7 @@ const DescriptionInfo = { } const VersionComponent = { + componentId: "[PC Preview] unknown componentId", componentType: ComponentType.OTA, upgradeAction: UpgradeAction.UPGRADE, displayVersion: "[PC Preview] unknown displayVersion", @@ -465,4 +492,19 @@ const EventClassifyInfo = { const UpgradeFile = { fileType: ComponentType, filePath: "[PC Preview] unknown filePath" +} + +const DescriptionOptions = { + format: DescriptionFormat, + language: "[PC Preview] unknown language", +} + +const ComponentDescription = { + componentId: "[PC Preview] unknown componentId", + descriptionInfo: DescriptionInfo, +} + +const DescriptionFormat = { + STANDARD: 0, + SIMPLIFIED : 1, } \ No newline at end of file