mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Zepp OS: Improve loyalty cards logging
This commit is contained in:
+2
@@ -16,6 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.capabilities.loyaltycards;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.builder.CompareToBuilder;
|
||||
@@ -132,6 +133,7 @@ public class LoyaltyCard implements Serializable, Comparable<LoyaltyCard> {
|
||||
return lastUsed;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
|
||||
+20
-5
@@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -70,14 +71,14 @@ public class ZeppOsLoyaltyCardService extends AbstractZeppOsService {
|
||||
public void handlePayload(final byte[] payload) {
|
||||
switch (payload[0]) {
|
||||
case CMD_CAPABILITIES_RESPONSE:
|
||||
LOG.info("Loyalty cards capabilities, version1={}, version2={}", payload[1], payload[2]);
|
||||
|
||||
supportedFormats.clear();
|
||||
supportedColors.clear();
|
||||
int version = payload[1];
|
||||
|
||||
final int version = payload[1];
|
||||
getSupport().evaluateGBDeviceEvent(new GBDeviceEventUpdatePreferences(PREF_VERSION, version));
|
||||
|
||||
if (version != 1 || payload[2] != 1) {
|
||||
LOG.warn("Unexpected loyalty cards service version");
|
||||
LOG.warn("Unexpected loyalty cards service version {}, {}", version, payload[2]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -105,7 +106,14 @@ public class ZeppOsLoyaltyCardService extends AbstractZeppOsService {
|
||||
supportedColors.add(color);
|
||||
}
|
||||
|
||||
getSupport().evaluateGBDeviceEvent(new GBDeviceEventUpdatePreferences(PREF_VERSION, version));
|
||||
LOG.info(
|
||||
"Loyalty cards version1={}, version2={}, formats={}, colors={}",
|
||||
payload[1],
|
||||
payload[2],
|
||||
supportedFormats,
|
||||
supportedColors
|
||||
);
|
||||
|
||||
return;
|
||||
case CMD_SET_ACK:
|
||||
LOG.info("Loyalty cards set ACK, status = {}", payload[1]);
|
||||
@@ -155,11 +163,18 @@ public class ZeppOsLoyaltyCardService extends AbstractZeppOsService {
|
||||
}
|
||||
|
||||
private List<LoyaltyCard> filterSupportedCards(final List<LoyaltyCard> cards) {
|
||||
if (supportedFormats.isEmpty()) {
|
||||
LOG.warn("Supported formats are not known");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final List<LoyaltyCard> ret = new ArrayList<>();
|
||||
|
||||
for (final LoyaltyCard card : cards) {
|
||||
if (supportedFormats.contains(card.getBarcodeFormat())) {
|
||||
ret.add(card);
|
||||
} else {
|
||||
LOG.warn("Ignoring unsupported card format {}", card.getBarcodeFormat());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user