Prevent SecurityException during unit tests

Mock out displayOsd because it broadcasts an intent, which causes a
runtime error due to missing permissions on ADT-4.

Test: atest com.android.server.hdmi.SystemAudioAutoInitiationActionTest#testReceiveSystemAudioMode_systemAudioOn

Bug: 289908764
Change-Id: Ie3020da76c6d9996119493dc042de8d91c414623
This commit is contained in:
Winni Chang
2023-07-26 09:17:46 +08:00
parent 3dbac6587e
commit 924613dcb8

View File

@@ -81,6 +81,20 @@ public class SystemAudioAutoInitiationActionTest {
protected void writeStringSystemProperty(String key, String value) {
// do nothing
}
/**
* Override displayOsd to prevent it from broadcasting an intent, which
* can trigger a SecurityException.
*/
@Override
void displayOsd(int messageId) {
// do nothing
}
@Override
void displayOsd(int messageId, int extra) {
// do nothing
}
};
mHdmiControlService.setIoLooper(myLooper);