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

Commit 68c280a4 authored by Paul Colta's avatar Paul Colta
Browse files

HDMI: Implement getter & setter for TvBehaviorOnStandbyMessage

Test: atest com.android.server.hdmi
Bug: 430986255
Flag: EXEMPT bugfix
Change-Id: Ice2cc762b8e526d53939377a560216e4ee6ed90c
parent d742610b
Loading
Loading
Loading
Loading
+54 −0
Original line number Diff line number Diff line
@@ -449,6 +449,16 @@ public final class HdmiControlManager {
     * @hide
     */
    public static final int TV_BEHAVIOR_ON_STANDBY_MESSAGE_GO_TO_DREAM = 1;
    /**
     * @see HdmiControlManager#CEC_SETTING_NAME_TV_BEHAVIOR_ON_STANDBY_MESSAGE
     * @hide
     */
    @IntDef(prefix = { "TV_BEHAVIOR_ON_STANDBY_MESSAGE_" }, value = {
            TV_BEHAVIOR_ON_STANDBY_MESSAGE_GO_TO_SLEEP,
            TV_BEHAVIOR_ON_STANDBY_MESSAGE_GO_TO_DREAM
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface TvBehaviorOnStandbyMessage {}

    // -- Scope of CEC power control messages sent by a playback device.
    /**
@@ -2415,6 +2425,50 @@ public final class HdmiControlManager {
        }
    }

    /**
     * Set the TV's behavior upon receiving a <Standby> message.
     *
     * <p>Sets whether the TV should go to sleep or go to dream.
     *
     * @see HdmiControlManager#CEC_SETTING_NAME_TV_BEHAVIOR_ON_STANDBY_MESSAGE
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.HDMI_CEC)
    public void setTvBehaviorOnStandbyMessage(@NonNull @TvBehaviorOnStandbyMessage int value) {
        if (mService == null) {
          Log.e(TAG, "setTvBehaviorOnStandbyMessage: HdmiControlService is not available");
          throw new RuntimeException("HdmiControlService is not available");
        }
        try {
          mService.setCecSettingIntValue(CEC_SETTING_NAME_TV_BEHAVIOR_ON_STANDBY_MESSAGE, value);
        } catch (RemoteException e) {
          throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Get the TV's behavior upon receiving a <Standby> message.
     *
     * <p>Reflects whether the TV will go to sleep or go to dream.
     *
     * @see HdmiControlManager#CEC_SETTING_NAME_TV_BEHAVIOR_ON_STANDBY_MESSAGE
     * @hide
     */
    @NonNull
    @TvBehaviorOnStandbyMessage
    @RequiresPermission(android.Manifest.permission.HDMI_CEC)
    public int getTvBehaviorOnStandbyMessage() {
        if (mService == null) {
          Log.e(TAG, "getTvBehaviorOnStandbyMessage: HdmiControlService is not available");
          throw new RuntimeException("HdmiControlService is not available");
        }
        try {
          return mService.getCecSettingIntValue(CEC_SETTING_NAME_TV_BEHAVIOR_ON_STANDBY_MESSAGE);
        } catch (RemoteException e) {
          throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Set the status of Power Control.
     *