diff --git a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/AppManager.test.ets b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/AppManager.test.ets index 525265325b9f7a9626754d95c4a7bf400f93ee5a..55153e41deb9a04f24a3c7e64c361757d5918abf 100644 --- a/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/AppManager.test.ets +++ b/ability/ability_runtime/actssystemapitest/entry/src/main/ets/test/AppManager.test.ets @@ -242,5 +242,125 @@ export default function appManagerTest() { done(); }) }) + + + /** + * @tc.number: System_API_Test_App_Manager_1100 + * @tc.name: callback form GetProcessMemoryByPid system interface interception test + * @tc.desc: Test the third-party application call GetProcessMemoryByPid will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_1100',0, function (done) { + let TAG = 'System_API_Test_App_Manager_1100'; + let pid = 0; + appManager.getProcessMemoryByPid(pid, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_App_Manager_1200 + * @tc.name: promise form GetProcessMemoryByPid system interface interception test + * @tc.desc: Test the third-party application call GetProcessMemoryByPid will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_1200',0, function (done) { + let TAG = 'System_API_Test_App_Manager_1200'; + let pid = 0; + appManager.getProcessMemoryByPid(pid) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_App_Manager_1300 + * @tc.name: callback form getRunningProcessInfoByBundleName system interface interception test + * @tc.desc: Test the third-party application call getRunningProcessInfoByBundleName will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_1300',0, function (done) { + let TAG = 'System_API_Test_App_Manager_1300'; + let bundleName = "com.ohos.application"; + appManager.getRunningProcessInfoByBundleName(bundleName, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_App_Manager_1400 + * @tc.name: promise form getRunningProcessInfoByBundleName system interface interception test + * @tc.desc: Test the third-party application call getRunningProcessInfoByBundleName will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_1400',0, function (done) { + let TAG = 'System_API_Test_App_Manager_1400'; + let bundleName = "com.ohos.application"; + appManager.getRunningProcessInfoByBundleName(bundleName) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + /** + * @tc.number: System_API_Test_App_Manager_1500 + * @tc.name: callback form getRunningProcessInfoByBundleName system interface interception test + * @tc.desc: Test the third-party application call getRunningProcessInfoByBundleName will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_1500',0, function (done) { + let TAG = 'System_API_Test_App_Manager_1500'; + let bundleName = "com.ohos.application"; + let userId = 100; + appManager.getRunningProcessInfoByBundleName(bundleName, userId, (err) => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }); + }) + + /** + * @tc.number: System_API_Test_App_Manager_1600 + * @tc.name: promise form getRunningProcessInfoByBundleName system interface interception test + * @tc.desc: Test the third-party application call getRunningProcessInfoByBundleName will be blocked + * @tc.level 3 + */ + it('System_API_Test_App_Manager_1600',0, function (done) { + let TAG = 'System_API_Test_App_Manager_1600'; + let bundleName = "com.ohos.application"; + let userId = 100; + appManager.getRunningProcessInfoByBundleName(bundleName, userId) + .then(err => { + console.log(TAG + ` err->${JSON.stringify(err)}`); + expect().assertFail(); + done(); + }) + .catch(err => { + console.log(TAG + " err.code: " + err.code); + expect(err.code).assertEqual(ERROR_CODE); + done(); + }) + }) + + }) +} }) } \ No newline at end of file diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts index d6babb94a4e64c5aa266f403b10cbe5f1c3553f9..1a0da3138c1d52d3b098c82404edd2fc4e56c02b 100644 --- a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts +++ b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts @@ -21,6 +21,7 @@ const TAG: string = '[UIExtAbility]' export default class UIExtAbility extends UIExtensionAbility { onCreate() { Logger.log(TAG, `UIExtAbility onCreate`) + let UiExtensionContext:common.UIExtensionContext = this.context; } onForeground() { diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/pages/index.ets index b74f4b036f6aac2156043f8fd4f047225d106ba8..fcb29a89f45a9e971ad6b21c9ea030a8f2798cc6 100644 --- a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/pages/index.ets +++ b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/pages/index.ets @@ -16,7 +16,8 @@ import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession' import commonEventManager from '@ohos.commonEventManager' import Logger from '../model/Logger' - +import common from '@ohos.app.ability.common'; +let context= getContext(this) as common.UIExtensionContext; const TAG: string = '[UIExtAbility]' const sleepTimeOne = 1000; @@ -29,6 +30,23 @@ struct Index { private session: UIExtensionContentSession = storage.get('session'); aboutToAppear() { + let options = { + parameters: { + cacheDir: context.cacheDir, + tempDir: context.tempDir, + filesDir: context.filesDir, + databaseDir: context.databaseDir, + preferencesDir: context.preferencesDir, + bundleCodeDir: context.bundleCodeDir, + distributedFilesDir: context.distributedFilesDir, + stageMode: context.stageMode, + area: context.area, + eventHub: context.eventHub + } + } + commonEventManager.publish('0100_UIExtensionAbilityContext', options, (err) => { + console.log('SUB_AA_Extension_UIServiceExtensionAbility_Context_0100 commonEventManager 0100_UIExtensionAbilityContext'); + }) let appearEvent = 'ACTS_UIExtension_AboutToAppear'; let terminateSelfWithResultEvent = 'ACTS_UIExtension_TerminateSelfWithResult'; let sendDataEvent = 'ACTS_UIExtension_SendData';