1eace7efcSopenharmony_ci/*
2eace7efcSopenharmony_ci * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
3eace7efcSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4eace7efcSopenharmony_ci * you may not use this file except in compliance with the License.
5eace7efcSopenharmony_ci * You may obtain a copy of the License at
6eace7efcSopenharmony_ci *
7eace7efcSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8eace7efcSopenharmony_ci *
9eace7efcSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10eace7efcSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11eace7efcSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12eace7efcSopenharmony_ci * See the License for the specific language governing permissions and
13eace7efcSopenharmony_ci * limitations under the License.
14eace7efcSopenharmony_ci */
15eace7efcSopenharmony_ci#ifndef OHOS_ABILITY_RUNTIME_SYSTEM_DIALOG_SCHEDULER_H
16eace7efcSopenharmony_ci#define OHOS_ABILITY_RUNTIME_SYSTEM_DIALOG_SCHEDULER_H
17eace7efcSopenharmony_ci
18eace7efcSopenharmony_ci#include <functional>
19eace7efcSopenharmony_ci
20eace7efcSopenharmony_ci#include "application_info.h"
21eace7efcSopenharmony_ci#include "bundle_mgr_interface.h"
22eace7efcSopenharmony_ci#include "singleton.h"
23eace7efcSopenharmony_ci
24eace7efcSopenharmony_cinamespace OHOS {
25eace7efcSopenharmony_cinamespace AAFwk {
26eace7efcSopenharmony_cienum class DialogType {
27eace7efcSopenharmony_ci    DIALOG_ANR = 0,
28eace7efcSopenharmony_ci    DIALOG_TIPS,
29eace7efcSopenharmony_ci    DIALOG_SELECTOR,
30eace7efcSopenharmony_ci    DIALOG_JUMP_INTERCEPTOR,
31eace7efcSopenharmony_ci};
32eace7efcSopenharmony_cienum class DialogAlign {
33eace7efcSopenharmony_ci    TOP = 0,
34eace7efcSopenharmony_ci    CENTER,
35eace7efcSopenharmony_ci    BOTTOM,
36eace7efcSopenharmony_ci    LEFT,
37eace7efcSopenharmony_ci    RIGHT,
38eace7efcSopenharmony_ci};
39eace7efcSopenharmony_cistruct DialogPosition {
40eace7efcSopenharmony_ci    int32_t offsetX = 0;
41eace7efcSopenharmony_ci    int32_t offsetY = 0;
42eace7efcSopenharmony_ci    int32_t width = 0;
43eace7efcSopenharmony_ci    int32_t height = 0;
44eace7efcSopenharmony_ci    int32_t window_width = 0;
45eace7efcSopenharmony_ci    int32_t window_height = 0;
46eace7efcSopenharmony_ci    int32_t window_offsetX = 0;
47eace7efcSopenharmony_ci    int32_t window_offsetY = 0;
48eace7efcSopenharmony_ci    int32_t width_narrow = 0;
49eace7efcSopenharmony_ci    int32_t height_narrow = 0;
50eace7efcSopenharmony_ci    bool wideScreen = true;
51eace7efcSopenharmony_ci    bool oversizeHeight = false;
52eace7efcSopenharmony_ci    DialogAlign align = DialogAlign::CENTER;
53eace7efcSopenharmony_ci};
54eace7efcSopenharmony_cistruct DialogAppInfo {
55eace7efcSopenharmony_ci    int32_t abilityIconId = 0;
56eace7efcSopenharmony_ci    int32_t abilityLabelId = 0;
57eace7efcSopenharmony_ci    int32_t bundleIconId = 0;
58eace7efcSopenharmony_ci    int32_t bundleLabelId = 0;
59eace7efcSopenharmony_ci    std::string bundleName = {};
60eace7efcSopenharmony_ci    std::string abilityName = {};
61eace7efcSopenharmony_ci    std::string moduleName = {};
62eace7efcSopenharmony_ci    bool visible = true;
63eace7efcSopenharmony_ci    int32_t appIndex = 0;
64eace7efcSopenharmony_ci    AppExecFwk::MultiAppModeData multiAppMode;
65eace7efcSopenharmony_ci};
66eace7efcSopenharmony_ci/**
67eace7efcSopenharmony_ci * @class SystemDialogScheduler
68eace7efcSopenharmony_ci * SystemDialogScheduler.
69eace7efcSopenharmony_ci */
70eace7efcSopenharmony_ciclass SystemDialogScheduler : public DelayedSingleton<SystemDialogScheduler> {
71eace7efcSopenharmony_cipublic:
72eace7efcSopenharmony_ci
73eace7efcSopenharmony_ci    explicit SystemDialogScheduler() = default;
74eace7efcSopenharmony_ci    virtual ~SystemDialogScheduler() = default;
75eace7efcSopenharmony_ci
76eace7efcSopenharmony_ci    int GetSelectorDialogWantCommon(const std::vector<DialogAppInfo> &dialogAppInfos, Want &requestWant,
77eace7efcSopenharmony_ci        Want &targetWant, const sptr<IRemoteObject> &callerToken);
78eace7efcSopenharmony_ci    int GetPcSelectorDialogWant(const std::vector<DialogAppInfo> &dialogAppInfos, Want &requestWant, Want &targetWant,
79eace7efcSopenharmony_ci        const std::string &type, int32_t userId, const sptr<IRemoteObject> &callerToken);
80eace7efcSopenharmony_ci    int GetSelectorDialogWant(const std::vector<DialogAppInfo> &dialogAppInfos, Want &requestWant, Want &targetWant,
81eace7efcSopenharmony_ci        const sptr<IRemoteObject> &callerToken);
82eace7efcSopenharmony_ci    Want GetTipsDialogWant(const sptr<IRemoteObject> &callerToken);
83eace7efcSopenharmony_ci    Want GetJumpInterceptorDialogWant(Want &targetWant);
84eace7efcSopenharmony_ci    Want GetSwitchUserDialogWant();
85eace7efcSopenharmony_ci    bool GetAssertFaultDialogWant(Want &want);
86eace7efcSopenharmony_ci
87eace7efcSopenharmony_ciprivate:
88eace7efcSopenharmony_ci    const std::string GetSelectorParams(const std::vector<DialogAppInfo> &infos) const;
89eace7efcSopenharmony_ci    const std::string GetPcSelectorParams(const std::vector<DialogAppInfo> &infos,
90eace7efcSopenharmony_ci        const std::string &type, int32_t userId, const std::string &action) const;
91eace7efcSopenharmony_ci    const std::string GetDialogPositionParams(const DialogPosition position) const;
92eace7efcSopenharmony_ci
93eace7efcSopenharmony_ci    void InitDialogPosition(DialogType type, DialogPosition &position) const;
94eace7efcSopenharmony_ci    void GetDialogPositionAndSize(DialogType type, DialogPosition &position, int lineNums = 0) const;
95eace7efcSopenharmony_ci    void GetSelectorDialogPositionAndSize(
96eace7efcSopenharmony_ci        DialogPosition &portraitPosition, DialogPosition &landscapePosition, int lineNums) const;
97eace7efcSopenharmony_ci    void GetSelectorDialogLandscapePosition(
98eace7efcSopenharmony_ci        DialogPosition &position, int32_t height, int32_t width, int lineNums, float densityPixels) const;
99eace7efcSopenharmony_ci    void DialogLandscapePositionAdaptive(
100eace7efcSopenharmony_ci        DialogPosition &position, float densityPixels, int lineNums) const;
101eace7efcSopenharmony_ci    void GetSelectorDialogPortraitPosition(
102eace7efcSopenharmony_ci        DialogPosition &position, int32_t height, int32_t width, int lineNums, float densityPixels) const;
103eace7efcSopenharmony_ci    void DialogPortraitPositionAdaptive(
104eace7efcSopenharmony_ci        DialogPosition &position, float densityPixels, int lineNums) const;
105eace7efcSopenharmony_ci    void DialogPositionAdaptive(DialogPosition &position, int lineNums) const;
106eace7efcSopenharmony_ci};
107eace7efcSopenharmony_ci}  // namespace AAFwk
108eace7efcSopenharmony_ci}  // namespace OHOS
109eace7efcSopenharmony_ci#endif  // OHOS_ABILITY_RUNTIME_SYSTEM_DIALOG_SCHEDULER_H
110