-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Emery Ferrari
committed
Jul 2, 2020
1 parent
420c708
commit d1124b5
Showing
6 changed files
with
209 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.emeryferrari.iosrr; | ||
import javax.xml.parsers.*; | ||
import org.w3c.dom.*; | ||
public class InfoPlist { | ||
private final String deviceName; | ||
private final String displayName; | ||
private final String backupDate; | ||
private final String iOSVersion; | ||
private final String file; | ||
private InfoPlist(String deviceName, String displayName, String backupDate, String iOSVersion, String file) { | ||
this.deviceName = deviceName; | ||
this.displayName = displayName; | ||
this.backupDate = backupDate; | ||
this.iOSVersion = iOSVersion; | ||
this.file = file; | ||
} | ||
public String getDeviceName() { | ||
return deviceName; | ||
} | ||
public String getDisplayName() { | ||
return displayName; | ||
} | ||
public String getBackupDate() { | ||
return backupDate; | ||
} | ||
public String getiOSVersion() { | ||
return iOSVersion; | ||
} | ||
public String getFile() { | ||
return file; | ||
} | ||
public int getiOSRelease() { | ||
String version = iOSVersion.split(" ")[1].substring(0, 2); | ||
if (version.endsWith(".")) { | ||
return Integer.parseInt(version.substring(0, 1)); | ||
} | ||
return Integer.parseInt(version); | ||
} | ||
public static InfoPlist getInstance(String file) { | ||
try { | ||
String fileTemp = file + "Info.plist"; | ||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); | ||
DocumentBuilder builder = factory.newDocumentBuilder(); | ||
Document document = builder.parse(fileTemp); | ||
document.getDocumentElement().normalize(); | ||
NodeList nodes = document.getElementsByTagName("string"); | ||
String displayName = nodes.item(1).getTextContent(); | ||
boolean stop = false; | ||
String deviceName = null; | ||
String iOSVersion = null; | ||
for (int i = 4; !stop; i++) { | ||
if (nodes.item(i).getTextContent().startsWith("iP")) { | ||
deviceName = nodes.item(i+1).getTextContent(); | ||
iOSVersion = "iOS " + nodes.item(i+2).getTextContent(); | ||
stop = true; | ||
} | ||
} | ||
String backupDate = document.getElementsByTagName("date").item(0).getTextContent(); | ||
String backupDate1 = backupDate.substring(0, 10); | ||
String backupDate2 = backupDate.substring(14, 19); | ||
backupDate = backupDate1 + "@" + backupDate2; | ||
return new InfoPlist(deviceName, displayName, backupDate, iOSVersion, file); | ||
} catch (Exception ex) { | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters