Loading services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java +7 −15 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ abstract class HdmiCecLocalDevice { protected final int mDeviceType; protected int mPreferredAddress; @GuardedBy("mLock") protected HdmiDeviceInfo mDeviceInfo; private HdmiDeviceInfo mDeviceInfo; protected int mLastKeycode = HdmiCecKeycode.UNSUPPORTED_KEYCODE; protected int mLastKeyRepeatCount = 0; Loading Loading @@ -666,22 +666,18 @@ abstract class HdmiCecLocalDevice { * Computes the set of supported device features, and updates local state to match. */ private void updateDeviceFeatures() { synchronized (mLock) { setDeviceInfo(getDeviceInfo().toBuilder() .setDeviceFeatures(computeDeviceFeatures()) .build()); } } /** * Computes and returns the set of supported device features. Updates local state to match. */ protected final DeviceFeatures getDeviceFeatures() { updateDeviceFeatures(); synchronized (mLock) { return getDeviceInfo().getDeviceFeatures(); } } @Constants.HandleMessageResult protected int handleGiveFeatures(HdmiCecMessage message) { Loading Loading @@ -982,14 +978,12 @@ abstract class HdmiCecLocalDevice { return mDeviceType; } @GuardedBy("mLock") HdmiDeviceInfo getDeviceInfo() { synchronized (mLock) { return mDeviceInfo; } } @GuardedBy("mLock") void setDeviceInfo(HdmiDeviceInfo info) { synchronized (mLock) { mDeviceInfo = info; Loading Loading @@ -1042,11 +1036,9 @@ abstract class HdmiCecLocalDevice { // Send <Give Features> if using CEC 2.0 or above. if (mService.getCecVersion() >= HdmiControlManager.HDMI_CEC_VERSION_2_0) { synchronized (mLock) { mService.sendCecCommand(HdmiCecMessageBuilder.buildGiveFeatures( getDeviceInfo().getLogicalAddress(), targetAddress)); } } // If we don't already have a {@link SetAudioVolumeLevelDiscoveryAction} for the target // device, start one. Loading services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java +4 −8 Original line number Diff line number Diff line Loading @@ -138,10 +138,8 @@ public class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource { // does not poll local devices, we should put device info of local device // manually here. for (HdmiCecLocalDevice device : mService.getAllLocalDevices()) { synchronized (device.mLock) { mService.getHdmiCecNetwork().addCecDevice(device.getDeviceInfo()); } } List<HotplugDetectionAction> hotplugActions = getActions(HotplugDetectionAction.class); Loading Loading @@ -179,12 +177,10 @@ public class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource { @ServiceThreadOnly void deviceSelect(int id, IHdmiControlCallback callback) { assertRunOnServiceThread(); synchronized (mLock) { if (id == getDeviceInfo().getId()) { mService.oneTouchPlay(callback); return; } } HdmiDeviceInfo targetDevice = mService.getHdmiCecNetwork().getDeviceInfo(id); if (targetDevice == null) { invokeCallback(callback, HdmiControlManager.RESULT_TARGET_NOT_AVAILABLE); Loading services/core/java/com/android/server/hdmi/HdmiControlService.java +7 −14 Original line number Diff line number Diff line Loading @@ -1331,7 +1331,6 @@ public class HdmiControlService extends SystemService { */ private boolean sourceAddressIsLocal(HdmiCecMessage message) { for (HdmiCecLocalDevice device : getAllLocalDevices()) { synchronized (device.mLock) { if (message.getSource() == device.getDeviceInfo().getLogicalAddress() && message.getSource() != Constants.ADDR_UNREGISTERED) { HdmiLogger.warning( Loading @@ -1339,7 +1338,6 @@ public class HdmiControlService extends SystemService { return true; } } } return false; } Loading Loading @@ -1560,9 +1558,7 @@ public class HdmiControlService extends SystemService { if (deviceInfo.getDisplayName().equals(newDisplayName)) { continue; } synchronized (device.mLock) { device.setDeviceInfo(deviceInfo.toBuilder().setDisplayName(newDisplayName).build()); } sendCecCommand( HdmiCecMessageBuilder.buildSetOsdNameCommand( deviceInfo.getLogicalAddress(), Constants.ADDR_TV, newDisplayName)); Loading Loading @@ -4096,10 +4092,7 @@ public class HdmiControlService extends SystemService { public void onAudioDeviceVolumeChanged( @NonNull AudioDeviceAttributes audioDevice, @NonNull VolumeInfo volumeInfo) { int localDeviceAddress; synchronized (mLocalDevice.mLock) { localDeviceAddress = mLocalDevice.getDeviceInfo().getLogicalAddress(); } int localDeviceAddress = mLocalDevice.getDeviceInfo().getLogicalAddress(); sendCecCommand(SetAudioVolumeLevelMessage.build( localDeviceAddress, mSystemAudioDevice.getLogicalAddress(), Loading services/tests/servicestests/src/com/android/server/hdmi/BaseAbsoluteVolumeControlTest.java +1 −3 Original line number Diff line number Diff line Loading @@ -212,10 +212,8 @@ public abstract class BaseAbsoluteVolumeControlTest { } protected int getLogicalAddress() { synchronized (mHdmiCecLocalDevice.mLock) { return mHdmiCecLocalDevice.getDeviceInfo().getLogicalAddress(); } } /** * Simulates the volume behavior of {@code device} being set to {@code behavior}. Loading services/tests/servicestests/src/com/android/server/hdmi/DeviceSelectActionFromPlaybackTest.java +3 −4 Original line number Diff line number Diff line Loading @@ -147,10 +147,9 @@ public class DeviceSelectActionFromPlaybackTest { // The addresses depend on local device's LA. // This help the tests to pass with every local device LA. synchronized (mHdmiCecLocalDevicePlayback.mLock) { mPlaybackLogicalAddress1 = mHdmiCecLocalDevicePlayback.getDeviceInfo().getLogicalAddress(); } mPlaybackLogicalAddress2 = mPlaybackLogicalAddress1 == ADDR_PLAYBACK_2 ? ADDR_PLAYBACK_1 : ADDR_PLAYBACK_2; mPlaybackLogicalAddress3 = mPlaybackLogicalAddress1 == ADDR_PLAYBACK_3 Loading Loading
services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java +7 −15 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ abstract class HdmiCecLocalDevice { protected final int mDeviceType; protected int mPreferredAddress; @GuardedBy("mLock") protected HdmiDeviceInfo mDeviceInfo; private HdmiDeviceInfo mDeviceInfo; protected int mLastKeycode = HdmiCecKeycode.UNSUPPORTED_KEYCODE; protected int mLastKeyRepeatCount = 0; Loading Loading @@ -666,22 +666,18 @@ abstract class HdmiCecLocalDevice { * Computes the set of supported device features, and updates local state to match. */ private void updateDeviceFeatures() { synchronized (mLock) { setDeviceInfo(getDeviceInfo().toBuilder() .setDeviceFeatures(computeDeviceFeatures()) .build()); } } /** * Computes and returns the set of supported device features. Updates local state to match. */ protected final DeviceFeatures getDeviceFeatures() { updateDeviceFeatures(); synchronized (mLock) { return getDeviceInfo().getDeviceFeatures(); } } @Constants.HandleMessageResult protected int handleGiveFeatures(HdmiCecMessage message) { Loading Loading @@ -982,14 +978,12 @@ abstract class HdmiCecLocalDevice { return mDeviceType; } @GuardedBy("mLock") HdmiDeviceInfo getDeviceInfo() { synchronized (mLock) { return mDeviceInfo; } } @GuardedBy("mLock") void setDeviceInfo(HdmiDeviceInfo info) { synchronized (mLock) { mDeviceInfo = info; Loading Loading @@ -1042,11 +1036,9 @@ abstract class HdmiCecLocalDevice { // Send <Give Features> if using CEC 2.0 or above. if (mService.getCecVersion() >= HdmiControlManager.HDMI_CEC_VERSION_2_0) { synchronized (mLock) { mService.sendCecCommand(HdmiCecMessageBuilder.buildGiveFeatures( getDeviceInfo().getLogicalAddress(), targetAddress)); } } // If we don't already have a {@link SetAudioVolumeLevelDiscoveryAction} for the target // device, start one. Loading
services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java +4 −8 Original line number Diff line number Diff line Loading @@ -138,10 +138,8 @@ public class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource { // does not poll local devices, we should put device info of local device // manually here. for (HdmiCecLocalDevice device : mService.getAllLocalDevices()) { synchronized (device.mLock) { mService.getHdmiCecNetwork().addCecDevice(device.getDeviceInfo()); } } List<HotplugDetectionAction> hotplugActions = getActions(HotplugDetectionAction.class); Loading Loading @@ -179,12 +177,10 @@ public class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource { @ServiceThreadOnly void deviceSelect(int id, IHdmiControlCallback callback) { assertRunOnServiceThread(); synchronized (mLock) { if (id == getDeviceInfo().getId()) { mService.oneTouchPlay(callback); return; } } HdmiDeviceInfo targetDevice = mService.getHdmiCecNetwork().getDeviceInfo(id); if (targetDevice == null) { invokeCallback(callback, HdmiControlManager.RESULT_TARGET_NOT_AVAILABLE); Loading
services/core/java/com/android/server/hdmi/HdmiControlService.java +7 −14 Original line number Diff line number Diff line Loading @@ -1331,7 +1331,6 @@ public class HdmiControlService extends SystemService { */ private boolean sourceAddressIsLocal(HdmiCecMessage message) { for (HdmiCecLocalDevice device : getAllLocalDevices()) { synchronized (device.mLock) { if (message.getSource() == device.getDeviceInfo().getLogicalAddress() && message.getSource() != Constants.ADDR_UNREGISTERED) { HdmiLogger.warning( Loading @@ -1339,7 +1338,6 @@ public class HdmiControlService extends SystemService { return true; } } } return false; } Loading Loading @@ -1560,9 +1558,7 @@ public class HdmiControlService extends SystemService { if (deviceInfo.getDisplayName().equals(newDisplayName)) { continue; } synchronized (device.mLock) { device.setDeviceInfo(deviceInfo.toBuilder().setDisplayName(newDisplayName).build()); } sendCecCommand( HdmiCecMessageBuilder.buildSetOsdNameCommand( deviceInfo.getLogicalAddress(), Constants.ADDR_TV, newDisplayName)); Loading Loading @@ -4096,10 +4092,7 @@ public class HdmiControlService extends SystemService { public void onAudioDeviceVolumeChanged( @NonNull AudioDeviceAttributes audioDevice, @NonNull VolumeInfo volumeInfo) { int localDeviceAddress; synchronized (mLocalDevice.mLock) { localDeviceAddress = mLocalDevice.getDeviceInfo().getLogicalAddress(); } int localDeviceAddress = mLocalDevice.getDeviceInfo().getLogicalAddress(); sendCecCommand(SetAudioVolumeLevelMessage.build( localDeviceAddress, mSystemAudioDevice.getLogicalAddress(), Loading
services/tests/servicestests/src/com/android/server/hdmi/BaseAbsoluteVolumeControlTest.java +1 −3 Original line number Diff line number Diff line Loading @@ -212,10 +212,8 @@ public abstract class BaseAbsoluteVolumeControlTest { } protected int getLogicalAddress() { synchronized (mHdmiCecLocalDevice.mLock) { return mHdmiCecLocalDevice.getDeviceInfo().getLogicalAddress(); } } /** * Simulates the volume behavior of {@code device} being set to {@code behavior}. Loading
services/tests/servicestests/src/com/android/server/hdmi/DeviceSelectActionFromPlaybackTest.java +3 −4 Original line number Diff line number Diff line Loading @@ -147,10 +147,9 @@ public class DeviceSelectActionFromPlaybackTest { // The addresses depend on local device's LA. // This help the tests to pass with every local device LA. synchronized (mHdmiCecLocalDevicePlayback.mLock) { mPlaybackLogicalAddress1 = mHdmiCecLocalDevicePlayback.getDeviceInfo().getLogicalAddress(); } mPlaybackLogicalAddress2 = mPlaybackLogicalAddress1 == ADDR_PLAYBACK_2 ? ADDR_PLAYBACK_1 : ADDR_PLAYBACK_2; mPlaybackLogicalAddress3 = mPlaybackLogicalAddress1 == ADDR_PLAYBACK_3 Loading