Skip to content

Commit 51a59a7

Browse files
committed
🐛 Adding null check for HeadsetService onInit and refactored onServiceConnected for COnrealityHeadsetPlugin
1 parent d5ba669 commit 51a59a7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

conreality_headset/android/src/main/java/app/conreality/plugins/headset/ConrealityHeadsetPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ public void onServiceConnected(final @NonNull ComponentName name, final @NonNull
118118
assert(service != null);
119119

120120
Log.d(TAG, String.format("onServiceConnected: name=%s service=%s", name, service));
121-
this.service = ((HeadsetService.LocalBinder)service).getService();
121+
HeadsetService.LocalBinder binder = (HeadsetService.LocalBinder) service;
122+
this.service = (HeadsetService) binder.getService();
122123
this.service.onConnection(this.registrar.context());
123124
}
124125

conreality_headset/android/src/main/java/app/conreality/plugins/headset/HeadsetService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public int onStartCommand(final @NonNull Intent intent, final int flags, final i
8888
/** Implements TextToSpeech.OnInitListener#onInit(). */
8989
@Override
9090
public void onInit(final int status) {
91-
if (status == TextToSpeech.SUCCESS) {
91+
if (status == TextToSpeech.SUCCESS && this.ttsQueue != null) {
9292
if (Log.isLoggable(TAG, Log.DEBUG)) {
9393
Log.d(TAG, "Initialized the speech synthesis engine.");
9494
}

0 commit comments

Comments
 (0)