Loading services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java +25 −15 Original line number Original line Diff line number Diff line Loading @@ -45,6 +45,7 @@ import android.provider.Settings.Global; import android.util.ArraySet; import android.util.ArraySet; import android.util.Slog; import android.util.Slog; import android.util.SparseArray; import android.util.SparseArray; import android.util.SparseBooleanArray; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy; import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.IndentingPrintWriter; Loading @@ -71,9 +72,8 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { @ServiceThreadOnly @ServiceThreadOnly private boolean mArcEstablished = false; private boolean mArcEstablished = false; // Whether ARC feature is enabled or not. The default value is true. // Stores whether ARC feature is enabled per port. True by default for all the ARC-enabled ports. // TODO: once adding system setting for it, read the value to it. private final SparseBooleanArray mArcFeatureEnabled = new SparseBooleanArray(); private boolean mArcFeatureEnabled = true; // Whether System audio mode is activated or not. // Whether System audio mode is activated or not. // This becomes true only when all system audio sequences are finished. // This becomes true only when all system audio sequences are finished. Loading Loading @@ -190,6 +190,10 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { @ServiceThreadOnly @ServiceThreadOnly protected void onAddressAllocated(int logicalAddress, int reason) { protected void onAddressAllocated(int logicalAddress, int reason) { assertRunOnServiceThread(); assertRunOnServiceThread(); List<HdmiPortInfo> ports = mService.getPortInfo(); for (HdmiPortInfo port : ports) { mArcFeatureEnabled.put(port.getId(), port.isArcSupported()); } mService.registerTvInputCallback(mTvInputCallback); mService.registerTvInputCallback(mTvInputCallback); mService.sendCecCommand(HdmiCecMessageBuilder.buildReportPhysicalAddressCommand( mService.sendCecCommand(HdmiCecMessageBuilder.buildReportPhysicalAddressCommand( mAddress, mService.getPhysicalAddress(), mDeviceType)); mAddress, mService.getPhysicalAddress(), mDeviceType)); Loading Loading @@ -793,7 +797,8 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { if (getSystemAudioModeSetting() && !isSystemAudioActivated()) { if (getSystemAudioModeSetting() && !isSystemAudioActivated()) { addAndStartAction(new SystemAudioAutoInitiationAction(this, avr.getLogicalAddress())); addAndStartAction(new SystemAudioAutoInitiationAction(this, avr.getLogicalAddress())); } } if (isArcFeatureEnabled() && !hasAction(SetArcTransmissionStateAction.class)) { if (isArcFeatureEnabled(avr.getPortId()) && !hasAction(SetArcTransmissionStateAction.class)) { startArcAction(true); startArcAction(true); } } } } Loading Loading @@ -902,7 +907,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { // Should not activate ARC if +5V status is false. // Should not activate ARC if +5V status is false. HdmiPortInfo portInfo = mService.getPortInfo(portId); HdmiPortInfo portInfo = mService.getPortInfo(portId); if (portInfo.isArcSupported()) { if (portInfo.isArcSupported()) { changeArcFeatureEnabled(isConnected); changeArcFeatureEnabled(portId, isConnected); } } } } Loading @@ -914,20 +919,25 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { } } /** /** * Returns whether ARC is enabled or not. * Returns true if ARC is currently established on a certain port. */ */ @ServiceThreadOnly @ServiceThreadOnly boolean isArcEstabilished() { boolean isArcEstablished() { assertRunOnServiceThread(); assertRunOnServiceThread(); return mArcFeatureEnabled && mArcEstablished; if (mArcEstablished) { for (int i = 0; i < mArcFeatureEnabled.size(); i++) { if (mArcFeatureEnabled.valueAt(i)) return true; } } return false; } } @ServiceThreadOnly @ServiceThreadOnly void changeArcFeatureEnabled(boolean enabled) { void changeArcFeatureEnabled(int portId, boolean enabled) { assertRunOnServiceThread(); assertRunOnServiceThread(); if (mArcFeatureEnabled != enabled) { if (mArcFeatureEnabled.get(portId) != enabled) { mArcFeatureEnabled = enabled; mArcFeatureEnabled.put(portId, enabled); if (enabled) { if (enabled) { if (!mArcEstablished) { if (!mArcEstablished) { startArcAction(true); startArcAction(true); Loading @@ -941,9 +951,9 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { } } @ServiceThreadOnly @ServiceThreadOnly boolean isArcFeatureEnabled() { boolean isArcFeatureEnabled(int portId) { assertRunOnServiceThread(); assertRunOnServiceThread(); return mArcFeatureEnabled; return mArcFeatureEnabled.get(portId); } } @ServiceThreadOnly @ServiceThreadOnly Loading Loading @@ -1078,7 +1088,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { && isConnectedToArcPort(avr.getPhysicalAddress()) && isConnectedToArcPort(avr.getPhysicalAddress()) && isDirectConnectAddress(avr.getPhysicalAddress())) { && isDirectConnectAddress(avr.getPhysicalAddress())) { if (shouldCheckArcFeatureEnabled) { if (shouldCheckArcFeatureEnabled) { return isArcFeatureEnabled(); return isArcFeatureEnabled(avr.getPortId()); } else { } else { return true; return true; } } Loading Loading @@ -1620,7 +1630,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { // Seq #44. // Seq #44. removeAction(RequestArcInitiationAction.class); removeAction(RequestArcInitiationAction.class); if (!hasAction(RequestArcTerminationAction.class) && isArcEstabilished()) { if (!hasAction(RequestArcTerminationAction.class) && isArcEstablished()) { addAndStartAction(new RequestArcTerminationAction(this, avr.getLogicalAddress())); addAndStartAction(new RequestArcTerminationAction(this, avr.getLogicalAddress())); } } } } Loading services/core/java/com/android/server/hdmi/HotplugDetectionAction.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -261,7 +261,7 @@ final class HotplugDetectionAction extends HdmiCecFeatureAction { // Turn off system audio mode and update settings. // Turn off system audio mode and update settings. tv().setSystemAudioMode(false, true); tv().setSystemAudioMode(false, true); if (tv().isArcEstabilished()) { if (tv().isArcEstablished()) { tv().setAudioReturnChannel(false); tv().setAudioReturnChannel(false); addAndStartAction(new RequestArcTerminationAction(localDevice(), address)); addAndStartAction(new RequestArcTerminationAction(localDevice(), address)); } } Loading Loading
services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java +25 −15 Original line number Original line Diff line number Diff line Loading @@ -45,6 +45,7 @@ import android.provider.Settings.Global; import android.util.ArraySet; import android.util.ArraySet; import android.util.Slog; import android.util.Slog; import android.util.SparseArray; import android.util.SparseArray; import android.util.SparseBooleanArray; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy; import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.IndentingPrintWriter; Loading @@ -71,9 +72,8 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { @ServiceThreadOnly @ServiceThreadOnly private boolean mArcEstablished = false; private boolean mArcEstablished = false; // Whether ARC feature is enabled or not. The default value is true. // Stores whether ARC feature is enabled per port. True by default for all the ARC-enabled ports. // TODO: once adding system setting for it, read the value to it. private final SparseBooleanArray mArcFeatureEnabled = new SparseBooleanArray(); private boolean mArcFeatureEnabled = true; // Whether System audio mode is activated or not. // Whether System audio mode is activated or not. // This becomes true only when all system audio sequences are finished. // This becomes true only when all system audio sequences are finished. Loading Loading @@ -190,6 +190,10 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { @ServiceThreadOnly @ServiceThreadOnly protected void onAddressAllocated(int logicalAddress, int reason) { protected void onAddressAllocated(int logicalAddress, int reason) { assertRunOnServiceThread(); assertRunOnServiceThread(); List<HdmiPortInfo> ports = mService.getPortInfo(); for (HdmiPortInfo port : ports) { mArcFeatureEnabled.put(port.getId(), port.isArcSupported()); } mService.registerTvInputCallback(mTvInputCallback); mService.registerTvInputCallback(mTvInputCallback); mService.sendCecCommand(HdmiCecMessageBuilder.buildReportPhysicalAddressCommand( mService.sendCecCommand(HdmiCecMessageBuilder.buildReportPhysicalAddressCommand( mAddress, mService.getPhysicalAddress(), mDeviceType)); mAddress, mService.getPhysicalAddress(), mDeviceType)); Loading Loading @@ -793,7 +797,8 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { if (getSystemAudioModeSetting() && !isSystemAudioActivated()) { if (getSystemAudioModeSetting() && !isSystemAudioActivated()) { addAndStartAction(new SystemAudioAutoInitiationAction(this, avr.getLogicalAddress())); addAndStartAction(new SystemAudioAutoInitiationAction(this, avr.getLogicalAddress())); } } if (isArcFeatureEnabled() && !hasAction(SetArcTransmissionStateAction.class)) { if (isArcFeatureEnabled(avr.getPortId()) && !hasAction(SetArcTransmissionStateAction.class)) { startArcAction(true); startArcAction(true); } } } } Loading Loading @@ -902,7 +907,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { // Should not activate ARC if +5V status is false. // Should not activate ARC if +5V status is false. HdmiPortInfo portInfo = mService.getPortInfo(portId); HdmiPortInfo portInfo = mService.getPortInfo(portId); if (portInfo.isArcSupported()) { if (portInfo.isArcSupported()) { changeArcFeatureEnabled(isConnected); changeArcFeatureEnabled(portId, isConnected); } } } } Loading @@ -914,20 +919,25 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { } } /** /** * Returns whether ARC is enabled or not. * Returns true if ARC is currently established on a certain port. */ */ @ServiceThreadOnly @ServiceThreadOnly boolean isArcEstabilished() { boolean isArcEstablished() { assertRunOnServiceThread(); assertRunOnServiceThread(); return mArcFeatureEnabled && mArcEstablished; if (mArcEstablished) { for (int i = 0; i < mArcFeatureEnabled.size(); i++) { if (mArcFeatureEnabled.valueAt(i)) return true; } } return false; } } @ServiceThreadOnly @ServiceThreadOnly void changeArcFeatureEnabled(boolean enabled) { void changeArcFeatureEnabled(int portId, boolean enabled) { assertRunOnServiceThread(); assertRunOnServiceThread(); if (mArcFeatureEnabled != enabled) { if (mArcFeatureEnabled.get(portId) != enabled) { mArcFeatureEnabled = enabled; mArcFeatureEnabled.put(portId, enabled); if (enabled) { if (enabled) { if (!mArcEstablished) { if (!mArcEstablished) { startArcAction(true); startArcAction(true); Loading @@ -941,9 +951,9 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { } } @ServiceThreadOnly @ServiceThreadOnly boolean isArcFeatureEnabled() { boolean isArcFeatureEnabled(int portId) { assertRunOnServiceThread(); assertRunOnServiceThread(); return mArcFeatureEnabled; return mArcFeatureEnabled.get(portId); } } @ServiceThreadOnly @ServiceThreadOnly Loading Loading @@ -1078,7 +1088,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { && isConnectedToArcPort(avr.getPhysicalAddress()) && isConnectedToArcPort(avr.getPhysicalAddress()) && isDirectConnectAddress(avr.getPhysicalAddress())) { && isDirectConnectAddress(avr.getPhysicalAddress())) { if (shouldCheckArcFeatureEnabled) { if (shouldCheckArcFeatureEnabled) { return isArcFeatureEnabled(); return isArcFeatureEnabled(avr.getPortId()); } else { } else { return true; return true; } } Loading Loading @@ -1620,7 +1630,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { // Seq #44. // Seq #44. removeAction(RequestArcInitiationAction.class); removeAction(RequestArcInitiationAction.class); if (!hasAction(RequestArcTerminationAction.class) && isArcEstabilished()) { if (!hasAction(RequestArcTerminationAction.class) && isArcEstablished()) { addAndStartAction(new RequestArcTerminationAction(this, avr.getLogicalAddress())); addAndStartAction(new RequestArcTerminationAction(this, avr.getLogicalAddress())); } } } } Loading
services/core/java/com/android/server/hdmi/HotplugDetectionAction.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -261,7 +261,7 @@ final class HotplugDetectionAction extends HdmiCecFeatureAction { // Turn off system audio mode and update settings. // Turn off system audio mode and update settings. tv().setSystemAudioMode(false, true); tv().setSystemAudioMode(false, true); if (tv().isArcEstabilished()) { if (tv().isArcEstablished()) { tv().setAudioReturnChannel(false); tv().setAudioReturnChannel(false); addAndStartAction(new RequestArcTerminationAction(localDevice(), address)); addAndStartAction(new RequestArcTerminationAction(localDevice(), address)); } } Loading