Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 24943bf1 authored by Przemyslaw Szczepaniak's avatar Przemyslaw Szczepaniak
Browse files

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
parent f3d5de82
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -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);
        }