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

Commit 2784968e authored by Marvin Ramin's avatar Marvin Ramin Committed by Android (Google) Code Review
Browse files

Merge "Migrate CEC version Setting to use HdmiCecConfig"

parents 3824be05 45604275
Loading
Loading
Loading
Loading
+75 −0
Original line number Diff line number Diff line
@@ -344,6 +344,29 @@ public final class HdmiControlManager {
    @Retention(RetentionPolicy.SOURCE)
    public @interface HdmiCecControl {}

    // -- Supported HDM-CEC versions.
    /**
     * Version constant for HDMI-CEC v1.4b.
     *
     * @hide
     */
    public static final int HDMI_CEC_VERSION_1_4_b = 0x05;
    /**
     * Version constant for HDMI-CEC v2.0.
     *
     * @hide
     */
    public static final int HDMI_CEC_VERSION_2_0 = 0x06;
    /**
     * @hide
     */
    @IntDef({
            HDMI_CEC_VERSION_1_4_b,
            HDMI_CEC_VERSION_2_0
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface HdmiCecVersion {}

    // -- Which devices the playback device can send a <Standby> message to upon going to sleep.
    /**
     * Send <Standby> to TV only.
@@ -427,6 +450,12 @@ public final class HdmiControlManager {
     * @hide
     */
    public static final String CEC_SETTING_NAME_HDMI_CEC_ENABLED = "hdmi_cec_enabled";
    /**
     * Name of a setting controlling the version of HDMI-CEC used.
     *
     * @hide
     */
    public static final String CEC_SETTING_NAME_HDMI_CEC_VERSION = "hdmi_cec_version";
    /**
     * Name of a setting deciding on the Standby message behaviour on sleep.
     *
@@ -452,6 +481,7 @@ public final class HdmiControlManager {
     */
    @StringDef({
        CEC_SETTING_NAME_HDMI_CEC_ENABLED,
        CEC_SETTING_NAME_HDMI_CEC_VERSION,
        CEC_SETTING_NAME_SEND_STANDBY_ON_SLEEP,
        CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST,
        CEC_SETTING_NAME_SYSTEM_AUDIO_MODE_MUTING,
@@ -1414,6 +1444,51 @@ public final class HdmiControlManager {
        }
    }

    /**
     * Set the 'hdmi_cec_version' option.
     *
     * @param value the desired value
     * @throws IllegalArgumentException when the new value is not allowed.
     * @throws RuntimeException when the HdmiControlService is not available.
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.HDMI_CEC)
    public void setHdmiCecVersion(@NonNull @HdmiCecVersion 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_HDMI_CEC_VERSION, value);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Get the value of 'hdmi_cec_enabled' option.
     *
     * @return the current value.
     * @throws RuntimeException when the HdmiControlService is not available.
     *
     * @hide
     */
    @NonNull
    @HdmiCecVersion
    @RequiresPermission(android.Manifest.permission.HDMI_CEC)
    public int getHdmiCecVersion() {
        if (mService == null) {
            Log.e(TAG, "HdmiControlService is not available");
            throw new RuntimeException("HdmiControlService is not available");
        }
        try {
            return mService.getCecSettingIntValue(CEC_SETTING_NAME_HDMI_CEC_VERSION);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Set the 'send_standby_on_sleep' option.
     *
+5 −1
Original line number Diff line number Diff line
@@ -229,6 +229,8 @@ public class HdmiCecConfig {
        switch (setting.getName()) {
            case HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_ENABLED:
                return STORAGE_GLOBAL_SETTINGS;
            case HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_VERSION:
                return STORAGE_GLOBAL_SETTINGS;
            case HdmiControlManager.CEC_SETTING_NAME_SEND_STANDBY_ON_SLEEP:
                return STORAGE_GLOBAL_SETTINGS;
            case HdmiControlManager.CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST:
@@ -245,6 +247,8 @@ public class HdmiCecConfig {
        switch (setting.getName()) {
            case HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_ENABLED:
                return Global.HDMI_CONTROL_ENABLED;
            case HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_VERSION:
                return Global.HDMI_CEC_VERSION;
            case HdmiControlManager.CEC_SETTING_NAME_SEND_STANDBY_ON_SLEEP:
                return Global.HDMI_CONTROL_SEND_STANDBY_ON_SLEEP;
            case HdmiControlManager.CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST:
+5 −7
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import static com.android.server.hdmi.Constants.OPTION_MHL_ENABLE;
import static com.android.server.hdmi.Constants.OPTION_MHL_INPUT_SWITCHING;
import static com.android.server.hdmi.Constants.OPTION_MHL_POWER_CHARGE;
import static com.android.server.hdmi.Constants.OPTION_MHL_SERVICE_CONTROL;
import static com.android.server.hdmi.Constants.VERSION_1_4;
import static com.android.server.power.ShutdownThread.SHUTDOWN_ACTION_PROPERTY;

import android.annotation.IntDef;
@@ -81,7 +80,6 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.SystemService;
import com.android.server.hdmi.Constants.CecVersion;
import com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly;
import com.android.server.hdmi.HdmiCecController.AllocateAddressCallback;
import com.android.server.hdmi.HdmiCecLocalDevice.ActiveSource;
@@ -391,8 +389,8 @@ public class HdmiControlService extends SystemService {
    @Nullable
    private Looper mIoLooper;

    @CecVersion
    private int mCecVersion = Constants.VERSION_1_4;
    @HdmiControlManager.HdmiCecVersion
    private int mCecVersion;

    // Last input port before switching to the MHL port. Should switch back to this port
    // when the mobile device sends the request one touch play with off.
@@ -820,7 +818,8 @@ public class HdmiControlService extends SystemService {

    private void initializeCec(int initiatedBy) {
        mAddressAllocated = false;
        mCecVersion = readIntSetting(Global.HDMI_CEC_VERSION, VERSION_1_4);
        mCecVersion = getHdmiCecConfig().getIntValue(
                HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_VERSION);

        mCecController.setOption(OptionKey.SYSTEM_CEC_CONTROL, true);
        mCecController.setLanguage(mMenuLanguage);
@@ -1028,7 +1027,7 @@ public class HdmiControlService extends SystemService {
    /**
     * Returns version of CEC.
     */
    @CecVersion
    @HdmiControlManager.HdmiCecVersion
    int getCecVersion() {
        return mCecVersion;
    }
@@ -2191,7 +2190,6 @@ public class HdmiControlService extends SystemService {
            if (!DumpUtils.checkDumpPermission(getContext(), TAG, writer)) return;
            final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");

            pw.println("mCecVersion: " + mCecVersion);
            pw.println("mProhibitMode: " + mProhibitMode);
            pw.println("mPowerStatus: " + mPowerStatus);

+2 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.server.hdmi.Constants.ADDR_BACKUP_2;
import static com.android.server.hdmi.Constants.ADDR_TV;

import android.annotation.Nullable;
import android.hardware.hdmi.HdmiControlManager;
import android.hardware.hdmi.HdmiDeviceInfo;
import android.util.Slog;
import android.util.SparseArray;
@@ -134,7 +135,7 @@ final class HdmiUtils {
    static boolean isEligibleAddressForCecVersion(int cecVersion, int logicalAddress) {
        if (isValidAddress(logicalAddress)) {
            if (logicalAddress == ADDR_BACKUP_1 || logicalAddress == ADDR_BACKUP_2) {
                return cecVersion == Constants.VERSION_2_0;
                return cecVersion >= HdmiControlManager.HDMI_CEC_VERSION_2_0;
            }
            return true;
        }
+7 −0
Original line number Diff line number Diff line
@@ -74,6 +74,8 @@ public class ActiveSourceActionTest {
        when(mContextSpy.getSystemService(PowerManager.class)).thenReturn(powerManager);
        when(mIPowerManagerMock.isInteractive()).thenReturn(true);

        HdmiCecConfig hdmiCecConfig = new FakeHdmiCecConfig(mContextSpy);

        mHdmiControlService = new HdmiControlService(mContextSpy) {
            @Override
            AudioManager getAudioManager() {
@@ -104,6 +106,11 @@ public class ActiveSourceActionTest {
            void writeStringSystemProperty(String key, String value) {
                // do nothing
            }

            @Override
            HdmiCecConfig getHdmiCecConfig() {
                return hdmiCecConfig;
            }
        };

        Looper looper = mTestLooper.getLooper();
Loading