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..060cd061fd74e1f3fa3fb6c4445db295beea7b5a 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,122 @@ 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..4cd1ce4b6e807407edd1d605e4eb05e752225448 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 @@ -15,12 +15,13 @@ import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility' import Logger from '../model/Logger' - +import common from '@ohos.app.ability.common'; 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..bd91152438e3f8fd627e7641de6ff023ee375713 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';