Small refactoring for FileSynthesisCallback.
Removed unused callerIdentity member and removed null checks
for the dispatcher.
Change-Id: I2983f5d48a7a593bc998ba4e033f1e815fa61819
diff --git a/core/java/android/speech/tts/FileSynthesisCallback.java b/core/java/android/speech/tts/FileSynthesisCallback.java
index 2b882d3..c7a4ccc 100644
--- a/core/java/android/speech/tts/FileSynthesisCallback.java
+++ b/core/java/android/speech/tts/FileSynthesisCallback.java
@@ -15,6 +15,7 @@
*/
package android.speech.tts;
+import android.annotation.NonNull;
import android.media.AudioFormat;
import android.speech.tts.TextToSpeechService.UtteranceProgressDispatcher;
import android.util.Log;
@@ -46,7 +47,6 @@
private FileChannel mFileChannel;
private final UtteranceProgressDispatcher mDispatcher;
- private final Object mCallerIdentity;
private boolean mStarted = false;
private boolean mDone = false;
@@ -54,12 +54,11 @@
/** Status code of synthesis */
protected int mStatusCode;
- FileSynthesisCallback(FileChannel fileChannel, UtteranceProgressDispatcher dispatcher,
- Object callerIdentity, boolean clientIsUsingV2) {
+ FileSynthesisCallback(@NonNull FileChannel fileChannel,
+ @NonNull UtteranceProgressDispatcher dispatcher, boolean clientIsUsingV2) {
super(clientIsUsingV2);
mFileChannel = fileChannel;
mDispatcher = dispatcher;
- mCallerIdentity = callerIdentity;
mStatusCode = TextToSpeech.SUCCESS;
}
@@ -75,9 +74,7 @@
mStatusCode = TextToSpeech.STOPPED;
cleanUp();
- if (mDispatcher != null) {
- mDispatcher.dispatchOnStop();
- }
+ mDispatcher.dispatchOnStop();
}
}
@@ -134,9 +131,7 @@
mAudioFormat = audioFormat;
mChannelCount = channelCount;
- if (mDispatcher != null) {
- mDispatcher.dispatchOnStart();
- }
+ mDispatcher.dispatchOnStart();
fileChannel = mFileChannel;
}
@@ -214,8 +209,7 @@
if (DBG) Log.d(TAG, "Request has been aborted.");
return errorCodeOnStop();
}
- if (mDispatcher != null && mStatusCode != TextToSpeech.SUCCESS &&
- mStatusCode != TextToSpeech.STOPPED) {
+ if (mStatusCode != TextToSpeech.SUCCESS && mStatusCode != TextToSpeech.STOPPED) {
mDispatcher.dispatchOnError(mStatusCode);
return TextToSpeech.ERROR;
}
@@ -239,9 +233,7 @@
synchronized (mStateLock) {
closeFile();
- if (mDispatcher != null) {
- mDispatcher.dispatchOnSuccess();
- }
+ mDispatcher.dispatchOnSuccess();
return TextToSpeech.SUCCESS;
}
} catch (IOException ex) {
diff --git a/core/java/android/speech/tts/TextToSpeechService.java b/core/java/android/speech/tts/TextToSpeechService.java
index c3aed75..8c355d8 100644
--- a/core/java/android/speech/tts/TextToSpeechService.java
+++ b/core/java/android/speech/tts/TextToSpeechService.java
@@ -1032,8 +1032,7 @@
@Override
protected AbstractSynthesisCallback createSynthesisCallback() {
- return new FileSynthesisCallback(mFileOutputStream.getChannel(),
- this, getCallerIdentity(), false);
+ return new FileSynthesisCallback(mFileOutputStream.getChannel(), this, false);
}
@Override