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

Commit 8d5fa098 authored by Michal Olech's avatar Michal Olech Committed by Android (Google) Code Review
Browse files

Merge changes I5ac00d59,I41a59081,I63c7cf35

* changes:
  [CEC Configuration] Fix race condition with listeners
  [2.0] Disable sending <User Control Pressed> in attempts to change the active source to a 2.0 device
  [CEC Configuration] Add 'tv_wake_on_one_touch_play' option
parents 1c9c511c b4e2a5bc
Loading
Loading
Loading
Loading
+75 −2
Original line number Original line Diff line number Diff line
@@ -480,6 +480,28 @@ public final class HdmiControlManager {
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    public @interface VolumeControl {}
    public @interface VolumeControl {}


    // -- Whether TV Wake on One Touch Play is enabled or disabled.
    /**
     * TV Wake on One Touch Play enabled.
     *
     * @hide
     */
    public static final int TV_WAKE_ON_ONE_TOUCH_PLAY_ENABLED = 1;
    /**
     * TV Wake on One Touch Play disabled.
     *
     * @hide
     */
    public static final int TV_WAKE_ON_ONE_TOUCH_PLAY_DISABLED = 0;
    /**
     * @hide
     */
    @IntDef(prefix = { "TV_WAKE_ON_ONE_TOUCH_PLAY_" }, value = {
            TV_WAKE_ON_ONE_TOUCH_PLAY_ENABLED,
            TV_WAKE_ON_ONE_TOUCH_PLAY_DISABLED
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface TvWakeOnOneTouchPlay {}


    // -- Settings available in the CEC Configuration.
    // -- Settings available in the CEC Configuration.
    /**
    /**
@@ -519,7 +541,6 @@ public final class HdmiControlManager {
    @SystemApi
    @SystemApi
    public static final String CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING =
    public static final String CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING =
            "system_audio_mode_muting";
            "system_audio_mode_muting";

    /**
    /**
     * Controls whether volume control commands via HDMI CEC are enabled.
     * Controls whether volume control commands via HDMI CEC are enabled.
     *
     *
@@ -555,7 +576,14 @@ public final class HdmiControlManager {
     */
     */
    public static final String CEC_SETTING_NAME_VOLUME_CONTROL_MODE =
    public static final String CEC_SETTING_NAME_VOLUME_CONTROL_MODE =
            "volume_control_enabled";
            "volume_control_enabled";

    /**
     * Name of a setting deciding whether the TV will automatically turn on upon reception
     * of the CEC command &lt;Text View On&gt; or &lt;Image View On&gt;.
     *
     * @hide
     */
    public static final String CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY =
            "tv_wake_on_one_touch_play";
    /**
    /**
     * @hide
     * @hide
     */
     */
@@ -566,6 +594,7 @@ public final class HdmiControlManager {
        CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST,
        CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST,
        CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING,
        CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING,
        CEC_SETTING_NAME_VOLUME_CONTROL_MODE,
        CEC_SETTING_NAME_VOLUME_CONTROL_MODE,
        CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY,
    })
    })
    public @interface CecSettingName {}
    public @interface CecSettingName {}


