Skip to content

Commit 6d73986

Browse files
Yuncheol HeoAndroid (Google) Code Review
authored andcommitted
Merge "Make it not to go to sleep when changing TV's input to the others." into lmp-dev
2 parents b93d265 + 64bafd9 commit 6d73986

2 files changed

Lines changed: 63 additions & 12 deletions

File tree

services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ protected final boolean onMessage(HdmiCecMessage message) {
210210
return handleReportPhysicalAddress(message);
211211
case Constants.MESSAGE_ROUTING_CHANGE:
212212
return handleRoutingChange(message);
213+
case Constants.MESSAGE_ROUTING_INFORMATION:
214+
return handleRoutingInformation(message);
213215
case Constants.MESSAGE_INITIATE_ARC:
214216
return handleInitiateArc(message);
215217
case Constants.MESSAGE_TERMINATE_ARC:
@@ -331,6 +333,10 @@ protected boolean handleRoutingChange(HdmiCecMessage message) {
331333
return false;
332334
}
333335

336+
protected boolean handleRoutingInformation(HdmiCecMessage message) {
337+
return false;
338+
}
339+
334340
protected boolean handleReportPhysicalAddress(HdmiCecMessage message) {
335341
return false;
336342
}

services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
package com.android.server.hdmi;
1818

19-
import android.hardware.hdmi.HdmiDeviceInfo;
2019
import android.hardware.hdmi.HdmiControlManager;
20+
import android.hardware.hdmi.HdmiDeviceInfo;
2121
import android.hardware.hdmi.IHdmiControlCallback;
2222
import android.os.RemoteException;
2323
import android.os.SystemProperties;
@@ -137,28 +137,73 @@ void markActiveSource() {
137137
protected boolean handleActiveSource(HdmiCecMessage message) {
138138
assertRunOnServiceThread();
139139
int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams());
140+
mayResetActiveSource(physicalAddress);
141+
return true; // Broadcast message.
142+
}
143+
144+
private void mayResetActiveSource(int physicalAddress) {
140145
if (physicalAddress != mService.getPhysicalAddress()) {
141146
mIsActiveSource = false;
142-
if (mService.isPowerOnOrTransient()) {
143-
mService.nap();
144-
}
145-
return true;
146147
}
147-
return false;
148148
}
149149

150150
@Override
151151
@ServiceThreadOnly
152152
protected boolean handleSetStreamPath(HdmiCecMessage message) {
153153
assertRunOnServiceThread();
154154
int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams());
155+
maySetActiveSource(physicalAddress);
156+
maySendActiveSource();
157+
wakeUpIfActiveSource();
158+
return true; // Broadcast message.
159+
}
160+
161+
// Samsung model, we tested, sends <RoutingChange> and <RequestActiveSource> consecutively,
162+
// Then if there is no <ActiveSource> response, it will change the input to
163+
// the internal source. To handle this, we'll set ActiveSource aggressively.
164+
@Override
165+
@ServiceThreadOnly
166+
protected boolean handleRoutingChange(HdmiCecMessage message) {
167+
assertRunOnServiceThread();
168+
int newPath = HdmiUtils.twoBytesToInt(message.getParams(), 2);
169+
maySetActiveSource(newPath);
170+
return true; // Broadcast message.
171+
}
172+
173+
@Override
174+
@ServiceThreadOnly
175+
protected boolean handleRoutingInformation(HdmiCecMessage message) {
176+
assertRunOnServiceThread();
177+
int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams());
178+
maySetActiveSource(physicalAddress);
179+
return true; // Broadcast message.
180+
}
181+
182+
private void maySetActiveSource(int physicalAddress) {
155183
if (physicalAddress == mService.getPhysicalAddress()) {
156-
if (mService.isPowerStandbyOrTransient()) {
157-
mService.wakeUp();
158-
}
159-
return true;
184+
mIsActiveSource = true;
185+
}
186+
}
187+
188+
private void wakeUpIfActiveSource() {
189+
if (mIsActiveSource && mService.isPowerStandbyOrTransient()) {
190+
mService.wakeUp();
160191
}
161-
return false;
192+
}
193+
194+
private void maySendActiveSource() {
195+
if (mIsActiveSource) {
196+
mService.sendCecCommand(HdmiCecMessageBuilder.buildActiveSource(
197+
mAddress, mService.getPhysicalAddress()));
198+
}
199+
}
200+
201+
@Override
202+
@ServiceThreadOnly
203+
protected boolean handleRequestActiveSource(HdmiCecMessage message) {
204+
assertRunOnServiceThread();
205+
maySendActiveSource();
206+
return true; // Broadcast message.
162207
}
163208

164209
@Override
@@ -174,4 +219,4 @@ protected void disableDevice(boolean initiatedByCec, PendingActionClearedCallbac
174219
mIsActiveSource = false;
175220
checkIfPendingActionsCleared();
176221
}
177-
}
222+
}

0 commit comments

Comments
 (0)