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

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

Merge "Workaround missing OnChannelClose for DisplayManagerService" into pi-dev

parents 61f77509 f5d491ca
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -588,6 +588,14 @@ class Service : public std::enable_shared_from_this<Service> {
    ForEachChannelUnlocked(action);
  }

  /*
   * Return true if a channel with the given ID exists in the Channel map.
   */
  bool HasChannelId(int channel_id) const {
    std::lock_guard<std::mutex> autolock(channels_mutex_);
    return channels_.find(channel_id) != channels_.end();
  }

  /*
   * Subclasses of Service may override this method to provide a text string
   * describing the state of the service. This method is called by
+8 −0
Original line number Diff line number Diff line
@@ -45,6 +45,14 @@ std::shared_ptr<pdx::Channel> DisplayManagerService::OnChannelOpen(
  const int user_id = message.GetEffectiveUserId();
  const bool trusted = user_id == AID_ROOT || IsTrustedUid(user_id);

  // Check if the display_manager_ has a defunct channel.
  if (display_manager_ && !HasChannelId(display_manager_->channel_id())) {
    ALOGE("DisplayManagerService::OnChannelOpen: Found defunct channel %d with "
          "no OnChannelClose, clearing prior display manager.",
          display_manager_->channel_id());
    display_manager_ = nullptr;
  }

  // Prevent more than one display manager from registering at a time or
  // untrusted UIDs from connecting.
  if (display_manager_ || !trusted) {