remove MainApp::getSpecificPlugin
This commit is contained in:
parent
56152fa1fa
commit
d2a4aea9e2
|
@ -415,19 +415,6 @@ public class MainApp extends Application {
|
|||
return newList;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T extends PluginBase> T getSpecificPlugin(Class<T> pluginClass) {
|
||||
if (pluginsList != null) {
|
||||
for (PluginBase p : pluginsList) {
|
||||
if (pluginClass.isAssignableFrom(p.getClass()))
|
||||
return (T) p;
|
||||
}
|
||||
} else {
|
||||
log.error("pluginsList=null");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isEngineeringModeOrRelease() {
|
||||
if (!Config.APS)
|
||||
return true;
|
||||
|
|
|
@ -536,11 +536,11 @@ public class TDDStatsActivity extends NoSplashActivity {
|
|||
|
||||
public static boolean isOldData(List<TDD> historyList) {
|
||||
Object activePump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
PumpInterface dana = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||
PumpInterface danaRS = MainApp.getSpecificPlugin(DanaRSPlugin.class);
|
||||
PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||
PumpInterface danaKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
||||
PumpInterface insight = MainApp.getSpecificPlugin(LocalInsightPlugin.class);
|
||||
PumpInterface dana = DanaRPlugin.getPlugin();
|
||||
PumpInterface danaRS = DanaRSPlugin.getPlugin();
|
||||
PumpInterface danaV2 = DanaRv2Plugin.getPlugin();
|
||||
PumpInterface danaKorean = DanaRKoreanPlugin.getPlugin();
|
||||
PumpInterface insight = LocalInsightPlugin.getPlugin();
|
||||
|
||||
boolean startsYesterday = activePump == dana || activePump == danaRS || activePump == danaV2 || activePump == danaKorean || activePump == insight;
|
||||
|
||||
|
|
|
@ -122,8 +122,7 @@ public class FoodFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp
|
||||
.getSpecificPlugin(FoodPlugin.class).getService().getFoodData());
|
||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(FoodPlugin.getPlugin().getService().getFoodData());
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
loadData();
|
||||
|
@ -151,7 +150,7 @@ public class FoodFragment extends Fragment {
|
|||
}
|
||||
|
||||
void loadData() {
|
||||
unfiltered = MainApp.getSpecificPlugin(FoodPlugin.class).getService().getFoodData();
|
||||
unfiltered = FoodPlugin.getPlugin().getService().getFoodData();
|
||||
}
|
||||
|
||||
void fillCategories() {
|
||||
|
@ -297,7 +296,7 @@ public class FoodFragment extends Fragment {
|
|||
if (_id != null && !_id.equals("")) {
|
||||
NSUpload.removeFoodFromNS(_id);
|
||||
}
|
||||
MainApp.getSpecificPlugin(FoodPlugin.class).getService().delete(food);
|
||||
FoodPlugin.getPlugin().getService().delete(food);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
||||
|
|
|
@ -27,7 +27,7 @@ public class AckAlarmReceiver extends BroadcastReceiver {
|
|||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
||||
AckAlarmReceiver.class.getSimpleName());
|
||||
NSClientPlugin nsClientPlugin = MainApp.getSpecificPlugin(NSClientPlugin.class);
|
||||
NSClientPlugin nsClientPlugin = NSClientPlugin.getPlugin();
|
||||
if (!nsClientPlugin.isEnabled(PluginType.GENERAL)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ public class DBAccessReceiver extends BroadcastReceiver {
|
|||
}
|
||||
|
||||
public boolean shouldUpload() {
|
||||
NSClientPlugin nsClientPlugin = MainApp.getSpecificPlugin(NSClientPlugin.class);
|
||||
NSClientPlugin nsClientPlugin = NSClientPlugin.getPlugin();
|
||||
return nsClientPlugin.isEnabled(PluginType.GENERAL) && !SP.getBoolean(R.string.key_ns_noupload, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -265,10 +265,10 @@ public class NSClientService extends Service {
|
|||
nsAPIhashCode = Hashing.sha1().hashString(nsAPISecret, Charsets.UTF_8).toString();
|
||||
|
||||
RxBus.INSTANCE.send(new EventNSClientStatus("Initializing"));
|
||||
if (!MainApp.getSpecificPlugin(NSClientPlugin.class).isAllowed()) {
|
||||
if (!NSClientPlugin.getPlugin().isAllowed()) {
|
||||
RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "not allowed"));
|
||||
RxBus.INSTANCE.send(new EventNSClientStatus("Not allowed"));
|
||||
} else if (MainApp.getSpecificPlugin(NSClientPlugin.class).paused) {
|
||||
} else if (NSClientPlugin.getPlugin().paused) {
|
||||
RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "paused"));
|
||||
RxBus.INSTANCE.send(new EventNSClientStatus("Paused"));
|
||||
} else if (!nsEnabled) {
|
||||
|
@ -386,7 +386,7 @@ public class NSClientService extends Service {
|
|||
}
|
||||
|
||||
public void readPreferences() {
|
||||
nsEnabled = MainApp.getSpecificPlugin(NSClientPlugin.class).isEnabled(PluginType.GENERAL);
|
||||
nsEnabled = NSClientPlugin.getPlugin().isEnabled(PluginType.GENERAL);
|
||||
nsURL = SP.getString(R.string.key_nsclientinternal_url, "");
|
||||
nsAPISecret = SP.getString(R.string.key_nsclientinternal_api_secret, "");
|
||||
nsDevice = SP.getString("careportal_enteredby", "");
|
||||
|
|
|
@ -1146,7 +1146,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
}
|
||||
|
||||
// **** Calibration & CGM buttons ****
|
||||
boolean xDripIsBgSource = MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginType.BGSOURCE);
|
||||
boolean xDripIsBgSource = SourceXdripPlugin.getPlugin().isEnabled(PluginType.BGSOURCE);
|
||||
boolean dexcomIsSource = SourceDexcomPlugin.INSTANCE.isEnabled(PluginType.BGSOURCE);
|
||||
boolean bgAvailable = DatabaseHelper.actualBg() != null;
|
||||
if (calibrationButton != null) {
|
||||
|
|
|
@ -310,8 +310,8 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
switch (splitted[1].toUpperCase()) {
|
||||
case "DISABLE":
|
||||
case "STOP":
|
||||
LoopPlugin loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
|
||||
if (loopPlugin != null && loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
loopPlugin.setPluginEnabled(PluginType.LOOP, false);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
|
@ -329,8 +329,8 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
break;
|
||||
case "ENABLE":
|
||||
case "START":
|
||||
loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
|
||||
if (loopPlugin != null && !loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
loopPlugin = LoopPlugin.getPlugin();
|
||||
if (!loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, R.string.smscommunicator_loophasbeenenabled));
|
||||
RxBus.INSTANCE.send(new EventRefreshOverview("SMS_LOOP_START"));
|
||||
|
@ -340,8 +340,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
receivedSms.processed = true;
|
||||
break;
|
||||
case "STATUS":
|
||||
loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
|
||||
if (loopPlugin != null) {
|
||||
loopPlugin = LoopPlugin.getPlugin();
|
||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
if (loopPlugin.isSuspended())
|
||||
reply = String.format(MainApp.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend());
|
||||
|
@ -351,7 +350,6 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
reply = MainApp.gs(R.string.smscommunicator_loopisdisabled);
|
||||
}
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply));
|
||||
}
|
||||
receivedSms.processed = true;
|
||||
break;
|
||||
case "RESUME":
|
||||
|
|
|
@ -437,11 +437,11 @@ public class ActionStringHandler {
|
|||
|
||||
public static boolean isOldData(List<TDD> historyList) {
|
||||
Object activePump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
PumpInterface dana = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||
PumpInterface danaRS = MainApp.getSpecificPlugin(DanaRSPlugin.class);
|
||||
PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||
PumpInterface danaKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
||||
PumpInterface insight = MainApp.getSpecificPlugin(LocalInsightPlugin.class);
|
||||
PumpInterface dana = DanaRPlugin.getPlugin();
|
||||
PumpInterface danaRS = DanaRSPlugin.getPlugin();
|
||||
PumpInterface danaV2 = DanaRv2Plugin.getPlugin();
|
||||
PumpInterface danaKorean = DanaRKoreanPlugin.getPlugin();
|
||||
PumpInterface insight = LocalInsightPlugin.getPlugin();
|
||||
|
||||
boolean startsYesterday = activePump == dana || activePump == danaRS || activePump == danaV2 || activePump == danaKorean || activePump == insight;
|
||||
|
||||
|
|
|
@ -51,9 +51,9 @@ public class DanaRUserOptionsActivity extends NoSplashActivity {
|
|||
NumberPicker lowReservoir;
|
||||
Button saveToPumpButton;
|
||||
// This is for Dana pumps only
|
||||
boolean isRS = MainApp.getSpecificPlugin(DanaRSPlugin.class) != null && MainApp.getSpecificPlugin(DanaRSPlugin.class).isEnabled(PluginType.PUMP);
|
||||
boolean isDanaR = MainApp.getSpecificPlugin(DanaRPlugin.class) != null && MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginType.PUMP);
|
||||
boolean isDanaRv2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class) != null && MainApp.getSpecificPlugin(DanaRv2Plugin.class).isEnabled(PluginType.PUMP);
|
||||
boolean isRS = DanaRSPlugin.getPlugin().isEnabled(PluginType.PUMP);
|
||||
boolean isDanaR = DanaRPlugin.getPlugin().isEnabled(PluginType.PUMP);
|
||||
boolean isDanaRv2 = DanaRv2Plugin.getPlugin().isEnabled(PluginType.PUMP);
|
||||
|
||||
@Override
|
||||
protected synchronized void onResume() {
|
||||
|
|
|
@ -32,7 +32,7 @@ public class MsgCheckValue extends MessageBase {
|
|||
pump.protocol = intFromBuff(bytes, 1, 1);
|
||||
pump.productCode = intFromBuff(bytes, 2, 1);
|
||||
if (pump.model != DanaRPump.EXPORT_MODEL) {
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model");
|
||||
DanaRPlugin.getPlugin().disconnect("Wrong Model");
|
||||
log.debug("Wrong model selected");
|
||||
}
|
||||
|
||||
|
|
|
@ -31,19 +31,19 @@ public class MsgInitConnStatusTime extends MessageBase {
|
|||
if (bytes.length - 10 > 7) {
|
||||
Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL);
|
||||
RxBus.INSTANCE.send(new EventNewNotification(notification));
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model");
|
||||
DanaRPlugin.getPlugin().disconnect("Wrong Model");
|
||||
log.error("Wrong model selected. Switching to Korean DanaR");
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, false);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentVisible(PluginType.PUMP, false);
|
||||
DanaRKoreanPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, true);
|
||||
DanaRKoreanPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, true);
|
||||
DanaRPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, false);
|
||||
DanaRPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, false);
|
||||
|
||||
DanaRPump.reset(); // mark not initialized
|
||||
|
||||
//If profile coming from pump, switch it as well
|
||||
if (MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginType.PROFILE)) {
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, false);
|
||||
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
|
||||
if (DanaRPlugin.getPlugin().isEnabled(PluginType.PROFILE)) {
|
||||
(DanaRPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, false);
|
||||
(DanaRKoreanPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, true);
|
||||
}
|
||||
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("ChangingDanaDriver");
|
||||
|
|
|
@ -35,17 +35,17 @@ public class MsgInitConnStatusTime_k extends MessageBase {
|
|||
RxBus.INSTANCE.send(new EventNewNotification(notification));
|
||||
DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model");
|
||||
log.error("Wrong model selected. Switching to export DanaR");
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, false);
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, false);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentVisible(PluginType.PUMP, true);
|
||||
DanaRKoreanPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, false);
|
||||
DanaRKoreanPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, false);
|
||||
DanaRPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, true);
|
||||
DanaRPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, true);
|
||||
|
||||
DanaRPump.reset(); // mark not initialized
|
||||
|
||||
//If profile coming from pump, switch it as well
|
||||
if (MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginType.PROFILE)) {
|
||||
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, false);
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
|
||||
if (DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PROFILE)) {
|
||||
(DanaRKoreanPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, false);
|
||||
(DanaRPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, true);
|
||||
}
|
||||
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("ChangingKoreanDanaDriver");
|
||||
|
|
|
@ -249,7 +249,7 @@ public class DanaRSService extends Service {
|
|||
|
||||
public PumpEnactResult loadEvents() {
|
||||
|
||||
if (!MainApp.getSpecificPlugin(DanaRSPlugin.class).isInitialized()) {
|
||||
if (!DanaRSPlugin.getPlugin().isInitialized()) {
|
||||
PumpEnactResult result = new PumpEnactResult().success(false);
|
||||
result.comment = "pump not initialized";
|
||||
return result;
|
||||
|
|
|
@ -45,19 +45,19 @@ public class MsgCheckValue_v2 extends MessageBase {
|
|||
pump.lastConnection = 0;
|
||||
Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL);
|
||||
RxBus.INSTANCE.send(new EventNewNotification(notification));
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model");
|
||||
DanaRPlugin.getPlugin().disconnect("Wrong Model");
|
||||
log.error("Wrong model selected. Switching to Korean DanaR");
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, false);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentVisible(PluginType.PUMP, false);
|
||||
DanaRKoreanPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, true);
|
||||
DanaRKoreanPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, true);
|
||||
DanaRPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, false);
|
||||
DanaRPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, false);
|
||||
|
||||
DanaRPump.reset(); // mark not initialized
|
||||
|
||||
//If profile coming from pump, switch it as well
|
||||
if (MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginType.PROFILE)) {
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, false);
|
||||
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
|
||||
if (DanaRPlugin.getPlugin().isEnabled(PluginType.PROFILE)) {
|
||||
(DanaRPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, false);
|
||||
(DanaRKoreanPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, true);
|
||||
}
|
||||
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("ChangingDanaRv2Driver");
|
||||
|
@ -72,15 +72,15 @@ public class MsgCheckValue_v2 extends MessageBase {
|
|||
RxBus.INSTANCE.send(new EventNewNotification(notification));
|
||||
DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model");
|
||||
log.error("Wrong model selected. Switching to non APS DanaR");
|
||||
(MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setPluginEnabled(PluginType.PUMP, false);
|
||||
(MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setFragmentVisible(PluginType.PUMP, false);
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PUMP, true);
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setFragmentVisible(PluginType.PUMP, true);
|
||||
(DanaRv2Plugin.getPlugin()).setPluginEnabled(PluginType.PUMP, false);
|
||||
(DanaRv2Plugin.getPlugin()).setFragmentVisible(PluginType.PUMP, false);
|
||||
(DanaRPlugin.getPlugin()).setPluginEnabled(PluginType.PUMP, true);
|
||||
(DanaRPlugin.getPlugin()).setFragmentVisible(PluginType.PUMP, true);
|
||||
|
||||
//If profile coming from pump, switch it as well
|
||||
if (MainApp.getSpecificPlugin(DanaRv2Plugin.class).isEnabled(PluginType.PROFILE)) {
|
||||
(MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setPluginEnabled(PluginType.PROFILE, false);
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
|
||||
if (DanaRv2Plugin.getPlugin().isEnabled(PluginType.PROFILE)) {
|
||||
(DanaRv2Plugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, false);
|
||||
(DanaRPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, true);
|
||||
}
|
||||
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("ChangingDanaRv2Driver");
|
||||
|
|
|
@ -471,7 +471,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
public PumpEnactResult loadEvents() {
|
||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||
|
||||
if (!MainApp.getSpecificPlugin(DanaRv2Plugin.class).isInitialized()) {
|
||||
if (!DanaRv2Plugin.getPlugin().isInitialized()) {
|
||||
PumpEnactResult result = new PumpEnactResult().success(false);
|
||||
result.comment = "pump not initialized";
|
||||
return result;
|
||||
|
|
|
@ -50,8 +50,8 @@ public class CommandSetProfile extends Command {
|
|||
// Send SMS notification if ProfileSwitch is comming from NS
|
||||
ProfileSwitch profileSwitch = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(System.currentTimeMillis());
|
||||
if (profileSwitch != null && r.enacted && profileSwitch.source == Source.NIGHTSCOUT) {
|
||||
SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class);
|
||||
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginType.GENERAL)) {
|
||||
SmsCommunicatorPlugin smsCommunicatorPlugin = SmsCommunicatorPlugin.getPlugin();
|
||||
if (smsCommunicatorPlugin.isEnabled(PluginType.GENERAL)) {
|
||||
smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.gs(R.string.profile_set_ok));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import static org.mockito.ArgumentMatchers.any;
|
|||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -234,17 +235,6 @@ public class AAPSMocker {
|
|||
|
||||
}
|
||||
|
||||
public static DanaRPlugin mockDanaRPlugin() {
|
||||
PowerMockito.mockStatic(DanaRPlugin.class);
|
||||
DanaRPlugin danaRPlugin = mock(DanaRPlugin.class);
|
||||
DanaRv2Plugin danaRv2Plugin = mock(DanaRv2Plugin.class);
|
||||
DanaRKoreanPlugin danaRKoreanPlugin = mock(DanaRKoreanPlugin.class);
|
||||
when(MainApp.getSpecificPlugin(DanaRPlugin.class)).thenReturn(danaRPlugin);
|
||||
when(MainApp.getSpecificPlugin(DanaRv2Plugin.class)).thenReturn(danaRv2Plugin);
|
||||
when(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).thenReturn(danaRKoreanPlugin);
|
||||
return danaRPlugin;
|
||||
}
|
||||
|
||||
public static Profile getValidProfile() {
|
||||
try {
|
||||
if (profile == null)
|
||||
|
|
|
@ -57,7 +57,7 @@ import static org.powermock.api.mockito.PowerMockito.when;
|
|||
L.class, SP.class, MainApp.class, DateUtil.class, ProfileFunctions.class,
|
||||
TreatmentsPlugin.class, SmsManager.class, IobCobCalculatorPlugin.class,
|
||||
CommandQueue.class, ConfigBuilderPlugin.class, NSUpload.class, ProfileInterface.class,
|
||||
SimpleProfilePlugin.class, XdripCalibrations.class, VirtualPumpPlugin.class
|
||||
SimpleProfilePlugin.class, XdripCalibrations.class, VirtualPumpPlugin.class, LoopPlugin.class
|
||||
})
|
||||
|
||||
public class SmsCommunicatorPluginTest {
|
||||
|
@ -744,8 +744,9 @@ public class SmsCommunicatorPluginTest {
|
|||
smsCommunicatorPlugin = SmsCommunicatorPlugin.getPlugin();
|
||||
smsCommunicatorPlugin.setPluginEnabled(PluginType.GENERAL, true);
|
||||
|
||||
mockStatic(LoopPlugin.class);
|
||||
loopPlugin = mock(LoopPlugin.class);
|
||||
when(MainApp.getSpecificPlugin(LoopPlugin.class)).thenReturn(loopPlugin);
|
||||
when(LoopPlugin.getPlugin()).thenReturn(loopPlugin);
|
||||
|
||||
Mockito.doAnswer(invocation -> {
|
||||
Callback callback = invocation.getArgument(1);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
|
@ -22,13 +23,6 @@ import static org.junit.Assert.assertEquals;
|
|||
public class MsgInitConnStatusTimeTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockConfigBuilder();
|
||||
AAPSMocker.mockCommandQueue();
|
||||
AAPSMocker.mockDanaRPlugin();
|
||||
MsgInitConnStatusTime packet = new MsgInitConnStatusTime();
|
||||
|
||||
// test message decoding
|
||||
|
@ -56,4 +50,13 @@ public class MsgInitConnStatusTimeTest {
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void mock() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockConfigBuilder();
|
||||
AAPSMocker.mockCommandQueue();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
|
@ -20,17 +21,10 @@ import static org.junit.Assert.*;
|
|||
import static org.powermock.api.mockito.PowerMockito.when;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, DanaRv2Plugin.class, DanaRPlugin.class, ConfigBuilderPlugin.class, CommandQueue.class})
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, ConfigBuilderPlugin.class, CommandQueue.class})
|
||||
public class MsgCheckValue_v2Test {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockDanaRPlugin();
|
||||
AAPSMocker.mockConfigBuilder();
|
||||
AAPSMocker.mockCommandQueue();
|
||||
Treatment t = new Treatment();
|
||||
MsgCheckValue_v2 packet = new MsgCheckValue_v2();
|
||||
// test message decoding
|
||||
|
@ -55,4 +49,13 @@ public class MsgCheckValue_v2Test {
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void mock() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockConfigBuilder();
|
||||
AAPSMocker.mockCommandQueue();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
|
@ -18,15 +19,10 @@ import static org.junit.Assert.*;
|
|||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, DanaRv2Plugin.class, DanaRPlugin.class})
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetHistoryEntry_v2Test {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockDanaRPlugin();
|
||||
|
||||
MsgSetHistoryEntry_v2 initializerTest = new MsgSetHistoryEntry_v2((byte) 1, System.currentTimeMillis(), 1, 0);
|
||||
MsgSetHistoryEntry_v2 packet = new MsgSetHistoryEntry_v2();
|
||||
|
@ -56,4 +52,11 @@ public class MsgSetHistoryEntry_v2Test {
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void mock() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
|
@ -19,16 +20,10 @@ import static org.junit.Assert.*;
|
|||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, DanaRv2Plugin.class, DanaRPlugin.class})
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgStatusTempBasal_v2Test {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockDanaRPlugin();
|
||||
|
||||
MsgStatusTempBasal_v2 packet = new MsgStatusTempBasal_v2();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
// test message decoding
|
||||
|
@ -57,4 +52,12 @@ public class MsgStatusTempBasal_v2Test {
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void mock() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue