Merge pull request #1893 from MilosKozak/lint

lint recommendations - code style
This commit is contained in:
Milos Kozak 2019-07-28 10:28:17 +02:00 committed by GitHub
commit 53b9d97f5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 114 additions and 134 deletions

View file

@ -6,8 +6,9 @@ import info.nightscout.androidaps.plugins.aps.loop.APSResult;
* Created by mike on 10.06.2016. * Created by mike on 10.06.2016.
*/ */
public interface APSInterface { public interface APSInterface {
public APSResult getLastAPSResult(); APSResult getLastAPSResult();
public long getLastAPSRun();
public void invoke(String initiator, boolean tempBasalFallback); long getLastAPSRun();
void invoke(String initiator, boolean tempBasalFallback);
} }

View file

@ -61,6 +61,6 @@ public interface ConstraintsInterface {
default Constraint<Double> applyMaxIOBConstraints(Constraint<Double> maxIob) { default Constraint<Double> applyMaxIOBConstraints(Constraint<Double> maxIob) {
return maxIob; return maxIob;
}; }
} }

View file

@ -18,21 +18,30 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
public interface PumpInterface { public interface PumpInterface {
boolean isInitialized(); // true if pump status has been read and is ready to accept commands boolean isInitialized(); // true if pump status has been read and is ready to accept commands
boolean isSuspended(); // true if suspended (not delivering insulin) boolean isSuspended(); // true if suspended (not delivering insulin)
boolean isBusy(); // if true pump is not ready to accept commands right now boolean isBusy(); // if true pump is not ready to accept commands right now
boolean isConnected(); // true if BT connection is established boolean isConnected(); // true if BT connection is established
boolean isConnecting(); // true if BT connection is in progress boolean isConnecting(); // true if BT connection is in progress
boolean isHandshakeInProgress(); // true if BT is connected but initial handshake is still in progress boolean isHandshakeInProgress(); // true if BT is connected but initial handshake is still in progress
void finishHandshaking(); // set initial handshake completed void finishHandshaking(); // set initial handshake completed
void connect(String reason); void connect(String reason);
void disconnect(String reason); void disconnect(String reason);
void stopConnecting(); void stopConnecting();
void getPumpStatus(); void getPumpStatus();
// Upload to pump new basal profile // Upload to pump new basal profile
PumpEnactResult setNewBasalProfile(Profile profile); PumpEnactResult setNewBasalProfile(Profile profile);
boolean isThisProfileSet(Profile profile); boolean isThisProfileSet(Profile profile);
long lastDataTime(); long lastDataTime();
@ -44,19 +53,28 @@ public interface PumpInterface {
int getBatteryLevel(); // in percent as integer int getBatteryLevel(); // in percent as integer
PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo); PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo);
void stopBolusDelivering(); void stopBolusDelivering();
PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew); PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew);
PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew); PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew);
PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes); PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes);
//some pumps might set a very short temp close to 100% as cancelling a temp can be noisy //some pumps might set a very short temp close to 100% as cancelling a temp can be noisy
//when the cancel request is requested by the user (forced), the pump should always do a real cancel //when the cancel request is requested by the user (forced), the pump should always do a real cancel
PumpEnactResult cancelTempBasal(boolean enforceNew); PumpEnactResult cancelTempBasal(boolean enforceNew);
PumpEnactResult cancelExtendedBolus(); PumpEnactResult cancelExtendedBolus();
// Status to be passed to NS // Status to be passed to NS
JSONObject getJSONStatus(Profile profile, String profileName); JSONObject getJSONStatus(Profile profile, String profileName);
ManufacturerType manufacturer(); ManufacturerType manufacturer();
PumpType model(); PumpType model();
String serialNumber(); String serialNumber();
// Pump capabilities // Pump capabilities
@ -69,7 +87,7 @@ public interface PumpInterface {
PumpEnactResult loadTDDs(); PumpEnactResult loadTDDs();
public boolean canHandleDST(); boolean canHandleDST();
List<CustomAction> getCustomActions(); List<CustomAction> getCustomActions();

View file

@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.nio.charset.StandardCharsets;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
@ -277,7 +278,7 @@ public class DetermineBasalAdapterAMAJS {
private String readFile(String filename) throws IOException { private String readFile(String filename) throws IOException {
byte[] bytes = mScriptReader.readFile(filename); byte[] bytes = mScriptReader.readFile(filename);
String string = new String(bytes, "UTF-8"); String string = new String(bytes, StandardCharsets.UTF_8);
if (string.startsWith("#!/usr/bin/env node")) { if (string.startsWith("#!/usr/bin/env node")) {
string = string.substring(20); string = string.substring(20);
} }

View file

@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.nio.charset.StandardCharsets;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
@ -207,7 +208,7 @@ public class DetermineBasalAdapterMAJS {
private String readFile(String filename) throws IOException { private String readFile(String filename) throws IOException {
byte[] bytes = mScriptReader.readFile(filename); byte[] bytes = mScriptReader.readFile(filename);
String string = new String(bytes, "UTF-8"); String string = new String(bytes, StandardCharsets.UTF_8);
if (string.startsWith("#!/usr/bin/env node")) { if (string.startsWith("#!/usr/bin/env node")) {
string = string.substring(20); string = string.substring(20);
} }

View file

@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.nio.charset.StandardCharsets;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
@ -340,7 +341,7 @@ public class DetermineBasalAdapterSMBJS {
private String readFile(String filename) throws IOException { private String readFile(String filename) throws IOException {
byte[] bytes = mScriptReader.readFile(filename); byte[] bytes = mScriptReader.readFile(filename);
String string = new String(bytes, "UTF-8"); String string = new String(bytes, StandardCharsets.UTF_8);
if (string.startsWith("#!/usr/bin/env node")) { if (string.startsWith("#!/usr/bin/env node")) {
string = string.substring(20); string = string.substring(20);
} }

View file

@ -178,7 +178,7 @@ public class MaintenancePlugin extends PluginBase {
* @return * @return
*/ */
public String constructName() { public String constructName() {
return "AndroidAPS_LOG_" + String.valueOf(new Date().getTime()) + LoggerUtils.SUFFIX; return "AndroidAPS_LOG_" + new Date().getTime() + LoggerUtils.SUFFIX;
} }
public void zip(File zipFile, List<File> files) throws IOException { public void zip(File zipFile, List<File> files) throws IOException {
@ -187,7 +187,7 @@ public class MaintenancePlugin extends PluginBase {
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile))); ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));
for (File file : files) { for (File file : files) {
byte data[] = new byte[BUFFER_SIZE]; byte[] data = new byte[BUFFER_SIZE];
try(FileInputStream fileInputStream = new FileInputStream( file )) { try(FileInputStream fileInputStream = new FileInputStream( file )) {

View file

@ -21,7 +21,7 @@ public class DismissNotificationService extends IntentService {
public DismissNotificationService(){ public DismissNotificationService(){
super("DismissNotificationService"); super("DismissNotificationService");
}; }
@Override @Override
protected void onHandleIntent(@Nullable Intent intent) { protected void onHandleIntent(@Nullable Intent intent) {

View file

@ -52,7 +52,7 @@ public class InsulinFragment extends Fragment {
private void updateGUI() { private void updateGUI() {
insulinName.setText(ConfigBuilderPlugin.getPlugin().getActiveInsulin().getFriendlyName()); insulinName.setText(ConfigBuilderPlugin.getPlugin().getActiveInsulin().getFriendlyName());
insulinComment.setText(ConfigBuilderPlugin.getPlugin().getActiveInsulin().getComment()); insulinComment.setText(ConfigBuilderPlugin.getPlugin().getActiveInsulin().getComment());
insulinDia.setText(MainApp.gs(R.string.dia) + " " + Double.toString(ConfigBuilderPlugin.getPlugin().getActiveInsulin().getDia()) + "h"); insulinDia.setText(MainApp.gs(R.string.dia) + " " + ConfigBuilderPlugin.getPlugin().getActiveInsulin().getDia() + "h");
insulinGraph.show(ConfigBuilderPlugin.getPlugin().getActiveInsulin()); insulinGraph.show(ConfigBuilderPlugin.getPlugin().getActiveInsulin());
} }

View file

@ -1,21 +1,20 @@
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink; package info.nightscout.androidaps.plugins.pump.common.hw.rileylink;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkBLE; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkBLE;
@ -112,7 +111,7 @@ public class RileyLinkUtil {
private static synchronized RileyLinkServiceState workWithServiceState(RileyLinkServiceState newState, private static synchronized RileyLinkServiceState workWithServiceState(RileyLinkServiceState newState,
RileyLinkError errorCode, boolean set) { RileyLinkError errorCode, boolean set) {
if (set) { if (set) {
@ -121,17 +120,17 @@ public class RileyLinkUtil {
if (L.isEnabled(L.PUMP)) if (L.isEnabled(L.PUMP))
LOG.info("RileyLink State Changed: {} {}", newState, errorCode == null ? "" : " - Error State: " LOG.info("RileyLink State Changed: {} {}", newState, errorCode == null ? "" : " - Error State: "
+ errorCode.name()); + errorCode.name());
RileyLinkUtil.historyRileyLink.add(new RLHistoryItem(RileyLinkUtil.rileyLinkServiceData.serviceState, RileyLinkUtil.historyRileyLink.add(new RLHistoryItem(RileyLinkUtil.rileyLinkServiceData.serviceState,
RileyLinkUtil.rileyLinkServiceData.errorCode, targetDevice)); RileyLinkUtil.rileyLinkServiceData.errorCode, targetDevice));
MainApp.bus().post(new EventMedtronicDeviceStatusChange(newState, errorCode)); MainApp.bus().post(new EventMedtronicDeviceStatusChange(newState, errorCode));
return null; return null;
} else { } else {
return (RileyLinkUtil.rileyLinkServiceData == null || RileyLinkUtil.rileyLinkServiceData.serviceState == null) ? // return (RileyLinkUtil.rileyLinkServiceData == null || RileyLinkUtil.rileyLinkServiceData.serviceState == null) ? //
RileyLinkServiceState.NotStarted RileyLinkServiceState.NotStarted
: RileyLinkUtil.rileyLinkServiceData.serviceState; : RileyLinkUtil.rileyLinkServiceData.serviceState;
} }
} }
@ -259,7 +258,7 @@ public class RileyLinkUtil {
case 0x03: // Complete list of 16-bit UUIDs case 0x03: // Complete list of 16-bit UUIDs
while (length >= 2) { while (length >= 2) {
uuids uuids
.add(UUID.fromString(String.format("%08x-0000-1000-8000-00805f9b34fb", buffer.getShort()))); .add(UUID.fromString(String.format("%08x-0000-1000-8000-00805f9b34fb", buffer.getShort())));
length -= 2; length -= 2;
} }
break; break;
@ -275,11 +274,7 @@ public class RileyLinkUtil {
case 0x09: case 0x09:
byte[] nameBytes = new byte[length - 1]; byte[] nameBytes = new byte[length - 1];
buffer.get(nameBytes); buffer.get(nameBytes);
try { name = new String(nameBytes, StandardCharsets.UTF_8);
name = new String(nameBytes, "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
break; break;
default: default:
buffer.position(buffer.position() + length - 1); buffer.position(buffer.position() + length - 1);

View file

@ -10,6 +10,6 @@ public enum ServiceTransportType {
ServiceNotification, // ServiceNotification, //
ServiceCommand, // ServiceCommand, //
ServiceResult; ServiceResult
} }

View file

@ -305,12 +305,12 @@ public class ByteUtil {
} }
public static String getHex(byte abyte0[]) { public static String getHex(byte[] abyte0) {
return abyte0 != null ? getHex(abyte0, abyte0.length) : null; return abyte0 != null ? getHex(abyte0, abyte0.length) : null;
} }
public static String getString(short abyte0[]) { public static String getString(short[] abyte0) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (short i : abyte0) { for (short i : abyte0) {
@ -330,7 +330,7 @@ public class ByteUtil {
} }
public static String getHex(byte abyte0[], int i) { public static String getHex(byte[] abyte0, int i) {
StringBuffer stringbuffer = new StringBuffer(); StringBuffer stringbuffer = new StringBuffer();
if (abyte0 != null) { if (abyte0 != null) {
i = Math.min(i, abyte0.length); i = Math.min(i, abyte0.length);

View file

@ -13,7 +13,7 @@ import java.util.List;
*/ */
public class StringUtil { public class StringUtil {
public static DecimalFormat DecimalFormaters[] = { public static DecimalFormat[] DecimalFormaters = {
new DecimalFormat("#0"), new DecimalFormat("#0.0"), new DecimalFormat("#0.00"), new DecimalFormat("#0.000")}; new DecimalFormat("#0"), new DecimalFormat("#0.0"), new DecimalFormat("#0.00"), new DecimalFormat("#0.000")};

View file

@ -27,7 +27,6 @@ public class BLEScanActivity extends AppCompatActivity {
private ListView listView = null; private ListView listView = null;
private ListAdapter mListAdapter = null; private ListAdapter mListAdapter = null;
private ArrayList<BluetoothDeviceItem> mDevices = new ArrayList<>(); private ArrayList<BluetoothDeviceItem> mDevices = new ArrayList<>();
;
private BluetoothAdapter mBluetoothAdapter = null; private BluetoothAdapter mBluetoothAdapter = null;
private BluetoothLeScanner mBluetoothLeScanner = null; private BluetoothLeScanner mBluetoothLeScanner = null;

View file

@ -47,8 +47,6 @@ public class DanaRS_Packet {
return null; return null;
} }
;
// STATIC FUNCTIONS // STATIC FUNCTIONS
public static int getCommand(byte[] data) { public static int getCommand(byte[] data) {

View file

@ -853,7 +853,6 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
if (extendedBolus != null) { if (extendedBolus != null) {
extendedBolus.durationInMinutes = (int) ((System.currentTimeMillis() - extendedBolus.date) / 60000); extendedBolus.durationInMinutes = (int) ((System.currentTimeMillis() - extendedBolus.date) / 60000);
if (extendedBolus.durationInMinutes <= 0) { if (extendedBolus.durationInMinutes <= 0) {
;
final String _id = extendedBolus._id; final String _id = extendedBolus._id;
if (NSUpload.isIdValid(_id)) if (NSUpload.isIdValid(_id))
NSUpload.removeCareportalEntryFromNS(_id); NSUpload.removeCareportalEntryFromNS(_id);

View file

@ -3,6 +3,6 @@ package info.nightscout.androidaps.plugins.pump.insight.app_layer.history;
public enum HistoryReadingDirection { public enum HistoryReadingDirection {
FORWARD, FORWARD,
BACKWARD; BACKWARD
} }

View file

@ -5,5 +5,5 @@ public enum AlertCategory {
REMINDER, REMINDER,
MAINTENANCE, MAINTENANCE,
WARNING, WARNING,
ERROR; ERROR
} }

View file

@ -3,5 +3,5 @@ package info.nightscout.androidaps.plugins.pump.insight.descriptors;
public enum AlertStatus { public enum AlertStatus {
ACTIVE, ACTIVE,
SNOOZED; SNOOZED
} }

View file

@ -27,5 +27,5 @@ public enum AlertType {
MAINTENANCE_30, MAINTENANCE_30,
ERROR_6, ERROR_6,
ERROR_10, ERROR_10,
ERROR_13; ERROR_13
} }

View file

@ -6,5 +6,5 @@ public enum BasalProfile {
PROFILE_2, PROFILE_2,
PROFILE_3, PROFILE_3,
PROFILE_4, PROFILE_4,
PROFILE_5; PROFILE_5
} }

View file

@ -4,5 +4,5 @@ public enum BatteryType {
ALKALI, ALKALI,
LITHIUM, LITHIUM,
NI_MH; NI_MH
} }

View file

@ -4,5 +4,5 @@ public enum BolusType {
STANDARD, STANDARD,
EXTENDED, EXTENDED,
MULTIWAVE; MULTIWAVE
} }

View file

@ -3,5 +3,5 @@ package info.nightscout.androidaps.plugins.pump.insight.descriptors;
public enum CartridgeType { public enum CartridgeType {
PREFILLED, PREFILLED,
SELF_FILLED; SELF_FILLED
} }

View file

@ -4,5 +4,5 @@ public enum MessagePriority {
NORMAL, NORMAL,
HIGHER, HIGHER,
HIGHEST; HIGHEST
} }

View file

@ -4,5 +4,5 @@ public enum OperatingMode {
STARTED, STARTED,
STOPPED, STOPPED,
PAUSED; PAUSED
} }

View file

@ -4,5 +4,5 @@ public enum SymbolStatus {
FULL, FULL,
LOW, LOW,
EMPTY; EMPTY
} }

View file

@ -4,5 +4,5 @@ public enum PairingStatus {
CONFIRMED, CONFIRMED,
REJECTED, REJECTED,
PENDING; PENDING
} }

View file

@ -14,5 +14,5 @@ public enum SatlError {
WRONG_STATE, WRONG_STATE,
INVALID_MESSAGE_TYPE, INVALID_MESSAGE_TYPE,
INVALID_PAYLOAD_LENGTH, INVALID_PAYLOAD_LENGTH,
NONE; NONE
} }

View file

@ -1,8 +1,8 @@
package info.nightscout.androidaps.plugins.pump.insight.utils; package info.nightscout.androidaps.plugins.pump.insight.utils;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.nio.charset.StandardCharsets;
public class ByteBuf { public class ByteBuf {
@ -45,13 +45,11 @@ public class ByteBuf {
} }
public void putBytes(byte b, int count) { public void putBytes(byte b, int count) {
for (int i = 0; i < count; i++) bytes[size++] = b; for (int i = 0; i < count; i++) bytes[size++] = b;
} }
public byte[] getBytes(int position, int length) { public byte[] getBytes(int position, int length) {
byte[] copy = new byte[length]; byte[] copy = new byte[length];
System.arraycopy(bytes, position, copy, 0, length); System.arraycopy(bytes, position, copy, 0, length);
@ -68,7 +66,7 @@ public class ByteBuf {
return copy; return copy;
} }
public byte[] readBytes() { byte[] readBytes() {
return readBytes(size); return readBytes(size);
} }
@ -82,15 +80,14 @@ public class ByteBuf {
} }
private byte[] getBytesLE(int position, int length) {
public byte[] getBytesLE(int position, int length) {
byte[] copy = new byte[length]; byte[] copy = new byte[length];
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
copy[i] = bytes[length - 1 - i + position]; copy[i] = bytes[length - 1 - i + position];
return copy; return copy;
} }
public byte[] getBytesLE(int length) { private byte[] getBytesLE(int length) {
return getBytesLE(0, length); return getBytesLE(0, length);
} }
@ -100,13 +97,13 @@ public class ByteBuf {
return copy; return copy;
} }
public void putBytesLE(byte[] bytes, int length) { private void putBytesLE(byte[] bytes, int length) {
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
this.bytes[size + length - 1 - i] = bytes[i]; this.bytes[size + length - 1 - i] = bytes[i];
size += length; size += length;
} }
public void putBytesLE(byte[] bytes) { void putBytesLE(byte[] bytes) {
putBytesLE(bytes, bytes.length); putBytesLE(bytes, bytes.length);
} }
@ -116,12 +113,11 @@ public class ByteBuf {
} }
private short getUInt8(int position) {
public short getUInt8(int position) {
return (short) (bytes[position] & 0xFF); return (short) (bytes[position] & 0xFF);
} }
public short getUInt8() { private short getUInt8() {
return getUInt8(0); return getUInt8(0);
} }
@ -136,13 +132,12 @@ public class ByteBuf {
} }
public int getUInt16LE(int position) { public int getUInt16LE(int position) {
return (bytes[position++] & 0xFF | return (bytes[position++] & 0xFF |
(bytes[position] & 0xFF) << 8); (bytes[position] & 0xFF) << 8);
} }
public int getUInt16LE() { private int getUInt16LE() {
return getUInt16LE(0); return getUInt16LE(0);
} }
@ -158,14 +153,13 @@ public class ByteBuf {
} }
private double getUInt16Decimal(int position) {
public double getUInt16Decimal(int position) {
return new BigDecimal(getUInt16LE(position)) return new BigDecimal(getUInt16LE(position))
.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP) .divide(new BigDecimal(100), 2, RoundingMode.HALF_UP)
.doubleValue(); .doubleValue();
} }
public double getUInt16Decimal() { private double getUInt16Decimal() {
return getUInt16Decimal(0); return getUInt16Decimal(0);
} }
@ -183,14 +177,13 @@ public class ByteBuf {
} }
private double getUInt32Decimal100(int position) {
public double getUInt32Decimal100(int position) {
return new BigDecimal(getUInt32LE(position)) return new BigDecimal(getUInt32LE(position))
.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP) .divide(new BigDecimal(100), 2, RoundingMode.HALF_UP)
.doubleValue(); .doubleValue();
} }
public double getUInt32Decimal100() { private double getUInt32Decimal100() {
return getUInt32Decimal100(0); return getUInt32Decimal100(0);
} }
@ -208,14 +201,13 @@ public class ByteBuf {
} }
private double getUInt32Decimal1000(int position) {
public double getUInt32Decimal1000(int position) {
return new BigDecimal(getUInt32LE(position)) return new BigDecimal(getUInt32LE(position))
.divide(new BigDecimal(1000), 3, RoundingMode.HALF_UP) .divide(new BigDecimal(1000), 3, RoundingMode.HALF_UP)
.doubleValue(); .doubleValue();
} }
public double getUInt32Decimal1000() { private double getUInt32Decimal1000() {
return getUInt32Decimal1000(0); return getUInt32Decimal1000(0);
} }
@ -233,9 +225,8 @@ public class ByteBuf {
} }
private short getShort(int position) {
public short getShort(int position) { return (short) (bytes[position++] << 8 |
return (short) (bytes[position++] << 8 |
bytes[position] & 0xFF); bytes[position] & 0xFF);
} }
@ -255,15 +246,14 @@ public class ByteBuf {
} }
private long getUInt32LE(int position) {
public long getUInt32LE(int position) {
return ((long) bytes[position++] & 0xFF) | return ((long) bytes[position++] & 0xFF) |
((long) bytes[position++] & 0xFF) << 8 | ((long) bytes[position++] & 0xFF) << 8 |
((long) bytes[position++] & 0xFF) << 16 | ((long) bytes[position++] & 0xFF) << 16 |
((long) bytes[position] & 0xFF) << 24; ((long) bytes[position] & 0xFF) << 24;
} }
public long getUInt32LE() { private long getUInt32LE() {
return getUInt32LE(0); return getUInt32LE(0);
} }
@ -281,18 +271,12 @@ public class ByteBuf {
} }
private String getUTF16(int position, int stringLength) {
public String getUTF16(int position, int stringLength) { String string = new String(getBytes(position, stringLength * 2 + 2), StandardCharsets.UTF_16LE);
try { return string.substring(0, string.indexOf(new String(new char[]{0, 0})));
String string = new String(getBytes(position, stringLength * 2 + 2), "UTF-16LE");
return string.substring(0, string.indexOf(new String(new char[] {0, 0})));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
} }
public String getUTF16(int stringLength) { private String getUTF16(int stringLength) {
return getUTF16(0, stringLength); return getUTF16(0, stringLength);
} }
@ -303,27 +287,17 @@ public class ByteBuf {
} }
public void putUTF16(String string, int stringLength) { public void putUTF16(String string, int stringLength) {
try { putBytes(string.getBytes(StandardCharsets.UTF_16LE), stringLength * 2);
putBytes(string.getBytes("UTF-16LE"), stringLength * 2); putBytes((byte) 0, 2);
putBytes((byte) 0, 2);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
} }
private String getASCII(int position, int stringLength) {
public String getASCII(int position, int stringLength) { String string = new String(getBytes(position, stringLength + 1), StandardCharsets.US_ASCII);
try { return string.substring(0, string.indexOf(0));
String string = new String(getBytes(position, stringLength + 1), "US-ASCII");
return string.substring(0, string.indexOf(0));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
} }
public String getASCII(int stringLength) { private String getASCII(int stringLength) {
return getASCII(0, stringLength); return getASCII(0, stringLength);
} }
@ -334,16 +308,11 @@ public class ByteBuf {
} }
public void putASCII(String string, int stringLength) { public void putASCII(String string, int stringLength) {
try { putBytes(string.getBytes(StandardCharsets.UTF_16LE), stringLength * 2);
putBytes(string.getBytes("UTF-16LE"), stringLength * 2); putBytes((byte) 0, 1);
putBytes((byte) 0, 1);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
} }
public boolean getBoolean(int position) { public boolean getBoolean(int position) {
return getUInt16LE(position) == 75; return getUInt16LE(position) == 75;
} }
@ -363,7 +332,6 @@ public class ByteBuf {
} }
public static ByteBuf from(byte[] bytes, int length) { public static ByteBuf from(byte[] bytes, int length) {
ByteBuf byteBuf = new ByteBuf(length); ByteBuf byteBuf = new ByteBuf(length);
byteBuf.putBytes(bytes, length); byteBuf.putBytes(bytes, length);

View file

@ -412,7 +412,7 @@ public class MedtronicConverter {
} }
public double decodeMaxBolus(byte ai[]) { public double decodeMaxBolus(byte[] ai) {
return is523orHigher() ? decodeBolusInsulin(ByteUtil.toInt(ai[5], ai[6])) : decodeBolusInsulin(ByteUtil return is523orHigher() ? decodeBolusInsulin(ByteUtil.toInt(ai[5], ai[6])) : decodeBolusInsulin(ByteUtil
.asUINT8(ai[5])); .asUINT8(ai[5]));
} }

View file

@ -30,9 +30,9 @@ public enum CGMSHistoryEntryType {
SensorCalFactor(0x0f, "SensorCalFactor", 1, 4, 2, DateType.MinuteSpecific), // SensorCalFactor(0x0f, "SensorCalFactor", 1, 4, 2, DateType.MinuteSpecific), //
Something10(0x10, "10-Something", 1, 4, 0, DateType.MinuteSpecific), // Something10(0x10, "10-Something", 1, 4, 0, DateType.MinuteSpecific), //
Something19(0x13, "19-Something", 1, 0, 0, DateType.PreviousTimeStamp), Something19(0x13, "19-Something", 1, 0, 0, DateType.PreviousTimeStamp),
GlucoseSensorData(0xFF, "GlucoseSensorData", 1, 0, 0, DateType.PreviousTimeStamp);; GlucoseSensorData(0xFF, "GlucoseSensorData", 1, 0, 0, DateType.PreviousTimeStamp);
private static Map<Integer, CGMSHistoryEntryType> opCodeMap = new HashMap<Integer, CGMSHistoryEntryType>(); private static Map<Integer, CGMSHistoryEntryType> opCodeMap = new HashMap<>();
static { static {
for (CGMSHistoryEntryType type : values()) { for (CGMSHistoryEntryType type : values()) {
@ -40,7 +40,7 @@ public enum CGMSHistoryEntryType {
} }
} }
public boolean schemaSet = false; public boolean schemaSet;
private int opCode; private int opCode;
private String description; private String description;
private int headLength; private int headLength;
@ -129,7 +129,6 @@ public enum CGMSHistoryEntryType {
MinuteSpecific, // MinuteSpecific, //
SecondSpecific, // SecondSpecific, //
PreviousTimeStamp // PreviousTimeStamp //
;
} }

View file

@ -217,7 +217,7 @@ public class MedtronicCGMSHistoryDecoder extends MedtronicHistoryDecoder<CGMSHis
} }
private <E extends Object> List<E> reverseList(List<E> dataClearInput, Class<E> clazz) { private <E> List<E> reverseList(List<E> dataClearInput, Class<E> clazz) {
List<E> outList = new ArrayList<E>(); List<E> outList = new ArrayList<E>();
@ -263,7 +263,7 @@ public class MedtronicCGMSHistoryDecoder extends MedtronicHistoryDecoder<CGMSHis
if (!entry.getEntryType().hasDate()) if (!entry.getEntryType().hasDate())
return null; return null;
byte data[] = entry.getDatetime(); byte[] data = entry.getDatetime();
if (entry.getEntryType().getDateType() == CGMSHistoryEntryType.DateType.MinuteSpecific) { if (entry.getEntryType().getDateType() == CGMSHistoryEntryType.DateType.MinuteSpecific) {

View file

@ -120,7 +120,7 @@ public class DailyTotalsDTO {
// Daily // Daily
byte body[] = data; // entry.getBody(); byte[] body = data; // entry.getBody();
//System.out.println("Totals 522"); //System.out.println("Totals 522");
for (int i = 0; i < body.length - 2; i++) { for (int i = 0; i < body.length - 2; i++) {

View file

@ -21,7 +21,7 @@ public class TempBasalProcessDTO {
} }
public static enum Operation { public enum Operation {
None, None,
Add, Add,
Edit Edit

View file

@ -8,6 +8,6 @@ public enum MedtronicUIResponseType {
Data, Data,
Error, Error,
Invalid; Invalid
} }

View file

@ -17,7 +17,7 @@ public class JsonHelper {
private static final Logger log = LoggerFactory.getLogger(JsonHelper.class); private static final Logger log = LoggerFactory.getLogger(JsonHelper.class);
private JsonHelper() {}; private JsonHelper() {}
public static Object safeGetObject(JSONObject json, String fieldName, Object defaultValue) { public static Object safeGetObject(JSONObject json, String fieldName, Object defaultValue) {
Object result = defaultValue; Object result = defaultValue;

View file

@ -44,7 +44,7 @@ public class ComposeTriggerTest {
public void testChangeConnector() { public void testChangeConnector() {
// initialize scenario // initialize scenario
TriggerConnector root = new TriggerConnector(TriggerConnector.Type.AND); TriggerConnector root = new TriggerConnector(TriggerConnector.Type.AND);
Trigger t[] = new Trigger[4]; Trigger[] t = new Trigger[4];
for (int i = 0; i < t.length; ++i) { for (int i = 0; i < t.length; ++i) {
t[i] = new DummyTrigger(); t[i] = new DummyTrigger();
root.add(t[i]); root.add(t[i]);

View file

@ -32,7 +32,7 @@ public class ActionTest extends Action {
@Override @Override
public Optional<Integer> icon() { public Optional<Integer> icon() {
return null; return Optional.absent();
} }
@Test @Test

View file

@ -585,7 +585,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
private void showBolusProgress(int progresspercent, String progresstatus) { private void showBolusProgress(int progresspercent, String progresstatus) {
Intent cancelIntent = new Intent(this, ListenerService.class); Intent cancelIntent = new Intent(this, ListenerService.class);
cancelIntent.setAction(ACTION_CANCELBOLUS); cancelIntent.setAction(ACTION_CANCELBOLUS);
PendingIntent cancelPendingIntent = PendingIntent.getService(this, 0, cancelIntent, 0);; PendingIntent cancelPendingIntent = PendingIntent.getService(this, 0, cancelIntent, 0);
long[] vibratePattern; long[] vibratePattern;
boolean vibreate = PreferenceManager boolean vibreate = PreferenceManager