• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 FOUNDATION_DM_DISPLAY_MANAGER_ADAPTER_LITE_H
17 #define FOUNDATION_DM_DISPLAY_MANAGER_ADAPTER_LITE_H
18 
19 #include <map>
20 #include <mutex>
21 
22 #include "display_lite.h"
23 #include "dm_common.h"
24 #include "singleton_delegator.h"
25 #include "zidl/screen_session_manager_lite_interface.h"
26 
27 namespace OHOS::Rosen {
28 class BaseAdapterLite {
29 public:
30     virtual ~BaseAdapterLite();
31     virtual DMError RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
32         DisplayManagerAgentType type);
33     virtual DMError UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
34         DisplayManagerAgentType type);
35     virtual void Clear();
36 protected:
37     bool InitDMSProxy();
38     std::recursive_mutex mutex_;
39     sptr<IScreenSessionManagerLite> displayManagerServiceProxy_ = nullptr;
40     sptr<IRemoteObject::DeathRecipient> dmsDeath_ = nullptr;
41     bool isProxyValid_ { false };
42 };
43 
44 class DMSDeathRecipientLite : public IRemoteObject::DeathRecipient {
45 public:
46     explicit DMSDeathRecipientLite(BaseAdapterLite& adapter);
47     virtual void OnRemoteDied(const wptr<IRemoteObject>& wptrDeath) override;
48 private:
49     BaseAdapterLite& adapter_;
50 };
51 
52 class DisplayManagerAdapterLite : public BaseAdapterLite {
53 WM_DECLARE_SINGLE_INSTANCE(DisplayManagerAdapterLite);
54 public:
55     virtual sptr<DisplayInfo> GetDefaultDisplayInfo();
56     virtual bool IsFoldable();
57     virtual FoldStatus GetFoldStatus();
58     virtual FoldDisplayMode GetFoldDisplayMode();
59     virtual sptr<DisplayInfo> GetDisplayInfo(DisplayId displayId);
60     virtual sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId);
61 private:
62     static inline SingletonDelegator<DisplayManagerAdapterLite> delegator;
63 };
64 } // namespace OHOS::Rosen
65 #endif // FOUNDATION_DM_DISPLAY_MANAGER_ADAPTER_LITE_H
66