Skip to content

Commit

Permalink
Updating print-pit output
Browse files Browse the repository at this point in the history
  • Loading branch information
adamoutler committed Nov 24, 2013
1 parent bf31145 commit 194b1d5
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 26 deletions.
17 changes: 11 additions & 6 deletions CASUALcore/src/CASUAL/archiving/libpit/PitEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public String getPartitionFriendlyName() {
while(part_name[i]==0 && i<part_name.length-1){
i++;
if (part_name[i]!=0){
filename=filename+"\nPartition Parameter: "+part_name[i];
filename=filename+" param: "+part_name[i];
break;
}
}
Expand Down Expand Up @@ -377,7 +377,7 @@ public String getFriendlyFileName() {
while(file_name[i]==0 && i<file_name.length-1){
i++;
if (file_name[i]!=0){
filename=filename+"\nFilename Parameter: "+file_name[i];
filename=filename+" param: "+file_name[i];
break;
}
}
Expand Down Expand Up @@ -448,7 +448,7 @@ public String getFOTAFriendlyName() {
while(fota_name[i]==0 && i<fota_name.length-1){
i++;
if (fota_name[i]!=0){
fotaname=fotaname+"\nFOTA Parameter: "+part_name[i];
fotaname=fotaname+" param: "+part_name[i];
break;
}
}
Expand Down Expand Up @@ -604,9 +604,14 @@ File Size (Obsolete): 0
sb.append("Filename: ").append(this.getFriendlyFileName()).append(n);
sb.append("Block Size: ").append(this.block_count).append(" (").append(getBlockCountFriendly(true)).append(")").append(n);
sb.append("Block range: ").append(this.block_start).append(" - ").append(getPartitionEndBlock());
sb.append("(ofs 0x").append(Integer.toHexString(this.block_start)).append(" - 0x").append(Integer.toHexString(getPartitionEndBlock())).append(")").append(n);
sb.append("Part/Dev/Filesystem/Bin/:").append(this.part_type).append(this.bin_type).append(this.filesystem).append(this.bin_type).append(n);
sb.append("FOTA Filename: ").append(this.getFotaName()).append(n);
sb.append(" (hex 0x").append(Integer.toHexString(this.block_start)).append(" - 0x").append(Integer.toHexString(getPartitionEndBlock())).append(")").append(n);
sb.append("PartType: ").append(this.part_type);
sb.append(" DevType: ").append(this.device_type);
sb.append(" FilesystemType: ").append(this.filesystem);
sb.append(" BinType: ").append(this.bin_type).append(n);
sb.append("Offset:").append(this.file_offset);
sb.append(" Size: ").append(this.file_size);
sb.append(" FOTA: ").append(this.getFotaName()).append(n);
sb.append(getPartitionDescritpion());
if (this.getFotaName().contains("remained")){
sb.append(" and the partition will expand to fill the remainder of the ").append(this.getHardwareTypeFriendlyName());
Expand Down
4 changes: 2 additions & 2 deletions CASUALcore/src/CASUAL/resources/CASUALApp.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Sat, 23 Nov 2013 14:01:27 -0600
#Sat, 23 Nov 2013 20:14:59 -0600
#Application.buildnumber=7476
#Wed Nov 20 21:33:54 CST 2013
Application.buildnumber=7476
Expand All @@ -11,6 +11,6 @@ Application.vendor=AdamOutler
Application.id=${Application.name}
Application.vendorId=AdamOutler
Application.interactions=GUI.development.CASUALShowJFrameMessageObject
Application.revision=912
Application.revision=915
Application.description=CASUAL Cross-platform Android Scripting and Unified Auxiliary Loader
Application.title=CASUAL R
51 changes: 48 additions & 3 deletions X/libpitX/src/com/casual_dev/libpitX/PitData.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public boolean matches(PitData otherPitData) {
}

/**
*
* clears all data in the pit file.
*/
public void clear() {
entryCount = 0;
Expand Down Expand Up @@ -323,20 +323,65 @@ public char[] getPhone() {
return pitName;
}

/**
* returns pit name with parameters
* @return PIT friendly name with parameters
*/
public String getPITFriendlyName() {
String pitFriendlyName = "";
for (int i = 0; i < pitName.length; i++) {
//first part of file will be filename
if (pitName[i] != 0) {
pitFriendlyName = pitFriendlyName + pitName[i];
} else { //anything after first 0 byte will be a parameter
while (pitName[i] == 0 && i < pitName.length - 1) {
i++;
if (pitName[i] != 0) {
pitFriendlyName = pitFriendlyName + "\nPIT Parameter: " + pitName[i];
break;
}
}
}
}
return pitFriendlyName;
}
/**
* returns filetype friendly name with parameters
* @return File Type friendly name with parameters
*/
public String getFileTypeFriendlyName() {
String filetypeFriendlyName = "";
for (int i = 0; i < fileType.length; i++) {
//first part of file will be filename
if (fileType[i] != 0) {
filetypeFriendlyName = filetypeFriendlyName + fileType[i];
} else { //anything after first 0 byte will be a parameter
while (fileType[i] == 0 && i < fileType.length - 1) {
i++;
if (fileType[i] != 0) {
filetypeFriendlyName = filetypeFriendlyName + "\nPIT Parameter: " + fileType[i];
break;
}
}
}
}
return filetypeFriendlyName;
}
@Override
public String toString() {
String n = System.getProperty("line.separator");
StringBuilder sb = new StringBuilder();
sb.append(n);
sb.append("PIT Name: ").append(this.pitName).append(n);
sb.append("PIT Name: ").append(getPITFriendlyName()).append(n);
sb.append("Entry Count: ").append(this.entryCount).append(n);
sb.append("File Type: ").append(this.fileType).append(n);
sb.append("File Type: ").append(getFileTypeFriendlyName()).append(n);
sb.append(n);
sb.append(n);
for (int i = 0; i < this.entries.size(); i++) {
sb.append("--- Entry #").append(i).append(" ---").append(n);
sb.append(entries.get(i).toString());
}
sb.append(n).append(n);
return sb.toString();
}

Expand Down
142 changes: 127 additions & 15 deletions X/libpitX/src/com/casual_dev/libpitX/PitEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@ public boolean matches(PitEntry otherPitEntry) {
public int getBinType() {
return bin_type;
}

/**
* gets the friendly name of bin
* AP or CP
* @return AP or CP
*/
public String getBinFriendlyType(){
if (bin_type==0){
return "AP";
} else {
return "CP";
}
}

/**
* binary type
Expand Down Expand Up @@ -278,7 +291,30 @@ public String getPartitionName() {
String partitionName = "";
return new String(part_name).trim();
}

/**
* Proper Friendly name and parameters of partition used to reference flash location
*
* @return partition name
*/
public String getPartitionFriendlyName() {
String filename = "";
for (int i = 0; i < part_name.length; i++) {
//first part of file will be filename
if (part_name[i] != 0) {
filename = filename + part_name[i];
} else { //anything after first 0 byte will be a parameter
while(part_name[i]==0 && i<part_name.length-1){
i++;
if (part_name[i]!=0){
filename=filename+" param: "+part_name[i];
break;
}
}
}

}
return (filename);
}
/**
* Proper name of partition used to reference flash location
*
Expand Down Expand Up @@ -316,12 +352,37 @@ public byte[] getFileNameBytes() {
*
* @return file name
*/
public String getFilename() {
public String getFilenameString() {
String filename = "";
for (int i = 0; i < file_name.length; i++) {
if (file_name[i] != 0) {
filename = filename + file_name[i];
}
}
return (filename);
}

/**
* Name of file when transferred from device
*
* @return file name
*/
public String getFriendlyFileName() {
String filename = "";
for (int i = 0; i < file_name.length; i++) {
//first part of file will be filename
if (file_name[i] != 0) {
filename = filename + file_name[i];
} else { //anything after first 0 byte will be a parameter
while(file_name[i]==0 && i<file_name.length-1){
i++;
if (file_name[i]!=0){
filename=filename+" param: "+file_name[i];
break;
}
}
}

}
return (filename);
}
Expand Down Expand Up @@ -372,7 +433,30 @@ public String getFotaName() {
}
return fotaname;
}

/**
* Proper Friendly name and parameters of partition used to reference flash location
*
* @return partition name
*/
public String getFOTAFriendlyName() {
String fotaname = "";
for (int i = 0; i < fota_name.length; i++) {
//first part of file will be filename
if (fota_name[i] != 0) {
fotaname = fotaname + fota_name[i];
} else { //anything after first 0 byte will be a parameter
while(fota_name[i]==0 && i<fota_name.length-1){
i++;
if (fota_name[i]!=0){
fotaname=fotaname+" param: "+part_name[i];
break;
}
}
}

}
return (fotaname);
}
/**
* Name of file when receiving an OTA update
*
Expand All @@ -396,6 +480,11 @@ public void setFotaName(String fotaName) {
}
}

/**
* returns partition type friendly name
* bct, bootloader, data, mbr, ebr, gp1, gpt, unknown
* @return friendly name of the partition type
*/
public String getPartitionTypeFriendlyName() {
switch (this.part_type) {
case 1:
Expand All @@ -418,7 +507,11 @@ public String getPartitionTypeFriendlyName() {
return "unknown";
}
}

/**
* gets the friendly name of the filesystem type
* raw, basic, enhanced, ext2, yaffs2, unknown
* @return friendly filesystem type name
*/
public String getFilesystemTypeFriendlyName() {
switch (this.filesystem) {
case 0:
Expand All @@ -438,6 +531,11 @@ public String getFilesystemTypeFriendlyName() {
}
}

/**
* returns the friendly hardware type
* nand, emmc, spi, ide, nand_x16, unknown
* @return the name of the hardware device
*/
public String getHardwareTypeFriendlyName() {
switch (this.device_type) {
case 1:
Expand Down Expand Up @@ -475,6 +573,14 @@ public String getBlockCountFriendly(boolean si) {

}


public String getPartitionDescritpion(){
String n = System.getProperty("line.separator");
StringBuilder sb=new StringBuilder();
sb.append("This ").append(this.getPartitionTypeFriendlyName()).append(" partion has a ").append(this.getFilesystemTypeFriendlyName()).append(" partition and resides on the ").append(this.getBinFriendlyType()).append(" ").append(this.getHardwareTypeFriendlyName());
return sb.toString();
}

@Override
public String toString() {
/* original entry from Heimdall
Expand All @@ -494,17 +600,23 @@ File Size (Obsolete): 0
StringBuilder sb = new StringBuilder();
String n = System.getProperty("line.separator");
sb.append("Partition ID: ").append(this.part_id).append(n);
sb.append("Partition Name: ").append(this.getPartitionName()).append(n);
sb.append("Flash Filename: ").append(this.getFilename()).append(n);
sb.append("Block Count: ").append(this.block_count).append(" (").append(getBlockCountFriendly(true)).append(")").append(n);
sb.append("Block Start: ").append(this.block_start).append(n);
sb.append("Last Block: ").append(getPartitionEndBlock()).append(n);
sb.append("Filesystem Type: ").append(this.filesystem).append(" (").append(this.getFilesystemTypeFriendlyName()).append(")").append(n);
sb.append("Partition Type: ").append(this.part_type).append(" (").append(this.getPartitionTypeFriendlyName()).append(")").append(n);
sb.append("Device Type: ").append(this.device_type).append(" (").append(this.getHardwareTypeFriendlyName()).append(")").append(n);
sb.append("Binary Type: ").append(this.bin_type).append(n);
sb.append("FOTA Filename: ").append(this.getFotaName()).append(n);
sb.append(n).append(n);
sb.append("Partition Name: ").append(this.getPartitionFriendlyName()).append(n);
sb.append("Filename: ").append(this.getFriendlyFileName()).append(n);
sb.append("Block Size: ").append(this.block_count).append(" (").append(getBlockCountFriendly(true)).append(")").append(n);
sb.append("Block range: ").append(this.block_start).append(" - ").append(getPartitionEndBlock());
sb.append(" (hex 0x").append(Integer.toHexString(this.block_start)).append(" - 0x").append(Integer.toHexString(getPartitionEndBlock())).append(")").append(n);
sb.append("PartType: ").append(this.part_type);
sb.append(" DevType: ").append(this.device_type);
sb.append(" FilesystemType: ").append(this.filesystem);
sb.append(" BinType: ").append(this.bin_type).append(n);
sb.append("Offset:").append(this.file_offset);
sb.append(" Size: ").append(this.file_size);
sb.append(" FOTA: ").append(this.getFotaName()).append(n);
sb.append(getPartitionDescritpion());
if (this.getFotaName().contains("remained")){
sb.append(" and the partition will expand to fill the remainder of the ").append(this.getHardwareTypeFriendlyName());
}
sb.append(n).append(n).append(n);
return sb.toString();
}

Expand Down

0 comments on commit 194b1d5

Please sign in to comment.