Pebble: fix NPE in getPlatformName

The NPE was triggered by recent changes in the HearthRate Charts (503cd31d91)
Since getModel was also affected by the same NPE, the function is now changed as well.
This commit is contained in:
Daniele Gobbetti 2024-09-25 15:09:01 +02:00
parent 2ac7aed8d0
commit 550e6a86f2

View File

@ -35,36 +35,39 @@ public class PebbleUtils {
private static final Logger LOG = LoggerFactory.getLogger(PebbleUtils.class); private static final Logger LOG = LoggerFactory.getLogger(PebbleUtils.class);
public static String getPlatformName(String hwRev) { public static String getPlatformName(String hwRev) {
String platformName; final String DEFAULT_PLATFORM = "aplite";
if (hwRev.startsWith("snowy")) { if (hwRev == null || hwRev.isEmpty()) {
platformName = "basalt"; return DEFAULT_PLATFORM;
} else if (hwRev.startsWith("spalding")) {
platformName = "chalk";
} else if (hwRev.startsWith("silk")) {
platformName = "diorite";
} else if (hwRev.startsWith("robert")) {
platformName = "emery";
} else {
platformName = "aplite";
} }
return platformName;
if (hwRev.startsWith("snowy")) {
return "basalt";
} else if (hwRev.startsWith("spalding")) {
return "chalk";
} else if (hwRev.startsWith("silk")) {
return "diorite";
} else if (hwRev.startsWith("robert")) {
return "emery";
}
return DEFAULT_PLATFORM;
} }
public static String getModel(String hwRev) { public static String getModel(String hwRev) {
//TODO: get real data? //TODO: get real data?
String model; final String DEFAULT_MODEL = "pebble_black";
if (hwRev.startsWith("snowy")) { if (hwRev == null || hwRev.isEmpty()) {
model = "pebble_time_black"; return DEFAULT_MODEL;
} else if (hwRev.startsWith("spalding")) {
model = "pebble_time_round_black_20mm";
} else if (hwRev.startsWith("silk")) {
model = "pebble2_black";
} else if (hwRev.startsWith("robert")) {
model = "pebble_time2_black";
} else {
model = "pebble_black";
} }
return model; if (hwRev.startsWith("snowy")) {
return "pebble_time_black";
} else if (hwRev.startsWith("spalding")) {
return "pebble_time_round_black_20mm";
} else if (hwRev.startsWith("silk")) {
return "pebble2_black";
} else if (hwRev.startsWith("robert")) {
return "pebble_time2_black";
}
return DEFAULT_MODEL;
} }
public static int getFwMajor(String fwString) { public static int getFwMajor(String fwString) {