1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef AUTHORIZATION_DIALOG_H
17 #define AUTHORIZATION_DIALOG_H
18 
19 #include <mutex>
20 
21 #include "ability_connect_callback_stub.h"
22 #include "ffrt_inner.h"
23 
24 namespace OHOS {
25 namespace MMI {
26 class AuthorizationDialog {
27 public:
28     AuthorizationDialog();
29     ~AuthorizationDialog();
30     bool ConnectSystemUi();
GetBundleName()31     static std::string GetBundleName()
32     {
33         return bundleName_;
34     }
35 
GetAbilityName()36     static std::string GetAbilityName()
37     {
38         return abilityName_;
39     }
40 
GetUiExtensionType()41     static std::string GetUiExtensionType()
42     {
43         return uiExtensionType_;
44     }
45 private:
46     class DialogAbilityConnection : public OHOS::AAFwk::AbilityConnectionStub {
47     public:
48         void OnAbilityConnectDone(
49             const AppExecFwk::ElementName& element, const sptr<IRemoteObject>& remoteObject, int resultCode) override;
50         void OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int resultCode) override;
51 
52     private:
53         std::mutex mutex_;
54     };
55 
56     sptr<OHOS::AAFwk::IAbilityConnection> dialogConnectionCallback_ {nullptr};
57     static std::string bundleName_;
58     static std::string abilityName_;
59     static std::string uiExtensionType_;
60 };
61 } // namespace MMI
62 } // namespace OHOS
63 
64 #endif // AUTHORIZATION_DIALOG_H