2828import java .util .Properties ;
2929
3030@ SuppressWarnings ({"unchecked" , "rawtypes" })
31- public class Devices {
31+ public final class Devices {
3232
33- private static final ObservableList < String > iPhones = unmodifiableArrayList ( "iPhone 3G[S]" , "iPhone 4 (GSM)" ,
33+ private static final String [] iPhones = { "iPhone 3G[S]" , "iPhone 4 (GSM)" ,
3434 "iPhone 4 (GSM 2012)" , "iPhone 4 (CDMA)" , "iPhone 4[S]" , "iPhone 5 (GSM)" , "iPhone 5 (Global)" ,
3535 "iPhone 5c (GSM)" , "iPhone 5c (Global)" , "iPhone 5s (GSM)" , "iPhone 5s (Global)" ,
3636 "iPhone 6+" , "iPhone 6" , "iPhone 6s" , "iPhone 6s+" , "iPhone SE" , "iPhone 7 (Global)(iPhone9,1)" ,
@@ -40,108 +40,94 @@ public class Devices {
4040 "iPhone XS Max (China) (iPhone11,4)" , "iPhone XS Max (iPhone11,6)" , "iPhone XR (iPhone11,8)" ,
4141 "iPhone 11 (iPhone12,1)" , "iPhone 11 Pro (iPhone12,3)" , "iPhone 11 Pro Max (iPhone12,5)" ,
4242 "iPhone SE 2 (iPhone12,8)" , "iPhone 12 mini (iPhone13,1)" , "iPhone 12 (iPhone13,2)" ,
43- "iPhone 12 Pro (iPhone13,3)" , "iPhone 12 Pro Max (iPhone13,4)" );
44-
45- private static final ObservableList <String > iPods =
46- unmodifiableArrayList ("iPod Touch 3" , "iPod Touch 4" , "iPod Touch 5" , "iPod Touch 6" ,
47- "iPod Touch 7 (iPod9,1)" );
48-
49- private static final ObservableList <String > iPads =
50- unmodifiableArrayList ("iPad 1" , "iPad 2 (WiFi)" , "iPad 2 (GSM)" ,
51- "iPad 2 (CDMA)" , "iPad 2 (Mid 2012)" , "iPad Mini (Wifi)" , "iPad Mini (GSM)" , "iPad Mini (Global)" ,
52- "iPad 3 (WiFi)" , "iPad 3 (CDMA)" , "iPad 3 (GSM)" , "iPad 4 (WiFi)" , "iPad 4 (GSM)" , "iPad 4 (Global)" ,
53- "iPad Air (Wifi)" , "iPad Air (Cellular)" , "iPad Air (China)" , "iPad Mini 2 (WiFi)" , "iPad Mini 2 (Cellular)" ,
54- "iPad Mini 2 (China)" , "iPad Mini 3 (WiFi)" , "iPad Mini 3 (Cellular)" , "iPad Mini 3 (China)" ,
55- "iPad Mini 4 (Wifi)" , "iPad Mini 4 (Cellular)" , "iPad Air 2 (WiFi)" , "iPad Air 2 (Cellular)" ,
56- "iPad Pro 9.7 (Wifi)" , "iPad Pro 9.7 (Cellular)" , "iPad Pro 12.9 (WiFi)" , "iPad Pro 12.9 (Cellular)" ,
57- "iPad 5 (Wifi)" , "iPad 5 (Cellular)" , "iPad Pro 2 12.9 (WiFi)(iPad7,1)" , "iPad Pro 2 12.9 (Cellular)(iPad7,2)" ,
58- "iPad Pro 10.5 (WiFi)(iPad7,3)" , "iPad 10.5 (Cellular)(iPad7,4)" , "iPad 6 (WiFi)(iPad 7,5)" ,
59- "iPad 6 (Cellular)(iPad7,6)" , "iPad 7 (WiFi)(iPad7,11)" , "iPad 7 (Cellular)(iPad7,12)" ,
60- "iPad Pro 3 11' (WiFi)(iPad8,1)" , "iPad Pro 3 11' (WiFi)(iPad8,2)" , "iPad Pro 3 11' (Cellular)(iPad8,3)" ,
61- "iPad Pro 3 11' (Cellular)(iPad8,4)" , "iPad Pro 3 12.9'(WiFi)(iPad8,5)" , "iPad Pro 3 12.9 (WiFi)(iPad8,6)" ,
62- "iPad Pro 3 12.9 (Cellular)(iPad8,7)" , "iPad Pro 3 12.9 (Cellular)(iPad8,8)" , "iPad Pro 4 11' (WiFi)(iPad8,9)" ,
63- "iPad Pro 4 11' (Cellular)(iPad8,10)" , "iPad Pro 4 12.9' (WiFi)(iPad8,11)" ,
64- "iPad Pro 4 12.9' (Cellular)(iPad8,12)" , "iPad Mini 5 (WiFi)(iPad11,1)" , "iPad Mini 5 (Cellular)(iPad11,2)" ,
65- "iPad Air 3 (WiFi)(iPad11,3)" , "iPad Air 3 (Cellular)(iPad11,4)" );
66-
67- private static final ObservableList <String > AppleTVs =
68- unmodifiableArrayList ("Apple TV 2G" , "Apple TV 3" , "Apple TV 3 (2013)" , "Apple TV 4 (2015)" , "Apple TV 4K" );
43+ "iPhone 12 Pro (iPhone13,3)" , "iPhone 12 Pro Max (iPhone13,4)" };
44+ private static final String [] iPads = {"iPad 1" , "iPad 2 (WiFi)" , "iPad 2 (GSM)" ,
45+ "iPad 2 (CDMA)" , "iPad 2 (Mid 2012)" , "iPad Mini (Wifi)" , "iPad Mini (GSM)" , "iPad Mini (Global)" ,
46+ "iPad 3 (WiFi)" , "iPad 3 (CDMA)" , "iPad 3 (GSM)" , "iPad 4 (WiFi)" , "iPad 4 (GSM)" , "iPad 4 (Global)" ,
47+ "iPad Air (Wifi)" , "iPad Air (Cellular)" , "iPad Air (China)" , "iPad Mini 2 (WiFi)" , "iPad Mini 2 (Cellular)" ,
48+ "iPad Mini 2 (China)" , "iPad Mini 3 (WiFi)" , "iPad Mini 3 (Cellular)" , "iPad Mini 3 (China)" ,
49+ "iPad Mini 4 (Wifi)" , "iPad Mini 4 (Cellular)" , "iPad Air 2 (WiFi)" , "iPad Air 2 (Cellular)" ,
50+ "iPad Pro 9.7 (Wifi)" , "iPad Pro 9.7 (Cellular)" , "iPad Pro 12.9 (WiFi)" , "iPad Pro 12.9 (Cellular)" ,
51+ "iPad 5 (Wifi)" , "iPad 5 (Cellular)" , "iPad Pro 2 12.9 (WiFi)(iPad7,1)" , "iPad Pro 2 12.9 (Cellular)(iPad7,2)" ,
52+ "iPad Pro 10.5 (WiFi)(iPad7,3)" , "iPad 10.5 (Cellular)(iPad7,4)" , "iPad 6 (WiFi)(iPad 7,5)" ,
53+ "iPad 6 (Cellular)(iPad7,6)" , "iPad 7 (WiFi)(iPad7,11)" , "iPad 7 (Cellular)(iPad7,12)" ,
54+ "iPad Pro 3 11' (WiFi)(iPad8,1)" , "iPad Pro 3 11' (WiFi)(iPad8,2)" , "iPad Pro 3 11' (Cellular)(iPad8,3)" ,
55+ "iPad Pro 3 11' (Cellular)(iPad8,4)" , "iPad Pro 3 12.9'(WiFi)(iPad8,5)" , "iPad Pro 3 12.9 (WiFi)(iPad8,6)" ,
56+ "iPad Pro 3 12.9 (Cellular)(iPad8,7)" , "iPad Pro 3 12.9 (Cellular)(iPad8,8)" , "iPad Pro 4 11' (WiFi)(iPad8,9)" ,
57+ "iPad Pro 4 11' (Cellular)(iPad8,10)" , "iPad Pro 4 12.9' (WiFi)(iPad8,11)" ,
58+ "iPad Pro 4 12.9' (Cellular)(iPad8,12)" , "iPad Mini 5 (WiFi)(iPad11,1)" , "iPad Mini 5 (Cellular)(iPad11,2)" ,
59+ "iPad Air 3 (WiFi)(iPad11,3)" , "iPad Air 3 (Cellular)(iPad11,4)" , "iPad 8 (WiFi) (iPad11,6)" ,
60+ "iPad 8 (Cellular) (iPad11,7)" , "iPad Air 4 (WiFi) (iPad13,1)" , "iPad Air 4 (Cellular) (iPad13,2)" };
61+
62+ private static final ObservableList <String > iPhoneList = FXCollections .observableArrayList (iPhones );
63+ private static final ObservableList <String > iPadList = FXCollections .observableArrayList (iPads );
64+
65+ private static final ObservableList <String > iPodList = unmodifiableArrayList ("iPod Touch 3" , "iPod Touch 4" ,
66+ "iPod Touch 5" , "iPod Touch 6" , "iPod Touch 7 (iPod9,1)" );
67+
68+ private static final ObservableList <String > AppleTVList = unmodifiableArrayList ("Apple TV 2G" , "Apple TV 3" ,
69+ "Apple TV 3 (2013)" , "Apple TV 4 (2015)" , "Apple TV 4K" );
6970
7071 private static final ObservableList <String > deviceTypes = unmodifiableArrayList ("iPhone" , "iPod" , "iPad" , "AppleTV" );
7172
72- private static final HashMap <String , String > requiresBoardConfig = new HashMap <>() ;
73+ private static final Map <String , String > boardConfigs ;
7374
7475 private static final Map <String , String > deviceModelIdentifiers ;
7576
7677 private static final Map <String , String > identifierDeviceModels = new HashMap <>();
7778
7879 static {
7980 try {
80- Properties properties = new Properties ();
81- properties .load (Devices .class .getResourceAsStream ("devicemodels.properties" ));
82- deviceModelIdentifiers = (Map ) properties ;
81+ deviceModelIdentifiers = loadProperties ("devicemodels.properties" );
8382 deviceModelIdentifiers .forEach ((k , v ) -> identifierDeviceModels .put (v , k ));
83+
84+ boardConfigs = loadProperties ("boardconfigs.properties" );
8485 } catch (IOException e ) {
8586 throw new UncheckedIOException (e );
8687 }
87- }
88-
89- static {
90- requiresBoardConfig .put ("iPhone13,4" , "D54pAP" );
91- requiresBoardConfig .put ("iPhone13,3" , "D53pAP" );
92- requiresBoardConfig .put ("iPhone13,2" , "D53gAP" );
93- requiresBoardConfig .put ("iPhone13,1" , "D52gAP" );
94- requiresBoardConfig .put ("iPhone12,8" , "D79AP" );
95- requiresBoardConfig .put ("iPad8,9" , "J417AP" );
96- requiresBoardConfig .put ("iPad8,10" , "J418AP" );
97- requiresBoardConfig .put ("iPad8,11" , "J420AP" );
98- requiresBoardConfig .put ("iPad8,12" , "J421AP" );
99-
100- // devices with multiple board configs
101- requiresBoardConfig .put ("iPhone8,1" , "" );
102- requiresBoardConfig .put ("iPhone8,2" , "" );
103- requiresBoardConfig .put ("iPhone8,4" , "" );
104- requiresBoardConfig .put ("iPad7,11" , "" );
105- requiresBoardConfig .put ("iPad6,11" , "" );
106- requiresBoardConfig .put ("iPad6,12" , "" );
107- }
10888
109- public static ObservableList <String > getiPhones () {
110- return iPhones ;
89+ updateLists ();
11190 }
11291
113- public static ObservableList <String > getiPods () {
114- return iPods ;
92+ /**
93+ * Updates the device lists based on the user preference to show older devices in the UI or not
94+ */
95+ public static void updateLists () {
96+ if (Prefs .getShowOldDevices ()) {
97+ iPhoneList .setAll (iPhones );
98+ iPadList .setAll (iPads );
99+ } else if (!iPhoneList .get (0 ).equals ("iPhone 6+" )) {
100+ iPhoneList .remove (0 , iPhoneList .indexOf ("iPhone 6+" ));
101+ iPadList .remove (0 , iPadList .indexOf ("iPad Mini 4 (Wifi)" ));
102+ }
115103 }
116104
117- public static ObservableList <String > getiPads () {
118- return iPads ;
105+ public static ObservableList <String > getiPhoneList () {
106+ return iPhoneList ;
119107 }
120108
121- public static ObservableList <String > getAppleTVs () {
122- return AppleTVs ;
123- }
109+ // other accessors not used
124110
125111 public static ObservableList <String > getDeviceTypes () {
126112 return deviceTypes ;
127113 }
128114
129- static boolean containsIdentifier (String identifier ) {
115+ public static boolean containsIdentifier (String identifier ) {
130116 return identifierDeviceModels .containsKey (identifier );
131117 }
132118
133- static String getBoardConfig (String identifier ) {
134- return requiresBoardConfig .get (identifier );
119+ public static String getBoardConfig (String identifier ) {
120+ return boardConfigs .get (identifier );
135121 }
136122
137- static String identifierToModel (String identifier ) {
123+ public static String identifierToModel (String identifier ) {
138124 if (identifier == null ) {
139125 return null ;
140126 }
141127 return identifierDeviceModels .get (identifier );
142128 }
143129
144- static String modelToIdentifier (String deviceModel ) {
130+ public static String modelToIdentifier (String deviceModel ) {
145131 if (deviceModel == null ) {
146132 return null ;
147133 }
@@ -151,7 +137,7 @@ static String modelToIdentifier(String deviceModel) {
151137 /**
152138 * @return either "iPhone", "iPod", "iPad", or "AppleTV"
153139 */
154- static String getDeviceType (String identifier ) {
140+ public static String getDeviceType (String identifier ) {
155141 if (identifier .startsWith ("iPhone" )) {
156142 return "iPhone" ;
157143 } else if (identifier .startsWith ("iPod" )) {
@@ -164,17 +150,17 @@ static String getDeviceType(String identifier) {
164150 throw new IllegalArgumentException ("Not found: " + identifier );
165151 }
166152
167- static ObservableList <String > getModelsForType (String deviceType ) {
153+ public static ObservableList <String > getModelsForType (String deviceType ) {
168154 return switch (deviceType == null ? "" : deviceType ) {
169- case "iPhone" -> iPhones ;
170- case "iPod" -> iPods ;
171- case "iPad" -> iPads ;
172- case "AppleTV" -> AppleTVs ;
155+ case "iPhone" -> iPhoneList ;
156+ case "iPod" -> iPodList ;
157+ case "iPad" -> iPadList ;
158+ case "AppleTV" -> AppleTVList ;
173159 default -> FXCollections .emptyObservableList ();
174160 };
175161 }
176162
177- static String getOSNameForType (String deviceType ) {
163+ public static String getOSNameForType (String deviceType ) {
178164 return switch (deviceType == null ? "" : deviceType ) {
179165 case "iPhone" , "iPod" -> "iOS" ;
180166 case "iPad" -> "iOS/iPadOS" ;
@@ -183,21 +169,28 @@ static String getOSNameForType(String deviceType) {
183169 };
184170 }
185171
186- static String getOSNameForIdentifier (String identifier ) {
172+ public static String getOSNameForIdentifier (String identifier ) {
187173 return getOSNameForType (getDeviceType (identifier ));
188174 }
189175
190- static boolean doesRequireBoardConfig (String deviceIdentifier ) {
191- return requiresBoardConfig .containsKey ( deviceIdentifier ) || ! containsIdentifier (deviceIdentifier );
176+ public static boolean doesRequireBoardConfig (String deviceIdentifier ) {
177+ return ! boardConfigs .containsKey (deviceIdentifier );
192178 }
193179
194- static boolean doesRequireApnonce (String deviceIdentifier ) {
180+ public static boolean doesRequireApnonce (String deviceIdentifier ) {
195181 return deviceIdentifier .startsWith ("iPhone11," ) || deviceIdentifier .startsWith ("iPhone12," ) ||
196- deviceIdentifier .startsWith ("iPad8," ) || deviceIdentifier .startsWith ("iPad11," );
182+ deviceIdentifier .startsWith ("iPhone13," ) || deviceIdentifier .startsWith ("iPad8," ) ||
183+ deviceIdentifier .startsWith ("iPad11," );
197184 }
198185
199186 @ SafeVarargs
200187 private static <T > ObservableList <T > unmodifiableArrayList (T ... items ) {
201188 return FXCollections .unmodifiableObservableList (FXCollections .observableArrayList (items ));
202189 }
190+
191+ private static Map <String , String > loadProperties (String resourceName ) throws IOException {
192+ Properties properties = new Properties ();
193+ properties .load (Devices .class .getResourceAsStream (resourceName ));
194+ return (Map ) properties ;
195+ }
203196}
0 commit comments