Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3078ed9a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Implement an API for vrwm to query if the current vr app is active"

parents a9f001e0 b7c8a4bd
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -265,6 +265,12 @@ std::unique_ptr<BufferConsumer> DisplayClient::GetPoseBuffer() {
  return BufferConsumer::Import(std::move(status));
}

bool DisplayClient::IsVrAppRunning() {
  auto status = InvokeRemoteMethod<DisplayRPC::IsVrAppRunning>();
  if (!status)
    return 0;
  return static_cast<bool>(status.get());
}

}  // namespace dvr
}  // namespace android
+3 −0
Original line number Diff line number Diff line
@@ -110,6 +110,9 @@ class DisplayClient : public pdx::ClientBase<DisplayClient> {

  std::unique_ptr<BufferConsumer> GetPoseBuffer();

  // Temporary query for current VR status. Will be removed later.
  bool IsVrAppRunning();

 private:
  friend BASE;

+2 −0
Original line number Diff line number Diff line
@@ -219,6 +219,7 @@ struct DisplayRPC {
    kOpVideoMeshSurfaceCreateProducerQueue,
    kOpSetViewerParams,
    kOpGetPoseBuffer,
    kOpIsVrAppRunning,
  };

  // Aliases.
@@ -248,6 +249,7 @@ struct DisplayRPC {
                    void(const ViewerParams& viewer_params));
  PDX_REMOTE_METHOD(GetPoseBuffer, kOpGetPoseBuffer,
                    LocalChannelHandle(Void));
  PDX_REMOTE_METHOD(IsVrAppRunning, kOpIsVrAppRunning, int(Void));
};

struct DisplayManagerRPC {
+15 −0
Original line number Diff line number Diff line
@@ -94,6 +94,11 @@ int DisplayService::HandleMessage(pdx::Message& message) {
          *this, &DisplayService::OnGetPoseBuffer, message);
      return 0;

    case DisplayRPC::IsVrAppRunning::Opcode:
      DispatchRemoteMethod<DisplayRPC::IsVrAppRunning>(
          *this, &DisplayService::IsVrAppRunning, message);
      return 0;

    // Direct the surface specific messages to the surface instance.
    case DisplayRPC::CreateBufferQueue::Opcode:
    case DisplayRPC::SetAttributes::Opcode:
@@ -355,5 +360,15 @@ void DisplayService::NotifyDisplayConfigurationUpdate() {
    update_notifier_();
}

int DisplayService::IsVrAppRunning(pdx::Message& message) {
  bool visible = true;
  ForEachDisplaySurface([&visible](const std::shared_ptr<DisplaySurface>& surface) {
    if (surface->client_z_order() == 0 && !surface->IsVisible())
      visible = false;
  });

  REPLY_SUCCESS_RETURN(message, visible, 0);
}

}  // namespace dvr
}  // namespace android
+3 −0
Original line number Diff line number Diff line
@@ -87,6 +87,9 @@ class DisplayService : public pdx::ServiceBase<DisplayService> {
                         const ViewerParams& view_params);
  pdx::LocalChannelHandle OnGetPoseBuffer(pdx::Message& message);

  // Temporary query for current VR status. Will be removed later.
  int IsVrAppRunning(pdx::Message& message);

  // Called by DisplaySurface to signal that a surface property has changed and
  // the display manager should be notified.
  void NotifyDisplayConfigurationUpdate();
Loading