cec: resolve HdmiCecTvPowerToggleTest issue [1/1]

PD#SWPL-105252
BUG=269812391

Problem:
PendingActionClearedCallback in disableDevice could be
called after the local device is initiated.

Solution:
Clear the running actions and call the cleared callback
directly in disableDevice method.

Verify:
sc2

Change-Id: I83d292dea4318f6978039076e2b8d302deb2e5f4
Signed-off-by: an.xi <an.xi@amlogic.com>
This commit is contained in:
an.xi
2023-02-02 12:10:22 +00:00
committed by Paul Colța
parent ac189d4a55
commit 5271e51578
2 changed files with 18 additions and 0 deletions

View File

@@ -1125,6 +1125,16 @@ abstract class HdmiCecLocalDevice {
removeActionExcept(clazz, null);
}
// Remove all running actions.
@ServiceThreadOnly
void removeAllActions() {
assertRunOnServiceThread();
for (HdmiCecFeatureAction action : mActions) {
action.finish(false);
}
mActions.clear();
}
// Remove all actions matched with the given Class type besides |exception|.
@ServiceThreadOnly
<T extends HdmiCecFeatureAction> void removeActionExcept(

View File

@@ -229,6 +229,14 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
super.disableDevice(initiatedByCec, callback);
assertRunOnServiceThread();
mService.unregisterTvInputCallback(mTvInputCallback);
// Removing actions and invoking the callback is similar to
// HdmiCecLocalDevicePlayback#disableDevice and HdmiCecLocalDeviceTv#disableDevice,
// with the difference that in those classes only specific actions are removed and
// here we remove all actions. We don't expect any issues with removing all actions
// at this time, but we have to pay attention in the future.
removeAllActions();
// Call the callback instantly or else it will be called 5 seconds later.
checkIfPendingActionsCleared();
}
@Override