Skip to content

Commit 398ae47

Browse files
committed
Add additional null check
Add another check in case the manager listener is never instantiated
1 parent c0e5a39 commit 398ae47

1 file changed

Lines changed: 49 additions & 45 deletions

File tree

base/src/main/java/com/smartdevicelink/managers/BaseSdlManager.java

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -187,53 +187,57 @@ protected void checkLifecycleConfiguration() {
187187
final Language actualHMILanguage = this.getRegisterAppInterfaceResponse().getHmiDisplayLanguage();
188188

189189
if ((actualLanguage != null && !actualLanguage.equals(language)) || (actualHMILanguage != null && !actualHMILanguage.equals(hmiLanguage))) {
190-
191-
final LifecycleConfigurationUpdate lcu = managerListener.managerShouldUpdateLifecycle(actualLanguage, actualHMILanguage);
192-
193-
ChangeRegistration changeRegistration;
194-
changeRegistration = new ChangeRegistration(actualLanguage, actualHMILanguage);
195-
196-
if (lcu != null) {
197-
changeRegistration.setAppName(lcu.getAppName());
198-
changeRegistration.setNgnMediaScreenAppName(lcu.getShortAppName());
199-
changeRegistration.setTtsName(lcu.getTtsName());
200-
changeRegistration.setVrSynonyms(lcu.getVoiceRecognitionCommandNames());
201-
changeRegistration.setOnRPCResponseListener(new OnRPCResponseListener() {
202-
@Override
203-
public void onResponse(int correlationId, RPCResponse response) {
204-
if (response.getSuccess()) {
205-
try {
206-
DebugTool.logInfo(TAG, response.serializeJSON().toString());
207-
} catch (JSONException e) {
208-
e.printStackTrace();
209-
}
210-
211-
// go through and change sdlManager properties that were changed via the LCU update
212-
hmiLanguage = actualHMILanguage;
213-
language = actualLanguage;
214-
215-
if (lcu.getAppName() != null) {
216-
appName = lcu.getAppName();
217-
}
218-
219-
if (lcu.getShortAppName() != null) {
220-
shortAppName = lcu.getShortAppName();
190+
if(managerListener != null) {
191+
final LifecycleConfigurationUpdate lcu = managerListener.managerShouldUpdateLifecycle(actualLanguage, actualHMILanguage);
192+
193+
ChangeRegistration changeRegistration;
194+
changeRegistration = new ChangeRegistration(actualLanguage, actualHMILanguage);
195+
196+
if (lcu != null) {
197+
changeRegistration.setAppName(lcu.getAppName());
198+
changeRegistration.setNgnMediaScreenAppName(lcu.getShortAppName());
199+
changeRegistration.setTtsName(lcu.getTtsName());
200+
changeRegistration.setVrSynonyms(lcu.getVoiceRecognitionCommandNames());
201+
changeRegistration.setOnRPCResponseListener(new OnRPCResponseListener() {
202+
@Override
203+
public void onResponse(int correlationId, RPCResponse response) {
204+
if (response.getSuccess()) {
205+
try {
206+
DebugTool.logInfo(TAG, response.serializeJSON().toString());
207+
} catch (JSONException e) {
208+
e.printStackTrace();
209+
}
210+
211+
// go through and change sdlManager properties that were changed via the LCU update
212+
hmiLanguage = actualHMILanguage;
213+
language = actualLanguage;
214+
215+
if (lcu.getAppName() != null) {
216+
appName = lcu.getAppName();
217+
}
218+
219+
if (lcu.getShortAppName() != null) {
220+
shortAppName = lcu.getShortAppName();
221+
}
222+
223+
if (lcu.getTtsName() != null) {
224+
ttsChunks = lcu.getTtsName();
225+
}
226+
227+
if (lcu.getVoiceRecognitionCommandNames() != null) {
228+
vrSynonyms = lcu.getVoiceRecognitionCommandNames();
229+
}
230+
} else {
231+
DebugTool.logError(TAG, "Change Registration onError: " + response.getResultCode() + " | Info: " + response.getInfo());
232+
retryChangeRegistration();
221233
}
222-
223-
if (lcu.getTtsName() != null) {
224-
ttsChunks = lcu.getTtsName();
225-
}
226-
227-
if (lcu.getVoiceRecognitionCommandNames() != null) {
228-
vrSynonyms = lcu.getVoiceRecognitionCommandNames();
229-
}
230-
} else {
231-
DebugTool.logError(TAG, "Change Registration onError: " + response.getResultCode() + " | Info: " + response.getInfo());
232-
retryChangeRegistration();
233234
}
234-
}
235-
});
236-
this.sendRPC(changeRegistration);
235+
});
236+
this.sendRPC(changeRegistration);
237+
}
238+
}
239+
else {
240+
DebugTool.logError(TAG, "SdlManagerListener is null");
237241
}
238242
}
239243
}

0 commit comments

Comments
 (0)