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

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

Merge "tv.cec: Update framework code to call Treble HAL"

parents e88be615 bc6e372b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -19,8 +19,9 @@ LOCAL_AIDL_INCLUDES += \
LOCAL_JAVA_LIBRARIES := \
    services.net \
    telephony-common \
    android.hardware.light@2.0-java \
    android.hardware.power@1.0-java \
    android.hardware.light@2.0-java
    android.hardware.tv.cec@1.0-java

LOCAL_STATIC_JAVA_LIBRARIES := tzdata_update

+1 −26
Original line number Diff line number Diff line
@@ -188,12 +188,6 @@ final class Constants {
    static final int INVALID_PHYSICAL_ADDRESS = HdmiDeviceInfo.PATH_INVALID;
    static final int PATH_INTERNAL = HdmiDeviceInfo.PATH_INTERNAL;

    // Send result codes. It should be consistent with hdmi_cec.h's send_message error code.
    static final int SEND_RESULT_SUCCESS = 0;
    static final int SEND_RESULT_NAK = 1;
    static final int SEND_RESULT_BUSY = 2;
    static final int SEND_RESULT_FAILURE = 3;

    // Strategy for device polling.
    // Should use "OR(|) operation of POLL_STRATEGY_XXX and POLL_ITERATION_XXX.
    static final int POLL_STRATEGY_MASK = 0x3;  // first and second bit.
@@ -231,26 +225,7 @@ final class Constants {
    static final int RECORDING_TYPE_OWN_SOURCE = 4;

    // Definitions used for setOption(). These should be in sync with the definition
    // in hardware/libhardware/include/hardware/{hdmi_cec.h,mhl.h}.

    // TV gets turned on by incoming <Text/Image View On>. enabled by default.
    // If set to disabled, TV won't turn on automatically.
    static final int OPTION_CEC_AUTO_WAKEUP = 1;

    // If set to disabled, all CEC commands are discarded.
    static final int OPTION_CEC_ENABLE = 2;

    // If set to disabled, system service yields control of CEC to sub-microcontroller.
    // If enabled, it takes the control back.
    static final int OPTION_CEC_SERVICE_CONTROL = 3;

    // Put other devices to standby when TV goes to standby. enabled by default.
    // If set to disabled, TV doesn't send <Standby> to other devices.
    static final int OPTION_CEC_AUTO_DEVICE_OFF = 4;

    // Passes the language used in the system when updated. The value to use is the 3 byte
    // code as defined in ISO/FDIS 639-2.
    static final int OPTION_CEC_SET_LANGUAGE = 5;
    // in hardware/libhardware/include/hardware/mhl.h.

    // If set to disabled, TV does not switch ports when mobile device is connected.
    static final int OPTION_MHL_INPUT_SWITCHING = 101;
+3 −3
Original line number Diff line number Diff line
@@ -16,13 +16,13 @@

package com.android.server.hdmi;

import android.hardware.hdmi.HdmiDeviceInfo;
import android.hardware.hdmi.HdmiControlManager;
import android.hardware.hdmi.HdmiDeviceInfo;
import android.hardware.hdmi.HdmiTvClient;
import android.hardware.hdmi.IHdmiControlCallback;
import android.hardware.tv.cec.V1_0.SendMessageResult;
import android.os.RemoteException;
import android.util.Slog;

import com.android.server.hdmi.HdmiControlService.SendMessageCallback;

/**
@@ -95,7 +95,7 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {
        sendCommand(mGivePowerStatus, new SendMessageCallback() {
            @Override
            public void onSendCompleted(int error) {
                if (error != Constants.SEND_RESULT_SUCCESS) {
                if (error != SendMessageResult.SUCCESS) {
                    invokeCallback(HdmiControlManager.RESULT_COMMUNICATION_FAILED);
                    finish();
                    return;
+33 −18
Original line number Diff line number Diff line
@@ -17,23 +17,23 @@
package com.android.server.hdmi;

import android.hardware.hdmi.HdmiPortInfo;
import android.hardware.tv.cec.V1_0.Result;
import android.hardware.tv.cec.V1_0.SendMessageResult;
import android.os.Handler;
import android.os.Looper;
import android.os.MessageQueue;
import android.util.Slog;
import android.util.SparseArray;

import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.Predicate;
import com.android.server.hdmi.HdmiAnnotations.IoThreadOnly;
import com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly;
import com.android.server.hdmi.HdmiControlService.DevicePollingCallback;

import libcore.util.EmptyArray;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import libcore.util.EmptyArray;
import sun.util.locale.LanguageTag;

/**
 * Manages HDMI-CEC command and behaviors. It converts user's command into CEC command
@@ -256,7 +256,7 @@ final class HdmiCecController {
        if (HdmiUtils.isValidAddress(newLogicalAddress)) {
            return nativeAddLogicalAddress(mNativePtr, newLogicalAddress);
        } else {
            return -1;
            return Result.FAILURE_INVALID_ARGS;
        }
    }

@@ -320,13 +320,27 @@ final class HdmiCecController {
     * Set an option to CEC HAL.
     *
     * @param flag key of option
     * @param value value of option
     * @param enabled whether to enable/disable the given option.
     */
    @ServiceThreadOnly
    void setOption(int flag, boolean enabled) {
        assertRunOnServiceThread();
        HdmiLogger.debug("setOption: [flag:%d, enabled:%b]", flag, enabled);
        nativeSetOption(mNativePtr, flag, enabled);
    }

    /**
     * Informs CEC HAL about the current system language.
     *
     * @param language Three-letter code defined in ISO/FDIS 639-2. Must be lowercase letters.
     */
    @ServiceThreadOnly
    void setOption(int flag, int value) {
    void setLanguage(String language) {
        assertRunOnServiceThread();
        HdmiLogger.debug("setOption: [flag:%d, value:%d]", flag, value);
        nativeSetOption(mNativePtr, flag, value);
        if (!LanguageTag.isLanguage(language)) {
            return;
        }
        nativeSetLanguage(mNativePtr, language);
    }

    /**
@@ -336,9 +350,9 @@ final class HdmiCecController {
     * @param enabled whether to enable/disable ARC
     */
    @ServiceThreadOnly
    void setAudioReturnChannel(int port, boolean enabled) {
    void enableAudioReturnChannel(int port, boolean enabled) {
        assertRunOnServiceThread();
        nativeSetAudioReturnChannel(mNativePtr, port, enabled);
        nativeEnableAudioReturnChannel(mNativePtr, port, enabled);
    }

    /**
@@ -472,9 +486,9 @@ final class HdmiCecController {
            // <Polling Message> is a message which has empty body.
            int ret =
                    nativeSendCecCommand(mNativePtr, sourceAddress, destinationAddress, EMPTY_BODY);
            if (ret == Constants.SEND_RESULT_SUCCESS) {
            if (ret == SendMessageResult.SUCCESS) {
                return true;
            } else if (ret != Constants.SEND_RESULT_NAK) {
            } else if (ret != SendMessageResult.NACK) {
                // Unusual failure
                HdmiLogger.warning("Failed to send a polling message(%d->%d) with return code %d",
                        sourceAddress, destinationAddress, ret);
@@ -572,17 +586,17 @@ final class HdmiCecController {
                HdmiLogger.debug("[S]:" + cecMessage);
                byte[] body = buildBody(cecMessage.getOpcode(), cecMessage.getParams());
                int i = 0;
                int errorCode = Constants.SEND_RESULT_SUCCESS;
                int errorCode = SendMessageResult.SUCCESS;
                do {
                    errorCode = nativeSendCecCommand(mNativePtr, cecMessage.getSource(),
                            cecMessage.getDestination(), body);
                    if (errorCode == Constants.SEND_RESULT_SUCCESS) {
                    if (errorCode == SendMessageResult.SUCCESS) {
                        break;
                    }
                } while (i++ < HdmiConfig.RETRANSMISSION_COUNT);

                final int finalError = errorCode;
                if (finalError != Constants.SEND_RESULT_SUCCESS) {
                if (finalError != SendMessageResult.SUCCESS) {
                    Slog.w(TAG, "Failed to send " + cecMessage);
                }
                if (callback != null) {
@@ -636,7 +650,8 @@ final class HdmiCecController {
    private static native int nativeGetVersion(long controllerPtr);
    private static native int nativeGetVendorId(long controllerPtr);
    private static native HdmiPortInfo[] nativeGetPortInfos(long controllerPtr);
    private static native void nativeSetOption(long controllerPtr, int flag, int value);
    private static native void nativeSetAudioReturnChannel(long controllerPtr, int port, boolean flag);
    private static native void nativeSetOption(long controllerPtr, int flag, boolean enabled);
    private static native void nativeSetLanguage(long controllerPtr, String language);
    private static native void nativeEnableAudioReturnChannel(long controllerPtr, int port, boolean flag);
    private static native boolean nativeIsConnected(long controllerPtr, int port);
}
+6 −6
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.hardware.hdmi.HdmiPortInfo;
import android.hardware.hdmi.HdmiRecordSources;
import android.hardware.hdmi.HdmiTimerRecordSources;
import android.hardware.hdmi.IHdmiControlCallback;
import android.hardware.tv.cec.V1_0.SendMessageResult;
import android.media.AudioManager;
import android.media.AudioSystem;
import android.media.tv.TvInputInfo;
@@ -46,7 +47,6 @@ import android.util.ArraySet;
import android.util.Slog;
import android.util.SparseArray;
import android.util.SparseBooleanArray;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.hdmi.DeviceDiscoveryAction.DeviceDiscoveryCallback;
@@ -57,9 +57,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.HashMap;

/**
 * Represent a logical device of type TV residing in Android system.
@@ -910,7 +910,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
        HdmiLogger.debug("Set Arc Status[old:%b new:%b]", mArcEstablished, enabled);
        boolean oldStatus = mArcEstablished;
        // 1. Enable/disable ARC circuit.
        setAudioReturnChannel(enabled);
        enableAudioReturnChannel(enabled);
        // 2. Notify arc status to audio service.
        notifyArcStatusToAudioService(enabled);
        // 3. Update arc status;
@@ -922,11 +922,11 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
     * Switch hardware ARC circuit in the system.
     */
    @ServiceThreadOnly
    void setAudioReturnChannel(boolean enabled) {
    void enableAudioReturnChannel(boolean enabled) {
        assertRunOnServiceThread();
        HdmiDeviceInfo avr = getAvrDeviceInfo();
        if (avr != null) {
            mService.setAudioReturnChannel(avr.getPortId(), enabled);
            mService.enableAudioReturnChannel(avr.getPortId(), enabled);
        }
    }

@@ -1870,7 +1870,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
        mService.sendCecCommand(message, new SendMessageCallback() {
            @Override
            public void onSendCompleted(int error) {
                if (error != Constants.SEND_RESULT_SUCCESS) {
                if (error != SendMessageResult.SUCCESS) {
                    announceClearTimerRecordingResult(recorderAddress,
                            CLEAR_TIMER_STATUS_FAIL_TO_CLEAR_SELECTED_SOURCE);
                }
Loading