Search in sources :

Example 16 with HdmiDeviceInfo

use of android.hardware.hdmi.HdmiDeviceInfo in project android_frameworks_base by ResurrectionRemix.

the class TvInputService method onBind.

@Override
public final IBinder onBind(Intent intent) {
    return new ITvInputService.Stub() {

        @Override
        public void registerCallback(ITvInputServiceCallback cb) {
            if (cb != null) {
                mCallbacks.register(cb);
            }
        }

        @Override
        public void unregisterCallback(ITvInputServiceCallback cb) {
            if (cb != null) {
                mCallbacks.unregister(cb);
            }
        }

        @Override
        public void createSession(InputChannel channel, ITvInputSessionCallback cb, String inputId) {
            if (channel == null) {
                Log.w(TAG, "Creating session without input channel");
            }
            if (cb == null) {
                return;
            }
            SomeArgs args = SomeArgs.obtain();
            args.arg1 = channel;
            args.arg2 = cb;
            args.arg3 = inputId;
            mServiceHandler.obtainMessage(ServiceHandler.DO_CREATE_SESSION, args).sendToTarget();
        }

        @Override
        public void createRecordingSession(ITvInputSessionCallback cb, String inputId) {
            if (cb == null) {
                return;
            }
            SomeArgs args = SomeArgs.obtain();
            args.arg1 = cb;
            args.arg2 = inputId;
            mServiceHandler.obtainMessage(ServiceHandler.DO_CREATE_RECORDING_SESSION, args).sendToTarget();
        }

        @Override
        public void notifyHardwareAdded(TvInputHardwareInfo hardwareInfo) {
            mServiceHandler.obtainMessage(ServiceHandler.DO_ADD_HARDWARE_INPUT, hardwareInfo).sendToTarget();
        }

        @Override
        public void notifyHardwareRemoved(TvInputHardwareInfo hardwareInfo) {
            mServiceHandler.obtainMessage(ServiceHandler.DO_REMOVE_HARDWARE_INPUT, hardwareInfo).sendToTarget();
        }

        @Override
        public void notifyHdmiDeviceAdded(HdmiDeviceInfo deviceInfo) {
            mServiceHandler.obtainMessage(ServiceHandler.DO_ADD_HDMI_INPUT, deviceInfo).sendToTarget();
        }

        @Override
        public void notifyHdmiDeviceRemoved(HdmiDeviceInfo deviceInfo) {
            mServiceHandler.obtainMessage(ServiceHandler.DO_REMOVE_HDMI_INPUT, deviceInfo).sendToTarget();
        }
    };
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) SomeArgs(com.android.internal.os.SomeArgs) InputChannel(android.view.InputChannel)

Example 17 with HdmiDeviceInfo

use of android.hardware.hdmi.HdmiDeviceInfo in project android_frameworks_base by ResurrectionRemix.

the class HdmiCecLocalDeviceTv method isInDeviceList.

/**
     * Whether a device of the specified physical address and logical address exists
     * in a device info list. However, both are minimal condition and it could
     * be different device from the original one.
     *
     * @param logicalAddress logical address of a device to be searched
     * @param physicalAddress physical address of a device to be searched
     * @return true if exist; otherwise false
     */
