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

Commit b7c8a4bd authored by Albert Chaulk's avatar Albert Chaulk
Browse files

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

The API returns if the client_order 0 layer is visible or not. This
aids in 2D app detection

Bug: None
Test: Manual with permissionsgen & calculator

Change-Id: Id988e61a9f93885e93c28ed83ffaffd84f3bdf15
parent 297e6deb
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