mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-25 12:23:20 -04:00
Signed-off-by: mingxihua <mingxihua@huawei.com>
This commit is contained in:
@@ -68,7 +68,7 @@ public:
|
||||
bool GetANRDialogWant(int userId, int pid, AAFwk::Want &want);
|
||||
Want GetSelectorDialogWant(const std::vector<DialogAppInfo> &dialogAppInfos, Want &targetWant,
|
||||
const sptr<IRemoteObject> &callerToken);
|
||||
Want GetTipsDialogWant();
|
||||
Want GetTipsDialogWant(const sptr<IRemoteObject> &callerToken);
|
||||
|
||||
void SetDeviceType(const std::string &deviceType)
|
||||
{
|
||||
|
||||
@@ -87,7 +87,7 @@ int ImplicitStartProcessor::ImplicitStartAbility(AbilityRequest &request, int32_
|
||||
};
|
||||
if (dialogAppInfos.size() == 0) {
|
||||
HILOG_ERROR("implicit query ability infos failed, show tips dialog.");
|
||||
Want want = sysDialogScheduler->GetTipsDialogWant();
|
||||
Want want = sysDialogScheduler->GetTipsDialogWant(request.callerToken);
|
||||
auto abilityMgr = DelayedSingleton<AbilityManagerService>::GetInstance();
|
||||
abilityMgr->StartAbility(want);
|
||||
return ERR_IMPLICIT_START_ABILITY_FAIL;
|
||||
|
||||
@@ -122,7 +122,7 @@ const std::string SystemDialogScheduler::GetAnrParams(const DialogPosition posit
|
||||
return anrData.dump();
|
||||
}
|
||||
|
||||
Want SystemDialogScheduler::GetTipsDialogWant()
|
||||
Want SystemDialogScheduler::GetTipsDialogWant(const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
HILOG_DEBUG("GetTipsDialogWant start");
|
||||
|
||||
@@ -137,6 +137,7 @@ Want SystemDialogScheduler::GetTipsDialogWant()
|
||||
want.SetElementName(BUNDLE_NAME_DIALOG, ABILITY_NAME_TIPS_DIALOG);
|
||||
want.SetParam(DIALOG_POSITION, GetDialogPositionParams(position));
|
||||
want.SetParam(DIALOG_PARAMS, params);
|
||||
want.SetParam(CALLER_TOKEN, callerToken);
|
||||
return want;
|
||||
}
|
||||
|
||||
|
||||
+10
-1
@@ -30,9 +30,11 @@ export default class TipsServiceExtensionAbility extends extension {
|
||||
}
|
||||
|
||||
onRequest(want, startId) {
|
||||
console.debug(TAG, "onRequest, want: " + JSON.stringify(want));
|
||||
globalThis.abilityWant = want;
|
||||
globalThis.params = JSON.parse(want["parameters"]["params"]);
|
||||
globalThis.position = JSON.parse(want["parameters"]["position"]);
|
||||
globalThis.callerToken = want["parameters"]["callerToken"];
|
||||
|
||||
display.getDefaultDisplay().then(dis => {
|
||||
let navigationBarRect = {
|
||||
@@ -48,7 +50,7 @@ export default class TipsServiceExtensionAbility extends extension {
|
||||
if (deviceInfo.deviceType == "phone") {
|
||||
this.createWindow("TipsDialog" + startId, window.WindowType.TYPE_SYSTEM_ALERT, navigationBarRect);
|
||||
} else {
|
||||
this.createWindow("TipsDialog" + startId, window.WindowType.TYPE_FLOAT, navigationBarRect);
|
||||
this.createWindow("TipsDialog" + startId, window.WindowType.TYPE_DIALOG, navigationBarRect);
|
||||
}
|
||||
winNum++;
|
||||
})
|
||||
@@ -62,6 +64,13 @@ export default class TipsServiceExtensionAbility extends extension {
|
||||
console.info(TAG, "create window");
|
||||
try {
|
||||
win = await window.create(globalThis.tipsExtensionContext, name, windowType);
|
||||
await win.bindDialogTarget(globalThis.callerToken.value, () => {
|
||||
win.destroyWindow();
|
||||
winNum--;
|
||||
if(winNum === 0) {
|
||||
globalThis.tipsExtensionContext.terminateSelf();
|
||||
}
|
||||
});
|
||||
await win.moveTo(rect.left, rect.top);
|
||||
await win.resetSize(rect.width, rect.height);
|
||||
await win.loadContent('pages/tipsDialog');
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ HWTEST_F(AbilityMgrServiceDialogTest, AbilityMgrServiceDialog_0100, TestSize.Lev
|
||||
HWTEST_F(AbilityMgrServiceDialogTest, AbilityMgrServiceDialog_0200, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("AbilityMgrServiceDialog_0200 start");
|
||||
auto want = systemDialogScheduler_->GetTipsDialogWant();
|
||||
auto want = systemDialogScheduler_->GetTipsDialogWant(nullptr);
|
||||
EXPECT_EQ(want.GetElement().GetBundleName(), "com.ohos.amsdialog");
|
||||
EXPECT_EQ(want.GetElement().GetAbilityName(), "TipsDialog");
|
||||
HILOG_INFO("AbilityMgrServiceDialog_0200 end");
|
||||
|
||||
Reference in New Issue
Block a user