@@ -1869,4 +1898,48 @@ public final class HdmiControlManager {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        }
    }
    }

    /**
     * Set the current status of TV Wake on One Touch Play.
     *
     * <p>Sets whether the TV should wake up upon reception of &lt;Text View On&gt;
     * or &lt;Image View On&gt;.
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.HDMI_CEC)
    public void setTvWakeOnOneTouchPlay(@NonNull @TvWakeOnOneTouchPlay int value) {
        if (mService == null) {
            Log.e(TAG, "HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
        }
        try {
            mService.setCecSettingIntValue(CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY, value);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Get the current status of TV Wake on One Touch Play.
     *
     * <p>Reflects whether the TV should wake up upon reception of &lt;Text View On&gt;
     * or &lt;Image View On&gt;.
     *
     * @hide
     */
    @NonNull
    @TvWakeOnOneTouchPlay
    @RequiresPermission(android.Manifest.permission.HDMI_CEC)
    public int getTvWakeOnOneTouchPlay() {
        if (mService == null) {
            Log.e(TAG, "HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
        }
        try {
            return mService.getCecSettingIntValue(CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
}
}
+73 −46
Original line number Original line Diff line number Diff line
@@ -23,6 +23,8 @@ import android.hardware.hdmi.IHdmiControlCallback;
import android.hardware.tv.cec.V1_0.SendMessageResult;
import android.hardware.tv.cec.V1_0.SendMessageResult;
import android.os.RemoteException;
import android.os.RemoteException;
import android.util.Slog;
import android.util.Slog;

import com.android.internal.annotations.VisibleForTesting;
import com.android.server.hdmi.HdmiControlService.SendMessageCallback;
import com.android.server.hdmi.HdmiControlService.SendMessageCallback;


/**
/**
@@ -47,7 +49,8 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {


    // State in which we wait for <Report Power Status> to come in response to the command
    // State in which we wait for <Report Power Status> to come in response to the command
    // <Give Device Power Status> we have sent.
    // <Give Device Power Status> we have sent.
    private static final int STATE_WAIT_FOR_REPORT_POWER_STATUS = 1;
    @VisibleForTesting
    static final int STATE_WAIT_FOR_REPORT_POWER_STATUS = 1;


    // State in which we wait for the device power status to switch to 'Standby'.
    // State in which we wait for the device power status to switch to 'Standby'.
    // We wait till the status becomes 'Standby' before we send <Set Stream Path>
    // We wait till the status becomes 'Standby' before we send <Set Stream Path>
@@ -56,11 +59,13 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {


    // State in which we wait for the device power status to switch to 'on'. We wait
    // State in which we wait for the device power status to switch to 'on'. We wait
    // maximum 100 seconds (20 * 5) before we give up and just send <Set Stream Path>.
    // maximum 100 seconds (20 * 5) before we give up and just send <Set Stream Path>.
    private static final int STATE_WAIT_FOR_DEVICE_POWER_ON = 3;
    @VisibleForTesting
    static final int STATE_WAIT_FOR_DEVICE_POWER_ON = 3;


    private final HdmiDeviceInfo mTarget;
    private final HdmiDeviceInfo mTarget;
    private final IHdmiControlCallback mCallback;
    private final IHdmiControlCallback mCallback;
    private final HdmiCecMessage mGivePowerStatus;
    private final HdmiCecMessage mGivePowerStatus;
    private final boolean mIsCec20;


    private int mPowerStatusCounter = 0;
    private int mPowerStatusCounter = 0;


@@ -71,13 +76,22 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {
     * @param target target logical device that will be a new active source
     * @param target target logical device that will be a new active source
     * @param callback callback object
     * @param callback callback object
     */
     */
    public DeviceSelectAction(HdmiCecLocalDeviceTv source,
    DeviceSelectAction(HdmiCecLocalDeviceTv source, HdmiDeviceInfo target,
            HdmiDeviceInfo target, IHdmiControlCallback callback) {
                              IHdmiControlCallback callback) {
        this(source, target, callback,
             source.getDeviceInfo().getCecVersion() >= HdmiControlManager.HDMI_CEC_VERSION_2_0
                     && target.getCecVersion() >= HdmiControlManager.HDMI_CEC_VERSION_2_0);
    }

    @VisibleForTesting
    DeviceSelectAction(HdmiCecLocalDeviceTv source, HdmiDeviceInfo target,
                       IHdmiControlCallback callback, boolean isCec20) {
        super(source);
        super(source);
        mCallback = callback;
        mCallback = callback;
        mTarget = target;
        mTarget = target;
        mGivePowerStatus = HdmiCecMessageBuilder.buildGiveDevicePowerStatus(
        mGivePowerStatus = HdmiCecMessageBuilder.buildGiveDevicePowerStatus(
                getSourceAddress(), getTargetAddress());
                getSourceAddress(), getTargetAddress());
        mIsCec20 = isCec20;
    }
    }


    int getTargetAddress() {
    int getTargetAddress() {
@@ -86,8 +100,18 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {


    @Override
    @Override
    public boolean start() {
    public boolean start() {
        // Seq #9
        if (mIsCec20) {
            sendSetStreamPath();
        }
        if (!mIsCec20 || mTarget.getDevicePowerStatus()
                              == HdmiControlManager.POWER_STATUS_UNKNOWN) {
            queryDevicePowerStatus();
            queryDevicePowerStatus();
        } else if (mTarget.getDevicePowerStatus() == HdmiControlManager.POWER_STATUS_ON) {
            invokeCallbackAndFinish(HdmiControlManager.RESULT_SUCCESS);
            return true;
        }
        mState = STATE_WAIT_FOR_REPORT_POWER_STATUS;
        addTimer(mState, HdmiConfig.TIMEOUT_MS);
        return true;
        return true;
    }
    }


@@ -96,14 +120,10 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {
            @Override
            @Override
            public void onSendCompleted(int error) {
            public void onSendCompleted(int error) {
                if (error != SendMessageResult.SUCCESS) {
                if (error != SendMessageResult.SUCCESS) {
                    invokeCallback(HdmiControlManager.RESULT_COMMUNICATION_FAILED);
                    invokeCallbackAndFinish(HdmiControlManager.RESULT_COMMUNICATION_FAILED);
                    finish();
                    return;
                }
                }
            }
            }
        });
        });
        mState = STATE_WAIT_FOR_REPORT_POWER_STATUS;
        addTimer(mState, HdmiConfig.TIMEOUT_MS);
    }
    }


    @Override
    @Override
