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 <string>
20#include "iremote_object.h"
21#include "refbase.h"
22#include "ui_appearance_ability_interface.h"
23
24namespace OHOS {
25namespace ArkUi::UiAppearance {
26class UiAppearanceDeathRecipient : public IRemoteObject::DeathRecipient {
27public:
28    explicit UiAppearanceDeathRecipient() = default;
29    ~UiAppearanceDeathRecipient() = default;
30    void OnRemoteDied(const wptr<IRemoteObject>& object) override;
31};
32
33class UiAppearanceAbilityClient : public RefBase {
34public:
35    UiAppearanceAbilityClient() = default;
36    ~UiAppearanceAbilityClient() = default;
37    static sptr<UiAppearanceAbilityClient> GetInstance();
38
39    int32_t SetDarkMode(UiAppearanceAbilityInterface::DarkMode mode);
40    int32_t GetDarkMode();
41    int32_t GetFontScale(std::string& fontScale);
42    int32_t SetFontScale(std::string& fontScale);
43    int32_t GetFontWeightScale(std::string& fontWeightScale);
44    int32_t SetFontWeightScale(std::string& fontWeightScale);
45    void OnRemoteSaDied(const wptr<IRemoteObject>& object);
46
47private:
48    sptr<UiAppearanceAbilityInterface> GetUiAppearanceServiceProxy();
49    static sptr<UiAppearanceAbilityInterface> CreateUiAppearanceServiceProxy();
50
51    static inline std::mutex instanceLock_;
52    static inline sptr<UiAppearanceAbilityClient> instance_;
53    static inline sptr<UiAppearanceAbilityInterface> uiAppearanceServiceProxy_;
54    static inline sptr<UiAppearanceDeathRecipient> deathRecipient_;
55};
56} // namespace ArkUi::UiAppearance
57} // namespace OHOS
58#endif // UI_APPEARANCE_ABILITY_CLIENT_H