15ccb8f90Sopenharmony_ci/*
25ccb8f90Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
35ccb8f90Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
45ccb8f90Sopenharmony_ci * you may not use this file except in compliance with the License.
55ccb8f90Sopenharmony_ci * You may obtain a copy of the License at
65ccb8f90Sopenharmony_ci *
75ccb8f90Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
85ccb8f90Sopenharmony_ci *
95ccb8f90Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
105ccb8f90Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
115ccb8f90Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
125ccb8f90Sopenharmony_ci * See the License for the specific language governing permissions and
135ccb8f90Sopenharmony_ci * limitations under the License.
145ccb8f90Sopenharmony_ci */
155ccb8f90Sopenharmony_ci
165ccb8f90Sopenharmony_ci#ifndef POWERMGR_POWER_MANAGER_SHUTDOWN_DIALOG_H
175ccb8f90Sopenharmony_ci#define POWERMGR_POWER_MANAGER_SHUTDOWN_DIALOG_H
185ccb8f90Sopenharmony_ci
195ccb8f90Sopenharmony_ci#include <mutex>
205ccb8f90Sopenharmony_ci
215ccb8f90Sopenharmony_ci#include "ability_connect_callback_interface.h"
225ccb8f90Sopenharmony_ci#include "ability_connect_callback_stub.h"
235ccb8f90Sopenharmony_ci#include "ffrt_utils.h"
245ccb8f90Sopenharmony_ci
255ccb8f90Sopenharmony_cinamespace OHOS {
265ccb8f90Sopenharmony_cinamespace PowerMgr {
275ccb8f90Sopenharmony_ciclass ShutdownDialog {
285ccb8f90Sopenharmony_cipublic:
295ccb8f90Sopenharmony_ci    ShutdownDialog();
305ccb8f90Sopenharmony_ci    ~ShutdownDialog();
315ccb8f90Sopenharmony_ci    void KeyMonitorInit();
325ccb8f90Sopenharmony_ci    void KeyMonitorCancel();
335ccb8f90Sopenharmony_ci    bool ConnectSystemUi();
345ccb8f90Sopenharmony_ci    bool IsLongPress() const;
355ccb8f90Sopenharmony_ci    void ResetLongPressFlag();
365ccb8f90Sopenharmony_ci    void StartVibrator();
375ccb8f90Sopenharmony_ci    void LoadDialogConfig();
385ccb8f90Sopenharmony_ci    static std::string GetBundleName()
395ccb8f90Sopenharmony_ci    {
405ccb8f90Sopenharmony_ci        return bundleName_;
415ccb8f90Sopenharmony_ci    }
425ccb8f90Sopenharmony_ci
435ccb8f90Sopenharmony_ci    static std::string GetAbilityName()
445ccb8f90Sopenharmony_ci    {
455ccb8f90Sopenharmony_ci        return abilityName_;
465ccb8f90Sopenharmony_ci    }
475ccb8f90Sopenharmony_ci
485ccb8f90Sopenharmony_ci    static std::string GetUiExtensionType()
495ccb8f90Sopenharmony_ci    {
505ccb8f90Sopenharmony_ci        return uiExtensionType_;
515ccb8f90Sopenharmony_ci    }
525ccb8f90Sopenharmony_ciprivate:
535ccb8f90Sopenharmony_ci    class DialogAbilityConnection : public OHOS::AAFwk::AbilityConnectionStub {
545ccb8f90Sopenharmony_ci    public:
555ccb8f90Sopenharmony_ci        void OnAbilityConnectDone(
565ccb8f90Sopenharmony_ci            const AppExecFwk::ElementName& element, const sptr<IRemoteObject>& remoteObject, int resultCode) override;
575ccb8f90Sopenharmony_ci        void OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int resultCode) override;
585ccb8f90Sopenharmony_ci
595ccb8f90Sopenharmony_ci    private:
605ccb8f90Sopenharmony_ci        std::mutex mutex_;
615ccb8f90Sopenharmony_ci    };
625ccb8f90Sopenharmony_ci
635ccb8f90Sopenharmony_ci    int32_t longPressId_ {0};
645ccb8f90Sopenharmony_ci    sptr<OHOS::AAFwk::IAbilityConnection> dialogConnectionCallback_ {nullptr};
655ccb8f90Sopenharmony_ci    FFRTQueue queue_ {"shutdown_dialog"};
665ccb8f90Sopenharmony_ci    static std::string bundleName_;
675ccb8f90Sopenharmony_ci    static std::string abilityName_;
685ccb8f90Sopenharmony_ci    static std::string uiExtensionType_;
695ccb8f90Sopenharmony_ci};
705ccb8f90Sopenharmony_ci} // namespace PowerMgr
715ccb8f90Sopenharmony_ci} // namespace OHOS
725ccb8f90Sopenharmony_ci
735ccb8f90Sopenharmony_ci#endif // POWERMGR_POWER_MANAGER_SHUTDOWN_DIALOG_H
74