package quant.rich.emoney.entity.config; import java.util.HashMap; import java.util.Map; import lombok.Data; import lombok.experimental.Accessors; import lombok.extern.slf4j.Slf4j; import quant.rich.emoney.interfaces.ConfigInfo; import quant.rich.emoney.interfaces.IConfig; @Data @Accessors(chain = true) @Slf4j @ConfigInfo(name = "安卓 SDK Level 设置", initDefault = true, managed = false) public class AndroidSdkLevelConfig implements IConfig { Map androidVerToSdk; public AndroidSdkLevelConfig() { androidVerToSdk = new HashMap<>(); androidVerToSdk.put("15", 35); androidVerToSdk.put("14", 34); androidVerToSdk.put("13", 33); androidVerToSdk.put("12L", 32); androidVerToSdk.put("12", 31); androidVerToSdk.put("11", 30); androidVerToSdk.put("10", 29); androidVerToSdk.put("9", 28); androidVerToSdk.put("8.1", 27); androidVerToSdk.put("8.0", 26); androidVerToSdk.put("7.1", 25); androidVerToSdk.put("7.0", 24); androidVerToSdk.put("6.0", 23); androidVerToSdk.put("5.1", 22); androidVerToSdk.put("5.0", 21); androidVerToSdk.put("4.4W", 20); androidVerToSdk.put("4.4", 19); androidVerToSdk.put("4.3", 18); androidVerToSdk.put("4.2", 17); androidVerToSdk.put("4.1", 16); androidVerToSdk.put("4.0.3", 15); androidVerToSdk.put("4.0.1", 14); androidVerToSdk.put("3.2", 13); androidVerToSdk.put("3.1", 12); androidVerToSdk.put("3.0", 11); androidVerToSdk.put("2.3.3", 10); androidVerToSdk.put("2.3", 9); androidVerToSdk.put("2.2", 8); androidVerToSdk.put("2.1", 7); androidVerToSdk.put("2.0.1", 6); androidVerToSdk.put("2.0", 5); androidVerToSdk.put("1.6", 4); androidVerToSdk.put("1.5", 3); androidVerToSdk.put("1.1", 2); androidVerToSdk.put("1.0", 1); } public int getSdkLevel(String androidVersion) { if (androidVerToSdk.containsKey(androidVersion)) { return androidVerToSdk.get(androidVersion); } // 模糊匹配前缀 for (String key : androidVerToSdk.keySet()) { if (androidVersion.startsWith(key)) { return androidVerToSdk.get(key); } } throw new IllegalArgumentException("未知的 Android 版本: " + androidVersion); } }