display_manager_service.h revision eaa5522feac452703a0836310047d4b15702487d
1#ifndef ANDROID_DVR_SERVICES_DISPLAYD_DISPLAY_MANAGER_SERVICE_H_
2#define ANDROID_DVR_SERVICES_DISPLAYD_DISPLAY_MANAGER_SERVICE_H_
3
4#include <pdx/service.h>
5#include <private/dvr/display_rpc.h>
6
7#include "display_service.h"
8
9namespace android {
10namespace dvr {
11
12class DisplayManagerService;
13
14// The display manager is a client of the display manager service. This class
15// represents the connected client that the display manager service sends
16// notifications to.
17class DisplayManager : public pdx::Channel {
18 public:
19  DisplayManager(DisplayManagerService* service, int channel_id)
20      : service_(service), channel_id_(channel_id) {}
21
22  int channel_id() const { return channel_id_; }
23
24  // Sets or clears the channel event mask to indicate pending events that the
25  // display manager on the other end of the channel should read and handle.
26  // When |pending| is true the POLLIN bit is set in the event mask; when
27  // |pending| is false the POLLIN bit is cleared in the event mask.
28  void SetNotificationsPending(bool pending);
29
30 private:
31  DisplayManager(const DisplayManager&) = delete;
32  void operator=(const DisplayManager&) = delete;
33
34  DisplayManagerService* service_;
35  int channel_id_;
36};
37
38// The display manager service marshalls state and events from the display
39// service to the display manager.
40class DisplayManagerService : public pdx::ServiceBase<DisplayManagerService> {
41 public:
42  std::shared_ptr<pdx::Channel> OnChannelOpen(pdx::Message& message) override;
43  void OnChannelClose(pdx::Message& message,
44                      const std::shared_ptr<pdx::Channel>& channel) override;
45  pdx::Status<void> HandleMessage(pdx::Message& message) override;
46
47 private:
48  friend BASE;
49
50  explicit DisplayManagerService(
51      const std::shared_ptr<DisplayService>& display_service);
52
53  std::vector<DisplaySurfaceInfo> OnGetSurfaceList(pdx::Message& message);
54  int OnUpdateSurfaces(pdx::Message& message,
55                       const std::map<int, DisplaySurfaceAttributes>& updates);
56
57  pdx::Status<BorrowedNativeBufferHandle> OnSetupNamedBuffer(
58      pdx::Message& message, const std::string& name, size_t size,
59      uint64_t producer_usage, uint64_t consumer_usage);
60
61  // Called by the display service to indicate changes to display surfaces that
62  // the display manager should evaluate.
63  void OnDisplaySurfaceChange();
64
65  DisplayManagerService(const DisplayManagerService&) = delete;
66  void operator=(const DisplayManagerService&) = delete;
67
68  std::shared_ptr<DisplayService> display_service_;
69  std::shared_ptr<DisplayManager> display_manager_;
70};
71
72}  // namespace dvr
73}  // namespace android
74
75#endif  // ANDROID_DVR_SERVICES_DISPLAYD_DISPLAY_MANAGER_SERVICE_H_
76