@@ -113,7 +133,6 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {
        }
        }
        int opcode = cmd.getOpcode();
        int opcode = cmd.getOpcode();
        byte[] params = cmd.getParams();
        byte[] params = cmd.getParams();

        switch (mState) {
        switch (mState) {
            case STATE_WAIT_FOR_REPORT_POWER_STATUS:
            case STATE_WAIT_FOR_REPORT_POWER_STATUS:
                if (opcode == Constants.MESSAGE_REPORT_POWER_STATUS) {
                if (opcode == Constants.MESSAGE_REPORT_POWER_STATUS) {
@@ -129,21 +148,23 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {
    private boolean handleReportPowerStatus(int powerStatus) {
    private boolean handleReportPowerStatus(int powerStatus) {
        switch (powerStatus) {
        switch (powerStatus) {
            case HdmiControlManager.POWER_STATUS_ON:
            case HdmiControlManager.POWER_STATUS_ON:
                sendSetStreamPath();
                selectDevice();
                return true;
                return true;
            case HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY:
            case HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY:
                if (mPowerStatusCounter < 4) {
                if (mPowerStatusCounter < 4) {
                    mState = STATE_WAIT_FOR_DEVICE_TO_TRANSIT_TO_STANDBY;
                    mState = STATE_WAIT_FOR_DEVICE_TO_TRANSIT_TO_STANDBY;
                    addTimer(mState, TIMEOUT_TRANSIT_TO_STANDBY_MS);
                    addTimer(mState, TIMEOUT_TRANSIT_TO_STANDBY_MS);
                } else {
                } else {
                    sendSetStreamPath();
                    selectDevice();
                }
                }
                return true;
                return true;
            case HdmiControlManager.POWER_STATUS_STANDBY:
            case HdmiControlManager.POWER_STATUS_STANDBY:
                if (mPowerStatusCounter == 0) {
                if (mPowerStatusCounter == 0) {
                    turnOnDevice();
                    turnOnDevice();
                    mState = STATE_WAIT_FOR_DEVICE_POWER_ON;
                    addTimer(mState, TIMEOUT_POWER_ON_MS);
                } else {
                } else {
                    sendSetStreamPath();
                    selectDevice();
                }
                }
                return true;
                return true;
            case HdmiControlManager.POWER_STATUS_TRANSIENT_TO_ON:
            case HdmiControlManager.POWER_STATUS_TRANSIENT_TO_ON:
@@ -151,33 +172,13 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {
                    mState = STATE_WAIT_FOR_DEVICE_POWER_ON;
                    mState = STATE_WAIT_FOR_DEVICE_POWER_ON;
                    addTimer(mState, TIMEOUT_POWER_ON_MS);
                    addTimer(mState, TIMEOUT_POWER_ON_MS);
                } else {
                } else {
                    sendSetStreamPath();
                    selectDevice();
                }
                }
                return true;
                return true;
        }
        }
        return false;
        return false;
    }
    }


    private void turnOnDevice() {
        sendUserControlPressedAndReleased(mTarget.getLogicalAddress(),
                HdmiCecKeycode.CEC_KEYCODE_POWER);
        sendUserControlPressedAndReleased(mTarget.getLogicalAddress(),
                HdmiCecKeycode.CEC_KEYCODE_POWER_ON_FUNCTION);
        mState = STATE_WAIT_FOR_DEVICE_POWER_ON;
        addTimer(mState, TIMEOUT_POWER_ON_MS);
    }

    private void sendSetStreamPath() {
        // Turn the active source invalidated, which remains so till <Active Source> comes from
        // the selected device.
        tv().getActiveSource().invalidate();
        tv().setActivePath(mTarget.getPhysicalAddress());
        sendCommand(HdmiCecMessageBuilder.buildSetStreamPath(
                getSourceAddress(), mTarget.getPhysicalAddress()));
        invokeCallback(HdmiControlManager.RESULT_SUCCESS);
        finish();
    }

    @Override
    @Override
    public void handleTimerEvent(int timeoutState) {
    public void handleTimerEvent(int timeoutState) {
        if (mState != timeoutState) {
        if (mState != timeoutState) {
@@ -187,28 +188,54 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {
        switch (mState) {
        switch (mState) {
            case STATE_WAIT_FOR_REPORT_POWER_STATUS:
            case STATE_WAIT_FOR_REPORT_POWER_STATUS:
                if (tv().isPowerStandbyOrTransient()) {
                if (tv().isPowerStandbyOrTransient()) {
                    invokeCallback(HdmiControlManager.RESULT_INCORRECT_MODE);
                    invokeCallbackAndFinish(HdmiControlManager.RESULT_INCORRECT_MODE);
                    finish();
                    return;
                    return;
                }
                }
                sendSetStreamPath();
                selectDevice();
                break;
                break;
            case STATE_WAIT_FOR_DEVICE_TO_TRANSIT_TO_STANDBY:
            case STATE_WAIT_FOR_DEVICE_TO_TRANSIT_TO_STANDBY:
            case STATE_WAIT_FOR_DEVICE_POWER_ON:
            case STATE_WAIT_FOR_DEVICE_POWER_ON:
                mPowerStatusCounter++;
                mPowerStatusCounter++;
                queryDevicePowerStatus();
                queryDevicePowerStatus();
                mState = STATE_WAIT_FOR_REPORT_POWER_STATUS;
                addTimer(mState, HdmiConfig.TIMEOUT_MS);
                break;
                break;
        }
        }
    }
    }


    private void invokeCallback(int result) {
    private void turnOnDevice() {
        if (mCallback == null) {
        if (!mIsCec20) {
            return;
            sendUserControlPressedAndReleased(mTarget.getLogicalAddress(),
                    HdmiCecKeycode.CEC_KEYCODE_POWER);
            sendUserControlPressedAndReleased(mTarget.getLogicalAddress(),
                    HdmiCecKeycode.CEC_KEYCODE_POWER_ON_FUNCTION);
        }
    }
    }

    private void selectDevice() {
        if (!mIsCec20) {
            sendSetStreamPath();
        }
        invokeCallbackAndFinish(HdmiControlManager.RESULT_SUCCESS);
    }

    private void sendSetStreamPath() {
        // Turn the active source invalidated, which remains so till <Active Source> comes from
        // the selected device.
        tv().getActiveSource().invalidate();
        tv().setActivePath(mTarget.getPhysicalAddress());
        sendCommand(HdmiCecMessageBuilder.buildSetStreamPath(
                getSourceAddress(), mTarget.getPhysicalAddress()));
    }

    private void invokeCallbackAndFinish(int result) {
        if (mCallback != null) {
            try {
            try {
                mCallback.onComplete(result);
                mCallback.onComplete(result);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Slog.e(TAG, "Callback failed:" + e);
                Slog.e(TAG, "Callback failed:" + e);
            }
            }
        }
        }
        finish();
    }
}
}
+28 −14
Original line number Original line Diff line number Diff line
@@ -37,6 +37,7 @@ import android.provider.Settings.Global;
import android.util.ArrayMap;
import android.util.ArrayMap;
import android.util.Slog;
import android.util.Slog;


import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.hdmi.cec.config.CecSettings;
import com.android.server.hdmi.cec.config.CecSettings;
import com.android.server.hdmi.cec.config.Setting;
import com.android.server.hdmi.cec.config.Setting;
@@ -95,6 +96,9 @@ public class HdmiCecConfig {
    @Nullable private final CecSettings mSystemConfig;
    @Nullable private final CecSettings mSystemConfig;
    @Nullable private final CecSettings mVendorOverride;
    @Nullable private final CecSettings mVendorOverride;


    private final Object mLock = new Object();

    @GuardedBy("mLock")
    private final ArrayMap<Setting, Set<SettingChangeListener>>
    private final ArrayMap<Setting, Set<SettingChangeListener>>
            mSettingChangeListeners = new ArrayMap<>();
            mSettingChangeListeners = new ArrayMap<>();


@@ -297,6 +301,8 @@ public class HdmiCecConfig {
                return STORAGE_SHARED_PREFS;
                return STORAGE_SHARED_PREFS;
            case HdmiControlManager.CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING:
            case HdmiControlManager.CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING:
                return STORAGE_SHARED_PREFS;
                return STORAGE_SHARED_PREFS;
            case HdmiControlManager.CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY:
                return STORAGE_GLOBAL_SETTINGS;
            default:
            default:
                throw new RuntimeException("Invalid CEC setting '" + setting.getName()
                throw new RuntimeException("Invalid CEC setting '" + setting.getName()
                        + "' storage.");
                        + "' storage.");
@@ -317,6 +323,8 @@ public class HdmiCecConfig {
                return setting.getName();
                return setting.getName();
            case HdmiControlManager.CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING:
            case HdmiControlManager.CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING:
                return setting.getName();
                return setting.getName();
            case HdmiControlManager.CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY:
                return Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED;
            default:
            default:
                throw new RuntimeException("Invalid CEC setting '" + setting.getName()
                throw new RuntimeException("Invalid CEC setting '" + setting.getName()
                    + "' storage key.");
                    + "' storage key.");
@@ -385,6 +393,7 @@ public class HdmiCecConfig {
    }
    }


    private void notifySettingChanged(@NonNull Setting setting) {
    private void notifySettingChanged(@NonNull Setting setting) {
        synchronized (mLock) {
            Set<SettingChangeListener> listeners = mSettingChangeListeners.get(setting);
            Set<SettingChangeListener> listeners = mSettingChangeListeners.get(setting);
            if (listeners == null) {
            if (listeners == null) {
                return;  // No listeners registered, do nothing.
                return;  // No listeners registered, do nothing.
@@ -393,6 +402,7 @@ public class HdmiCecConfig {
                listener.onChange(setting.getName());
                listener.onChange(setting.getName());
            }
            }
        }
        }
    }


    /**
    /**
     * This method registers Global Setting change observer.
     * This method registers Global Setting change observer.
@@ -436,11 +446,13 @@ public class HdmiCecConfig {
            throw new IllegalArgumentException("Change listeners for setting '" + name
            throw new IllegalArgumentException("Change listeners for setting '" + name
                    + "' not supported.");
                    + "' not supported.");
        }
        }
        synchronized (mLock) {
            if (!mSettingChangeListeners.containsKey(setting)) {
            if (!mSettingChangeListeners.containsKey(setting)) {
                mSettingChangeListeners.put(setting, new HashSet<>());
                mSettingChangeListeners.put(setting, new HashSet<>());
            }
            }
            mSettingChangeListeners.get(setting).add(listener);
            mSettingChangeListeners.get(setting).add(listener);
        }
        }
    }


    /**
    /**
     * Remove change listener for a given setting name.
     * Remove change listener for a given setting name.
@@ -451,6 +463,7 @@ public class HdmiCecConfig {
        if (setting == null) {
        if (setting == null) {
            throw new IllegalArgumentException("Setting '" + name + "' does not exist.");
            throw new IllegalArgumentException("Setting '" + name + "' does not exist.");
        }
        }
        synchronized (mLock) {
            if (mSettingChangeListeners.containsKey(setting)) {
            if (mSettingChangeListeners.containsKey(setting)) {
                Set<SettingChangeListener> listeners = mSettingChangeListeners.get(setting);
                Set<SettingChangeListener> listeners = mSettingChangeListeners.get(setting);
                listeners.remove(listener);
                listeners.remove(listener);
@@ -459,6 +472,7 @@ public class HdmiCecConfig {
                }
                }
            }
            }
        }
        }
    }


    /**
    /**
     * Returns a list of all settings based on the XML metadata.
     * Returns a list of all settings based on the XML metadata.
+4 −13
Original line number Original line Diff line number Diff line
@@ -94,9 +94,6 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
    // If true, TV going to standby mode puts other devices also to standby.
    // If true, TV going to standby mode puts other devices also to standby.
    private boolean mAutoDeviceOff;
    private boolean mAutoDeviceOff;


    // If true, TV wakes itself up when receiving <Text/Image View On>.
    private boolean mAutoWakeup;

    private final HdmiCecStandbyModeHandler mStandbyHandler;
    private final HdmiCecStandbyModeHandler mStandbyHandler;


    // If true, do not do routing control/send active source for internal source.
    // If true, do not do routing control/send active source for internal source.
@@ -163,7 +160,6 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
        mPrevPortId = Constants.INVALID_PORT_ID;
        mPrevPortId = Constants.INVALID_PORT_ID;
        mAutoDeviceOff = mService.readBooleanSetting(Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED,
        mAutoDeviceOff = mService.readBooleanSetting(Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED,
                true);
                true);
        mAutoWakeup = mService.readBooleanSetting(Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED, true);
        mSystemAudioControlFeatureEnabled =
        mSystemAudioControlFeatureEnabled =
                mService.readBooleanSetting(Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED, true);
                mService.readBooleanSetting(Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED, true);
        mStandbyHandler = new HdmiCecStandbyModeHandler(service, this);
        mStandbyHandler = new HdmiCecStandbyModeHandler(service, this);
@@ -641,7 +637,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
        // implemented in such a way that Android system is not really put to standby mode
        // implemented in such a way that Android system is not really put to standby mode
        // but only the display is set to blank. Then the command leads to the effect of
        // but only the display is set to blank. Then the command leads to the effect of
        // turning on the display by the invocation of PowerManager.wakeUp().
        // turning on the display by the invocation of PowerManager.wakeUp().
        if (mService.isPowerStandbyOrTransient() && mAutoWakeup) {
        if (mService.isPowerStandbyOrTransient() && getAutoWakeup()) {
            mService.wakeUp();
            mService.wakeUp();
        }
        }
        return true;
        return true;
@@ -1215,16 +1211,12 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
        mAutoDeviceOff = enabled;
        mAutoDeviceOff = enabled;
    }
    }


    @ServiceThreadOnly
    void setAutoWakeup(boolean enabled) {
        assertRunOnServiceThread();
        mAutoWakeup = enabled;
    }

    @ServiceThreadOnly
    @ServiceThreadOnly
    boolean getAutoWakeup() {
    boolean getAutoWakeup() {
        assertRunOnServiceThread();
        assertRunOnServiceThread();
        return mAutoWakeup;
        return mService.getHdmiCecConfig().getIntValue(
                  HdmiControlManager.CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY)
                    == HdmiControlManager.TV_WAKE_ON_ONE_TOUCH_PLAY_ENABLED;
    }
    }


    @Override
    @Override
@@ -1552,7 +1544,6 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
        pw.println("mSystemAudioMute: " + mSystemAudioMute);
        pw.println("mSystemAudioMute: " + mSystemAudioMute);
        pw.println("mSystemAudioControlFeatureEnabled: " + mSystemAudioControlFeatureEnabled);
        pw.println("mSystemAudioControlFeatureEnabled: " + mSystemAudioControlFeatureEnabled);
        pw.println("mAutoDeviceOff: " + mAutoDeviceOff);
        pw.println("mAutoDeviceOff: " + mAutoDeviceOff);
        pw.println("mAutoWakeup: " + mAutoWakeup);
        pw.println("mSkipRoutingControl: " + mSkipRoutingControl);
        pw.println("mSkipRoutingControl: " + mSkipRoutingControl);
        pw.println("mPrevPortId: " + mPrevPortId);
        pw.println("mPrevPortId: " + mPrevPortId);
    }
    }
+10 −7
Original line number Original line Diff line number Diff line
@@ -526,6 +526,16 @@ public class HdmiControlService extends SystemService {
                        initializeCec(INITIATED_BY_ENABLE_CEC);
                        initializeCec(INITIATED_BY_ENABLE_CEC);
                    }
                    }
                });
                });
        mHdmiCecConfig.registerChangeListener(
                HdmiControlManager.CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY,
                new HdmiCecConfig.SettingChangeListener() {
                    @Override
                    public void onChange(String setting) {
                        if (isTvDeviceEnabled()) {
                            setCecOption(OptionKey.WAKEUP, tv().getAutoWakeup());
                        }
                    }
                });
    }
    }


    private void bootCompleted() {
    private void bootCompleted() {
@@ -651,7 +661,6 @@ public class HdmiControlService extends SystemService {
        ContentResolver resolver = getContext().getContentResolver();
        ContentResolver resolver = getContext().getContentResolver();
        String[] settings = new String[] {
        String[] settings = new String[] {
                Global.HDMI_CONTROL_VOLUME_CONTROL_ENABLED,
                Global.HDMI_CONTROL_VOLUME_CONTROL_ENABLED,
                Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED,
                Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED,
                Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED,
                Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED,
                Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED,
                Global.MHL_INPUT_SWITCHING_ENABLED,
                Global.MHL_INPUT_SWITCHING_ENABLED,
@@ -680,12 +689,6 @@ public class HdmiControlService extends SystemService {
                    setHdmiCecVolumeControlEnabledInternal(getHdmiCecConfig().getIntValue(
                    setHdmiCecVolumeControlEnabledInternal(getHdmiCecConfig().getIntValue(
                            HdmiControlManager.CEC_SETTING_NAME_VOLUME_CONTROL_MODE));
                            HdmiControlManager.CEC_SETTING_NAME_VOLUME_CONTROL_MODE));
                    break;
                    break;
                case Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED:
                    if (isTvDeviceEnabled()) {
                        tv().setAutoWakeup(enabled);
                    }
                    setCecOption(OptionKey.WAKEUP, enabled);
                    break;
                case Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED:
                case Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED:
                    for (int type : mLocalDevices) {
                    for (int type : mLocalDevices) {
                        HdmiCecLocalDevice localDevice = mHdmiCecNetwork.getLocalDevice(type);
                        HdmiCecLocalDevice localDevice = mHdmiCecNetwork.getLocalDevice(type);
Loading