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

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

Merge "Guard against missing device info" into sc-dev

parents f66ec9e5 493d9e2f
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -100,8 +100,13 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {
        // Wake-up on <Set Stream Path> was not mandatory before CEC 2.0.
        // The message is re-sent at the end of the action for devices that don't support 2.0.
        sendSetStreamPath();
        int targetPowerStatus = localDevice().mService.getHdmiCecNetwork()
                .getCecDeviceInfo(getTargetAddress()).getDevicePowerStatus();
        int targetPowerStatus = HdmiControlManager.POWER_STATUS_UNKNOWN;
        HdmiDeviceInfo targetDevice = localDevice().mService.getHdmiCecNetwork().getCecDeviceInfo(
                getTargetAddress());
        if (targetDevice != null) {
            targetPowerStatus = targetDevice.getDevicePowerStatus();
        }

        if (!mIsCec20 || targetPowerStatus == HdmiControlManager.POWER_STATUS_UNKNOWN) {
            queryDevicePowerStatus();
        } else if (targetPowerStatus == HdmiControlManager.POWER_STATUS_ON) {
+2 −1
Original line number Diff line number Diff line
@@ -500,7 +500,8 @@ abstract class HdmiCecLocalDevice {

        HdmiDeviceInfo cecDeviceInfo = mService.getHdmiCecNetwork().getCecDeviceInfo(address);
        // If no non-default display name is available for the device, request the devices OSD name.
        if (cecDeviceInfo.getDisplayName().equals(HdmiUtils.getDefaultDeviceName(address))) {
        if (cecDeviceInfo != null && cecDeviceInfo.getDisplayName().equals(
                HdmiUtils.getDefaultDeviceName(address))) {
            mService.sendCecCommand(
                    HdmiCecMessageBuilder.buildGiveOsdNameCommand(mAddress, address));
        }
+3 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static android.hardware.hdmi.HdmiControlManager.TIMER_RECORDING_TYPE_ANAL
import static android.hardware.hdmi.HdmiControlManager.TIMER_RECORDING_TYPE_DIGITAL;
import static android.hardware.hdmi.HdmiControlManager.TIMER_RECORDING_TYPE_EXTERNAL;

import android.annotation.Nullable;
import android.hardware.hdmi.HdmiControlManager;
import android.hardware.hdmi.HdmiDeviceInfo;
import android.hardware.hdmi.HdmiPortInfo;
@@ -1147,6 +1148,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
                && getAvrDeviceInfo() != null;
    }

    @Nullable
    @ServiceThreadOnly
    HdmiDeviceInfo getAvrDeviceInfo() {
        assertRunOnServiceThread();
@@ -1157,6 +1159,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
        return getSafeAvrDeviceInfo() != null;
    }

    @Nullable
    HdmiDeviceInfo getSafeAvrDeviceInfo() {
        return mService.getHdmiCecNetwork().getSafeCecDeviceInfo(Constants.ADDR_AUDIO_SYSTEM);
    }
+7 −0
Original line number Diff line number Diff line
@@ -185,6 +185,12 @@ public class HdmiCecNetwork {
        mLocalDevices.clear();
    }

    /**
     * Get the device info of a local device or a device in the CEC network by a device id.
     * @param id id of the device to get
     * @return the device with the given id, or {@code null}
     */
    @Nullable
    public HdmiDeviceInfo getDeviceInfo(int id) {
        return mDeviceInfos.get(id);
    }
@@ -717,6 +723,7 @@ public class HdmiCecNetwork {
     * @return {@link HdmiDeviceInfo} matched with the given {@code logicalAddress}.
     * Returns null if no logical address matched
     */
    @Nullable
    HdmiDeviceInfo getSafeCecDeviceInfo(int logicalAddress) {
        for (HdmiDeviceInfo info : mSafeAllDeviceInfos) {
            if (info.isCecDevice() && info.getLogicalAddress() == logicalAddress) {
+1 −0
Original line number Diff line number Diff line
@@ -988,6 +988,7 @@ public class HdmiControlService extends SystemService {
        return mCecController.getVendorId();
    }

    @Nullable
    @ServiceThreadOnly
    HdmiDeviceInfo getDeviceInfo(int logicalAddress) {
        assertRunOnServiceThread();
Loading