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

Commit d2f1fc4c authored by Oliver Woodman's avatar Oliver Woodman
Browse files

Improve RemoteDisplayProvider documentation and exceptions

Bug: b/211549545
Change-Id: I37866b30879fe9e43f3213c1f2eb25c817f11f03
Tested: Trivial refactor
parent f786af32
Loading
Loading
Loading
Loading
+26 −10
Original line number Diff line number Diff line
@@ -238,13 +238,18 @@ public abstract class RemoteDisplayProvider {
     * Adds the specified remote display and notifies the system.
     *
     * @param display The remote display that was added.
     * @throws IllegalStateException if there is already a display with the same id.
     * @throws IllegalStateException if the argument is null, or if there is already a display with
     *         the same id.
     */
    public void addDisplay(RemoteDisplay display) {
        if (display == null || mDisplays.containsKey(display.getId())) {
            throw new IllegalArgumentException("display");
        if (display == null) {
            throw new IllegalArgumentException("display cannot be null");
        }
        mDisplays.put(display.getId(), display);
        String displayId = display.getId();
        if (mDisplays.containsKey(displayId)) {
            throw new IllegalArgumentException("display already exists with id: " + displayId);
        }
        mDisplays.put(displayId, display);
        publishState();
    }

@@ -252,11 +257,16 @@ public abstract class RemoteDisplayProvider {
     * Updates information about the specified remote display and notifies the system.
     *
     * @param display The remote display that was added.
     * @throws IllegalStateException if the display was n
     * @throws IllegalStateException if the argument is null, or if the provider is not aware of the
     *         display.
     */
    public void updateDisplay(RemoteDisplay display) {
        if (display == null || mDisplays.get(display.getId()) != display) {
            throw new IllegalArgumentException("display");
        if (display == null) {
            throw new IllegalArgumentException("display cannot be null");
        }
        String displayId = display.getId();
        if (mDisplays.get(displayId) != display) {
            throw new IllegalArgumentException("unexpected display with id: " + displayId);
        }
        publishState();
    }
@@ -265,12 +275,18 @@ public abstract class RemoteDisplayProvider {
     * Removes the specified remote display and tells the system about it.
     *
     * @param display The remote display that was removed.
     * @throws IllegalStateException if the argument is null, or if the provider is not aware of the
     *         display.
     */
    public void removeDisplay(RemoteDisplay display) {
        if (display == null || mDisplays.get(display.getId()) != display) {
            throw new IllegalArgumentException("display");
        if (display == null) {
            throw new IllegalArgumentException("display cannot be null");
        }
        String displayId = display.getId();
        if (mDisplays.get(displayId) != display) {
            throw new IllegalArgumentException("unexpected display with id: " + displayId);
        }
        mDisplays.remove(display.getId());
        mDisplays.remove(displayId);
        publishState();
    }