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

Commit a94417a5 authored by Jinsuk Kim's avatar Jinsuk Kim
Browse files

CEC: Refactoring for MHL

This helps MHL code clean-up.

- Factored MHL constants out to a new class
- Renamed some methods

Bug: 17479050
Change-Id: Ia39f8bb51ce552ac10f587e6ee0431951f2f494b
parent d4a94db1
Loading
Loading
Loading
Loading
+0 −32
Original line number Diff line number Diff line
@@ -255,37 +255,5 @@ final class Constants {
    //     values which denotes the device type in HDMI Spec 1.4.
    static final String PROPERTY_DEVICE_TYPE = "ro.hdmi.device_type";

    // --------------------------------------------------
    // MHL sub command message types.
    static final int MHL_MSG_MSGE  = 0x02;
    static final int MHL_MSG_RCP   = 0x10;
    static final int MHL_MSG_RCPK  = 0x11;
    static final int MHL_MSG_RCPE  = 0x12;
    static final int MHL_MSG_RAP   = 0x20;
    static final int MHL_MSG_RAPK  = 0x21;

    // MHL RAP messages.
    static final int MHL_RAP_ACTION_POLL = 0x00;
    static final int MHL_RAP_ACTION_CONTENT_ON = 0x10;
    static final int MHL_RAP_ACTION_CONTENT_OFF = 0x11;

    // MHL RAPK messages.
    static final int MHL_RAPK_NO_ERROR = 0x00;
    static final int MHL_RAPK_UNRECOGNIZED_ACTION = 0x01;
    static final int MHL_RAPK_UNSUPPORTED_ACTION = 0x02;
    static final int MHL_RAPK_RESPONDER_BUSY = 0x03;

    static final int MHL_INVALID_ADOPTER_ID = -1;
    static final int MHL_INVALID_DEVICE_ID = -1;

    static final int MHL_CBUS_MODE_OCBUS = 1;
    static final int MHL_CBUS_MODE_ECBUS_S = 2;
    static final int MHL_CBUS_MODE_ECBUS_D = 3;

    // MHL RCPE messages
    static final int MHL_RCPE_NO_ERROR = 0x00;
    static final int MHL_RCPE_INEFFECTIVE_KEYCODE = 0x01;
    static final int MHL_RCPE_RESPONDER_BUSY = 0x02;

    private Constants() { /* cannot be instantiated */ }
}
+13 −13
Original line number Diff line number Diff line
@@ -856,8 +856,8 @@ public final class HdmiControlService extends SystemService {
            HdmiMhlLocalDevice device = mMhlController.removeLocalDevice(portId);
            if (device != null) {
                device.onDeviceRemoved();
                // There is no explicit event for device removal unlike capability register event
                // used for device addition . Hence we remove the device on hotplug event.
                // There is no explicit event for device removal.
                // Hence we remove the device on hotplug event.
                HdmiDeviceInfo deviceInfo = device.getInfo();
                if (deviceInfo != null) {
                    invokeDeviceEventListeners(deviceInfo, DEVICE_EVENT_REMOVE_DEVICE);
@@ -871,40 +871,40 @@ public final class HdmiControlService extends SystemService {
    }

    @ServiceThreadOnly
    void handleMhlCbusModeChanged(int portId, int cbusmode) {
    void handleMhlBusModeChanged(int portId, int busmode) {
        assertRunOnServiceThread();
        HdmiMhlLocalDevice device = mMhlController.getLocalDevice(portId);
        if (device != null) {
            device.setCbusMode(cbusmode);
            device.setBusMode(busmode);
        } else {
            Slog.w(TAG, "No mhl device exists for cbus mode change[portId:" + portId +
                    ", cbusmode:" + cbusmode + "]");
            Slog.w(TAG, "No mhl device exists for bus mode change[portId:" + portId +
                    ", busmode:" + busmode + "]");
        }
    }

    @ServiceThreadOnly
    void handleMhlVbusOvercurrent(int portId, boolean on) {
    void handleMhlBusOvercurrent(int portId, boolean on) {
        assertRunOnServiceThread();
        HdmiMhlLocalDevice device = mMhlController.getLocalDevice(portId);
        if (device != null) {
            device.onVbusOvercurrentDetected(on);
            device.onBusOvercurrentDetected(on);
        } else {
            Slog.w(TAG, "No mhl device exists for vbus overcurrent event[portId:" + portId + "]");
            Slog.w(TAG, "No mhl device exists for bus overcurrent event[portId:" + portId + "]");
        }
    }

    @ServiceThreadOnly
    void handleMhlCapabilityRegisterChanged(int portId, int adopterId, int deviceId) {
    void handleMhlDeviceStatusChanged(int portId, int adopterId, int deviceId) {
        assertRunOnServiceThread();
        HdmiMhlLocalDevice device = mMhlController.getLocalDevice(portId);

        // Hotplug event should already have been called before capability register change event.
        // Hotplug event should already have been called before device status change event.
        if (device != null) {
            device.setCapabilityRegister(adopterId, deviceId);
            device.setDeviceStatusChange(adopterId, deviceId);
            invokeDeviceEventListeners(device.getInfo(), DEVICE_EVENT_ADD_DEVICE);
            updateSafeMhlInput();
        } else {
            Slog.w(TAG, "No mhl device exists for capability register change event[portId:"
            Slog.w(TAG, "No mhl device exists for device status event[portId:"
                    + portId + ", adopterId:" + adopterId + ", deviceId:" + deviceId + "]");
        }
    }
+40 −0
Original line number Diff line number Diff line
package com.android.server.hdmi;

/**
 * Defines constants related to MHL protocol internal implementation.
 */
final class MhlConstants {
    // --------------------------------------------------
    // MHL sub command message types.
    static final int MSG_MSGE  = 0x02;
    static final int MSG_RCP   = 0x10;
    static final int MSG_RCPK  = 0x11;
    static final int MSG_RCPE  = 0x12;
    static final int MSG_RAP   = 0x20;
    static final int MSG_RAPK  = 0x21;

    // MHL RAP messages.
    static final int RAP_ACTION_POLL = 0x00;
    static final int RAP_ACTION_CONTENT_ON = 0x10;
    static final int RAP_ACTION_CONTENT_OFF = 0x11;

    // MHL RAPK messages.
    static final int RAPK_NO_ERROR = 0x00;
    static final int RAPK_UNRECOGNIZED_ACTION = 0x01;
    static final int RAPK_UNSUPPORTED_ACTION = 0x02;
    static final int RAPK_RESPONDER_BUSY = 0x03;

    static final int INVALID_ADOPTER_ID = -1;
    static final int INVALID_DEVICE_ID = -1;

    static final int CBUS_MODE_OCBUS = 1;
    static final int CBUS_MODE_ECBUS_S = 2;
    static final int CBUS_MODE_ECBUS_D = 3;

    // MHL RCPE messages
    static final int RCPE_NO_ERROR = 0x00;
    static final int RCPE_INEFFECTIVE_KEYCODE = 0x01;
    static final int RCPE_RESPONDER_BUSY = 0x02;

    private MhlConstants() { /* cannot be instantiated */ }
}