From 2319536adc9cd34a884cf50deff0172aada402d5 Mon Sep 17 00:00:00 2001 From: fabriziocasellato Date: Mon, 11 Nov 2019 09:57:35 +0100 Subject: [PATCH] Cumulative corrections for Milos msgs in 2019, 7 Nov about try/catch and missed 'if null' contition --- .../SmsCommunicatorPlugin.java | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.java index f34a66ca4b..f40d60523c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.java @@ -792,9 +792,8 @@ public class SmsCommunicatorPlugin extends PluginBase { messageToConfirm = new AuthRequest(this, receivedSms, reply, passCode, new SmsAction() { @Override public void run() { - try { - Profile currentProfile = ProfileFunctions.getInstance().getProfile(); - + Profile currentProfile = ProfileFunctions.getInstance().getProfile(); + if (currentProfile != null) { int keyDuration = 0; Integer defaultTargetDuration = 0; int keyTarget = 0; @@ -843,9 +842,8 @@ public class SmsCommunicatorPlugin extends PluginBase { String reply = String.format(MainApp.gs(R.string.smscommunicator_tt_set), ttString, ttDuration); sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply)); - } catch (Exception e) { + } else { sendSMS(new Sms(receivedSms.phoneNumber, R.string.smscommunicator_unknowncommand)); - return; } } }); @@ -864,15 +862,9 @@ public class SmsCommunicatorPlugin extends PluginBase { messageToConfirm = new AuthRequest(this, receivedSms, reply, passCode, new SmsAction() { @Override public void run() { - try { - SP.putBoolean(R.string.key_smscommunicator_remotecommandsallowed, false); - String reply = String.format(MainApp.gs(R.string.smscommunicator_stoppedsms)); - sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply)); - } catch (Exception e) { - e.printStackTrace(); - sendSMS(new Sms(receivedSms.phoneNumber, R.string.smscommunicator_unknowncommand)); - return; - } + SP.putBoolean(R.string.key_smscommunicator_remotecommandsallowed, false); + String reply = String.format(MainApp.gs(R.string.smscommunicator_stoppedsms)); + sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply)); } }); } else