@ServiceThreadOnly
boolean isInDeviceList(int logicalAddress, int physicalAddress) {
    assertRunOnServiceThread();
    HdmiDeviceInfo device = getCecDeviceInfo(logicalAddress);
    if (device == null) {
        return false;
    }
    return device.getPhysicalAddress() == physicalAddress;
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 18 with HdmiDeviceInfo

use of android.hardware.hdmi.HdmiDeviceInfo in project android_frameworks_base by ResurrectionRemix.

the class HdmiCecLocalDeviceTv method removeCecDevice.

/**
     * Called when a device is removed or removal of device is detected.
     *
     * @param address a logical address of a device to be removed
     */
@ServiceThreadOnly
final void removeCecDevice(int address) {
    assertRunOnServiceThread();
    HdmiDeviceInfo info = removeDeviceInfo(HdmiDeviceInfo.idForCecDevice(address));
    mCecMessageCache.flushMessagesFrom(address);
    invokeDeviceEventListener(info, HdmiControlManager.DEVICE_EVENT_REMOVE_DEVICE);
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Example 19 with HdmiDeviceInfo

use of android.hardware.hdmi.HdmiDeviceInfo in project android_frameworks_base by ResurrectionRemix.

the class ActiveSourceHandler method process.

/**
     * Handles the incoming active source command.
     *
     * @param newActive new active source information
     * @param deviceType device type of the new active source
     */
void process(ActiveSource newActive, int deviceType) {
    // Seq #17
    HdmiCecLocalDeviceTv tv = mSource;
    HdmiDeviceInfo device = mService.getDeviceInfo(newActive.logicalAddress);
    if (device == null) {
        tv.startNewDeviceAction(newActive, deviceType);
    }
    if (!tv.isProhibitMode()) {
        ActiveSource old = ActiveSource.of(tv.getActiveSource());
        tv.updateActiveSource(newActive);
        boolean notifyInputChange = (mCallback == null);
        if (!old.equals(newActive)) {
            tv.setPrevPortId(tv.getActivePortId());
        }
        tv.updateActiveInput(newActive.physicalAddress, notifyInputChange);
        invokeCallback(HdmiControlManager.RESULT_SUCCESS);
    } else {
        // TV is in a mode that should keep its current source/input from
        // being changed for its operation. Reclaim the active source
        // or switch the port back to the one used for the current mode.
        ActiveSource current = tv.getActiveSource();
        if (current.logicalAddress == getSourceAddress()) {
            HdmiCecMessage activeSourceCommand = HdmiCecMessageBuilder.buildActiveSource(current.logicalAddress, current.physicalAddress);
            mService.sendCecCommand(activeSourceCommand);
            tv.updateActiveSource(current);
            invokeCallback(HdmiControlManager.RESULT_SUCCESS);
        } else {
            tv.startRoutingControl(newActive.physicalAddress, current.physicalAddress, true, mCallback);
        }
    }
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) ActiveSource(com.android.server.hdmi.HdmiCecLocalDevice.ActiveSource)

Example 20 with HdmiDeviceInfo

use of android.hardware.hdmi.HdmiDeviceInfo in project android_frameworks_base by ResurrectionRemix.

the class HdmiCecLocalDeviceTv method handleSetOsdName.

@Override
@ServiceThreadOnly
protected boolean handleSetOsdName(HdmiCecMessage message) {
    int source = message.getSource();
    HdmiDeviceInfo deviceInfo = getCecDeviceInfo(source);
    // If the device is not in device list, ignore it.
    if (deviceInfo == null) {
        Slog.e(TAG, "No source device info for <Set Osd Name>." + message);
        return true;
    }
    String osdName = null;
    try {
        osdName = new String(message.getParams(), "US-ASCII");
    } catch (UnsupportedEncodingException e) {
        Slog.e(TAG, "Invalid <Set Osd Name> request:" + message, e);
        return true;
    }
    if (deviceInfo.getDisplayName().equals(osdName)) {
        Slog.i(TAG, "Ignore incoming <Set Osd Name> having same osd name:" + message);
        return true;
    }
    addCecDevice(new HdmiDeviceInfo(deviceInfo.getLogicalAddress(), deviceInfo.getPhysicalAddress(), deviceInfo.getPortId(), deviceInfo.getDeviceType(), deviceInfo.getVendorId(), osdName));
    return true;
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ServiceThreadOnly(com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)

Aggregations

HdmiDeviceInfo (android.hardware.hdmi.HdmiDeviceInfo)172 ServiceThreadOnly (com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly)110 ArrayList (java.util.ArrayList)15 TvInputHardwareInfo (android.media.tv.TvInputHardwareInfo)12 HdmiPortInfo (android.hardware.hdmi.HdmiPortInfo)10 SendMessageCallback (com.android.server.hdmi.HdmiControlService.SendMessageCallback)10 IHdmiControlCallback (android.hardware.hdmi.IHdmiControlCallback)5 RemoteException (android.os.RemoteException)5 ArraySet (android.util.ArraySet)5 SparseArray (android.util.SparseArray)5 SparseIntArray (android.util.SparseIntArray)5 InputChannel (android.view.InputChannel)5 SomeArgs (com.android.internal.os.SomeArgs)5 DeviceDiscoveryCallback (com.android.server.hdmi.DeviceDiscoveryAction.DeviceDiscoveryCallback)5 AllocateAddressCallback (com.android.server.hdmi.HdmiCecController.AllocateAddressCallback)5 ActiveSource (com.android.server.hdmi.HdmiCecLocalDevice.ActiveSource)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 BitSet (java.util.BitSet)5 TvInputInfo (android.media.tv.TvInputInfo)4 Message (android.os.Message)4