Low storage notification

This commit is contained in:
Milos Kozak 2019-03-07 11:32:09 +01:00
parent e8a41b01b7
commit f7c6f60131
4 changed files with 17 additions and 4 deletions

View file

@ -68,4 +68,7 @@ public class Constants {
//SMS Communicator //SMS Communicator
public static final long SMS_CONFIRM_TIMEOUT = T.mins(5).msecs(); public static final long SMS_CONFIRM_TIMEOUT = T.mins(5).msecs();
//Storage [MB]
public static final long MINIMUM_FREE_SPACE = 200;
} }

View file

@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.Constraint;
@ -16,6 +17,9 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
/** /**
* Created by Rumen on 06.03.2019. * Created by Rumen on 06.03.2019.
@ -47,9 +51,14 @@ public class StorageConstraintPlugin extends PluginBase implements ConstraintsIn
@Override @Override
public Constraint<Boolean> isClosedLoopAllowed(Constraint<Boolean> value) { public Constraint<Boolean> isClosedLoopAllowed(Constraint<Boolean> value) {
long diskfree = getAvailableInternalMemorySize(); long diskfree = getAvailableInternalMemorySize();
log.debug("Internal storage free (Mb):"+diskfree); if (L.isEnabled(L.CONSTRAINTS))
if (diskfree < 200) { log.debug("Internal storage free (Mb):" + diskfree);
value.set(false, MainApp.gs(R.string.diskfull), this); if (diskfree < Constants.MINIMUM_FREE_SPACE) {
value.set(false, MainApp.gs(R.string.diskfull, Constants.MINIMUM_FREE_SPACE), this);
Notification notification = new Notification(Notification.DISKFULL, MainApp.gs(R.string.diskfull, Constants.MINIMUM_FREE_SPACE), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
} else {
MainApp.bus().post(new EventDismissNotification(Notification.DISKFULL));
} }
return value; return value;

View file

@ -73,6 +73,7 @@ public class Notification {
public static final int INSIGHT_TIMEOUT_DURING_HANDSHAKE = 48; public static final int INSIGHT_TIMEOUT_DURING_HANDSHAKE = 48;
public static final int DST_LOOP_DISABLED = 49; public static final int DST_LOOP_DISABLED = 49;
public static final int DST_IN_24H = 50; public static final int DST_IN_24H = 50;
public static final int DISKFULL = 51;
public int id; public int id;

View file

@ -1313,7 +1313,7 @@
<string name="dst_in_24h_warning">Dayligh Saving time change in 24h or less</string> <string name="dst_in_24h_warning">Dayligh Saving time change in 24h or less</string>
<string name="dst_loop_disabled_warning">Dayligh Saving time change in less than 3 hours - Closed loop diabled</string> <string name="dst_loop_disabled_warning">Dayligh Saving time change in less than 3 hours - Closed loop diabled</string>
<string name="storage">internal storage constraint</string> <string name="storage">internal storage constraint</string>
<string name="diskfull">Free at least 200Mb from internal storage! Loop disabled!</string> <string name="diskfull">Free at least %1$d MB from internal storage! Loop disabled!</string>
<plurals name="objective_days"> <plurals name="objective_days">
<item quantity="one">%1$d day</item> <item quantity="one">%1$d day</item>
<item quantity="other">%1$d days</item> <item quantity="other">%1$d days</item>