SBS CARBS command
This commit is contained in:
parent
a62750c3a3
commit
e9aa4835ed
|
@ -4,6 +4,7 @@ abstract class SmsAction implements Runnable {
|
||||||
Double aDouble;
|
Double aDouble;
|
||||||
Integer anInteger;
|
Integer anInteger;
|
||||||
Integer secondInteger;
|
Integer secondInteger;
|
||||||
|
Long secondLong;
|
||||||
String aString;
|
String aString;
|
||||||
|
|
||||||
SmsAction() {}
|
SmsAction() {}
|
||||||
|
@ -30,4 +31,8 @@ abstract class SmsAction implements Runnable {
|
||||||
this.anInteger = anInteger;
|
this.anInteger = anInteger;
|
||||||
this.secondInteger = secondInteger;
|
this.secondInteger = secondInteger;
|
||||||
}
|
}
|
||||||
|
SmsAction(Integer anInteger, Long secondLong) {
|
||||||
|
this.anInteger = anInteger;
|
||||||
|
this.secondLong = secondLong;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
|
|
||||||
fun isCommand(command: String, number: String): Boolean {
|
fun isCommand(command: String, number: String): Boolean {
|
||||||
when (command.toUpperCase(Locale.getDefault())) {
|
when (command.toUpperCase(Locale.getDefault())) {
|
||||||
"BG", "LOOP", "TREATMENTS", "NSCLIENT", "PUMP", "BASAL", "BOLUS", "EXTENDED", "CAL", "PROFILE", "TARGET", "SMS" -> return true
|
"BG", "LOOP", "TREATMENTS", "NSCLIENT", "PUMP", "BASAL", "BOLUS", "EXTENDED", "CAL", "PROFILE", "TARGET", "SMS", "CARBS" -> return true
|
||||||
}
|
}
|
||||||
return messageToConfirm?.requester?.phoneNumber == number
|
return messageToConfirm?.requester?.phoneNumber == number
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,12 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_remotecommandnotallowed))
|
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_remotecommandnotallowed))
|
||||||
else if (splitted.size == 2 && DateUtil.now() - lastRemoteBolusTime < Constants.remoteBolusMinDistance) sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_remotebolusnotallowed))
|
else if (splitted.size == 2 && DateUtil.now() - lastRemoteBolusTime < Constants.remoteBolusMinDistance) sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_remotebolusnotallowed))
|
||||||
else if (splitted.size == 2 && pump.isSuspended) sendSMS(Sms(receivedSms.phoneNumber, R.string.pumpsuspended))
|
else if (splitted.size == 2 && pump.isSuspended) sendSMS(Sms(receivedSms.phoneNumber, R.string.pumpsuspended))
|
||||||
else if (splitted.size == 2 || splitted.size == 3) processBOLUS(splitted, receivedSms) else sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
else if (splitted.size == 2 || splitted.size == 3) processBOLUS(splitted, receivedSms)
|
||||||
|
else sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
|
"CARBS" ->
|
||||||
|
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_remotecommandnotallowed))
|
||||||
|
else if (splitted.size == 2 || splitted.size == 3) processCARBS(splitted, receivedSms)
|
||||||
|
else sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
"CAL" ->
|
"CAL" ->
|
||||||
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_remotecommandnotallowed))
|
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_remotecommandnotallowed))
|
||||||
else if (splitted.size == 2) processCAL(splitted, receivedSms)
|
else if (splitted.size == 2) processCAL(splitted, receivedSms)
|
||||||
|
@ -219,7 +224,8 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
else sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
else sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
"SMS" ->
|
"SMS" ->
|
||||||
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_remotecommandnotallowed))
|
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_remotecommandnotallowed))
|
||||||
else if (splitted.size == 2) processSMS(splitted, receivedSms) else sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
else if (splitted.size == 2) processSMS(splitted, receivedSms)
|
||||||
|
else sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
else ->
|
else ->
|
||||||
if (messageToConfirm?.requester?.phoneNumber == receivedSms.phoneNumber) {
|
if (messageToConfirm?.requester?.phoneNumber == receivedSms.phoneNumber) {
|
||||||
messageToConfirm?.action(splitted[0])
|
messageToConfirm?.action(splitted[0])
|
||||||
|
@ -271,9 +277,8 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_loopisdisabled))
|
sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_loopisdisabled))
|
||||||
}
|
|
||||||
receivedSms.processed = true
|
receivedSms.processed = true
|
||||||
}
|
}
|
||||||
"ENABLE", "START" -> {
|
"ENABLE", "START" -> {
|
||||||
|
@ -282,18 +287,17 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true)
|
loopPlugin.setPluginEnabled(PluginType.LOOP, true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_loophasbeenenabled))
|
sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_loophasbeenenabled))
|
||||||
send(EventRefreshOverview("SMS_LOOP_START"))
|
send(EventRefreshOverview("SMS_LOOP_START"))
|
||||||
} else {
|
} else
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_loopisenabled))
|
sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_loopisenabled))
|
||||||
}
|
|
||||||
receivedSms.processed = true
|
receivedSms.processed = true
|
||||||
}
|
}
|
||||||
"STATUS" -> {
|
"STATUS" -> {
|
||||||
val loopPlugin = LoopPlugin.getPlugin()
|
val loopPlugin = LoopPlugin.getPlugin()
|
||||||
val reply = if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
val reply = if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
if (loopPlugin.isSuspended()) String.format(MainApp.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend()) else MainApp.gs(R.string.smscommunicator_loopisenabled)
|
if (loopPlugin.isSuspended()) String.format(MainApp.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend())
|
||||||
} else {
|
else MainApp.gs(R.string.smscommunicator_loopisenabled)
|
||||||
|
} else
|
||||||
MainApp.gs(R.string.smscommunicator_loopisdisabled)
|
MainApp.gs(R.string.smscommunicator_loopisdisabled)
|
||||||
}
|
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, reply))
|
sendSMS(Sms(receivedSms.phoneNumber, reply))
|
||||||
receivedSms.processed = true
|
receivedSms.processed = true
|
||||||
}
|
}
|
||||||
|
@ -348,7 +352,8 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
send(EventNSClientRestart())
|
send(EventNSClientRestart())
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, "TREATMENTS REFRESH SENT"))
|
sendSMS(Sms(receivedSms.phoneNumber, "TREATMENTS REFRESH SENT"))
|
||||||
receivedSms.processed = true
|
receivedSms.processed = true
|
||||||
} else sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
} else
|
||||||
|
sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processNSCLIENT(splitted: Array<String>, receivedSms: Sms) {
|
private fun processNSCLIENT(splitted: Array<String>, receivedSms: Sms) {
|
||||||
|
@ -356,7 +361,8 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
send(EventNSClientRestart())
|
send(EventNSClientRestart())
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, "NSCLIENT RESTART SENT"))
|
sendSMS(Sms(receivedSms.phoneNumber, "NSCLIENT RESTART SENT"))
|
||||||
receivedSms.processed = true
|
receivedSms.processed = true
|
||||||
} else sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
} else
|
||||||
|
sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processPUMP(receivedSms: Sms) {
|
private fun processPUMP(receivedSms: Sms) {
|
||||||
|
@ -394,7 +400,8 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
if (splitted[1].toUpperCase(Locale.getDefault()) == "STATUS") {
|
if (splitted[1].toUpperCase(Locale.getDefault()) == "STATUS") {
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, ProfileFunctions.getInstance().profileName))
|
sendSMS(Sms(receivedSms.phoneNumber, ProfileFunctions.getInstance().profileName))
|
||||||
} else if (splitted[1].toUpperCase(Locale.getDefault()) == "LIST") {
|
} else if (splitted[1].toUpperCase(Locale.getDefault()) == "LIST") {
|
||||||
if (list.isEmpty()) sendSMS(Sms(receivedSms.phoneNumber, R.string.invalidprofile)) else {
|
if (list.isEmpty()) sendSMS(Sms(receivedSms.phoneNumber, R.string.invalidprofile))
|
||||||
|
else {
|
||||||
var reply = ""
|
var reply = ""
|
||||||
for (i in list.indices) {
|
for (i in list.indices) {
|
||||||
if (i > 0) reply += "\n"
|
if (i > 0) reply += "\n"
|
||||||
|
@ -407,9 +414,13 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
val pindex = SafeParse.stringToInt(splitted[1])
|
val pindex = SafeParse.stringToInt(splitted[1])
|
||||||
var percentage = 100
|
var percentage = 100
|
||||||
if (splitted.size > 2) percentage = SafeParse.stringToInt(splitted[2])
|
if (splitted.size > 2) percentage = SafeParse.stringToInt(splitted[2])
|
||||||
if (pindex > list.size) sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat)) else if (percentage == 0) sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat)) else if (pindex == 0) sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat)) else {
|
if (pindex > list.size) sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
|
else if (percentage == 0) sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
|
else if (pindex == 0) sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
|
else {
|
||||||
val profile = store.getSpecificProfile(list[pindex - 1] as String)
|
val profile = store.getSpecificProfile(list[pindex - 1] as String)
|
||||||
if (profile == null) sendSMS(Sms(receivedSms.phoneNumber, R.string.noprofile)) else {
|
if (profile == null) sendSMS(Sms(receivedSms.phoneNumber, R.string.noprofile))
|
||||||
|
else {
|
||||||
val passCode = generatePasscode()
|
val passCode = generatePasscode()
|
||||||
val reply = String.format(MainApp.gs(R.string.smscommunicator_profilereplywithcode), list[pindex - 1], percentage, passCode)
|
val reply = String.format(MainApp.gs(R.string.smscommunicator_profilereplywithcode), list[pindex - 1], percentage, passCode)
|
||||||
receivedSms.processed = true
|
receivedSms.processed = true
|
||||||
|
@ -453,7 +464,10 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
var duration = 30
|
var duration = 30
|
||||||
if (splitted.size > 2) duration = SafeParse.stringToInt(splitted[2])
|
if (splitted.size > 2) duration = SafeParse.stringToInt(splitted[2])
|
||||||
val profile = ProfileFunctions.getInstance().profile
|
val profile = ProfileFunctions.getInstance().profile
|
||||||
if (profile == null) sendSMS(Sms(receivedSms.phoneNumber, R.string.noprofile)) else if (tempBasalPct == 0 && splitted[1] != "0%") sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat)) else if (duration == 0) sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat)) else {
|
if (profile == null) sendSMS(Sms(receivedSms.phoneNumber, R.string.noprofile))
|
||||||
|
else if (tempBasalPct == 0 && splitted[1] != "0%") sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
|
else if (duration == 0) sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
|
else {
|
||||||
tempBasalPct = MainApp.getConstraintChecker().applyBasalPercentConstraints(Constraint(tempBasalPct), profile).value()
|
tempBasalPct = MainApp.getConstraintChecker().applyBasalPercentConstraints(Constraint(tempBasalPct), profile).value()
|
||||||
val passCode = generatePasscode()
|
val passCode = generatePasscode()
|
||||||
val reply = String.format(MainApp.gs(R.string.smscommunicator_basalpctreplywithcode), tempBasalPct, duration, passCode)
|
val reply = String.format(MainApp.gs(R.string.smscommunicator_basalpctreplywithcode), tempBasalPct, duration, passCode)
|
||||||
|
@ -482,7 +496,10 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
var duration = 30
|
var duration = 30
|
||||||
if (splitted.size > 2) duration = SafeParse.stringToInt(splitted[2])
|
if (splitted.size > 2) duration = SafeParse.stringToInt(splitted[2])
|
||||||
val profile = ProfileFunctions.getInstance().profile
|
val profile = ProfileFunctions.getInstance().profile
|
||||||
if (profile == null) sendSMS(Sms(receivedSms.phoneNumber, R.string.noprofile)) else if (tempBasal == 0.0 && splitted[1] != "0") sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat)) else if (duration == 0) sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat)) else {
|
if (profile == null) sendSMS(Sms(receivedSms.phoneNumber, R.string.noprofile))
|
||||||
|
else if (tempBasal == 0.0 && splitted[1] != "0") sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
|
else if (duration == 0) sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
|
else {
|
||||||
tempBasal = MainApp.getConstraintChecker().applyBasalConstraints(Constraint(tempBasal), profile).value()
|
tempBasal = MainApp.getConstraintChecker().applyBasalConstraints(Constraint(tempBasal), profile).value()
|
||||||
val passCode = generatePasscode()
|
val passCode = generatePasscode()
|
||||||
val reply = String.format(MainApp.gs(R.string.smscommunicator_basalreplywithcode), tempBasal, duration, passCode)
|
val reply = String.format(MainApp.gs(R.string.smscommunicator_basalreplywithcode), tempBasal, duration, passCode)
|
||||||
|
@ -492,7 +509,8 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
ConfigBuilderPlugin.getPlugin().commandQueue.tempBasalAbsolute(aDouble, secondInteger, true, profile, object : Callback() {
|
ConfigBuilderPlugin.getPlugin().commandQueue.tempBasalAbsolute(aDouble, secondInteger, true, profile, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
var replyText = if (result.isPercent) String.format(MainApp.gs(R.string.smscommunicator_tempbasalset_percent), result.percent, result.duration) else String.format(MainApp.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration)
|
var replyText = if (result.isPercent) String.format(MainApp.gs(R.string.smscommunicator_tempbasalset_percent), result.percent, result.duration)
|
||||||
|
else String.format(MainApp.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration)
|
||||||
replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true)
|
replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true)
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
} else {
|
} else {
|
||||||
|
@ -536,7 +554,8 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
var extended = SafeParse.stringToDouble(splitted[1])
|
var extended = SafeParse.stringToDouble(splitted[1])
|
||||||
val duration = SafeParse.stringToInt(splitted[2])
|
val duration = SafeParse.stringToInt(splitted[2])
|
||||||
extended = MainApp.getConstraintChecker().applyExtendedBolusConstraints(Constraint(extended)).value()
|
extended = MainApp.getConstraintChecker().applyExtendedBolusConstraints(Constraint(extended)).value()
|
||||||
if (extended == 0.0 || duration == 0) sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat)) else {
|
if (extended == 0.0 || duration == 0) sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
|
else {
|
||||||
val passCode = generatePasscode()
|
val passCode = generatePasscode()
|
||||||
val reply = String.format(MainApp.gs(R.string.smscommunicator_extendedreplywithcode), extended, duration, passCode)
|
val reply = String.format(MainApp.gs(R.string.smscommunicator_extendedreplywithcode), extended, duration, passCode)
|
||||||
receivedSms.processed = true
|
receivedSms.processed = true
|
||||||
|
@ -569,11 +588,10 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
} else if (bolus > 0.0) {
|
} else if (bolus > 0.0) {
|
||||||
val passCode = generatePasscode()
|
val passCode = generatePasscode()
|
||||||
val reply = if (isMeal) {
|
val reply = if (isMeal)
|
||||||
String.format(MainApp.gs(R.string.smscommunicator_mealbolusreplywithcode), bolus, passCode)
|
String.format(MainApp.gs(R.string.smscommunicator_mealbolusreplywithcode), bolus, passCode)
|
||||||
} else {
|
else
|
||||||
String.format(MainApp.gs(R.string.smscommunicator_bolusreplywithcode), bolus, passCode)
|
String.format(MainApp.gs(R.string.smscommunicator_bolusreplywithcode), bolus, passCode)
|
||||||
}
|
|
||||||
receivedSms.processed = true
|
receivedSms.processed = true
|
||||||
messageToConfirm = AuthRequest(this, receivedSms, reply, passCode, object : SmsAction(bolus) {
|
messageToConfirm = AuthRequest(this, receivedSms, reply, passCode, object : SmsAction(bolus) {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
|
@ -587,19 +605,23 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
ConfigBuilderPlugin.getPlugin().commandQueue.readStatus("SMS", object : Callback() {
|
ConfigBuilderPlugin.getPlugin().commandQueue.readStatus("SMS", object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (resultSuccess) {
|
if (resultSuccess) {
|
||||||
var replyText = if (isMeal) {
|
var replyText = if (isMeal)
|
||||||
String.format(MainApp.gs(R.string.smscommunicator_mealbolusdelivered), resultBolusDelivered)
|
String.format(MainApp.gs(R.string.smscommunicator_mealbolusdelivered), resultBolusDelivered)
|
||||||
} else {
|
else
|
||||||
String.format(MainApp.gs(R.string.smscommunicator_bolusdelivered), resultBolusDelivered)
|
String.format(MainApp.gs(R.string.smscommunicator_bolusdelivered), resultBolusDelivered)
|
||||||
}
|
|
||||||
replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true)
|
replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true)
|
||||||
lastRemoteBolusTime = DateUtil.now()
|
lastRemoteBolusTime = DateUtil.now()
|
||||||
if (isMeal) {
|
if (isMeal) {
|
||||||
ProfileFunctions.getInstance().profile?.let { currentProfile ->
|
ProfileFunctions.getInstance().profile?.let { currentProfile ->
|
||||||
var eatingSoonTTDuration = SP.getInt(R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration)
|
var eatingSoonTTDuration = SP.getInt(R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration)
|
||||||
eatingSoonTTDuration = if (eatingSoonTTDuration > 0) eatingSoonTTDuration else Constants.defaultEatingSoonTTDuration
|
eatingSoonTTDuration =
|
||||||
|
if (eatingSoonTTDuration > 0) eatingSoonTTDuration
|
||||||
|
else Constants.defaultEatingSoonTTDuration
|
||||||
var eatingSoonTT = SP.getDouble(R.string.key_eatingsoon_target, if (currentProfile.units == Constants.MMOL) Constants.defaultEatingSoonTTmmol else Constants.defaultEatingSoonTTmgdl)
|
var eatingSoonTT = SP.getDouble(R.string.key_eatingsoon_target, if (currentProfile.units == Constants.MMOL) Constants.defaultEatingSoonTTmmol else Constants.defaultEatingSoonTTmgdl)
|
||||||
eatingSoonTT = if (eatingSoonTT > 0) eatingSoonTT else if (currentProfile.units == Constants.MMOL) Constants.defaultEatingSoonTTmmol else Constants.defaultEatingSoonTTmgdl
|
eatingSoonTT =
|
||||||
|
if (eatingSoonTT > 0) eatingSoonTT
|
||||||
|
else if (currentProfile.units == Constants.MMOL) Constants.defaultEatingSoonTTmmol
|
||||||
|
else Constants.defaultEatingSoonTTmgdl
|
||||||
val tempTarget = TempTarget()
|
val tempTarget = TempTarget()
|
||||||
.date(System.currentTimeMillis())
|
.date(System.currentTimeMillis())
|
||||||
.duration(eatingSoonTTDuration)
|
.duration(eatingSoonTTDuration)
|
||||||
|
@ -629,6 +651,47 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
} else sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
} else sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun processCARBS(splitted: Array<String>, receivedSms: Sms) {
|
||||||
|
var grams = SafeParse.stringToInt(splitted[1])
|
||||||
|
var time = DateUtil.now()
|
||||||
|
if (splitted.size > 2) {
|
||||||
|
val seconds = DateUtil.toSeconds(splitted[2].toUpperCase(Locale.getDefault()))
|
||||||
|
val midnight = MidnightTime.calc()
|
||||||
|
if (seconds == 0 && (!splitted[2].startsWith("00:00") || !splitted[2].startsWith("12:00"))) {
|
||||||
|
sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
time = midnight + T.secs(seconds.toLong()).msecs()
|
||||||
|
}
|
||||||
|
grams = MainApp.getConstraintChecker().applyCarbsConstraints(Constraint(grams)).value()
|
||||||
|
if (grams == 0) sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))
|
||||||
|
else {
|
||||||
|
val passCode = generatePasscode()
|
||||||
|
val reply = String.format(MainApp.gs(R.string.smscommunicator_carbsreplywithcode), grams, DateUtil.timeString(time), passCode)
|
||||||
|
receivedSms.processed = true
|
||||||
|
messageToConfirm = AuthRequest(this, receivedSms, reply, passCode, object : SmsAction(grams, time) {
|
||||||
|
override fun run() {
|
||||||
|
val detailedBolusInfo = DetailedBolusInfo()
|
||||||
|
detailedBolusInfo.carbs = anInteger.toDouble()
|
||||||
|
detailedBolusInfo.date = secondLong
|
||||||
|
ConfigBuilderPlugin.getPlugin().commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||||
|
override fun run() {
|
||||||
|
if (result.success) {
|
||||||
|
var replyText = String.format(MainApp.gs(R.string.smscommunicator_carbsset), anInteger)
|
||||||
|
replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true)
|
||||||
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
|
} else {
|
||||||
|
var replyText = MainApp.gs(R.string.smscommunicator_carbsfailed)
|
||||||
|
replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true)
|
||||||
|
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun processTARGET(splitted: Array<String>, receivedSms: Sms) {
|
private fun processTARGET(splitted: Array<String>, receivedSms: Sms) {
|
||||||
val isMeal = splitted[1].equals("MEAL", ignoreCase = true)
|
val isMeal = splitted[1].equals("MEAL", ignoreCase = true)
|
||||||
val isActivity = splitted[1].equals("ACTIVITY", ignoreCase = true)
|
val isActivity = splitted[1].equals("ACTIVITY", ignoreCase = true)
|
||||||
|
@ -741,7 +804,8 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
sms.text = stripAccents(sms.text)
|
sms.text = stripAccents(sms.text)
|
||||||
try {
|
try {
|
||||||
if (L.isEnabled(L.SMS)) log.debug("Sending SMS to " + sms.phoneNumber + ": " + sms.text)
|
if (L.isEnabled(L.SMS)) log.debug("Sending SMS to " + sms.phoneNumber + ": " + sms.text)
|
||||||
if (sms.text.toByteArray().size <= 140) smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null) else {
|
if (sms.text.toByteArray().size <= 140) smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null)
|
||||||
|
else {
|
||||||
val parts = smsManager.divideMessage(sms.text)
|
val parts = smsManager.divideMessage(sms.text)
|
||||||
smsManager.sendMultipartTextMessage(sms.phoneNumber, null, parts,
|
smsManager.sendMultipartTextMessage(sms.phoneNumber, null, parts,
|
||||||
null, null)
|
null, null)
|
||||||
|
@ -797,4 +861,4 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
||||||
}
|
}
|
||||||
return countNumbers > 1
|
return countNumbers > 1
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -93,15 +93,15 @@ public class DateUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int toSeconds(String hh_colon_mm) {
|
public static int toSeconds(String hh_colon_mm) {
|
||||||
Pattern p = Pattern.compile("(\\d+):(\\d+)( a.m.| p.m.| AM | PM|)");
|
Pattern p = Pattern.compile("(\\d+):(\\d+)( a.m.| p.m.| AM| PM|AM|PM|)");
|
||||||
Matcher m = p.matcher(hh_colon_mm);
|
Matcher m = p.matcher(hh_colon_mm);
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
if (m.find()) {
|
if (m.find()) {
|
||||||
retval = SafeParse.stringToInt(m.group(1)) * 60 * 60 + SafeParse.stringToInt(m.group(2)) * 60;
|
retval = SafeParse.stringToInt(m.group(1)) * 60 * 60 + SafeParse.stringToInt(m.group(2)) * 60;
|
||||||
if ((m.group(3).equals(" a.m.") || m.group(3).equals(" AM")) && m.group(1).equals("12"))
|
if ((m.group(3).equals(" a.m.") || m.group(3).equals(" AM") || m.group(3).equals("AM")) && m.group(1).equals("12"))
|
||||||
retval -= 12 * 60 * 60;
|
retval -= 12 * 60 * 60;
|
||||||
if ((m.group(3).equals(" p.m.") || m.group(3).equals(" PM")) && !(m.group(1).equals("12")))
|
if ((m.group(3).equals(" p.m.") || m.group(3).equals(" PM") || m.group(3).equals("PM")) && !(m.group(1).equals("12")))
|
||||||
retval += 12 * 60 * 60;
|
retval += 12 * 60 * 60;
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
@ -367,10 +367,13 @@
|
||||||
<string name="smscommunicator_basalreplywithcode">To start basal %1$.2fU/h for %2$d min reply with code %3$s</string>
|
<string name="smscommunicator_basalreplywithcode">To start basal %1$.2fU/h for %2$d min reply with code %3$s</string>
|
||||||
<string name="smscommunicator_profilereplywithcode">To switch profile to %1$s %2$d%% reply with code %3$s</string>
|
<string name="smscommunicator_profilereplywithcode">To switch profile to %1$s %2$d%% reply with code %3$s</string>
|
||||||
<string name="smscommunicator_extendedreplywithcode">To start extended bolus %1$.2fU for %2$d min reply with code %3$s</string>
|
<string name="smscommunicator_extendedreplywithcode">To start extended bolus %1$.2fU for %2$d min reply with code %3$s</string>
|
||||||
|
<string name="smscommunicator_carbsreplywithcode">To enter %1$dg at %2$s reply with code %3$s</string>
|
||||||
<string name="smscommunicator_basalpctreplywithcode">To start basal %1$d%% for %2$d min reply with code %3$s</string>
|
<string name="smscommunicator_basalpctreplywithcode">To start basal %1$d%% for %2$d min reply with code %3$s</string>
|
||||||
<string name="smscommunicator_suspendreplywithcode">To suspend loop for %1$d minutes reply with code %2$s</string>
|
<string name="smscommunicator_suspendreplywithcode">To suspend loop for %1$d minutes reply with code %2$s</string>
|
||||||
<string name="smscommunicator_tempbasalset">Temp basal %1$.2fU/h for %2$d min started successfully</string>
|
<string name="smscommunicator_tempbasalset">Temp basal %1$.2fU/h for %2$d min started successfully</string>
|
||||||
<string name="smscommunicator_extendedset">Extended bolus %1$.2fU for %2$d min started successfully</string>
|
<string name="smscommunicator_extendedset">Extended bolus %1$.2fU for %2$d min started successfully</string>
|
||||||
|
<string name="smscommunicator_carbsset">Carbs %1$dg entered successfully</string>
|
||||||
|
<string name="smscommunicator_carbsfailed">Entering %1$dg of carbs failed</string>
|
||||||
<string name="smscommunicator_tempbasalset_percent">Temp basal %1$d%% for %2$d min started successfully</string>
|
<string name="smscommunicator_tempbasalset_percent">Temp basal %1$d%% for %2$d min started successfully</string>
|
||||||
<string name="smscommunicator_tempbasalfailed">Temp basal start failed</string>
|
<string name="smscommunicator_tempbasalfailed">Temp basal start failed</string>
|
||||||
<string name="smscommunicator_extendedfailed">Extended bolus start failed</string>
|
<string name="smscommunicator_extendedfailed">Extended bolus start failed</string>
|
||||||
|
|
|
@ -37,6 +37,7 @@ import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.anyLong;
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
@ -158,6 +159,8 @@ public class AAPSMocker {
|
||||||
when(MainApp.gs(R.string.smscommunicator_mealbolusreplywithcode)).thenReturn("To deliver meal bolus %1$.2fU reply with code %2$s");
|
when(MainApp.gs(R.string.smscommunicator_mealbolusreplywithcode)).thenReturn("To deliver meal bolus %1$.2fU reply with code %2$s");
|
||||||
when(MainApp.gs(R.string.smscommunicator_mealbolusdelivered)).thenReturn("Meal Bolus %1$.2fU delivered successfully");
|
when(MainApp.gs(R.string.smscommunicator_mealbolusdelivered)).thenReturn("Meal Bolus %1$.2fU delivered successfully");
|
||||||
when(MainApp.gs(R.string.smscommunicator_mealbolusdelivered_tt)).thenReturn("Target %1$s for %2$d minutes");
|
when(MainApp.gs(R.string.smscommunicator_mealbolusdelivered_tt)).thenReturn("Target %1$s for %2$d minutes");
|
||||||
|
when(MainApp.gs(R.string.smscommunicator_carbsreplywithcode)).thenReturn("To enter %1$dg at %2$s reply with code %3$s");
|
||||||
|
when(MainApp.gs(R.string.smscommunicator_carbsset)).thenReturn("Carbs %1$dg entered successfully");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MainApp mockMainApp() {
|
public static MainApp mockMainApp() {
|
||||||
|
@ -186,6 +189,7 @@ public class AAPSMocker {
|
||||||
when(SP.getLong(anyInt(), anyLong())).thenReturn(0L);
|
when(SP.getLong(anyInt(), anyLong())).thenReturn(0L);
|
||||||
when(SP.getBoolean(anyInt(), anyBoolean())).thenReturn(false);
|
when(SP.getBoolean(anyInt(), anyBoolean())).thenReturn(false);
|
||||||
when(SP.getInt(anyInt(), anyInt())).thenReturn(0);
|
when(SP.getInt(anyInt(), anyInt())).thenReturn(0);
|
||||||
|
when(SP.getString(anyInt(), anyString())).thenReturn("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void mockL() {
|
public static void mockL() {
|
||||||
|
|
|
@ -75,12 +75,6 @@ public class AuthRequestTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void prepareTests() {
|
public void prepareTests() {
|
||||||
smsCommunicatorPlugin = mock(SmsCommunicatorPlugin.class);
|
|
||||||
doAnswer((Answer) invocation -> {
|
|
||||||
sentSms = invocation.getArgument(0);
|
|
||||||
return null;
|
|
||||||
}).when(smsCommunicatorPlugin).sendSMS(any(Sms.class));
|
|
||||||
|
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
|
@ -88,5 +82,12 @@ public class AuthRequestTest {
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
|
|
||||||
mockStatic(DateUtil.class);
|
mockStatic(DateUtil.class);
|
||||||
|
|
||||||
|
smsCommunicatorPlugin = mock(SmsCommunicatorPlugin.class);
|
||||||
|
doAnswer((Answer) invocation -> {
|
||||||
|
sentSms = invocation.getArgument(0);
|
||||||
|
return null;
|
||||||
|
}).when(smsCommunicatorPlugin).sendSMS(any(Sms.class));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.powermock.api.mockito.PowerMockito.doAnswer;
|
import static org.powermock.api.mockito.PowerMockito.doAnswer;
|
||||||
import static org.powermock.api.mockito.PowerMockito.mock;
|
import static org.powermock.api.mockito.PowerMockito.mock;
|
||||||
import static org.powermock.api.mockito.PowerMockito.mockStatic;
|
import static org.powermock.api.mockito.PowerMockito.mockStatic;
|
||||||
|
import static org.powermock.api.mockito.PowerMockito.spy;
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
|
@ -720,6 +721,87 @@ public class SmsCommunicatorPluginTest {
|
||||||
Assert.assertEquals("Calibration sent. Receiving must be enabled in xDrip.", smsCommunicatorPlugin.getMessages().get(3).text);
|
Assert.assertEquals("Calibration sent. Receiving must be enabled in xDrip.", smsCommunicatorPlugin.getMessages().get(3).text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void processCarbsTest() {
|
||||||
|
Sms sms;
|
||||||
|
|
||||||
|
when(DateUtil.now()).thenReturn(1000000L);
|
||||||
|
when(SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(false);
|
||||||
|
//CAL
|
||||||
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
||||||
|
sms = new Sms("1234", "CARBS");
|
||||||
|
smsCommunicatorPlugin.processSms(sms);
|
||||||
|
Assert.assertEquals("CARBS", smsCommunicatorPlugin.getMessages().get(0).text);
|
||||||
|
Assert.assertEquals("Remote command is not allowed", smsCommunicatorPlugin.getMessages().get(1).text);
|
||||||
|
|
||||||
|
when(SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(true);
|
||||||
|
|
||||||
|
//CARBS
|
||||||
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
||||||
|
sms = new Sms("1234", "CARBS");
|
||||||
|
smsCommunicatorPlugin.processSms(sms);
|
||||||
|
Assert.assertEquals("CARBS", smsCommunicatorPlugin.getMessages().get(0).text);
|
||||||
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
||||||
|
|
||||||
|
when(MainApp.getConstraintChecker().applyCarbsConstraints(any())).thenReturn(new Constraint<>(0));
|
||||||
|
|
||||||
|
//CARBS 0
|
||||||
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
||||||
|
sms = new Sms("1234", "CARBS 0");
|
||||||
|
smsCommunicatorPlugin.processSms(sms);
|
||||||
|
Assert.assertEquals("CARBS 0", smsCommunicatorPlugin.getMessages().get(0).text);
|
||||||
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
||||||
|
|
||||||
|
when(MainApp.getConstraintChecker().applyCarbsConstraints(any())).thenReturn(new Constraint<>(1));
|
||||||
|
|
||||||
|
//CARBS 1
|
||||||
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
||||||
|
sms = new Sms("1234", "CARBS 1");
|
||||||
|
smsCommunicatorPlugin.processSms(sms);
|
||||||
|
Assert.assertEquals("CARBS 1", smsCommunicatorPlugin.getMessages().get(0).text);
|
||||||
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To enter 1g at 01:16AM reply with code"));
|
||||||
|
String passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
||||||
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
||||||
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
||||||
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).text.startsWith("Carbs 1g entered successfully"));
|
||||||
|
|
||||||
|
//CARBS 1 a
|
||||||
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
||||||
|
sms = new Sms("1234", "CARBS 1 a");
|
||||||
|
smsCommunicatorPlugin.processSms(sms);
|
||||||
|
Assert.assertEquals("CARBS 1 a", smsCommunicatorPlugin.getMessages().get(0).text);
|
||||||
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("Wrong format"));
|
||||||
|
|
||||||
|
//CARBS 1 00
|
||||||
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
||||||
|
sms = new Sms("1234", "CARBS 1 00");
|
||||||
|
smsCommunicatorPlugin.processSms(sms);
|
||||||
|
Assert.assertEquals("CARBS 1 00", smsCommunicatorPlugin.getMessages().get(0).text);
|
||||||
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("Wrong format"));
|
||||||
|
|
||||||
|
//CARBS 1 12:01
|
||||||
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
||||||
|
sms = new Sms("1234", "CARBS 1 12:01");
|
||||||
|
smsCommunicatorPlugin.processSms(sms);
|
||||||
|
Assert.assertEquals("CARBS 1 12:01", smsCommunicatorPlugin.getMessages().get(0).text);
|
||||||
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To enter 1g at 12:01PM reply with code"));
|
||||||
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
||||||
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
||||||
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
||||||
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).text.startsWith("Carbs 1g entered successfully"));
|
||||||
|
|
||||||
|
//CARBS 1 3:01AM
|
||||||
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
||||||
|
sms = new Sms("1234", "CARBS 1 3:01AM");
|
||||||
|
smsCommunicatorPlugin.processSms(sms);
|
||||||
|
Assert.assertEquals("CARBS 1 3:01AM", smsCommunicatorPlugin.getMessages().get(0).text);
|
||||||
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To enter 1g at 03:01AM reply with code"));
|
||||||
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
||||||
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
||||||
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
||||||
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).text.startsWith("Carbs 1g entered successfully"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendNotificationToAllNumbers() {
|
public void sendNotificationToAllNumbers() {
|
||||||
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
||||||
|
@ -752,7 +834,7 @@ public class SmsCommunicatorPluginTest {
|
||||||
PowerMockito.when(IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "SMS COB")).thenReturn(new CobInfo(10d, 2d));
|
PowerMockito.when(IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "SMS COB")).thenReturn(new CobInfo(10d, 2d));
|
||||||
|
|
||||||
mockStatic(XdripCalibrations.class);
|
mockStatic(XdripCalibrations.class);
|
||||||
mockStatic(DateUtil.class);
|
spy(DateUtil.class);
|
||||||
mockStatic(SmsManager.class);
|
mockStatic(SmsManager.class);
|
||||||
SmsManager smsManager = mock(SmsManager.class);
|
SmsManager smsManager = mock(SmsManager.class);
|
||||||
when(SmsManager.getDefault()).thenReturn(smsManager);
|
when(SmsManager.getDefault()).thenReturn(smsManager);
|
||||||
|
|
Loading…
Reference in a new issue