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