• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 UI_APPEARANCE_ABILITY_CLIENT_H
17 #define UI_APPEARANCE_ABILITY_CLIENT_H
18 
19 #include "iremote_object.h"
20 #include "refbase.h"
21 #include "ui_appearance_ability_interface.h"
22 
23 namespace OHOS {
24 namespace ArkUi::UiAppearance {
25 class UiAppearanceDeathRecipient : public IRemoteObject::DeathRecipient {
26 public:
27     explicit UiAppearanceDeathRecipient() = default;
28     ~UiAppearanceDeathRecipient() = default;
29     void OnRemoteDied(const wptr<IRemoteObject>& object) override;
30 };
31 
32 class UiAppearanceAbilityClient : public RefBase {
33 public:
34     UiAppearanceAbilityClient() = default;
35     ~UiAppearanceAbilityClient() = default;
36     static sptr<UiAppearanceAbilityClient> GetInstance();
37 
38     int32_t SetDarkMode(UiAppearanceAbilityInterface::DarkMode mode);
39     int32_t GetDarkMode();
40     void OnRemoteSaDied(const wptr<IRemoteObject>& object);
41 
42 private:
43     sptr<UiAppearanceAbilityInterface> GetUiAppearanceServiceProxy();
44     static sptr<UiAppearanceAbilityInterface> CreateUiAppearanceServiceProxy();
45 
46     static inline std::mutex instanceLock_;
47     static inline sptr<UiAppearanceAbilityClient> instance_;
48     static inline sptr<UiAppearanceAbilityInterface> uiAppearanceServiceProxy_;
49     static inline sptr<UiAppearanceDeathRecipient> deathRecipient_;
50 };
51 } // namespace ArkUi::UiAppearance
52 } // namespace OHOS
53 #endif // UI_APPEARANCE_ABILITY_CLIENT_H