Failing Text-To-Speech CTS tests fix.

Fix for failing android.speech.tts.cts.TextToSpeechServiceTest#testSynthesizeToFile.
In test env, ParcelFileDescriptor instance may be EXACTLY the same one that client uses.
And if it's closed by a client, then service is prevented from writing anything to the output.

Bug: 8377754
Change-Id: I7f95aae1b877e543ab02d3c548b29537aa852a89
This commit is contained in:
Przemyslaw Szczepaniak
2013-03-13 15:45:28 +00:00
parent f3d5de8246
commit 24943bf19d

View File

@@ -810,9 +810,15 @@ public abstract class TextToSpeechService extends Service {
return TextToSpeech.ERROR;
}
// In test env, ParcelFileDescriptor instance may be EXACTLY the same
// one that is used by client. And it will be closed by a client, thus
// preventing us from writing anything to it.
final ParcelFileDescriptor sameFileDescriptor = ParcelFileDescriptor.adoptFd(
fileDescriptor.detachFd());
SpeechItem item = new SynthesisToFileOutputStreamSpeechItem(caller,
Binder.getCallingUid(), Binder.getCallingPid(), params, text,
new ParcelFileDescriptor.AutoCloseOutputStream(fileDescriptor));
new ParcelFileDescriptor.AutoCloseOutputStream(sameFileDescriptor));
return mSynthHandler.enqueueSpeechItem(TextToSpeech.QUEUE_ADD, item);
}