file_name
stringlengths
6
86
file_path
stringlengths
45
249
content
stringlengths
47
6.26M
file_size
int64
47
6.26M
language
stringclasses
1 value
extension
stringclasses
1 value
repo_name
stringclasses
767 values
repo_stars
int64
8
14.4k
repo_forks
int64
0
1.17k
repo_open_issues
int64
0
788
repo_created_at
stringclasses
767 values
repo_pushed_at
stringclasses
767 values
BundleCreator.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/BundleCreator.java
package org.flashtool.gui; import java.io.File; import java.io.IOException; import java.util.Iterator; import java.util.Vector; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.List; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Tree; import org.flashtool.flashsystem.Bundle; import org.flashtool.flashsystem.BundleEntry; import org.flashtool.flashsystem.BundleMetaData; import org.flashtool.flashsystem.Category; import org.flashtool.gui.models.CategoriesContentProvider; import org.flashtool.gui.models.CategoriesModel; import org.flashtool.gui.models.SinfilesLabelProvider; import org.flashtool.gui.tools.WidgetTask; import org.flashtool.gui.tools.createFTFJob; import org.flashtool.system.DeviceEntry; import org.flashtool.system.Devices; import org.flashtool.system.OS; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.layout.TreeColumnLayout; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; public class BundleCreator extends Dialog { protected Object result = new String("Create"); protected Shell shlBundler; private Text sourceFolder; private Text device; private Text branding; private Text version; Vector<BundleEntry> files = new Vector<BundleEntry>(); ListViewer listViewerFiles; private Label lblSelectSourceFolder; private Button btnSelectFolder; private Label lblNewLabel_2; private List listFolder; private Label lblNewLabel; private FormData fd_btnToRight; private Button btnToRight; private Composite compositeFirmwareContent; private BundleMetaData meta = new BundleMetaData(); private CategoriesModel model = new CategoriesModel(meta); TreeViewer treeViewerCategories; Button btnNoFinalVerification; private Label lblFolderList; private FormData fd_lblFolderList; private String _branding = ""; private String _version = ""; private String _deviceName=""; private String _variant = ""; public void setBranding(String lbranding) { _branding = lbranding; } public void setVersion(String lversion) { _version = lversion; } public void setVariant(String lid, String lvariant) { _deviceName=lid; _variant = lvariant; } /** * Create the dialog. * @param parent * @param style */ public BundleCreator(Shell parent, int style) { super(parent, style); setText("SWT Dialog"); } /** * Open the dialog. * @return the result */ public Object open() { createContents(); shlBundler.open(); shlBundler.layout(); Display display = getParent().getDisplay(); while (!shlBundler.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } public Object open(String folder) { createContents(); sourceFolder.setText(folder); meta.clear(); files = new Vector<BundleEntry>(); File srcdir = new File(sourceFolder.getText()); File[] chld = srcdir.listFiles(); for(int i = 0; i < chld.length; i++) { if (chld[i].getName().toUpperCase().endsWith("FSC") || chld[i].getName().toUpperCase().endsWith("SIN") || (chld[i].getName().toUpperCase().endsWith("TA")) || (chld[i].getName().toUpperCase().endsWith("XML") && (!chld[i].getName().toUpperCase().contains("UPDATE") && !chld[i].getName().toUpperCase().contains("FWINFO")))) { files.add(new BundleEntry(chld[i])); } } srcdir = new File(sourceFolder.getText()+File.separator+"boot"); if (srcdir.exists()) { chld = srcdir.listFiles(); for(int i = 0; i < chld.length; i++) { if (chld[i].getName().toUpperCase().endsWith("XML")) { files.add(new BundleEntry(chld[i])); } } } srcdir = new File(sourceFolder.getText()+File.separator+"partition"); if (srcdir.exists()) { chld = srcdir.listFiles(); for(int i = 0; i < chld.length; i++) { if (chld[i].getName().toUpperCase().endsWith("XML")) { files.add(new BundleEntry(chld[i])); } } } model.refresh(meta); treeViewerCategories.setInput(model); listViewerFiles.setInput(files); shlBundler.open(); shlBundler.layout(); Display display = getParent().getDisplay(); while (!shlBundler.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlBundler = new Shell(getParent(), getStyle()); shlBundler.setSize(664, 466); shlBundler.setText("Bundler"); shlBundler.setLayout(new FormLayout()); listViewerFiles = new ListViewer(shlBundler, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI); listFolder = listViewerFiles.getList(); FormData fd_listFolder = new FormData(); fd_listFolder.left = new FormAttachment(0, 10); listFolder.setLayoutData(fd_listFolder); listViewerFiles.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector)inputElement; return v.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }); listViewerFiles.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return ((BundleEntry)element).getName(); } }); listViewerFiles.setSorter(new ViewerSorter(){ public int compare(Viewer viewer, Object e1, Object e2) { return ((BundleEntry)e1).getName().compareTo(((BundleEntry)e2).getName()); } }); lblFolderList = new Label(shlBundler, SWT.NONE); fd_listFolder.top = new FormAttachment(lblFolderList, 6); fd_lblFolderList = new FormData(); fd_lblFolderList.left = new FormAttachment(0, 10); lblFolderList.setLayoutData(fd_lblFolderList); lblFolderList.setText("folder list :"); compositeFirmwareContent = new Composite(shlBundler, SWT.NONE); fd_listFolder.bottom = new FormAttachment(compositeFirmwareContent, 0, SWT.BOTTOM); compositeFirmwareContent.setLayout(new TreeColumnLayout()); FormData fd_compositeFirmwareContent = new FormData(); fd_compositeFirmwareContent.top = new FormAttachment(lblFolderList, 6); fd_compositeFirmwareContent.right = new FormAttachment(100, -10); compositeFirmwareContent.setLayoutData(fd_compositeFirmwareContent); treeViewerCategories = new TreeViewer(compositeFirmwareContent, SWT.BORDER | SWT.MULTI); Tree treeCategories = treeViewerCategories.getTree(); treeCategories.setHeaderVisible(true); treeCategories.setLinesVisible(true); treeViewerCategories.setContentProvider(new CategoriesContentProvider()); treeViewerCategories.setLabelProvider(new SinfilesLabelProvider()); treeViewerCategories.setSorter(new ViewerSorter(){ public int compare(Viewer viewer, Object e1, Object e2) { int cat1 = category(e1); int cat2 = category(e2); if (cat1 != cat2) return cat1 - cat2; if ((e1 instanceof Category) && (e2 instanceof Category)) return ((Category)e1).getId().compareTo(((Category)e2).getId()); else return ((File)e1).getName().compareTo(((File)e2).getName()); } }); // Expand the tree treeViewerCategories.setAutoExpandLevel(2); // Provide the input to the ContentProvider treeViewerCategories.setInput(new CategoriesModel(meta)); treeViewerCategories.refresh(); Button btnCancel = new Button(shlBundler, SWT.NONE); fd_compositeFirmwareContent.bottom = new FormAttachment(btnCancel, -5); fd_compositeFirmwareContent.bottom = new FormAttachment(btnCancel, -5); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = new String("Cancel"); shlBundler.dispose(); } }); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100, -10); fd_btnCancel.bottom = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.setText("Cancel"); Button btnCreate = new Button(shlBundler, SWT.NONE); btnCreate.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (sourceFolder.getText().length()==0) { showErrorMessageBox("You must point to a folder containing sin files"); return; } if ((device.getText().length()==0) || (version.getText().length()==0) || (branding.getText().length()==0)) { showErrorMessageBox("Device, Versio, Branding : all fields must be set"); return; } File f = new File(OS.getFolderFirmwares()+File.separator+_variant+"_"+version.getText()+"_"+branding.getText()+".ftf"); if (f.exists()) { showErrorMessageBox("This bundle name already exists"); return; } try { if (f.createNewFile()) f.delete(); else { showErrorMessageBox("The built filename from variant, version and branding is not valid. Choose another name"); return; } } catch (IOException ioe) { showErrorMessageBox("The built filename from variant, version and branding is not valid. Choose another name"); return; } Bundle b = new Bundle(); try { b.setMeta(meta); } catch (Exception ex) {} b.setDevice(_variant); b.setVersion(version.getText()); b.setBranding(branding.getText()); b.setCmd25(btnNoFinalVerification.getSelection()?"true":"false"); b.setNoErase(sourceFolder.getText()+File.separator+"update.xml"); if (!b.hasLoader()) { DeviceEntry ent = Devices.getDeviceFromVariant(_variant); if (ent.hasUnlockedLoader()) { String res = WidgetTask.openLoaderSelect(shlBundler); if (res.equals("U")) b.setLoader(new File(ent.getLoaderUnlocked())); else if (res.equals("L")) b.setLoader(new File(ent.getLoader())); else { showErrorMessageBox("This bundle must contain a loader"); return; } } else { b.setLoader(new File(ent.getLoader())); } } if (!b.hasFsc()) { DeviceEntry dev = Devices.getDeviceFromVariant(_variant); String fscpath = dev.getFlashScript(version.getText(), _variant); File fsc = new File(fscpath); if (fsc.exists()) { String result = WidgetTask.openYESNOBox(shlBundler, "A FSC script is found : "+fsc.getName()+". Do you want to add it ?"); if (Integer.parseInt(result)==SWT.YES) { b.setFsc(fsc); } } } createFTFJob j = new createFTFJob("Create FTF"); j.setBundle(b); j.schedule(); shlBundler.dispose(); } }); FormData fd_btnCreate = new FormData(); fd_btnCreate.bottom = new FormAttachment(100,-10); fd_btnCreate.right = new FormAttachment(btnCancel, -6); btnCreate.setLayoutData(fd_btnCreate); btnCreate.setText("Create"); btnToRight = new Button(shlBundler, SWT.NONE); fd_listFolder.right = new FormAttachment(btnToRight, -6); fd_compositeFirmwareContent.left = new FormAttachment(btnToRight, 6); btnToRight.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection)listViewerFiles.getSelection(); Iterator i = selection.iterator(); while (i.hasNext()) { BundleEntry f = (BundleEntry)i.next(); files.remove(f); try { meta.process(f); model.refresh(meta); treeViewerCategories.setInput(model); } catch (Exception ex) {ex.printStackTrace();} treeViewerCategories.setAutoExpandLevel(2); treeViewerCategories.refresh(); listViewerFiles.refresh(); } } }); fd_btnToRight = new FormData(); fd_btnToRight.right = new FormAttachment(100, -224); btnToRight.setLayoutData(fd_btnToRight); btnToRight.setText("->"); Button btnNewToLeft = new Button(shlBundler, SWT.NONE); fd_btnToRight.bottom = new FormAttachment(100, -143); btnNewToLeft.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection)treeViewerCategories.getSelection(); Iterator i = selection.iterator(); while (i.hasNext()) { Object o = i.next(); if (o instanceof Category) { Category c = (Category)o; Iterator<BundleEntry> j = c.getEntries().iterator(); while (j.hasNext()) { BundleEntry f=j.next(); files.add(f); meta.remove(f); model.refresh(meta); treeViewerCategories.setAutoExpandLevel(2); treeViewerCategories.refresh(); listViewerFiles.refresh(); } } if (o instanceof BundleEntry) { BundleEntry f = (BundleEntry)o; files.add(f); meta.remove(f); model.refresh(meta); treeViewerCategories.setAutoExpandLevel(2); treeViewerCategories.refresh(); listViewerFiles.refresh(); } } } }); FormData fd_btnNewToLeft = new FormData(); fd_btnNewToLeft.top = new FormAttachment(btnToRight, 23); fd_btnNewToLeft.right = new FormAttachment(100, -224); btnNewToLeft.setLayoutData(fd_btnNewToLeft); btnNewToLeft.setText("<-"); Composite compositeFolderSearch = new Composite(shlBundler, SWT.NONE); compositeFolderSearch.setLayout(new GridLayout(3, false)); FormData fd_compositeFolderSearch = new FormData(); fd_compositeFolderSearch.left = new FormAttachment(0, 10); fd_compositeFolderSearch.right = new FormAttachment(100, -10); fd_compositeFolderSearch.top = new FormAttachment(0, 10); compositeFolderSearch.setLayoutData(fd_compositeFolderSearch); lblSelectSourceFolder = new Label(compositeFolderSearch, SWT.NONE); GridData gd_lblSelectSourceFolder = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblSelectSourceFolder.widthHint = 151; lblSelectSourceFolder.setLayoutData(gd_lblSelectSourceFolder); lblSelectSourceFolder.setText("Select source folder :"); sourceFolder = new Text(compositeFolderSearch, SWT.BORDER); sourceFolder.setEditable(false); GridData gd_sourceFolder = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_sourceFolder.widthHint = 415; sourceFolder.setLayoutData(gd_sourceFolder); btnSelectFolder = new Button(compositeFolderSearch, SWT.NONE); btnSelectFolder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); btnSelectFolder.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DirectoryDialog dlg = new DirectoryDialog(shlBundler); // Set the initial filter path according // to anything they've selected or typed in dlg.setFilterPath(sourceFolder.getText()); // Change the title bar text dlg.setText("Directory chooser"); // Customizable message displayed in the dialog dlg.setMessage("Select a directory"); // Calling open() will open and run the dialog. // It will return the selected directory, or // null if user cancels String dir = dlg.open(); if (dir != null) { // Set the text box to the new selection if (!sourceFolder.getText().equals(dir)) { sourceFolder.setText(dir); meta.clear(); files = new Vector(); File srcdir = new File(sourceFolder.getText()); File[] chld = srcdir.listFiles(); for(int i = 0; i < chld.length; i++) { if (chld[i].getName().toUpperCase().endsWith("FSC") || chld[i].getName().toUpperCase().endsWith("SIN") || (chld[i].getName().toUpperCase().endsWith("TA")) || (chld[i].getName().toUpperCase().endsWith("XML") && (!chld[i].getName().toUpperCase().contains("UPDATE") && !chld[i].getName().toUpperCase().contains("FWINFO")))) { files.add(new BundleEntry(chld[i])); } } srcdir = new File(sourceFolder.getText()+File.separator+"boot"); if (srcdir.exists()) { chld = srcdir.listFiles(); for(int i = 0; i < chld.length; i++) { if (chld[i].getName().toUpperCase().endsWith("XML")) { files.add(new BundleEntry(chld[i])); } } } srcdir = new File(sourceFolder.getText()+File.separator+"partition"); if (srcdir.exists()) { chld = srcdir.listFiles(); for(int i = 0; i < chld.length; i++) { if (chld[i].getName().toUpperCase().endsWith("XML")) { files.add(new BundleEntry(chld[i])); } } } model.refresh(meta); treeViewerCategories.setInput(model); listViewerFiles.setInput(files); } } } }); btnSelectFolder.setText("..."); Composite compositeInfos = new Composite(shlBundler, SWT.NONE); fd_lblFolderList.top = new FormAttachment(compositeInfos, 6); compositeInfos.setLayout(new GridLayout(3, false)); FormData fd_compositeInfos = new FormData(); fd_compositeInfos.right = new FormAttachment(100,-10); fd_compositeInfos.top = new FormAttachment(compositeFolderSearch, 6); fd_compositeInfos.left = new FormAttachment(0, 10); compositeInfos.setLayoutData(fd_compositeInfos); lblNewLabel = new Label(compositeInfos, SWT.NONE); GridData gd_lblNewLabel = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); gd_lblNewLabel.widthHint = 68; lblNewLabel.setLayoutData(gd_lblNewLabel); lblNewLabel.setText("Device :"); device = new Text(compositeInfos, SWT.BORDER); device.setToolTipText("Double click to get list of devices"); device.addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { String result = WidgetTask.openDeviceSelector(shlBundler); if (result.length()>0) { DeviceEntry ent = new DeviceEntry(result); String variant = WidgetTask.openVariantSelector(ent.getId(),shlBundler); if (!variant.equals(ent.getId())) { device.setText(ent.getName() + " ("+variant+")"); _variant=variant; } } } }); device.setEditable(false); GridData gd_device = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_device.widthHint = 355; device.setLayoutData(gd_device); new Label(compositeInfos, SWT.NONE); lblNewLabel_2 = new Label(compositeInfos, SWT.NONE); lblNewLabel_2.setText("Branding :"); branding = new Text(compositeInfos, SWT.BORDER); GridData gd_branding = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_branding.widthHint = 355; branding.setLayoutData(gd_branding); btnNoFinalVerification = new Button(compositeInfos, SWT.CHECK); btnNoFinalVerification.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1)); btnNoFinalVerification.setText("No final verification"); Label lblNewLabel_1 = new Label(compositeInfos, SWT.NONE); lblNewLabel_1.setText("Version :"); version = new Text(compositeInfos, SWT.BORDER); GridData gd_version = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_version.widthHint = 355; version.setLayoutData(gd_version); new Label(compositeInfos, SWT.NONE); Label lblFirmwareContent = new Label(shlBundler, SWT.NONE); fd_lblFolderList.right = new FormAttachment(lblFirmwareContent, -67); FormData fd_lblFirmwareContent = new FormData(); fd_lblFirmwareContent.right = new FormAttachment(compositeFirmwareContent, 0, SWT.RIGHT); fd_lblFirmwareContent.bottom = new FormAttachment(compositeFirmwareContent, -6); fd_lblFirmwareContent.left = new FormAttachment(compositeFirmwareContent, 0, SWT.LEFT); lblFirmwareContent.setLayoutData(fd_lblFirmwareContent); lblFirmwareContent.setText("Firmware content :"); branding.setText(_branding); version.setText(_version); if (_deviceName.length()>0) device.setText(_deviceName + " ("+_variant+")"); } public void showErrorMessageBox(String message) { MessageBox mb = new MessageBox(shlBundler,SWT.ICON_ERROR|SWT.OK); mb.setText("Errorr"); mb.setMessage(message); int result = mb.open(); } }
21,122
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
LoaderSelect.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/LoaderSelect.java
package org.flashtool.gui; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.widgets.Label; public class LoaderSelect extends Dialog { protected Object result; protected Shell shell; Button btnLocked; /** * Create the dialog. * @param parent * @param style */ public LoaderSelect(Shell parent, int style) { super(parent, style); setText("Loader chooser"); } /** * Open the dialog. * @return the result */ public Object open() { createContents(); shell.open(); shell.layout(); Display display = getParent().getDisplay(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shell = new Shell(getParent(), getStyle()); shell.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { result = ""; event.doit = true; } }); shell.setSize(281, 143); shell.setText(getText()); shell.setLayout(new FormLayout()); Button btnCancel = new Button(shell, SWT.NONE); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100, -10); fd_btnCancel.bottom = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = ""; shell.dispose(); } }); btnCancel.setText("Cancel"); Button btnOK = new Button(shell, SWT.NONE); FormData fd_btnOK = new FormData(); fd_btnOK.right = new FormAttachment(btnCancel, -6); fd_btnOK.bottom = new FormAttachment(100, -10); btnOK.setLayoutData(fd_btnOK); btnOK.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (btnLocked.getSelection()) result="L"; else result="U"; shell.dispose(); } }); btnOK.setText("Ok"); Composite composite = new Composite(shell, SWT.NONE); FormData fd_composite = new FormData(); fd_composite.top = new FormAttachment(0, 10); fd_composite.left = new FormAttachment(0, 10); composite.setLayoutData(fd_composite); composite.setLayout(new GridLayout(1, false)); btnLocked = new Button(composite, SWT.RADIO); btnLocked.setText("Locked loader"); btnLocked.setSelection(true); Button btnUnlocked = new Button(composite, SWT.RADIO); btnUnlocked.setText("Unlocked loader"); } }
3,026
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
Decrypt.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/Decrypt.java
package org.flashtool.gui; import java.io.File; import java.util.Iterator; import java.util.Vector; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.List; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridData; public class Decrypt extends Dialog { protected Shell shlDecruptWizard; private Text txtSourceFolder; ListViewer listViewerFiles; ListViewer listViewerConvert; Vector files = new Vector(); Vector convert = new Vector(); Vector result = null; /** * Create the dialog. * @param parent * @param style */ public Decrypt(Shell parent, int style) { super(parent, style); } /** * Open the dialog. * @return the result */ public Vector open() { createContents(); shlDecruptWizard.open(); shlDecruptWizard.layout(); Display display = getParent().getDisplay(); while (!shlDecruptWizard.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlDecruptWizard = new Shell(getParent(), getStyle()); shlDecruptWizard.setSize(539, 323); shlDecruptWizard.setText("Decrypt Wizard"); shlDecruptWizard.setLayout(new FormLayout()); listViewerFiles = new ListViewer(shlDecruptWizard, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI); List list = listViewerFiles.getList(); FormData fd_list = new FormData(); fd_list.bottom = new FormAttachment(0, 229); fd_list.right = new FormAttachment(0, 223); fd_list.top = new FormAttachment(0, 71); fd_list.left = new FormAttachment(0, 10); list.setLayoutData(fd_list); listViewerFiles.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector)inputElement; return v.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }); listViewerFiles.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return ((File)element).getName(); } }); Label lblAvailableFiles = new Label(shlDecruptWizard, SWT.NONE); FormData fd_lblAvailableFiles = new FormData(); fd_lblAvailableFiles.right = new FormAttachment(0, 115); fd_lblAvailableFiles.top = new FormAttachment(0, 51); fd_lblAvailableFiles.left = new FormAttachment(0, 10); lblAvailableFiles.setLayoutData(fd_lblAvailableFiles); lblAvailableFiles.setText("Available files :"); listViewerConvert = new ListViewer(shlDecruptWizard, SWT.BORDER | SWT.V_SCROLL); List list_1 = listViewerConvert.getList(); FormData fd_list_1 = new FormData(); fd_list_1.bottom = new FormAttachment(list, 0, SWT.BOTTOM); fd_list_1.top = new FormAttachment(list, 0, SWT.TOP); fd_list_1.right = new FormAttachment(100,-10); fd_list_1.left = new FormAttachment(0, 282); list_1.setLayoutData(fd_list_1); listViewerConvert.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector)inputElement; return v.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }); listViewerConvert.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return ((File)element).getName(); } }); Label lblNewLabel_1 = new Label(shlDecruptWizard, SWT.NONE); FormData fd_lblNewLabel_1 = new FormData(); fd_lblNewLabel_1.top = new FormAttachment(0, 51); fd_lblNewLabel_1.left = new FormAttachment(0, 282); lblNewLabel_1.setLayoutData(fd_lblNewLabel_1); lblNewLabel_1.setText("Files to convert :"); Button btnCancel = new Button(shlDecruptWizard, SWT.NONE); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100, -10); fd_btnCancel.bottom = new FormAttachment(100,-10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { shlDecruptWizard.dispose(); } }); btnCancel.setText("Cancel"); Button btnConvert = new Button(shlDecruptWizard, SWT.NONE); FormData fd_btnConvert = new FormData(); fd_btnConvert.right = new FormAttachment(btnCancel, -6); fd_btnConvert.bottom = new FormAttachment(100,-10); btnConvert.setLayoutData(fd_btnConvert); btnConvert.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (convert.size()>0) result=convert; shlDecruptWizard.dispose(); } }); btnConvert.setText("Convert"); Composite composite = new Composite(shlDecruptWizard, SWT.NONE); composite.setLayout(new GridLayout(3, false)); FormData fd_composite = new FormData(); fd_composite.bottom = new FormAttachment(lblAvailableFiles, -6); fd_composite.left = new FormAttachment(0,10); fd_composite.right = new FormAttachment(100,-10); fd_composite.top = new FormAttachment(0, 10); composite.setLayoutData(fd_composite); Label lblSourceFolder = new Label(composite, SWT.NONE); GridData gd_lblSourceFolder = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblSourceFolder.widthHint = 106; lblSourceFolder.setLayoutData(gd_lblSourceFolder); lblSourceFolder.setText("Source Folder : "); txtSourceFolder = new Text(composite, SWT.BORDER); GridData gd_txtSourceFolder = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_txtSourceFolder.widthHint = 338; txtSourceFolder.setLayoutData(gd_txtSourceFolder); Button btnSourceFolder = new Button(composite, SWT.NONE); GridData gd_btnSourceFolder = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_btnSourceFolder.widthHint = 85; btnSourceFolder.setLayoutData(gd_btnSourceFolder); btnSourceFolder.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DirectoryDialog dlg = new DirectoryDialog(shlDecruptWizard); // Set the initial filter path according // to anything they've selected or typed in dlg.setFilterPath(txtSourceFolder.getText()); // Change the title bar text dlg.setText("Directory chooser"); // Customizable message displayed in the dialog dlg.setMessage("Select a directory"); // Calling open() will open and run the dialog. // It will return the selected directory, or // null if user cancels String dir = dlg.open(); if (dir != null) { // Set the text box to the new selection if (!txtSourceFolder.getText().equals(dir)) { txtSourceFolder.setText(dir); files = new Vector(); convert = new Vector(); File srcdir = new File(txtSourceFolder.getText()); File[] chld = srcdir.listFiles(); for(int i = 0; i < chld.length; i++) { if (chld[i].getName().toUpperCase().startsWith("FILE")) files.add(chld[i]); } listViewerFiles.setInput(files); listViewerConvert.setInput(convert); } } } }); btnSourceFolder.setText("..."); btnSourceFolder.setFont(new Font(Display.getCurrent(),"Arial",11,SWT.NONE)); Composite composite_1 = new Composite(shlDecruptWizard, SWT.NONE); composite_1.setLayout(new GridLayout(1, false)); FormData fd_composite_1 = new FormData(); fd_composite_1.bottom = new FormAttachment(100, -69); fd_composite_1.top = new FormAttachment(composite, 61); fd_composite_1.left = new FormAttachment(list, 5); fd_composite_1.right = new FormAttachment(list_1, -6); composite_1.setLayoutData(fd_composite_1); Button btnNewButton_1 = new Button(composite_1, SWT.NONE); GridData gd_btnNewButton_1 = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_btnNewButton_1.heightHint = 26; gd_btnNewButton_1.widthHint = 40; btnNewButton_1.setLayoutData(gd_btnNewButton_1); btnNewButton_1.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection)listViewerFiles.getSelection(); Iterator i = selection.iterator(); while (i.hasNext()) { File f = (File)i.next(); files.remove(f); convert.add(f); listViewerFiles.refresh(); listViewerConvert.refresh(); } } }); btnNewButton_1.setText("->"); new Label(composite_1, SWT.NONE); Button btnNewButton_2 = new Button(composite_1, SWT.NONE); GridData gd_btnNewButton_2 = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_btnNewButton_2.heightHint = 26; gd_btnNewButton_2.widthHint = 40; btnNewButton_2.setLayoutData(gd_btnNewButton_2); btnNewButton_2.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection)listViewerConvert.getSelection(); Iterator i = selection.iterator(); while (i.hasNext()) { File f = (File)i.next(); convert.remove(f); files.add(f); listViewerFiles.refresh(); listViewerConvert.refresh(); } } }); btnNewButton_2.setText("<-"); } }
10,583
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
WaitDeviceForFlashmode.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/WaitDeviceForFlashmode.java
package org.flashtool.gui; import org.eclipse.core.runtime.Status; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.flashtool.flashsystem.Flasher; import org.flashtool.gui.tools.SearchJob; import org.flashtool.system.DeviceChangedListener; import lombok.extern.slf4j.Slf4j; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.GridLayout; @Slf4j public class WaitDeviceForFlashmode extends Dialog { protected Object result = new String("OK"); protected Shell shlWaitForFlashmode; protected SearchJob job; /** * Create the dialog. * @param parent * @param style */ public WaitDeviceForFlashmode(Shell parent, int style) { super(parent, style); setText("Wait for Flashmode"); } /** * Open the dialog. * @return the result */ public Object open() { createContents(); shlWaitForFlashmode.open(); shlWaitForFlashmode.layout(); shlWaitForFlashmode.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { job.stopSearch(); result = new String("Canceled"); } }); Display display = getParent().getDisplay(); job = new SearchJob("Search Job"); DeviceChangedListener.disableDetection(); job.schedule(); while (!shlWaitForFlashmode.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } if (job.getState() == Status.OK) { shlWaitForFlashmode.dispose(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlWaitForFlashmode = new Shell(getParent(), getStyle()); shlWaitForFlashmode.setSize(580, 580); shlWaitForFlashmode.setText("Wait for Flashmode"); shlWaitForFlashmode.setLayout(new FormLayout()); Composite composite = new Composite(shlWaitForFlashmode, SWT.NONE); FormData fd_composite = new FormData(); fd_composite.left = new FormAttachment(0, 10); fd_composite.top = new FormAttachment(0, 74); composite.setLayoutData(fd_composite); composite.setLayout(new GridLayout(1, false)); // 2012 Line Of Xperias Text Label lblNewLabel00 = new Label(composite, SWT.NONE); lblNewLabel00.setText("2012"); Label lblNewLabel01 = new Label(composite, SWT.NONE); lblNewLabel01.setText("1. Unplug the device"); Label lblNewLabel02 = new Label(composite, SWT.NONE); lblNewLabel02.setText("2. Power off the device"); Label lblNewLabel03 = new Label(composite, SWT.NONE); lblNewLabel03.setText("3. Press the volume DOWN button"); Label lblNewLabel05 = new Label(composite, SWT.NONE); lblNewLabel05.setText("4. Plug the USB cable"); Composite composite2012 = new Composite(shlWaitForFlashmode, SWT.NONE); fd_composite.right = new FormAttachment(composite2012, -23); FormData fd_composite2012 = new FormData(); fd_composite2012.top = new FormAttachment(0, 10); fd_composite2012.left = new FormAttachment(0, 271); composite2012.setLayoutData(fd_composite2012); final GifCLabel lbl = new GifCLabel(composite2012, SWT.CENTER); lbl.setText(""); lbl.setGifImage(this.getClass().getResourceAsStream("/gui/ressources/flashmode2012.gif")); lbl.setBounds(22, 0, 271, 239); Composite composite2011 = new Composite(shlWaitForFlashmode, SWT.NONE); fd_composite2012.bottom = new FormAttachment(composite2011, -7); FormData fd_composite2011 = new FormData(); fd_composite2011.left = new FormAttachment(composite2012, 0, SWT.LEFT); fd_composite2011.right = new FormAttachment(100, -10); fd_composite2011.top = new FormAttachment(0, 256); composite2011.setLayoutData(fd_composite2011); final GifCLabel lbl2 = new GifCLabel(composite2011, SWT.CENTER); lbl2.setText(""); lbl2.setGifImage(this.getClass().getResourceAsStream("/gui/ressources/flashmode2011.gif")); lbl2.setBounds(23, 0, 270, 254); Button btnCancel = new Button(shlWaitForFlashmode, SWT.NONE); fd_composite2011.bottom = new FormAttachment(btnCancel, -6); fd_composite2012.right = new FormAttachment(btnCancel, 0, SWT.RIGHT); FormData fd_btnCancel = new FormData(); fd_btnCancel.bottom = new FormAttachment(100, -10); fd_btnCancel.right = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { job.stopSearch(); result = new String("Canceled"); shlWaitForFlashmode.dispose(); } }); btnCancel.setText("Cancel"); Composite composite_3 = new Composite(shlWaitForFlashmode, SWT.NONE); FormData fd_composite_3 = new FormData(); fd_composite_3.bottom = new FormAttachment(100, -108); fd_composite_3.right = new FormAttachment(composite, 0, SWT.RIGHT); fd_composite_3.left = new FormAttachment(0, 10); composite_3.setLayoutData(fd_composite_3); composite_3.setLayout(new GridLayout(1, false)); // Xperia 2011 Lines of Xperia Text Label lblNewLabel = new Label(composite_3, SWT.NONE); lblNewLabel.setText("2011"); Label lblNewLabel_1 = new Label(composite_3, SWT.NONE); lblNewLabel_1.setText("1. Unplug the device"); Label lblNewLabel_2 = new Label(composite_3, SWT.NONE); lblNewLabel_2.setText("2. Power off the device"); Label lblNewLabel_3 = new Label(composite_3, SWT.NONE); lblNewLabel_3.setText("3. Press the BACK button-"); Label lblNewLabel_4 = new Label(composite_3, SWT.NONE); lblNewLabel_4.setText("-Volume down for Xperia Ray"); Label lblNewLabel_5 = new Label(composite_3, SWT.NONE); lblNewLabel_5.setText("4. Plug the USB cable"); } }
6,016
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
RootPackageSelector.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/RootPackageSelector.java
package org.flashtool.gui; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.layout.GridData; public class RootPackageSelector extends Dialog { protected Object result; protected Shell shell; Button btnSuperuser; /** * Create the dialog. * @param parent * @param style */ public RootPackageSelector(Shell parent, int style) { super(parent, style); setText("Root Package chooser"); } /** * Open the dialog. * @return the result */ public Object open() { createContents(); shell.open(); shell.layout(); Display display = getParent().getDisplay(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shell = new Shell(getParent(), getStyle()); shell.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { result = ""; event.doit = true; } }); shell.setSize(310, 144); shell.setText(getText()); shell.setLayout(new FormLayout()); Button btnCancel = new Button(shell, SWT.NONE); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100, -10); fd_btnCancel.bottom = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = ""; shell.dispose(); } }); btnCancel.setText("Cancel"); Button btnOK = new Button(shell, SWT.NONE); FormData fd_btnOK = new FormData(); fd_btnOK.right = new FormAttachment(btnCancel, -10); fd_btnOK.bottom = new FormAttachment(100, -10); btnOK.setLayoutData(fd_btnOK); btnOK.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (btnSuperuser.getSelection()) result="Superuser"; else result="Supersu"; shell.dispose(); } }); btnOK.setText("Ok"); Composite composite = new Composite(shell, SWT.NONE); FormData fd_composite = new FormData(); fd_composite.left = new FormAttachment(0, 10); fd_composite.top = new FormAttachment(0, 10); composite.setLayoutData(fd_composite); composite.setLayout(new GridLayout(1, false)); btnSuperuser = new Button(composite, SWT.RADIO); btnSuperuser.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); btnSuperuser.setText("Superuser"); btnSuperuser.setSelection(true); Button btnSuperSU = new Button(composite, SWT.RADIO); btnSuperSU.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); btnSuperSU.setText("SuperSU"); } }
3,270
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
VariantSelector.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/VariantSelector.java
package org.flashtool.gui; import java.io.File; import java.util.HashSet; import java.util.Vector; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.flashtool.system.OS; import lombok.extern.slf4j.Slf4j; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.List; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.Viewer; @Slf4j public class VariantSelector extends Dialog { protected Object result; protected Shell shlVariantSelector; private Button btnCancel; HashSet<String> currentVariant; private List listVariant; /** * Create the dialog. * @param parent * @param style */ public VariantSelector(Shell parent, int style) { super(parent, style); setText("Variant Selector"); } /** * Open the dialog. * @return the result */ public Object open(HashSet<String> variantlist) { if (variantlist.size()==0) return null; currentVariant = variantlist; createContents(); shlVariantSelector.open(); shlVariantSelector.layout(); Display display = getParent().getDisplay(); while (!shlVariantSelector.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlVariantSelector = new Shell(getParent(), getStyle()); shlVariantSelector.setSize(261, 318); shlVariantSelector.setText("Variant Selector"); shlVariantSelector.setLayout(new FormLayout()); btnCancel = new Button(shlVariantSelector, SWT.NONE); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = null; shlVariantSelector.dispose(); } }); btnCancel.setText("Cancel"); ListViewer listVariantViewer = new ListViewer(shlVariantSelector, SWT.BORDER | SWT.V_SCROLL); listVariant = listVariantViewer.getList(); fd_btnCancel.bottom = new FormAttachment(100, -10); FormData fd_listVariant = new FormData(); fd_listVariant.top = new FormAttachment(0, 10); fd_listVariant.right = new FormAttachment(100, -10); fd_listVariant.left = new FormAttachment(0, 10); fd_listVariant.bottom = new FormAttachment(btnCancel, -6); listVariant.setLayoutData(fd_listVariant); listVariant.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { int selected = listVariant.getSelectionIndex(); String string = listVariant.getItem(selected); result = string; shlVariantSelector.dispose(); } }); listVariantViewer.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { HashSet<String> s = (HashSet<String>)inputElement; return s.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }); listVariantViewer.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return (String)element; } }); listVariantViewer.setInput(currentVariant); } }
3,987
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
DeviceSelector.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/DeviceSelector.java
package org.flashtool.gui; import java.util.Enumeration; import java.util.Properties; import java.util.Vector; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; import org.flashtool.gui.models.TableLine; import org.flashtool.gui.models.TableSorter; import org.flashtool.gui.models.VectorContentProvider; import org.flashtool.gui.models.VectorLabelProvider; import org.flashtool.system.DeviceEntry; import org.flashtool.system.Devices; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; public class DeviceSelector extends Dialog { protected Object result; protected Shell shlDeviceSelector; private Table tableDevices; private TableViewer tableViewer; /** * Create the dialog. * @param parent * @param style */ public DeviceSelector(Shell parent, int style) { super(parent, style); setText("Device Selector"); } /** * Open the dialog. * @return the result */ public Object open() { createContents(); fillTable(); shlDeviceSelector.open(); shlDeviceSelector.layout(); Display display = getParent().getDisplay(); while (!shlDeviceSelector.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Open the dialog. * @return the result */ public Object open(Properties p) { createContents(); fillTable(p); shlDeviceSelector.open(); shlDeviceSelector.layout(); Display display = getParent().getDisplay(); while (!shlDeviceSelector.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlDeviceSelector = new Shell(getParent(), getStyle()); shlDeviceSelector.setSize(289, 434); shlDeviceSelector.setText("Device Selector"); shlDeviceSelector.setLayout(new FormLayout()); Button btnCancel = new Button(shlDeviceSelector, SWT.NONE); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = null; shlDeviceSelector.dispose(); } }); FormData fd_btnCancel = new FormData(); fd_btnCancel.bottom = new FormAttachment(100, -10); fd_btnCancel.right = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.setText("Cancel"); Composite compositeTable = new Composite(shlDeviceSelector, SWT.NONE); compositeTable.setLayout(new FillLayout(SWT.HORIZONTAL)); FormData fd_compositeTable = new FormData(); fd_compositeTable.bottom = new FormAttachment(btnCancel, -6); fd_compositeTable.right = new FormAttachment(100,-10); fd_compositeTable.top = new FormAttachment(0, 10); fd_compositeTable.left = new FormAttachment(0, 10); compositeTable.setLayoutData(fd_compositeTable); tableViewer = new TableViewer(compositeTable,SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.SINGLE); tableViewer.setContentProvider(new VectorContentProvider()); tableViewer.setLabelProvider(new VectorLabelProvider()); tableDevices = tableViewer.getTable(); TableColumn[] columns = new TableColumn[2]; columns[0] = new TableColumn(tableDevices, SWT.NONE); columns[0].setText("Id"); columns[1] = new TableColumn(tableDevices, SWT.NONE); columns[1].setText("Name"); tableDevices.setHeaderVisible(true); tableDevices.setLinesVisible(true); tableDevices.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { TableItem[] selection = tableDevices.getSelection(); String string = selection[0].getText(0); result = string; shlDeviceSelector.dispose(); } }); TableSorter sort = new TableSorter(tableViewer); } public void fillTable() { Vector result = new Vector(); Enumeration<Object> e = Devices.listDevices(false); while (e.hasMoreElements()) { DeviceEntry entry = Devices.getDevice((String)e.nextElement()); TableLine line = new TableLine(); line.add(entry.getId()); line.add(entry.getName()); result.add(line); } tableViewer.setInput(result); tableViewer.getTable().setSortColumn(tableDevices.getColumn(0)); for (int nbcols=0;nbcols<tableDevices.getColumnCount();nbcols++) tableDevices.getColumn(nbcols).pack(); tableDevices.setSortColumn(tableDevices.getColumn(0)); tableDevices.setSortDirection(SWT.UP); tableViewer.refresh(); } public void fillTable(Properties p) { Vector result = new Vector(); Enumeration<Object> e = p.keys(); while (e.hasMoreElements()) { TableLine line = new TableLine(); String key = (String)e.nextElement(); line.add(key); line.add(p.getProperty(key)); result.add(line); } tableViewer.setInput(result); for (int nbcols=0;nbcols<tableDevices.getColumnCount();nbcols++) tableDevices.getColumn(nbcols).pack(); tableDevices.setSortColumn(tableDevices.getColumn(0)); tableDevices.setSortDirection(SWT.UP); tableViewer.refresh(); } }
5,648
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
ElfEditor.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/ElfEditor.java
package org.flashtool.gui; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.RandomAccessFile; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Button; import org.flashtool.windowbuilder.swt.SWTResourceManager; import lombok.extern.slf4j.Slf4j; import org.flashtool.binutils.elf.Attribute; import org.flashtool.binutils.elf.Elf; import org.flashtool.binutils.elf.ProgramHeader; import org.flashtool.binutils.elf.Section; import org.flashtool.flashsystem.S1Command; import org.flashtool.util.HexDump; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @Slf4j public class ElfEditor extends Dialog { protected Object result; protected Shell shlElfExtractor; private Text sourceFile; private Text textNbParts; private Elf elfobj; private Button btnExtract; /** * Create the dialog. * @param parent * @param style */ public ElfEditor(Shell parent, int style) { super(parent, style); setText("SWT Dialog"); } /** * Open the dialog. * @return the result */ public Object open() { createContents(); shlElfExtractor.open(); shlElfExtractor.layout(); Display display = getParent().getDisplay(); while (!shlElfExtractor.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlElfExtractor = new Shell(getParent(), getStyle()); shlElfExtractor.setSize(538, 183); shlElfExtractor.setText("Elf Extractor"); shlElfExtractor.setLayout(new FormLayout()); Composite composite = new Composite(shlElfExtractor, SWT.NONE); composite.setLayout(new GridLayout(3, false)); FormData fd_composite = new FormData(); fd_composite.top = new FormAttachment(0, 10); fd_composite.right = new FormAttachment(100, -10); fd_composite.left = new FormAttachment(0, 10); composite.setLayoutData(fd_composite); Label lblElfFile = new Label(composite, SWT.NONE); GridData gd_lblElfFile = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); gd_lblElfFile.widthHint = 62; lblElfFile.setLayoutData(gd_lblElfFile); lblElfFile.setText("Elf file :"); sourceFile = new Text(composite, SWT.BORDER); sourceFile.setEditable(false); GridData gd_sourceFile = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_sourceFile.widthHint = 385; sourceFile.setLayoutData(gd_sourceFile); Button btnFileChoose = new Button(composite, SWT.NONE); btnFileChoose.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog dlg = new FileDialog(shlElfExtractor); // Set the initial filter path according // to anything they've selected or typed in dlg.setFilterPath(sourceFile.getText()); dlg.setFilterExtensions(new String[]{"*.elf"}); // Change the title bar text dlg.setText("ELF File Chooser"); // Calling open() will open and run the dialog. // It will return the selected directory, or // null if user cancels String dir = dlg.open(); if (dir != null) { // Set the text box to the new selection if (!sourceFile.getText().equals(dir)) { try { elfobj = new org.flashtool.binutils.elf.Elf(new File(dir)); elfobj.loadSymbols(); Attribute attributes = elfobj.getAttributes(); Section[] sections = elfobj.getSections(); ProgramHeader[] programHeaders = elfobj.getProgramHeaders(); textNbParts.setText(Integer.toString(elfobj.getProgramHeaders().length)); sourceFile.setText(dir); btnExtract.setEnabled(true); log.info("You can now press the Unpack button to get the elf data content"); } catch (Exception ex) { ex.printStackTrace(); } } } } }); GridData gd_btnFileChoose = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_btnFileChoose.widthHint = 34; btnFileChoose.setLayoutData(gd_btnFileChoose); btnFileChoose.setText("..."); btnFileChoose.setFont(SWTResourceManager.getFont("Arial", 11, SWT.NORMAL)); Composite composite_1 = new Composite(shlElfExtractor, SWT.NONE); composite_1.setLayout(new GridLayout(3, false)); FormData fd_composite_1 = new FormData(); fd_composite_1.left = new FormAttachment(0,10); fd_composite_1.right = new FormAttachment(100, -10); fd_composite_1.top = new FormAttachment(composite, 6); composite_1.setLayoutData(fd_composite_1); Label lblNewLabel = new Label(composite_1, SWT.NONE); GridData gd_lblNewLabel = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); gd_lblNewLabel.widthHint = 129; lblNewLabel.setLayoutData(gd_lblNewLabel); lblNewLabel.setText("Number of parts : "); textNbParts = new Text(composite_1, SWT.BORDER); textNbParts.setEditable(false); btnExtract = new Button(composite_1, SWT.NONE); btnExtract.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { doUnpack(elfobj); } catch (Exception ex) { log.error(ex.getMessage()); } } }); btnExtract.setText("Unpack"); btnExtract.setEnabled(false); Button btnClose = new Button(shlElfExtractor, SWT.NONE); btnClose.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { shlElfExtractor.dispose(); } }); FormData fd_btnClose = new FormData(); fd_btnClose.bottom = new FormAttachment(100, -10); fd_btnClose.right = new FormAttachment(100,-10); btnClose.setLayoutData(fd_btnClose); btnClose.setText("Close"); } public void doUnpack(Elf elf) throws FileNotFoundException, IOException { String ctype=""; RandomAccessFile fin = new RandomAccessFile(elf.getFilename(),"r"); ProgramHeader[] aProgramHeaders = elf.getProgramHeaders(); int i = 0; for (ProgramHeader ph : aProgramHeaders) { fin.seek(ph.getFileOffset()); byte[] ident = new byte[ph.getFileSize()<352?(int)ph.getFileSize():352]; fin.read(ident); String identHex = HexDump.toHex(ident); if (identHex.contains("1F 8B")) ctype="ramdisk.gz"; else if (identHex.contains("00 00 A0 E1")) ctype="Image"; else if (identHex.contains("41 52 4D 64")) ctype="Image"; else if (identHex.contains("51 43 44 54")) ctype="qcdt"; else if (identHex.contains("53 31 5F 52 50 4D")) ctype="rpm.bin"; else if (new String(ident).contains("S1_Root") || new String(ident).contains("S1_SW_Root")) ctype="cert"; else if (ident.length<200) ctype="bootcmd"; else ctype=Integer.toString(i); fin.seek(ph.getFileOffset()); byte[] image = new byte[(int)ph.getFileSize()]; fin.read(image); log.info("Extracting part " + i + " to " +elf.getFilename()+"."+ctype); File f = new File(elf.getFilename()+"."+ctype); FileOutputStream fout = new FileOutputStream(f); fout.write(image); image=null; fout.flush(); fout.close(); i++; } fin.close(); log.info("ELF Extraction finished"); } }
7,780
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
CTabItemWithHexViewer.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/CTabItemWithHexViewer.java
package org.flashtool.gui; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.custom.CaretEvent; import org.eclipse.swt.custom.CaretListener; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.DragDetectEvent; import org.eclipse.swt.events.DragDetectListener; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseWheelListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.ScrollBar; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.flashtool.flashsystem.Bundle; import org.flashtool.flashsystem.S1Command; import org.flashtool.windowbuilder.swt.SWTResourceManager; import lombok.extern.slf4j.Slf4j; @Slf4j public class CTabItemWithHexViewer { private CTabFolder parent; private StyledText counter; private StyledText hexContent; private StyledText binContent; private String name; private int style; public CTabItemWithHexViewer(CTabFolder parent, String name, int style) { this.parent = parent; this.name = name; this.style = style; createEditor(); } public void loadContent(byte[] buffer) { hexContent.setText(""); int ctr = 0; StringBuffer hexContentStringBuffer = new StringBuffer(); StringBuffer counterStringBuffer = new StringBuffer("000000"); StringBuffer binContentStringBuffer = new StringBuffer(); for(byte c: buffer){ ctr++; String hex = String.format("%02X", c); char ch = (char)c; if (ch < 32 || ch > 126) { ch = '.'; } if(ctr % 16 == 0){ hexContentStringBuffer.append(hex).append("\n"); binContentStringBuffer.append(ch).append("\n"); counterStringBuffer.append("\n").append(String.format("%06d", ctr)); } else if (ctr % 8 == 0){ hexContentStringBuffer.append(hex).append(" "); binContentStringBuffer.append(ch); } else { hexContentStringBuffer.append(hex).append(" "); binContentStringBuffer.append(ch); } } hexContent.setText(hexContentStringBuffer.toString()); binContent.setText(binContentStringBuffer.toString()); counter.setText(counterStringBuffer.toString()); } private void createEditor(){ CTabItem tabItem = new CTabItem(parent, style); tabItem.setText(name); Composite composite = new Composite(parent, SWT.NONE); tabItem.setControl(composite); FormLayout fl_composite = new FormLayout(); fl_composite.marginWidth = 0; fl_composite.marginHeight = 0; composite.setLayout(fl_composite); counter = new StyledText(composite, SWT.BORDER | SWT.READ_ONLY); //counter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); FormData fd_counter = new FormData(); fd_counter.top=new FormAttachment(0, 0); fd_counter.bottom=new FormAttachment(100, 0); fd_counter.left=new FormAttachment(0, 0); counter.setLayoutData(fd_counter); counter.setFont(SWTResourceManager.getFont("Courier New", 10, SWT.NORMAL)); addListeners(counter); hexContent = new StyledText(composite, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL); FormData fd_hexContent = new FormData(); fd_hexContent.top=new FormAttachment(0, 0); fd_hexContent.bottom=new FormAttachment(100, 0); fd_hexContent.left=new FormAttachment(counter, 0); fd_hexContent.width=400; hexContent.setLayoutData(fd_hexContent); hexContent.setFont(SWTResourceManager.getFont("Courier New", 10, SWT.NORMAL)); addListeners(hexContent); binContent = new StyledText(composite, SWT.BORDER | SWT.READ_ONLY ); FormData fd_binContent = new FormData(); fd_binContent.top=new FormAttachment(0, 0); fd_binContent.bottom=new FormAttachment(100, 0); fd_binContent.left=new FormAttachment(hexContent, 0); fd_binContent.right=new FormAttachment(100, 0); binContent.setLayoutData(fd_binContent); //binContent.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, true, 1, 1)); binContent.setFont(SWTResourceManager.getFont("Courier New", 10, SWT.NORMAL)); addListeners(binContent); parent.setSelection(tabItem); } private void addListeners(final StyledText txt){ txt.addMouseWheelListener(new MouseWheelListener() { public void mouseScrolled(MouseEvent arg0) { binContent.setTopIndex(txt.getTopIndex()); hexContent.setTopIndex(txt.getTopIndex()); counter.setTopIndex(txt.getTopIndex()); } }); txt.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { binContent.setTopIndex(txt.getTopIndex()); hexContent.setTopIndex(txt.getTopIndex()); counter.setTopIndex(txt.getTopIndex()); } public void widgetSelected(SelectionEvent arg0) { binContent.setTopIndex(txt.getTopIndex()); hexContent.setTopIndex(txt.getTopIndex()); counter.setTopIndex(txt.getTopIndex()); } }); txt.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent arg0) { binContent.setTopIndex(txt.getTopIndex()); hexContent.setTopIndex(txt.getTopIndex()); counter.setTopIndex(txt.getTopIndex()); } }); txt.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent arg0) { binContent.setTopIndex(txt.getTopIndex()); hexContent.setTopIndex(txt.getTopIndex()); counter.setTopIndex(txt.getTopIndex()); } }); txt.addCaretListener(new CaretListener() { public void caretMoved(CaretEvent arg0) { binContent.setTopIndex(txt.getTopIndex()); hexContent.setTopIndex(txt.getTopIndex()); counter.setTopIndex(txt.getTopIndex()); } }); txt.addDragDetectListener(new DragDetectListener() { public void dragDetected(DragDetectEvent arg0) { binContent.setTopIndex(txt.getTopIndex()); hexContent.setTopIndex(txt.getTopIndex()); counter.setTopIndex(txt.getTopIndex()); } }); ScrollBar vbar = txt.getVerticalBar(); if(vbar != null){ vbar.addListener(SWT.Selection, new Listener(){ public void handleEvent(Event arg0) { binContent.setTopIndex(txt.getTopIndex()); hexContent.setTopIndex(txt.getTopIndex()); counter.setTopIndex(txt.getTopIndex()); } }); } } }
6,797
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
Main.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/Main.java
package org.flashtool.gui; import org.flashtool.flashsystem.FlasherConsole; import org.flashtool.jna.linux.JUsb; import org.flashtool.libusb.LibUsbException; import org.flashtool.logger.MyLogger; import org.flashtool.system.AWTKillerThread; import org.flashtool.system.GlobalConfig; import org.flashtool.system.OS; import lombok.extern.slf4j.Slf4j; import picocli.CommandLine; import picocli.CommandLine.Option; @Slf4j public class Main { @Option(names = {"-console" }, paramLabel = "CONSOLE", description = "Console mode invocation") private boolean console; @Option(names = { "--action" }, paramLabel = "ACTION", description = "Console mode action type") String action; @Option(names = { "--file" }, paramLabel = "FILE", description = "Console mode action type") String file; @Option(names = { "--wipedata" }, paramLabel = "FILE", description = "Console mode action type") String wipedata; @Option(names = { "--wipecache" }, paramLabel = "WIPECACHE", description = "Console mode action type") String wipecache; @Option(names = { "--baseband" }, paramLabel = "BASEBAND", description = "Console mode action type") String baseband; @Option(names = { "--kernel" }, paramLabel = "KERNEL", description = "Console mode action type") String kernel; @Option(names = { "--system" }, paramLabel = "SYSTEM", description = "Console mode action type") String system; @Option(names = { "-h", "--help" }, usageHelp = true, description = "display a help message") private boolean helpRequested; public static void main(String[] args) { Main main = new Main(); new CommandLine(main).parseArgs(args); main.run(); } public void run () { MyLogger.setMode(MyLogger.CONSOLE_MODE); MyLogger.setLevel(GlobalConfig.getProperty("loglevel")); log.info("JAVA_HOME : "+System.getProperty("java.home")); OS.getFolderFirmwaresDownloaded(); OS.getFolderFirmwaresPrepared(); OS.getFolderFirmwaresSinExtracted(); OS.getFolderMyDevices(); OS.getFolderRegisteredDevices(); AWTKillerThread k = new AWTKillerThread(); k.start(); try { Main.initLinuxUsb(); if (console) { processConsole(); } else { MyLogger.setMode(MyLogger.GUI_MODE); MainSWT window = new MainSWT(); window.open(); } } catch (Exception e) { e.printStackTrace(); } k.done(); } public static void initLinuxUsb() throws LibUsbException { if (OS.getName()!="windows") JUsb.init(); } /* private static OptionSet parseCmdLine(String[] args) { OptionParser parser = new OptionParser(); OptionSet options; parser.accepts( "console" ); try { options = parser.parse(args); } catch (Exception e) { parser.accepts("action").withRequiredArg().required(); parser.accepts("file").withOptionalArg().defaultsTo(""); parser.accepts("method").withOptionalArg().defaultsTo("auto"); parser.accepts("wipedata").withOptionalArg().defaultsTo("yes"); parser.accepts("wipecache").withOptionalArg().defaultsTo("yes"); parser.accepts("baseband").withOptionalArg().defaultsTo("yes"); parser.accepts("system").withOptionalArg().defaultsTo("yes"); parser.accepts("kernel").withOptionalArg().defaultsTo("yes"); options = parser.parse(args); } return options; }*/ public void processConsole() throws Exception { if (action == null) { System.out.println("An action is mandatory in console mode"); FlasherConsole.exit(); } if (action.toLowerCase().equals("flash")) { FlasherConsole.init(false); FlasherConsole.doFlash(file, wipedata.equals("yes"), wipecache.equals("yes"), baseband.equals("no"), kernel.equals("no"), system.equals("no")); } if (action.toLowerCase().equals("imei")) { FlasherConsole.init(false); FlasherConsole.doGetIMEI(); } if (action.toLowerCase().equals("root")) { FlasherConsole.init(true); FlasherConsole.doRoot(); } if (action.toLowerCase().equals("extract")) { FlasherConsole.init(true); FlasherConsole.doExtract(file); } //if (action.toLowerCase().equals("blunlock")) { // FlasherConsole.init(true); // FlasherConsole.doBLUnlock(); //} FlasherConsole.exit(); } }
4,201
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
MainSWT.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/MainSWT.java
package org.flashtool.gui; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.Properties; import java.util.Vector; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; import java.util.zip.Deflater; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.IJobChangeListener; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.ToolBar; import org.eclipse.swt.widgets.ToolItem; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.MenuItem; import org.flashtool.windowbuilder.swt.SWTResourceManager; import lombok.extern.slf4j.Slf4j; import org.flashtool.flashsystem.Bundle; import org.flashtool.flashsystem.Flasher; import org.flashtool.flashsystem.FlasherFactory; import org.flashtool.flashsystem.S1Command; import org.flashtool.gui.models.TABag; import org.flashtool.gui.models.TADevice; import org.flashtool.gui.tools.APKInstallJob; import org.flashtool.gui.tools.BackupSystemJob; import org.flashtool.gui.tools.BackupTAJob; import org.flashtool.gui.tools.BusyboxInstallJob; import org.flashtool.gui.tools.CleanJob; import org.flashtool.gui.tools.DecryptJob; import org.flashtool.gui.tools.DeviceApps; import org.flashtool.gui.tools.FTDExplodeJob; import org.flashtool.gui.tools.FlashJob; import org.flashtool.gui.tools.GetULCodeJob; import org.flashtool.gui.tools.MsgBox; import org.flashtool.gui.tools.OldUnlockJob; import org.flashtool.gui.tools.RawTAJob; import org.flashtool.gui.tools.RestoreTAJob; import org.flashtool.gui.tools.RootJob; import org.flashtool.gui.tools.VersionCheckerJob; import org.flashtool.gui.tools.WidgetTask; import org.flashtool.gui.tools.Yaffs2Job; import org.flashtool.jna.adb.AdbUtility; import org.flashtool.jna.linux.JUsb; import org.flashtool.logger.LogProgress; import org.flashtool.logger.MyLogger; import org.flashtool.parsers.ta.TARawParser; import org.flashtool.system.DeviceChangedListener; import org.flashtool.system.DeviceEntry; import org.flashtool.system.DeviceProperties; import org.flashtool.system.Devices; import org.flashtool.system.FTDEntry; import org.flashtool.system.FTShell; import org.flashtool.system.GlobalConfig; import org.flashtool.system.GlobalState; import org.flashtool.system.OS; import org.flashtool.system.Proxy; import org.flashtool.system.StatusEvent; import org.flashtool.system.StatusListener; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.widgets.ProgressBar; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.program.Program; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.custom.ScrolledComposite; @Slf4j public class MainSWT { protected Shell shlSonyericsson; //private static AdbPhoneThread phoneWatchdog; public static boolean guimode=false; protected ToolItem tltmFlash; protected ToolItem tltmRoot; protected ToolItem tltmAskRoot; protected ToolItem tltmBLU; protected ToolItem tltmClean; protected ToolItem tltmRecovery; protected ToolItem tltmApkInstall; protected MenuItem mntmSwitchPro; protected MenuItem mntmAdvanced; protected MenuItem mntmNoDevice; protected MenuItem mntmInstallBusybox; protected MenuItem mntmRawBackup; protected MenuItem mntmRawRestore; protected MenuItem mntmTARestore; protected MenuItem mntmBackupSystemApps; protected MenuItem mntmFlashSingleTA; protected MenuItem mntmFlashFromRaw; protected VersionCheckerJob vcheck; /** * Open the window. */ public void open() { if (GlobalConfig.getProperty("gitauto")==null) GlobalConfig.setProperty("gitauto", "true"); Display.setAppName("Flashtool"); Display display = Display.getDefault(); GlobalConfig.setProperty("clientheight", Integer.toString(display.getClientArea().height)); GlobalConfig.setProperty("clientwidth", Integer.toString(display.getClientArea().width)); GlobalConfig.setProperty("ydpi", Integer.toString(display.getDPI().y)); GlobalConfig.setProperty("xdpi", Integer.toString(display.getDPI().x)); createContents(); guimode=true; shlSonyericsson.open(); shlSonyericsson.layout(); shlSonyericsson.setSize(800, 450); boolean folderexists = (new File(OS.getWorkDir()+File.separator+"firmwares").exists() || new File(OS.getWorkDir()+File.separator+"custom"+File.separator+"mydevices").exists()); if (folderexists) { HomeSelector hs = new HomeSelector(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); String result = (String)hs.open(false); GlobalConfig.setProperty("user.flashtool", result); forceMove(OS.getWorkDir()+File.separator+"firmwares",OS.getFolderFirmwares()); forceMove(OS.getWorkDir()+File.separator+"custom"+File.separator+"mydevices",OS.getFolderRegisteredDevices()); new File(OS.getWorkDir()+File.separator+"firmwares").delete(); new File(OS.getWorkDir()+File.separator+"custom"+File.separator+"mydevices").delete(); } if (GlobalConfig.getProperty("gitauto").equals("true")) { WaitForDevicesSync sync = new WaitForDevicesSync(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); sync.open(); } WidgetTask.setEnabled(mntmAdvanced,GlobalConfig.getProperty("devfeatures").equals("yes")); StatusListener phoneStatus = new StatusListener() { public void statusChanged(StatusEvent e) { if (!e.isDriverOk()) { log.error("Drivers need to be installed for connected device."); log.error("You can find them in the drivers folder of Flashtool."); } else { if (e.getNew().equals("adb_unauthorized")) { log.info("Unauthorized device connected with USB debugging on"); log.info("Check the device to accept the authorization"); } if (e.getNew().equals("adb")) { log.info("Device connected with USB debugging on"); log.debug("Device connected, continuing with identification"); doIdent(); } if (e.getNew().equals("none")) { log.info("Device disconnected"); doDisableIdent(); } if (e.getNew().equals("flash")) { log.info("Device connected in flash mode"); doDisableIdent(); } if (e.getNew().equals("flash_obsolete")) { log.error("Device connected in flash mode but driver is too old"); doDisableIdent(); } if (e.getNew().equals("fastboot")) { log.info("Device connected in fastboot mode"); doDisableIdent(); } if (e.getNew().equals("normal")) { log.info("Device connected with USB debugging off"); log.info("For 2011 devices line, be sure you are not in MTP mode"); doDisableIdent(); } } } }; killAdbandFastboot(); Devices.load(); log.info("Starting phone detection"); DeviceChangedListener.starts(phoneStatus); //phoneWatchdog = new AdbPhoneThread(); //phoneWatchdog.start(); //phoneWatchdog.addStatusListener(phoneStatus); while (!shlSonyericsson.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } public void doDisableIdent() { WidgetTask.setEnabled(tltmFlash,true); WidgetTask.setEnabled(tltmRoot,false); WidgetTask.setEnabled(tltmAskRoot,false); WidgetTask.setEnabled(tltmApkInstall,false); WidgetTask.setMenuName(mntmNoDevice, "No Device"); WidgetTask.setEnabled(mntmNoDevice,false); WidgetTask.setEnabled(mntmRawBackup,false); WidgetTask.setEnabled(mntmRawRestore,false); WidgetTask.setEnabled(mntmTARestore,false); WidgetTask.setEnabled(tltmClean,false); WidgetTask.setEnabled(tltmRecovery,false); } /** * Create contents of the window. * @wbp.parser.entryPoint */ protected void createContents() { shlSonyericsson = new Shell(); shlSonyericsson.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { exitProgram(); shlSonyericsson.dispose(); } }); shlSonyericsson.setSize(800, 460); shlSonyericsson.setText("Sony Mobile Flasher by Androxyde"); shlSonyericsson.setImage(SWTResourceManager.getImage(MainSWT.class, "/gui/ressources/icons/flash_512.png")); shlSonyericsson.setLayout(new FormLayout() ); Menu menu = new Menu(shlSonyericsson, SWT.BAR); shlSonyericsson.setMenuBar(menu); MenuItem mntmFile = new MenuItem(menu, SWT.CASCADE); mntmFile.setText("File"); Menu menu_1 = new Menu(mntmFile); mntmFile.setMenu(menu_1); mntmSwitchPro = new MenuItem(menu_1, SWT.NONE); mntmSwitchPro.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean ispro = GlobalConfig.getProperty("devfeatures").equals("yes"); GlobalConfig.setProperty("devfeatures", ispro?"no":"yes"); ispro = GlobalConfig.getProperty("devfeatures").equals("yes"); WidgetTask.setEnabled(mntmAdvanced,ispro); if (ispro) { if (Devices.HasOneAdbConnected()) { boolean hasRoot = Devices.getCurrent().hasRoot(); WidgetTask.setEnabled(mntmRawRestore,hasRoot); WidgetTask.setEnabled(mntmRawBackup,true); WidgetTask.setEnabled(mntmTARestore,true); } else { WidgetTask.setEnabled(mntmRawRestore,false); WidgetTask.setEnabled(mntmRawBackup,false); WidgetTask.setEnabled(mntmTARestore,false); } } mntmSwitchPro.setText(ispro?"Switch Simple":"Switch Pro"); //mnDev.setVisible(!ispro); //mntmSwitchPro.setText(Language.getMessage(mntmSwitchPro.getName())); //mnDev.setText(Language.getMessage(mnDev.getName())); } }); mntmSwitchPro.setText(GlobalConfig.getProperty("devfeatures").equals("yes")?"Switch Simple":"Switch Pro"); MenuItem mntmChangeUserHome = new MenuItem(menu_1, SWT.NONE); mntmChangeUserHome.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { HomeSelector hs = new HomeSelector(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); String result = (String)hs.open(true); if (!result.equals(GlobalConfig.getProperty("user.flashtool")) && result.length()>0) { forceMove(GlobalConfig.getProperty("user.flashtool"),result); GlobalConfig.setProperty("user.flashtool", result); new File(result+File.separator+"config.properties").delete(); } } }); mntmChangeUserHome.setText("Change User Home"); MenuItem mntmExit = new MenuItem(menu_1, SWT.NONE); mntmExit.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { exitProgram(); shlSonyericsson.dispose(); } }); mntmExit.setText("Exit"); mntmNoDevice = new MenuItem(menu, SWT.CASCADE); mntmNoDevice.setText("No Device"); mntmNoDevice.setEnabled(false); Menu menu_device = new Menu(mntmNoDevice); mntmNoDevice.setMenu(menu_device); MenuItem mntmRoot = new MenuItem(menu_device, SWT.CASCADE); mntmRoot.setText("Root"); Menu menu_10 = new Menu(mntmRoot); mntmRoot.setMenu(menu_10); MenuItem mntmForcePsneuter = new MenuItem(menu_10, SWT.NONE); mntmForcePsneuter.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doRoot("doRootpsneuter"); } }); mntmForcePsneuter.setText("Force PsNeuter"); MenuItem mntmForceZergrush = new MenuItem(menu_10, SWT.NONE); mntmForceZergrush.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doRoot("doRootzergRush"); } }); mntmForceZergrush.setText("Force zergRush"); MenuItem mntmForceEmulator = new MenuItem(menu_10, SWT.NONE); mntmForceEmulator.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doRoot("doRootEmulator"); } }); mntmForceEmulator.setText("Force Emulator"); MenuItem mntmForceAdbrestore = new MenuItem(menu_10, SWT.NONE); mntmForceAdbrestore.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doRoot("doRootAdbRestore"); } }); mntmForceAdbrestore.setText("Force AdbRestore"); MenuItem mntmForceServicemenu = new MenuItem(menu_10, SWT.NONE); mntmForceServicemenu.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doRoot("doRootServiceMenu"); } }); mntmForceServicemenu.setText("Force ServiceMenu"); MenuItem mntmRunRootShell = new MenuItem(menu_10, SWT.NONE); mntmRunRootShell.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doRoot("doRootRunRootShell"); } }); mntmRunRootShell.setText("Force Run Root Shell"); MenuItem mntmTowelroot = new MenuItem(menu_10, SWT.NONE); mntmTowelroot.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doRoot("doRootTowelroot"); } }); mntmTowelroot.setText("Force towelroot"); mntmBackupSystemApps = new MenuItem(menu_device, SWT.NONE); mntmBackupSystemApps.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { BackupSystemJob bsj = new BackupSystemJob("Backup System apps"); bsj.schedule(); } }); mntmBackupSystemApps.setText("Backup system apps"); mntmInstallBusybox = new MenuItem(menu_device, SWT.NONE); mntmInstallBusybox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String busybox = Devices.getCurrent().getBusybox(true); if (busybox.length()>0) { BusyboxInstallJob bij = new BusyboxInstallJob("Busybox Install"); bij.setBusybox(busybox); bij.schedule(); } } }); mntmInstallBusybox.setText("Install busybox"); MenuItem mntmLaunchServicemenu = new MenuItem(menu_device, SWT.NONE); mntmLaunchServicemenu.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { log.info("Launching Service Menu. Plese check on your phone."); AdbUtility.run("am start -a android.intent.action.MAIN -n com.sonyericsson.android.servicemenu/.ServiceMainMenu"); } catch (Exception ex) { } } }); mntmLaunchServicemenu.setText("Launch ServiceMenu"); MenuItem mntmReboot = new MenuItem(menu_device, SWT.NONE); mntmReboot.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { Devices.getCurrent().reboot(); } catch (Exception ex) { } } }); mntmReboot.setText("Reboot"); MenuItem mntmNewSubmenu = new MenuItem(menu, SWT.CASCADE); mntmNewSubmenu.setText("Tools"); Menu menu_4 = new Menu(mntmNewSubmenu); mntmNewSubmenu.setMenu(menu_4); MenuItem mntmNewItem = new MenuItem(menu_4, SWT.NONE); mntmNewItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { SinEditor sedit = new SinEditor(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); sedit.open(); } }); mntmNewItem.setText("Sin Editor"); MenuItem mntmExtractors = new MenuItem(menu_4, SWT.CASCADE); mntmExtractors.setText("Extractors"); Menu menu_5 = new Menu(mntmExtractors); mntmExtractors.setMenu(menu_5); MenuItem mntmYaffs = new MenuItem(menu_5, SWT.NONE); mntmYaffs.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doYaffs2Unpack(); } }); mntmYaffs.setText("Yaffs2"); MenuItem mntmElf = new MenuItem(menu_5, SWT.NONE); mntmElf.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ElfEditor elfedit = new ElfEditor(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); elfedit.open(); } }); mntmElf.setText("Elf"); MenuItem mntmBundles = new MenuItem(menu_4, SWT.CASCADE); mntmBundles.setText("Bundles"); Menu menu_12 = new Menu(mntmBundles); mntmBundles.setMenu(menu_12); MenuItem mntmNewItem_1 = new MenuItem(menu_12, SWT.NONE); mntmNewItem_1.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Decrypt decrypt = new Decrypt(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); Vector result = decrypt.open(); if (result!=null) { File f = (File)result.get(0); final String folder = f.getParent(); DecryptJob dec = new DecryptJob("Decrypt"); dec.addJobChangeListener(new IJobChangeListener() { public void aboutToRun(IJobChangeEvent event) { } public void awake(IJobChangeEvent event) { } public void done(IJobChangeEvent event) { if (new File(folder+File.separator+"decrypted").exists()) { String result = WidgetTask.openBundleCreator(shlSonyericsson,folder+File.separator+"decrypted"); if (result.equals("Cancel")) log.info("Bundle creation canceled"); } } public void running(IJobChangeEvent event) { } public void scheduled(IJobChangeEvent event) { } public void sleeping(IJobChangeEvent event) { } }); dec.setFiles(result); dec.schedule(); } else { log.info("Decrypt canceled"); } } }); mntmNewItem_1.setText("FILESET Decrypt"); MenuItem mntmBundleCreation = new MenuItem(menu_12, SWT.NONE); mntmBundleCreation.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { BundleCreator cre = new BundleCreator(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); String result = (String)cre.open(); if (result.equals("Cancel")) log.info("Bundle creation canceled"); } }); mntmBundleCreation.setText("Create"); /*MenuItem mntmBundleCreationFrom = new MenuItem(menu_12, SWT.NONE); mntmBundleCreationFrom.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DBEditor dbe = new DBEditor(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); String result = (String)dbe.open(); if (result.equals("Cancel")) log.info("Bundle creation canceled"); } }); mntmBundleCreationFrom.setText("Create From Sony DB");*/ mntmAdvanced = new MenuItem(menu, SWT.CASCADE); mntmAdvanced.setText("Advanced"); Menu AdvancedMenu = new Menu(mntmAdvanced); mntmAdvanced.setMenu(AdvancedMenu); MenuItem mntmTrimArea = new MenuItem(AdvancedMenu, SWT.CASCADE); mntmTrimArea.setText("Trim Area"); Menu menu_9 = new Menu(mntmTrimArea); mntmTrimArea.setMenu(menu_9); MenuItem mntmS = new MenuItem(menu_9, SWT.CASCADE); mntmS.setText("S1"); Menu menu_13 = new Menu(mntmS); mntmS.setMenu(menu_13); MenuItem mntmTABackup = new MenuItem(menu_13, SWT.NONE); mntmTABackup.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doBackupTA(); } }); mntmTABackup.setText("Backup"); mntmTARestore = new MenuItem(menu_13, SWT.NONE); mntmTARestore.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TADevice result=null; File srcFolder = new File(Devices.getCurrent().getFolderRegisteted()+File.separator+"s1ta"); if (srcFolder.exists()) { if (srcFolder.listFiles().length>0) { File[] chld = srcFolder.listFiles(); HashMap<String,Vector<TABag>> backupset = new HashMap<String, Vector<TABag>>(); for (int i=0; i < chld.length ; i++) { File srcFolderBackup = new File(srcFolder.getAbsolutePath()+File.separator+chld[i].getName()); File chldPartition[] = srcFolderBackup.listFiles(); Vector<TABag> bags = new Vector<TABag>(); for (int j=0;j<chldPartition.length;j++) { try { TABag bag = new TABag(chldPartition[j]); if (bag.partition>0) bags.add(bag); } catch (Exception ex) {} } if (bags.size()>0) { backupset.put(chld[i].getName(), bags); } } if (backupset.size()>0) { TARestore restore = new TARestore(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); result = (TADevice)restore.open(backupset); } else { log.info("No backup found"); } } else { log.info("No backup found"); } } else { log.info("No backup found"); } if (result==null) { log.info("Canceled TA restore task"); } else { boolean toflash = false; for (int i = 0 ; i < result.getBags().size() ; i++) { if (result.getBags().get(i).toflash.size()>0) toflash=true; } if (!toflash) { log.info("Nothing to do with TA restore task"); } else { Bundle bundle = new Bundle(); bundle.setSimulate(GlobalConfig.getProperty("simulate").toLowerCase().equals("yes")); bundle.setMaxBuffer(3); log.info("Please connect your device into flashmode."); String connect = (String)WidgetTask.openWaitDeviceForFlashmode(shlSonyericsson); if (connect.equals("OK")) { final Flasher flash = FlasherFactory.getFlasher(bundle,shlSonyericsson); try { RestoreTAJob rjob = new RestoreTAJob("Flash"); rjob.setFlash(flash); rjob.setTA(result); rjob.schedule(); } catch (Exception ex){ log.error(ex.getMessage()); if (flash.getBundle()!=null) flash.getBundle().close(); log.info("Flash canceled"); DeviceChangedListener.enableDetection(); } } else { DeviceChangedListener.enableDetection(); log.info("Flash canceled"); } } } } }); mntmTARestore.setText("Restore"); mntmFlashSingleTA = new MenuItem(menu_13, SWT.NONE); mntmFlashSingleTA.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TADevice result=null; FileDialog dlg = new FileDialog(shlSonyericsson); dlg.setFilterExtensions(new String[]{"*.ta"}); dlg.setText("TA File Chooser"); String dir = dlg.open(); HashMap<String,Vector<TABag>> backupset = new HashMap<String, Vector<TABag>>(); Vector<TABag> bags = new Vector<TABag>(); if (dir!=null) { File taf = new File(dir); try { TABag bag = new TABag(taf); if (bag.partition>0) bags.add(bag); } catch (Exception ex) {} if (bags.size()>0) backupset.put(taf.getName(), bags); } if (backupset.size()>0) { TARestore restore = new TARestore(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); result = (TADevice)restore.open(backupset); } else { log.info("No TA file selected"); } if (result==null) { log.info("Canceled TA restore task"); } else { boolean toflash = false; for (int i = 0 ; i < result.getBags().size() ; i++) { if (result.getBags().get(i).toflash.size()>0) toflash=true; } if (!toflash) { log.info("Nothing to do with TA restore task"); } else { Bundle bundle = new Bundle(); bundle.setSimulate(GlobalConfig.getProperty("simulate").toLowerCase().equals("yes")); log.info("Please connect your device into flashmode."); String connect = (String)WidgetTask.openWaitDeviceForFlashmode(shlSonyericsson); if (connect.equals("OK")) { final Flasher flash = FlasherFactory.getFlasher(bundle,shlSonyericsson); try { RestoreTAJob rjob = new RestoreTAJob("Flash"); rjob.setFlash(flash); rjob.setTA(result); rjob.schedule(); } catch (Exception ex){ log.error(ex.getMessage()); log.info("Flash canceled"); DeviceChangedListener.enableDetection(); if (flash.getBundle()!=null) flash.getBundle().close(); } } else { log.info("Flash canceled"); DeviceChangedListener.enableDetection(); } } } } }); mntmFlashSingleTA.setText("Flash TA file"); MenuItem mntmRaw = new MenuItem(menu_9, SWT.CASCADE); mntmRaw.setText("Raw device"); Menu menu_14 = new Menu(mntmRaw); mntmRaw.setMenu(menu_14); mntmRawBackup = new MenuItem(menu_14, SWT.NONE); mntmRawBackup.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { RawTAJob rj = new RawTAJob("Raw TA"); rj.setAction("doBackup"); rj.setShell(shlSonyericsson); rj.schedule(); } }); mntmRawBackup.setText("Backup"); mntmRawBackup.setEnabled(false); mntmRawRestore = new MenuItem(menu_14, SWT.NONE); mntmRawRestore.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { RawTAJob rj = new RawTAJob("Raw TA"); rj.setAction("doRestore"); rj.setShell(shlSonyericsson); rj.schedule(); } }); mntmRawRestore.setText("Restore"); mntmRawRestore.setEnabled(false); mntmFlashFromRaw = new MenuItem(menu_13, SWT.NONE); mntmFlashFromRaw.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog dlg = new FileDialog(shlSonyericsson); dlg.setFilterExtensions(new String[]{"*.fta", "*.dd","*.img"}); dlg.setText("TA File Chooser"); String dir = dlg.open(); if (dir!=null) { try { log.info("Parsing " + dir+". Please wait"); TARawParser p = new TARawParser(new File(dir)); HashMap<String,Vector<TABag>> backup = new HashMap<String, Vector<TABag>>(); backup.put("rawta", p.getBags()); TADevice result=null; if (backup.size()>0) { TARestore restore = new TARestore(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); result = (TADevice)restore.open(backup); } else { log.info("Bad TA image. Aborting"); } if (result==null) { log.info("Canceled TA restore task"); } else { boolean toflash = false; for (int i = 0 ; i < result.getBags().size() ; i++) { if (result.getBags().get(i).toflash.size()>0) toflash=true; } if (!toflash) { log.info("Nothing to do with TA restore task"); } else { Bundle bundle = new Bundle(); bundle.setSimulate(GlobalConfig.getProperty("simulate").toLowerCase().equals("yes")); log.info("Please connect your device into flashmode."); String connect = (String)WidgetTask.openWaitDeviceForFlashmode(shlSonyericsson); if (connect.equals("OK")) { final Flasher flash = FlasherFactory.getFlasher(bundle,shlSonyericsson); try { RestoreTAJob rjob = new RestoreTAJob("Flash"); rjob.setFlash(flash); rjob.setTA(result); rjob.schedule(); } catch (Exception ex){ log.error(ex.getMessage()); log.info("Flash canceled"); DeviceChangedListener.enableDetection(); if (flash.getBundle()!=null) flash.getBundle().close(); } } else { log.info("Flash canceled"); DeviceChangedListener.enableDetection(); } } } } catch (Exception exc) {} } else { log.info("Operation canceled"); } } }); mntmFlashFromRaw.setText("Flash from raw image"); MenuItem mntmUsbLogParser = new MenuItem(AdvancedMenu, SWT.NONE); mntmUsbLogParser.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { USBLogviewer lv = new USBLogviewer(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); lv.open(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); mntmUsbLogParser.setText("USB log parser"); MenuItem mntmDevices = new MenuItem(menu, SWT.CASCADE); mntmDevices.setText("Devices"); Menu menu_6 = new Menu(mntmDevices); mntmDevices.setMenu(menu_6); MenuItem mntmNewSubmenu_1 = new MenuItem(menu_6, SWT.CASCADE); mntmNewSubmenu_1.setText("Devices Sync"); Menu menu_8 = new Menu(mntmNewSubmenu_1); mntmNewSubmenu_1.setMenu(menu_8); MenuItem mntmSyncFromGit = new MenuItem(menu_8, SWT.NONE); mntmSyncFromGit.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { WaitForDevicesSync sync = new WaitForDevicesSync(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); sync.open(); } }); mntmSyncFromGit.setText("Manual Sync"); MenuItem mntmAutoSync = new MenuItem(menu_8, SWT.CASCADE); mntmAutoSync.setText("Auto Sync"); Menu menu_11 = new Menu(mntmAutoSync); mntmAutoSync.setMenu(menu_11); MenuItem mntmOn = new MenuItem(menu_11, SWT.RADIO); mntmOn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { GlobalConfig.setProperty("gitauto", "true"); } }); mntmOn.setText("On"); mntmOn.setSelection((GlobalConfig.getProperty("gitauto").equals("true"))); MenuItem mntmOff = new MenuItem(menu_11, SWT.RADIO); mntmOff.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { GlobalConfig.setProperty("gitauto", "false"); } }); mntmOff.setText("Off"); mntmOff.setSelection((GlobalConfig.getProperty("gitauto").equals("false"))); MenuItem mntmCheckDrivers = new MenuItem(menu_6, SWT.NONE); mntmCheckDrivers.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Devices.CheckAdbDrivers(); } }); mntmCheckDrivers.setText("Check Drivers"); /*MenuItem mntmCheck = new MenuItem(menu_6, SWT.NONE); mntmCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Properties p = new Properties(); Enumeration<Object> list = Devices.listDevices(false); while (list.hasMoreElements()) { DeviceEntry entry = Devices.getDevice((String)list.nextElement()); if (entry.canShowUpdates()) p.setProperty(entry.getId(), entry.getName()); } String result = WidgetTask.openDeviceSelector(shlSonyericsson, p); if (result.length()>0) { DeviceEntry entry = new DeviceEntry(result); DeviceUpdates upd = new DeviceUpdates(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); upd.open(entry); } } }); mntmCheck.setText("Check Updates");*/ MenuItem mntmEditor = new MenuItem(menu_6, SWT.CASCADE); mntmEditor.setText("Manage"); Menu menu_7 = new Menu(mntmEditor); mntmEditor.setMenu(menu_7); /* MenuItem mntmNewItem_2 = new MenuItem(menu_7, SWT.NONE); mntmNewItem_2.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String url = WidgetTask.openUpdateURLFeeder(shlSonyericsson); if (url.length()>0) { try { UpdateURL u = new UpdateURL(url); if (!u.exists()) { u.dumpToFile(); CustIdManager mng = new CustIdManager(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); ModelUpdater m = new ModelUpdater(u); Models models = new Models(m.getDevice()); models.put(m.getModel(), m); mng.open(models); } else log.warn("This updateurl already exists"); } catch (Exception e1) { log.error(e1.getMessage()); e1.printStackTrace(); } } else { log.info("Add update URL canceled"); } } }); mntmNewItem_2.setText("Add Update URL");*/ //MenuItem mntmEdit = new MenuItem(menu_7, SWT.NONE); //mntmEdit.setText("Edit"); //MenuItem mntmAdd = new MenuItem(menu_7, SWT.NONE); //mntmAdd.setText("Add"); //MenuItem mntmRemove = new MenuItem(menu_7, SWT.NONE); //mntmRemove.setText("Remove"); MenuItem mntmExport = new MenuItem(menu_7, SWT.NONE); mntmExport.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Devices.listDevices(true); String devid = WidgetTask.openDeviceSelector(shlSonyericsson); DeviceEntry ent = Devices.getDevice(devid); if (devid.length()>0) { try { log.info("Beginning export of "+ent.getName()); doExportDevice(devid); log.info(ent.getName()+" exported successfully"); } catch (Exception ex) { log.error(ex.getMessage()); } } } }); mntmExport.setText("Export"); MenuItem mntmImport = new MenuItem(menu_7, SWT.NONE); mntmImport.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Devices.listDevices(true); Properties list = new Properties(); File[] lfiles = new File(OS.getFolderMyDevices()).listFiles(); for (int i=0;i<lfiles.length;i++) { if (lfiles[i].getName().endsWith(".ftd")) { String name = lfiles[i].getName(); name = name.substring(0,name.length()-4); try { FTDEntry entry = new FTDEntry(name); list.setProperty(entry.getId(), entry.getName()); } catch (Exception ex) {ex.printStackTrace();} } } if (list.size()>0) { String devid = WidgetTask.openDeviceSelector(shlSonyericsson,list); if (devid.length()>0) { try { FTDEntry entry = new FTDEntry(devid); MsgBox.setCurrentShell(shlSonyericsson); FTDExplodeJob j = new FTDExplodeJob("FTD Explode job"); j.setFTD(entry); j.schedule(); } catch (Exception ex) { log.error(ex.getMessage()); } } else { log.info("Import canceled"); } } else { MsgBox.error("No device to import"); } } }); mntmImport.setText("Import"); MenuItem mntmHelp = new MenuItem(menu, SWT.CASCADE); mntmHelp.setText("Help"); Menu menu_2 = new Menu(mntmHelp); mntmHelp.setMenu(menu_2); MenuItem mntmLogLevel = new MenuItem(menu_2, SWT.CASCADE); mntmLogLevel.setText("Log level"); Menu menu_3 = new Menu(mntmLogLevel); mntmLogLevel.setMenu(menu_3); MenuItem mntmError = new MenuItem(menu_3, SWT.RADIO); mntmError.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if(((MenuItem)e.getSource()).getSelection()) { MyLogger.setLevel("ERROR"); GlobalConfig.setProperty("loglevel", "error"); } } }); mntmError.setText("error"); MenuItem mntmWarning = new MenuItem(menu_3, SWT.RADIO); mntmWarning.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if(((MenuItem)e.getSource()).getSelection()) { MyLogger.setLevel("WARN"); GlobalConfig.setProperty("loglevel", "warn"); } } }); mntmWarning.setText("warning"); MenuItem mntmInfo = new MenuItem(menu_3, SWT.RADIO); mntmInfo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if(((MenuItem)e.getSource()).getSelection()) { MyLogger.setLevel("INFO"); GlobalConfig.setProperty("loglevel", "info"); } } }); mntmInfo.setText("info"); MenuItem mntmDebug = new MenuItem(menu_3, SWT.RADIO); mntmDebug.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if(((MenuItem)e.getSource()).getSelection()) { MyLogger.setLevel("DEBUG"); GlobalConfig.setProperty("loglevel", "debug"); } } }); mntmDebug.setText("debug"); MenuItem mntmAbout = new MenuItem(menu_2, SWT.NONE); mntmAbout.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { About about = new About(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); about.open(); } }); mntmAbout.setText("About"); if (GlobalConfig.getProperty("loglevel").equals("debug")) mntmDebug.setSelection(true); if (GlobalConfig.getProperty("loglevel").equals("warn")) mntmWarning.setSelection(true); if (GlobalConfig.getProperty("loglevel").equals("info")) mntmInfo.setSelection(true); if (GlobalConfig.getProperty("loglevel").equals("error")) mntmError.setSelection(true); ToolBar flashtoolToolBar = new ToolBar(shlSonyericsson, SWT.FLAT | SWT.RIGHT); FormData fd_flashtoolToolBar = new FormData(); fd_flashtoolToolBar.right = new FormAttachment(0, 440); fd_flashtoolToolBar.top = new FormAttachment(0, 10); fd_flashtoolToolBar.left = new FormAttachment(0, 10); flashtoolToolBar.setLayoutData(fd_flashtoolToolBar); tltmFlash = new ToolItem(flashtoolToolBar, SWT.NONE); tltmFlash.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { doFlash(); } catch (Exception ex) {} } }); tltmFlash.setImage(SWTResourceManager.getImage(MainSWT.class, "/gui/ressources/icons/flash_32.png")); tltmFlash.setToolTipText("Flash device"); tltmBLU = new ToolItem(flashtoolToolBar, SWT.NONE); tltmBLU.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doBLUnlock(); } }); tltmBLU.setToolTipText("Bootloader Unlock"); tltmBLU.setImage(SWTResourceManager.getImage(MainSWT.class, "/gui/ressources/icons/blu_32.png")); tltmRoot = new ToolItem(flashtoolToolBar, SWT.NONE); tltmRoot.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doRoot(); } }); tltmRoot.setImage(SWTResourceManager.getImage(MainSWT.class, "/gui/ressources/icons/root_32.png")); tltmRoot.setEnabled(false); tltmRoot.setToolTipText("Root device"); Button btnSaveLog = new Button(shlSonyericsson, SWT.NONE); btnSaveLog.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String saved = MyLogger.writeFile(); WidgetTask.openOKBox(shlSonyericsson, "Logfile saved to "+OS.getFolderUserFlashtool()+File.separator+"flashtool_"+saved+".log"); } }); FormData fd_btnSaveLog = new FormData(); fd_btnSaveLog.right = new FormAttachment(100, -10); btnSaveLog.setLayoutData(fd_btnSaveLog); btnSaveLog.setText("Save log"); tltmAskRoot = new ToolItem(flashtoolToolBar, SWT.NONE); tltmAskRoot.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doAskRoot(); } }); tltmAskRoot.setImage(SWTResourceManager.getImage(MainSWT.class, "/gui/ressources/icons/askroot_32.png")); tltmAskRoot.setEnabled(false); tltmAskRoot.setToolTipText("Ask for root permissions"); tltmApkInstall = new ToolItem(flashtoolToolBar, SWT.NONE); tltmApkInstall.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ApkInstaller inst = new ApkInstaller(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); String folder = inst.open(); if (folder.length()>0) { APKInstallJob aij = new APKInstallJob("APK Install"); aij.setFolder(folder); aij.schedule(); } else { log.info("Install APK canceled"); } } }); tltmApkInstall.setEnabled(false); tltmApkInstall.setImage(SWTResourceManager.getImage(MainSWT.class, "/gui/ressources/icons/customize_32.png")); tltmClean = new ToolItem(flashtoolToolBar, SWT.NONE); tltmClean.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Cleaner clean = new Cleaner(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); DeviceApps result = clean.open(); if (result != null) { CleanJob cj = new CleanJob("Clean Job"); cj.setDeviceApps(result); cj.schedule(); } else log.info("Cleaning canceled"); //WidgetTask.openOKBox(shlSonyericsson, "To be implemented"); } }); tltmClean.setToolTipText("Clean ROM"); tltmClean.setImage(SWTResourceManager.getImage(MainSWT.class, "/gui/ressources/icons/clean_32.png")); tltmClean.setEnabled(false); tltmRecovery = new ToolItem(flashtoolToolBar, SWT.NONE); tltmRecovery.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { WidgetTask.openOKBox(shlSonyericsson, "To be implemented"); } }); tltmRecovery.setToolTipText("Install Recovery"); tltmRecovery.setImage(SWTResourceManager.getImage(MainSWT.class, "/gui/ressources/icons/recovery_32.png")); tltmRecovery.setEnabled(false); ToolItem tltmNewItem_1 = new ToolItem(flashtoolToolBar, SWT.NONE); tltmNewItem_1.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { WaitForXperiFirm wx = new WaitForXperiFirm(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); wx.open(); } }); tltmNewItem_1.setImage(SWTResourceManager.getImage(MainSWT.class, "/gui/ressources/icons/download_32.png")); ToolItem tltmNewItem_2 = new ToolItem(flashtoolToolBar, SWT.NONE); tltmNewItem_2.setEnabled(false); ProgressBar progressBar = new ProgressBar(shlSonyericsson, SWT.NONE); fd_btnSaveLog.bottom = new FormAttachment(progressBar, -6, SWT.TOP); progressBar.setState(SWT.NORMAL); LogProgress.registerProgressBar(progressBar); FormData fd_progressBar = new FormData(); fd_progressBar.left = new FormAttachment(0, 10); fd_progressBar.right = new FormAttachment(100, -10); fd_progressBar.bottom = new FormAttachment(100, -10); progressBar.setLayoutData(fd_progressBar); ScrolledComposite scrolledLog = new ScrolledComposite(shlSonyericsson, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); FormData fd_scrolledLog = new FormData(); fd_scrolledLog.bottom = new FormAttachment(btnSaveLog, -6); fd_scrolledLog.left = new FormAttachment(0, 10); fd_scrolledLog.right = new FormAttachment(100, -10); scrolledLog.setLayoutData(fd_scrolledLog); scrolledLog.setExpandHorizontal(true); scrolledLog.setExpandVertical(true); StyledText logWindow = new StyledText(scrolledLog, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); logWindow.setEditable(false); MyLogger.getAppender().setStyledText(logWindow); //StringAppender.setTextArea(logWindow); GlobalState.setGUI(); scrolledLog.setContent(logWindow); scrolledLog.setMinSize(logWindow.computeSize(SWT.DEFAULT, SWT.DEFAULT)); ToolBar paypalToolbar = new ToolBar(shlSonyericsson, SWT.FLAT | SWT.RIGHT); fd_scrolledLog.top = new FormAttachment(paypalToolbar, 2); FormData fd_paypalToolbar = new FormData(); fd_paypalToolbar.top = new FormAttachment(0, 10); fd_paypalToolbar.right = new FormAttachment(100, -10); paypalToolbar.setLayoutData(fd_paypalToolbar); ToolItem paypalItem = new ToolItem(paypalToolbar, SWT.NONE); paypalItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Program.launch("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PPWH7M9MNCEPA"); } }); paypalItem.setImage(SWTResourceManager.getImage(MainSWT.class, "/gui/ressources/icons/paypal.png")); /* try { Language.Init(GlobalConfig.getProperty("language").toLowerCase()); } catch (Exception e) { log.info("Language files not installed"); }*/ log.info("Flashtool "+About.getVersion()); if (JUsb.getVersion().length()>0) log.info(JUsb.getVersion()); Proxy.setProxy(); vcheck = new VersionCheckerJob("Version Checker Job"); vcheck.setMessageFrame(shlSonyericsson); vcheck.schedule(); } public static void stopPhoneWatchdog() { DeviceChangedListener.stop(); try { AdbUtility.killServer(); } catch (Exception e) {} } public static void killAdbandFastboot() { stopPhoneWatchdog(); } public void exitProgram() { try { MyLogger.getAppender().setStyledText(null); log.info("Stopping watchdogs and exiting ..."); if (GlobalConfig.getProperty("killadbonexit").equals("yes")) { killAdbandFastboot(); } vcheck.done(); } catch (Exception e) {} } public void doIdent() { if (guimode) { String devid = Devices.identFromRecognition(); if (devid.length()==0) { if (Devices.listDevices(false).hasMoreElements()) { log.error("Cannot identify your device."); log.info("Selecting from user input"); devid=(String)WidgetTask.openDeviceSelector(shlSonyericsson); if (devid.length()>0) { Devices.setCurrent(devid); String prop = DeviceProperties.getProperty(Devices.getCurrent().getBuildProp()); if (!Devices.getCurrent().getRecognition().contains(prop)) { int response = Integer.parseInt(WidgetTask.openYESNOBox(shlSonyericsson, "Do you want to permanently identify this device as \n"+Devices.getCurrent().getName()+"?")); if (response == SWT.YES) Devices.getCurrent().addRecognitionToList(prop); } if (!Devices.isWaitingForReboot()) log.info("Connected device : " + Devices.getCurrent().getId()); } else { log.error("You can only flash devices."); } } } else { Devices.setCurrent(devid); if (!Devices.isWaitingForReboot()) log.info("Connected device : " + Devices.getCurrent().getName()); } if (devid.length()>0) { WidgetTask.setEnabled(mntmNoDevice, true); WidgetTask.setMenuName(mntmNoDevice, "My "+Devices.getCurrent().getId()); WidgetTask.setEnabled(mntmInstallBusybox,false); WidgetTask.setEnabled(mntmBackupSystemApps,false); if (!Devices.isWaitingForReboot()) { log.info("Installed version of busybox : " + Devices.getCurrent().getInstalledBusyboxVersion(false)); log.info("Android version : "+Devices.getCurrent().getVersion()+" / kernel version : "+Devices.getCurrent().getKernelVersion()+" / Platform : "+Devices.getCurrent().getArch()+"bits / Build number : " + Devices.getCurrent().getBuildId()); } if (Devices.getCurrent().isRecovery()) { log.info("Phone in recovery mode"); WidgetTask.setEnabled(tltmRoot,false); WidgetTask.setEnabled(tltmAskRoot,false); WidgetTask.setEnabled(tltmApkInstall,false); doGiveRoot(true); } else { boolean hasSU = Devices.getCurrent().hasSU(); WidgetTask.setEnabled(tltmRoot, !hasSU); WidgetTask.setEnabled(tltmApkInstall, true); boolean hasRoot=false; if (hasSU) { log.info("Checking root access"); hasRoot = Devices.getCurrent().hasRoot(); if (hasRoot) { doInstFlashtool(); } } doGiveRoot(hasRoot); } log.debug("Now setting buttons availability - btnRoot"); log.debug("mtmRootzergRush menu"); /*mntmRootzergRush.setEnabled(true); log.debug("mtmRootPsneuter menu"); mntmRootPsneuter.setEnabled(true); log.debug("mtmRootEmulator menu"); mntmRootEmulator.setEnabled(true); log.debug("mtmRootAdbRestore menu"); mntmRootAdbRestore.setEnabled(true); log.debug("mtmUnRoot menu"); mntmUnRoot.setEnabled(true);*/ boolean flash = Devices.getCurrent().canFlash(); log.debug("flashBtn button "+flash); WidgetTask.setEnabled(tltmFlash,flash); //log.debug("custBtn button"); //custBtn.setEnabled(true); log.debug("Now adding plugins"); //mnPlugins.removeAll(); //addDevicesPlugins(); //addGenericPlugins(); log.debug("Stop waiting for device"); if (Devices.isWaitingForReboot()) Devices.stopWaitForReboot(); log.debug("End of identification"); } } } public void doGiveRoot(boolean hasRoot) { /*btnCleanroot.setEnabled(true); mntmInstallBusybox.setEnabled(true); mntmClearCache.setEnabled(true); mntmBuildpropEditor.setEnabled(true); if (new File(Devices.getCurrent().getDeviceDir()+fsep+"rebrand").isDirectory()) mntmBuildpropRebrand.setEnabled(true); mntmRebootIntoRecoveryT.setEnabled(Devices.getCurrent().canRecovery()); mntmRebootDefaultRecovery.setEnabled(true); mntmSetDefaultRecovery.setEnabled(Devices.getCurrent().canRecovery()); mntmSetDefaultKernel.setEnabled(Devices.getCurrent().canKernel()); mntmRebootCustomKernel.setEnabled(Devices.getCurrent().canKernel()); mntmRebootDefaultKernel.setEnabled(true); //mntmInstallBootkit.setEnabled(true); //mntmRecoveryControler.setEnabled(true); mntmBackupSystemApps.setEnabled(true); btnXrecovery.setEnabled(Devices.getCurrent().canRecovery()); btnKernel.setEnabled(Devices.getCurrent().canKernel());*/ WidgetTask.setEnabled(tltmAskRoot,!hasRoot); WidgetTask.setEnabled(mntmInstallBusybox,hasRoot); WidgetTask.setEnabled(mntmBackupSystemApps,hasRoot); WidgetTask.setEnabled(tltmClean,hasRoot); WidgetTask.setEnabled(tltmRecovery,hasRoot&&Devices.getCurrent().canRecovery()); if (GlobalConfig.getProperty("devfeatures").equals("yes")) { WidgetTask.setEnabled(mntmRawRestore,hasRoot); WidgetTask.setEnabled(mntmRawBackup,true); WidgetTask.setEnabled(mntmTARestore,true); } WidgetTask.setEnabled(tltmAskRoot,!hasRoot); if (!Devices.isWaitingForReboot()) if (hasRoot) { log.info("Root Access Allowed"); AdbUtility.antiRic(); } else log.info("Root access denied"); } public void doAskRoot() { Job job = new Job("Give Root") { protected IStatus run(IProgressMonitor monitor) { log.warn("Please check your Phone and 'ALLOW' Superuseraccess!"); boolean hasRoot = Devices.getCurrent().hasRoot(); doGiveRoot(hasRoot); return Status.OK_STATUS; } }; job.schedule(); } public void doInstFlashtool() { try { if (!AdbUtility.exists("/system/flashtool")) { Devices.getCurrent().doBusyboxHelper(); log.info("Installing toolbox to device..."); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"ftkit.tar",GlobalConfig.getProperty("deviceworkdir")); FTShell ftshell = new FTShell("installftkit"); ftshell.runRoot(); } } catch (Exception e) { log.error(e.getMessage()); } } public void doFlash() throws Exception { String select = WidgetTask.openBootModeSelector(shlSonyericsson); if (select.equals("flashmode")) { doFlashmode(OS.getFolderFirmwares(),""); } else if (select.equals("fastboot")) doFastBoot(); else log.info("Flash canceled"); } public void doFastBoot() throws Exception { FastbootToolbox fbbox = new FastbootToolbox(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); fbbox.open(); } public void doFlashmode(final String pftfpath, final String pftfname) throws Exception { try { if (GlobalConfig.getProperty("devfeatures").equals("yes")) { WidgetTask.openOKBox(shlSonyericsson, "Warning, you are in Pro mode\n\nIn this mode, SIMLOCK is selectable if part of the bundle.\nThis can break your device.\nIf you are unsure, switch back to simple more before pressing flash button."); } FTFSelector ftfsel = new FTFSelector(shlSonyericsson,SWT.PRIMARY_MODAL | SWT.SHEET); final Bundle bundle = (Bundle)ftfsel.open(pftfpath, pftfname); if (bundle !=null) { log.info("Selected "+bundle); FlashJob fjob = new FlashJob("Flash"); try { fjob.setBundle(bundle); fjob.setShell(shlSonyericsson); fjob.schedule(); } catch (Exception e){ log.error(e.getMessage()); log.info("Flash canceled"); if (bundle!=null) bundle.close(); } } else log.info("Flash canceled"); } catch (Exception e) { e.printStackTrace(); } /*Worker.post(new Job() { public Object run() { System.out.println("flashmode"); if (bundle!=null) { X10flash flash=null; try { log.info("Preparing files for flashing"); bundle.open(); bundle.setSimulate(GlobalConfig.getProperty("simulate").toLowerCase().equals("yes")); flash = new X10flash(bundle); /*if ((new WaitDeviceFlashmodeGUI(flash)).deviceFound(_root)) { try { flash.openDevice(); flash.flashDevice(); } catch (Exception e) { e.printStackTrace(); } } } catch (BundleException ioe) { log.error("Error preparing files"); } catch (Exception e) { log.error(e.getMessage()); } bundle.close(); } else log.info("Flash canceled"); return null; } });*/ } public void doBLUnlock() { try { Bundle b = new Bundle(); b.setMaxBuffer(512*1024); log.info("Please connect your device into flashmode."); String result = (String)WidgetTask.openWaitDeviceForFlashmode(shlSonyericsson); if (result.equals("OK")) { final Flasher flash = FlasherFactory.getFlasher(b,shlSonyericsson); try { GetULCodeJob ulj = new GetULCodeJob("Unlock code"); ulj.setFlash(flash); ulj.addJobChangeListener(new IJobChangeListener() { public void aboutToRun(IJobChangeEvent event) {} public void awake(IJobChangeEvent event) {} public void running(IJobChangeEvent event) {} public void scheduled(IJobChangeEvent event) {} public void sleeping(IJobChangeEvent event) {} public void done(IJobChangeEvent event) { GetULCodeJob j = (GetULCodeJob)event.getJob(); if (j.getPhoneCert().length()>0) { OldUnlockJob uj = new OldUnlockJob("Unlock 2010"); uj.setPhoneCert(j.getPhoneCert()); uj.setPlatform(j.getPlatform()); uj.setStatus(j.getBLStatus()); uj.schedule(); } else { String ulcode=j.getULCode(); String imei = j.getIMEI(); String blstatus = j.getBLStatus(); String serial = j.getSerial(); if (j.isRooted()) { if (j.isRelockable()) { String result = WidgetTask.openBLWizard(shlSonyericsson, serial, imei, ulcode, flash, "R"); flash.close(); } else { flash.close(); log.warn("Your device cannot be relocked"); } } if (j.isRootable()) { if (j.alreadyUnlocked()) { String result = WidgetTask.openBLWizard(shlSonyericsson, serial, imei, ulcode, flash, "U"); flash.close(); } else { flash.close(); log.info("Now unplug your device and restart it into fastbootmode"); String result = (String)WidgetTask.openWaitDeviceForFastboot(shlSonyericsson); if (result.equals("OK")) { result = WidgetTask.openBLWizard(shlSonyericsson, serial, imei, ulcode, null, "U"); } else { log.info("Bootloader unlock canceled"); } } } LogProgress.initProgress(0); DeviceChangedListener.enableDetection(); } } }); ulj.schedule(); } catch (Exception e) { flash.close(); log.info("Bootloader unlock canceled"); LogProgress.initProgress(0); DeviceChangedListener.enableDetection(); } } else { log.info("Bootloader unlock canceled"); DeviceChangedListener.enableDetection(); } } catch (Exception e) { log.error(e.getMessage()); DeviceChangedListener.enableDetection(); } } public void doExportDevice(String device) throws Exception { File ftd = new File(OS.getFolderMyDevices()+File.separator+device+".ftd"); byte buffer[] = new byte[10240]; FileOutputStream stream = new FileOutputStream(ftd); JarOutputStream out = new JarOutputStream(stream); out.setLevel(Deflater.BEST_SPEED); File root = new File(OS.getFolderDevices()+File.separator+device); int rootindex = root.getAbsolutePath().length(); Collection<File> c = OS.listFileTree(root); Iterator<File> i = c.iterator(); while (i.hasNext()) { File entry = i.next(); String name = entry.getAbsolutePath().substring(rootindex-device.length()); if (entry.isDirectory()) name = name+"/"; JarEntry jarAdd = new JarEntry(name); out.putNextEntry(jarAdd); if (!entry.isDirectory()) { InputStream in = new FileInputStream(entry); while (true) { int nRead = in.read(buffer, 0, buffer.length); if (nRead <= 0) break; out.write(buffer, 0, nRead); } in.close(); } } out.close(); stream.close(); } public void doBackupTA() { WidgetTask.openOKBox(shlSonyericsson, "WARNING : This task will not create a FULL backup of your TA."); Bundle bundle = new Bundle(); bundle.setSimulate(GlobalConfig.getProperty("simulate").toLowerCase().equals("yes")); bundle.setMaxBuffer(512*1024); log.info("Please connect your device into flashmode."); String result = (String)WidgetTask.openWaitDeviceForFlashmode(shlSonyericsson); if (result.equals("OK")) { final Flasher flash = FlasherFactory.getFlasher(bundle,shlSonyericsson); try { BackupTAJob fjob = new BackupTAJob("Flash"); fjob.setFlash(flash); fjob.schedule(); } catch (Exception e) { log.error(e.getMessage()); log.info("S1 TA backup canceled"); DeviceChangedListener.enableDetection(); if (flash.getBundle()!=null) flash.getBundle().close(); } } else { DeviceChangedListener.enableDetection(); log.info("S1 TA backup canceled"); } } public void doRoot() { String pck = WidgetTask.openRootPackageSelector(shlSonyericsson); RootJob rj = new RootJob("Root device"); rj.setRootPackage(pck); rj.setParentShell(shlSonyericsson); if (Devices.getCurrent().getVersion().contains("4.3") || Devices.getCurrent().getVersion().contains("4.4")) rj.setAction("doRootTowelroot"); else if (Devices.getCurrent().getVersion().contains("4.2")) rj.setAction("doRootPerfEvent"); else if (Devices.getCurrent().getVersion().contains("4.1")) rj.setAction("doRootServiceMenu"); else if (Devices.getCurrent().getVersion().contains("4.0.3")) rj.setAction("doRootEmulator"); else if (Devices.getCurrent().getVersion().contains("4.0")) rj.setAction("doRootAdbRestore"); else if (Devices.getCurrent().getVersion().contains("2.3")) rj.setAction("doRootzergRush"); else rj.setAction("doRootpsneuter"); rj.schedule(); } public void doRoot(String rootmethod) { String pck = WidgetTask.openRootPackageSelector(shlSonyericsson); RootJob rj = new RootJob("Root device"); rj.setRootPackage(pck); rj.setParentShell(shlSonyericsson); rj.setAction(rootmethod); rj.schedule(); } public void doYaffs2Unpack() { FileDialog dlg = new FileDialog(shlSonyericsson); dlg.setFilterExtensions(new String[]{"*.yaffs2"}); dlg.setText("YAFFS2 File Chooser"); String dir = dlg.open(); if (dir != null) { Yaffs2Job yj = new Yaffs2Job("YAFFS2 Extractor"); yj.setFilename(dir); yj.schedule(); } else log.info("Canceled"); } public void forceMove(String source, String dest) { try { while (new File(source).list().length>0) WidgetTask.openOKBox(shlSonyericsson, "Please move "+source+" content to "+dest+"\n("+source+" folder MUST be empty once done)"); } catch (NullPointerException npe) {} } }
60,055
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
FastbootToolbox.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/FastbootToolbox.java
package org.flashtool.gui; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Shell; import org.flashtool.flashsystem.S1Command; import org.flashtool.gui.tools.FastBootToolBoxJob; import org.flashtool.gui.tools.WidgetTask; import lombok.extern.slf4j.Slf4j; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.widgets.Composite; @Slf4j public class FastbootToolbox extends Dialog { protected Object result; protected Shell shlFastbootToolbox; /** * Create the dialog. * @param parent * @param style */ public FastbootToolbox(Shell parent, int style) { super(parent, style); } /** * Open the dialog. * @return the result */ public Object open() { createContents(); shlFastbootToolbox.open(); shlFastbootToolbox.layout(); Display display = getParent().getDisplay(); while (!shlFastbootToolbox.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlFastbootToolbox = new Shell(getParent(), getStyle()); shlFastbootToolbox.setSize(823, 261); shlFastbootToolbox.setText("Fastboot Toolbox"); shlFastbootToolbox.setLayout(new FormLayout()); Button btnClose = new Button(shlFastbootToolbox, SWT.NONE); FormData fd_btnClose = new FormData(); fd_btnClose.bottom = new FormAttachment(100, -10); fd_btnClose.right = new FormAttachment(100, -10); btnClose.setLayoutData(fd_btnClose); btnClose.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { shlFastbootToolbox.dispose(); } }); btnClose.setText("Close"); Composite composite = new Composite(shlFastbootToolbox, SWT.NONE); composite.setLayout(new GridLayout(3, false)); FormData fd_composite = new FormData(); fd_composite.top = new FormAttachment(0, 10); fd_composite.right = new FormAttachment(100, -10); fd_composite.left = new FormAttachment(0, 10); composite.setLayoutData(fd_composite); Label lblVersion = new Label(composite, SWT.NONE); lblVersion.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); lblVersion.setText("Version 1.0"); Button btnCheckStatus = new Button(composite, SWT.NONE); GridData gd_btnCheckStatus = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_btnCheckStatus.widthHint = 208; btnCheckStatus.setLayoutData(gd_btnCheckStatus); btnCheckStatus.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doCheckDeviceStatus(); } }); btnCheckStatus.setText("Check Current Device Status"); Label lblByDooMLoRD = new Label(composite, SWT.NONE); lblByDooMLoRD.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); lblByDooMLoRD.setText("By DooMLoRD"); Button btnrRebootFBAdb = new Button(composite, SWT.NONE); GridData gd_btnrRebootFBAdb = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_btnrRebootFBAdb.widthHint = 273; btnrRebootFBAdb.setLayoutData(gd_btnrRebootFBAdb); btnrRebootFBAdb.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doRebootFastbootViaAdb(); } }); btnrRebootFBAdb.setText("Reboot into fastboot mode (via ADB)"); new Label(composite, SWT.NONE); Button btnRebootFBFB = new Button(composite, SWT.NONE); btnRebootFBFB.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); btnRebootFBFB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { log.info("Now plug your device in Fastboot Mode"); String result = (String)WidgetTask.openWaitDeviceForFastboot(shlFastbootToolbox); if (result.equals("OK")) { doRebootBackIntoFastbootMode(); } else { log.info("Failed"); } } }); btnRebootFBFB.setText("Reboot into fastboot mode (via Fastboot)"); Button btnHotboot = new Button(composite, SWT.NONE); btnHotboot.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); btnHotboot.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { log.info("Now plug your device in Fastboot Mode"); String result = (String)WidgetTask.openWaitDeviceForFastboot(shlFastbootToolbox); if (result.equals("OK")) { FileDialog dlg = new FileDialog(shlFastbootToolbox); dlg.setFilterExtensions(new String[]{"*.sin","*.elf","*.img"}); dlg.setText("Kernel Chooser"); String dir = dlg.open(); if (dir!=null) doHotBoot(dir); } else { log.info("Failed"); } } }); btnHotboot.setText("Select kernel to HotBoot"); Button btnFlashSystem = new Button(composite, SWT.NONE); btnFlashSystem.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); btnFlashSystem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { log.info("Now plug your device in Fastboot Mode"); String result = (String)WidgetTask.openWaitDeviceForFastboot(shlFastbootToolbox); if (result.equals("OK")) { FileDialog dlg = new FileDialog(shlFastbootToolbox); dlg.setFilterExtensions(new String[]{"*.sin","*.img","*.ext4","*.yaffs2"}); dlg.setText("System Chooser"); String dir = dlg.open(); if (dir!=null) doFlashSystem(dir); } else { log.info("Failed"); } } }); btnFlashSystem.setText("Select system to Flash"); Button btnFlashKernel = new Button(composite, SWT.NONE); btnFlashKernel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); btnFlashKernel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { log.info("Now plug your device in Fastboot Mode"); String result = (String)WidgetTask.openWaitDeviceForFastboot(shlFastbootToolbox); if (result.equals("OK")) { FileDialog dlg = new FileDialog(shlFastbootToolbox); dlg.setFilterExtensions(new String[]{"*.sin","*.elf","*.img"}); dlg.setText("Kernel Chooser"); String dir = dlg.open(); if (dir!=null) doFlashKernel(dir); } else { log.info("Failed"); } } }); btnFlashKernel.setText("Select kernel to Flash"); Button btnGetVerInfo = new Button(composite, SWT.NONE); btnGetVerInfo.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); btnGetVerInfo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { log.info("Now plug your device in Fastboot Mode"); String result = (String)WidgetTask.openWaitDeviceForFastboot(shlFastbootToolbox); if (result.equals("OK")) { doGetFastbootVerInfo(); } else { log.info("Filed"); } } }); btnGetVerInfo.setText("Get Ver Info"); new Label(composite, SWT.NONE); Button btnGetDeviceInfo = new Button(composite, SWT.NONE); btnGetDeviceInfo.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); btnGetDeviceInfo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { log.info("Now plug your device in Fastboot Mode"); String result = (String)WidgetTask.openWaitDeviceForFastboot(shlFastbootToolbox); if (result.equals("OK")) { doGetConnectedDeviceInfo(); } else { log.info("Failed"); } } }); btnGetDeviceInfo.setText("Get Device Info"); new Label(composite, SWT.NONE); Button btnReboot = new Button(composite, SWT.NONE); btnReboot.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); btnReboot.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { log.info("Now plug your device in Fastboot Mode"); String result = (String)WidgetTask.openWaitDeviceForFastboot(shlFastbootToolbox); if (result.equals("OK")) { doFastbootReboot(); } else { log.info("failed"); } } }); btnReboot.setText("Reboot device into system"); new Label(composite, SWT.NONE); } public void doRebootFastbootViaAdb() { FastBootToolBoxJob job = new FastBootToolBoxJob("Reboot fastboot via ADB"); job.setAction("doRebootFastbootViaAdb"); job.schedule(); } public void doCheckDeviceStatus(){ FastBootToolBoxJob job = new FastBootToolBoxJob("Check Device Status"); job.setAction("doCheckDeviceStatus"); job.schedule(); } public void doGetConnectedDeviceInfo() { FastBootToolBoxJob job = new FastBootToolBoxJob("Get Device Infos"); job.setAction("doGetConnectedDeviceInfo"); job.schedule(); } public void doGetFastbootVerInfo() { FastBootToolBoxJob job = new FastBootToolBoxJob("Get Device Vers Infos"); job.setAction("doGetFastbootVerInfo"); job.schedule(); } public void doRebootBackIntoFastbootMode() { FastBootToolBoxJob job = new FastBootToolBoxJob("Reboot device into fastboot"); job.setAction("doRebootBackIntoFastbootMode"); job.schedule(); } public void doFastbootReboot() { FastBootToolBoxJob job = new FastBootToolBoxJob("Reboot device"); job.setAction("doFastbootReboot"); job.schedule(); } public void doHotBoot(String kernel) { FastBootToolBoxJob job = new FastBootToolBoxJob("Hotboot device"); job.setAction("doHotbootKernel"); job.setImage(kernel); job.schedule(); } public void doFlashKernel(String kernel) { FastBootToolBoxJob job = new FastBootToolBoxJob("Flash kernel to device"); job.setAction("doFlashKernel"); job.setImage(kernel); job.schedule(); } public void doFlashSystem(String system) { FastBootToolBoxJob job = new FastBootToolBoxJob("Flash system to device"); job.setAction("doFlashSystem"); job.setImage(system); job.schedule(); } }
10,370
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
Cleaner.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/Cleaner.java
package org.flashtool.gui; import java.util.Enumeration; import java.util.Iterator; import java.util.Vector; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.List; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.ToolBar; import org.eclipse.swt.widgets.ToolItem; import org.flashtool.gui.tools.DeviceApps; public class Cleaner extends Dialog { protected Shell shlDecruptWizard; ListViewer listViewerInstalled; ListViewer listViewerToRemove; ListViewer listViewerAvailable; ListViewer listViewerToInstall; Vector<String> installed = new Vector<String>(); Vector<String> toremove = new Vector<String>(); Vector<String> available = new Vector<String>(); Vector<String> toinstall = new Vector<String>(); private List listInstalled; private List listToRemove; private Button btnCancel; private Composite compositeButtongroup1; DeviceApps apps; Combo comboProfile; /** * Create the dialog. * @param parent * @param style */ public Cleaner(Shell parent, int style) { super(parent, style); } /** * Open the dialog. * @return the result */ public DeviceApps open() { init(); createContents(); Button btnProfile = new Button(shlDecruptWizard, SWT.NONE); btnProfile.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { apps.saveProfile(); } }); FormData fd_btnProfile = new FormData(); fd_btnProfile.bottom = new FormAttachment(100, -10); fd_btnProfile.left = new FormAttachment(0,10); btnProfile.setLayoutData(fd_btnProfile); btnProfile.setText("Save profile"); Button btnSaveAsNew = new Button(shlDecruptWizard, SWT.NONE); btnSaveAsNew.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ProfileSave save = new ProfileSave(shlDecruptWizard,SWT.PRIMARY_MODAL | SWT.SHEET); save.open(apps); comboProfile.removeAll(); Iterator<String> itprofiles = apps.getProfiles().iterator(); while (itprofiles.hasNext()) { comboProfile.add(itprofiles.next()); } comboProfile.select(comboProfile.indexOf(apps.getCurrentProfile())); init(); } }); FormData fd_btnSaveAsNew = new FormData(); fd_btnSaveAsNew.left = new FormAttachment(btnProfile, 6); fd_btnSaveAsNew.bottom = new FormAttachment(100,-10); btnSaveAsNew.setLayoutData(fd_btnSaveAsNew); btnSaveAsNew.setText("Save as new profile"); shlDecruptWizard.open(); shlDecruptWizard.layout(); Display display = getParent().getDisplay(); while (!shlDecruptWizard.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return apps; } /** * Create contents of the dialog. */ private void createContents() { shlDecruptWizard = new Shell(getParent(), getStyle()); shlDecruptWizard.setSize(539, 497); shlDecruptWizard.setText("ROM Cleaner"); shlDecruptWizard.setLayout(new FormLayout()); listViewerInstalled = new ListViewer(shlDecruptWizard, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI); listInstalled = listViewerInstalled.getList(); listViewerInstalled.setSorter(new ViewerSorter()); FormData fd_listInstalled = new FormData(); fd_listInstalled.bottom = new FormAttachment(0, 229); fd_listInstalled.right = new FormAttachment(0, 223); fd_listInstalled.top = new FormAttachment(0, 71); fd_listInstalled.left = new FormAttachment(0, 10); listInstalled.setLayoutData(fd_listInstalled); listViewerInstalled.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector)inputElement; return v.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }); listViewerInstalled.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return (String)element; } }); Label lblInstalled = new Label(shlDecruptWizard, SWT.NONE); FormData fd_lblInstalled = new FormData(); fd_lblInstalled.right = new FormAttachment(0, 173); fd_lblInstalled.top = new FormAttachment(0, 51); fd_lblInstalled.left = new FormAttachment(0, 10); lblInstalled.setLayoutData(fd_lblInstalled); lblInstalled.setText("Installed on device :"); listViewerToRemove = new ListViewer(shlDecruptWizard, SWT.BORDER | SWT.V_SCROLL); listViewerToRemove.setSorter(new ViewerSorter()); listToRemove = listViewerToRemove.getList(); FormData fd_listToRemove = new FormData(); fd_listToRemove.bottom = new FormAttachment(listInstalled, 0, SWT.BOTTOM); fd_listToRemove.top = new FormAttachment(listInstalled, 0, SWT.TOP); fd_listToRemove.right = new FormAttachment(0, 522); fd_listToRemove.left = new FormAttachment(0, 282); listToRemove.setLayoutData(fd_listToRemove); listViewerToRemove.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector)inputElement; return v.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }); listViewerToRemove.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return (String)element; } }); Label lbltoremove = new Label(shlDecruptWizard, SWT.NONE); FormData fd_lbltoremove = new FormData(); fd_lbltoremove.right = new FormAttachment(0, 415); fd_lbltoremove.top = new FormAttachment(0, 51); fd_lbltoremove.left = new FormAttachment(0, 282); lbltoremove.setLayoutData(fd_lbltoremove); lbltoremove.setText("To be removed :"); btnCancel = new Button(shlDecruptWizard, SWT.NONE); FormData fd_btnCancel = new FormData(); fd_btnCancel.bottom = new FormAttachment(100, -10); fd_btnCancel.right = new FormAttachment(100,-10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { apps=null; shlDecruptWizard.dispose(); } }); btnCancel.setText("Cancel"); Button btnClean = new Button(shlDecruptWizard, SWT.NONE); FormData fd_btnClean = new FormData(); fd_btnClean.bottom = new FormAttachment(100, -10); fd_btnClean.right = new FormAttachment(btnCancel, -6); btnClean.setLayoutData(fd_btnClean); btnClean.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { apps.saveProfile(); shlDecruptWizard.dispose(); } }); btnClean.setText("Clean"); Composite compositeProfile = new Composite(shlDecruptWizard, SWT.NONE); compositeProfile.setLayout(new GridLayout(2, false)); FormData fd_compositeProfile = new FormData(); fd_compositeProfile.bottom = new FormAttachment(lblInstalled, -6); fd_compositeProfile.top = new FormAttachment(0, 10); fd_compositeProfile.left = new FormAttachment(listInstalled, 0, SWT.LEFT); fd_compositeProfile.right = new FormAttachment(listToRemove, 0, SWT.RIGHT); compositeProfile.setLayoutData(fd_compositeProfile); Label lblProfile = new Label(compositeProfile, SWT.NONE); GridData gd_lblProfile = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); gd_lblProfile.widthHint = 92; lblProfile.setLayoutData(gd_lblProfile); lblProfile.setText("Profile :"); comboProfile = new Combo(compositeProfile, SWT.READ_ONLY); comboProfile.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (!apps.getCurrentProfile().equals(comboProfile.getText())) { apps.setProfile(comboProfile.getText()); init(); listViewerInstalled.refresh(); listViewerToRemove.refresh(); listViewerToInstall.refresh(); listViewerAvailable.refresh(); } } }); comboProfile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); comboProfile.setText("default"); Iterator<String> itprofiles = apps.getProfiles().iterator(); while (itprofiles.hasNext()) { comboProfile.add(itprofiles.next()); } comboProfile.select(comboProfile.indexOf("default")); compositeButtongroup1 = new Composite(shlDecruptWizard, SWT.NONE); compositeButtongroup1.setLayout(new GridLayout(1, false)); FormData fd_compositeButtongroup1 = new FormData(); fd_compositeButtongroup1.bottom = new FormAttachment(listInstalled, -36, SWT.BOTTOM); fd_compositeButtongroup1.top = new FormAttachment(compositeProfile, 61); fd_compositeButtongroup1.right = new FormAttachment(listToRemove, -6); fd_compositeButtongroup1.left = new FormAttachment(listInstalled, 5); compositeButtongroup1.setLayoutData(fd_compositeButtongroup1); Button btnAddToRemove = new Button(compositeButtongroup1, SWT.NONE); GridData gd_btnAddToRemove = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_btnAddToRemove.heightHint = 26; gd_btnAddToRemove.widthHint = 40; btnAddToRemove.setLayoutData(gd_btnAddToRemove); btnAddToRemove.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection)listViewerInstalled.getSelection(); Iterator i = selection.iterator(); while (i.hasNext()) { String f = (String)i.next(); installed.remove(f); toremove.add(f); apps.setSafe(apps.getApkName(f)); listViewerInstalled.refresh(); listViewerToRemove.refresh(); } } }); btnAddToRemove.setText("->"); new Label(compositeButtongroup1, SWT.NONE); Button btnAddToInstalled = new Button(compositeButtongroup1, SWT.NONE); GridData gd_btnAddToInstalled = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_btnAddToInstalled.heightHint = 26; gd_btnAddToInstalled.widthHint = 40; btnAddToInstalled.setLayoutData(gd_btnAddToInstalled); btnAddToInstalled.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection)listViewerToRemove.getSelection(); Iterator i = selection.iterator(); while (i.hasNext()) { String f = (String)i.next(); toremove.remove(f); installed.add(f); apps.setUnsafe(apps.getApkName(f)); listViewerInstalled.refresh(); listViewerToRemove.refresh(); } } }); btnAddToInstalled.setText("<-"); Label lblAvailable = new Label(shlDecruptWizard, SWT.NONE); FormData fd_lblAvailable = new FormData(); fd_lblAvailable.top = new FormAttachment(listInstalled, 6); fd_lblAvailable.left = new FormAttachment(0, 10); lblAvailable.setLayoutData(fd_lblAvailable); lblAvailable.setText("Available for installation :"); Label lblToInstall = new Label(shlDecruptWizard, SWT.NONE); FormData fd_lblToInstall = new FormData(); fd_lblToInstall.top = new FormAttachment(listToRemove, 6); fd_lblToInstall.left = new FormAttachment(listToRemove, 0, SWT.LEFT); lblToInstall.setLayoutData(fd_lblToInstall); lblToInstall.setText("To be installed :"); listViewerAvailable = new ListViewer(shlDecruptWizard, SWT.BORDER | SWT.V_SCROLL); listViewerAvailable.setSorter(new ViewerSorter()); List listAvailable = listViewerAvailable.getList(); FormData fd_listAvailable = new FormData(); fd_listAvailable.top = new FormAttachment(lblAvailable, 6); fd_listAvailable.right = new FormAttachment(listInstalled, 0, SWT.RIGHT); fd_listAvailable.left = new FormAttachment(0, 10); listAvailable.setLayoutData(fd_listAvailable); listViewerAvailable.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector)inputElement; return v.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }); listViewerAvailable.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return (String)element; } }); listViewerToInstall = new ListViewer(shlDecruptWizard, SWT.BORDER | SWT.V_SCROLL); listViewerToInstall.setSorter(new ViewerSorter()); List listToInstall = listViewerToInstall.getList(); fd_listAvailable.bottom = new FormAttachment(listToInstall, 0, SWT.BOTTOM); FormData fd_listToInstall = new FormData(); fd_listToInstall.bottom = new FormAttachment(btnCancel, -6); fd_listToInstall.top = new FormAttachment(lblToInstall, 6); fd_listToInstall.left = new FormAttachment(listToRemove, 0, SWT.LEFT); fd_listToInstall.right = new FormAttachment(100, -11); listToInstall.setLayoutData(fd_listToInstall); listViewerToInstall.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector)inputElement; return v.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }); listViewerToInstall.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return (String)element; } }); Composite compositeButtongroup2 = new Composite(shlDecruptWizard, SWT.NONE); compositeButtongroup2.setLayout(new GridLayout(1, false)); FormData fd_compositeButtongroup2 = new FormData(); fd_compositeButtongroup2.bottom = new FormAttachment(100, -89); fd_compositeButtongroup2.right = new FormAttachment(compositeButtongroup1, 0, SWT.RIGHT); compositeButtongroup2.setLayoutData(fd_compositeButtongroup2); Button btnAddToBeInstalled = new Button(compositeButtongroup2, SWT.NONE); GridData gd_btnAddToBeInstalled = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_btnAddToBeInstalled.widthHint = 40; gd_btnAddToBeInstalled.heightHint = 26; btnAddToBeInstalled.setLayoutData(gd_btnAddToBeInstalled); btnAddToBeInstalled.setText("->"); new Label(compositeProfile, SWT.NONE); btnAddToBeInstalled.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection)listViewerAvailable.getSelection(); Iterator i = selection.iterator(); while (i.hasNext()) { String f = (String)i.next(); toinstall.add(f); available.remove(f); apps.setUnsafe(apps.getApkName(f)); listViewerToInstall.refresh(); listViewerAvailable.refresh(); } } }); Button btnAddToAvailable = new Button(compositeButtongroup2, SWT.NONE); GridData gd_btnAddToAvailable = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_btnAddToAvailable.widthHint = 40; gd_btnAddToAvailable.heightHint = 26; btnAddToAvailable.setLayoutData(gd_btnAddToAvailable); btnAddToAvailable.setText("<-"); new Label(compositeProfile, SWT.NONE); btnAddToAvailable.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection)listViewerToInstall.getSelection(); Iterator i = selection.iterator(); while (i.hasNext()) { String f = (String)i.next(); toinstall.remove(f); available.add(f); apps.setSafe(apps.getApkName(f)); listViewerToInstall.refresh(); listViewerAvailable.refresh(); } } }); listViewerInstalled.setInput(installed); listViewerToRemove.setInput(toremove); listViewerToInstall.setInput(toinstall); listViewerAvailable.setInput(available); } public void init() { if (apps==null) apps = new DeviceApps(); Enumeration<String> e1 = apps.getInstalled(false).elements(); installed.clear(); toremove.clear(); toinstall.clear(); available.clear(); while (e1.hasMoreElements()) { String elem = e1.nextElement(); installed.add(elem); // ListItem li = new ListItem(elem, apps.getRealName(elem),Color.black,Color.white); // listInstalledModel.addElement(li); } e1 = apps.getToBeRemoved(false).elements(); while (e1.hasMoreElements()) { String elem = e1.nextElement(); toremove.add(elem); // ListItem li = new ListItem(elem, apps.getRealName(elem),Color.black,Color.white); // listInstalledModel.addElement(li); } e1 = apps.getToBeInstalled(false).elements(); while (e1.hasMoreElements()) { String elem = e1.nextElement(); toinstall.add(elem); // ListItem li = new ListItem(elem, apps.getRealName(elem),Color.black,Color.white); // listInstalledModel.addElement(li); } e1 = apps.getRemoved(false).elements(); while (e1.hasMoreElements()) { String elem = e1.nextElement(); available.add(elem); // ListItem li = new ListItem(elem, apps.getRealName(elem),Color.black,Color.white); // listInstalledModel.addElement(li); } } }
18,452
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
WaitForUSBParser.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/WaitForUSBParser.java
package org.flashtool.gui; import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.IJobChangeListener; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.flashtool.gui.tools.DevicesSyncJob; import org.flashtool.gui.tools.USBParseJob; import org.flashtool.gui.tools.WidgetTask; import org.flashtool.parsers.simpleusblogger.Session; import lombok.extern.slf4j.Slf4j; @Slf4j public class WaitForUSBParser extends Dialog { protected Shell shlWaiForDevicesSync; protected boolean canClose = false; protected Dialog mydial; protected Session sess; /** * Create the dialog. * @param parent * @param style */ public WaitForUSBParser(Shell parent, int style) { super(parent, style); setText("Parsing USB log"); mydial = this; } /** * Open the dialog. * @return the result */ public Object open(String file, String folder) { createContents(file,folder); Label lblNewLabel = new Label(shlWaiForDevicesSync, SWT.NONE); lblNewLabel.setBounds(10, 32, 323, 20); lblNewLabel.setText("Please wait until the end of process"); shlWaiForDevicesSync.open(); shlWaiForDevicesSync.layout(); Display display = getParent().getDisplay(); while (!shlWaiForDevicesSync.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return sess; } /** * Create contents of the dialog. */ private void createContents(String file,String folder) { shlWaiForDevicesSync = new Shell(getParent(), getStyle()); shlWaiForDevicesSync.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { if (canClose) { sess = null; event.doit = true; } else { WidgetTask.openOKBox(shlWaiForDevicesSync, "Wait for end of process"); event.doit = false; } } }); shlWaiForDevicesSync.setSize(365, 130); shlWaiForDevicesSync.setText("Parsing USB log"); USBParseJob pj = new USBParseJob("USB log parser"); pj.setFilename(file); pj.setSinDir(folder); pj.addJobChangeListener(new IJobChangeListener() { public void aboutToRun(IJobChangeEvent event) { } public void awake(IJobChangeEvent event) { } public void done(IJobChangeEvent event) { sess = pj.getSession(); canClose=true; Display.getDefault().asyncExec( new Runnable() { public void run() { shlWaiForDevicesSync.dispose(); } } ); } public void running(IJobChangeEvent event) { } public void scheduled(IJobChangeEvent event) { } public void sleeping(IJobChangeEvent event) { } }); pj.schedule(); } }
3,052
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
SinEditor.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/SinEditor.java
package org.flashtool.gui; import java.io.File; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Text; import org.flashtool.flashsystem.S1Command; import org.flashtool.gui.tools.ExtractSinDataJob; import org.flashtool.parsers.sin.SinFile; import lombok.extern.slf4j.Slf4j; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.GridData; @Slf4j public class SinEditor extends Dialog { protected Object result; protected Shell shlSinEditor; private Button btnDumpHeader; private Button btnDumpData; private Button btnAdvanced; private Button btnNewButton_1; private Button btnClose; private Composite composite_1; private Label lblSinFile; private Text sourceFile; private Button button; private FormData fd_btnClose; private Composite composite; /** * Create the dialog. * @param parent * @param style */ public SinEditor(Shell parent, int style) { super(parent, style); setText("SWT Dialog"); } /** * Open the dialog. * @return the result */ public Object open() { createContents(); shlSinEditor.open(); shlSinEditor.layout(); Display display = getParent().getDisplay(); while (!shlSinEditor.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlSinEditor = new Shell(getParent(), getStyle()); shlSinEditor.setSize(528, 166); shlSinEditor.setText("Sin Editor"); shlSinEditor.setLayout(new FormLayout()); btnClose = new Button(shlSinEditor, SWT.NONE); fd_btnClose = new FormData(); fd_btnClose.right = new FormAttachment(100, -10); fd_btnClose.bottom = new FormAttachment(100, -10); btnClose.setLayoutData(fd_btnClose); btnClose.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { shlSinEditor.dispose(); } }); btnClose.setText("Close"); composite_1 = new Composite(shlSinEditor, SWT.NONE); composite_1.setLayout(new GridLayout(3, false)); FormData fd_composite_1 = new FormData(); fd_composite_1.top = new FormAttachment(0, 10); fd_composite_1.left = new FormAttachment(0,10); fd_composite_1.right = new FormAttachment(100, -10); composite_1.setLayoutData(fd_composite_1); lblSinFile = new Label(composite_1, SWT.NONE); GridData gd_lblSinFile = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); gd_lblSinFile.widthHint = 62; lblSinFile.setLayoutData(gd_lblSinFile); lblSinFile.setText("Sin file :"); sourceFile = new Text(composite_1, SWT.BORDER); sourceFile.setEnabled(false); GridData gd_sourceFile = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_sourceFile.widthHint = 369; sourceFile.setLayoutData(gd_sourceFile); button = new Button(composite_1, SWT.NONE); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog dlg = new FileDialog(shlSinEditor); // Set the initial filter path according // to anything they've selected or typed in dlg.setFilterPath(sourceFile.getText()); dlg.setFilterExtensions(new String[]{"*.sin"}); // Change the title bar text dlg.setText("SIN File Chooser"); // Calling open() will open and run the dialog. // It will return the selected directory, or // null if user cancels String dir = dlg.open(); if (dir != null) { // Set the text box to the new selection if (!sourceFile.getText().equals(dir)) { sourceFile.setText(dir); btnDumpHeader.setEnabled(true); btnDumpData.setEnabled(true); btnAdvanced.setEnabled(true); btnNewButton_1.setEnabled(true); } } } }); GridData gd_button = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_button.widthHint = 34; button.setLayoutData(gd_button); button.setText("..."); composite = new Composite(shlSinEditor, SWT.NONE); composite.setLayout(new GridLayout(4, false)); FormData fd_composite = new FormData(); fd_composite.top = new FormAttachment(composite_1, 6); fd_composite.left = new FormAttachment(0, 10); composite.setLayoutData(fd_composite); btnDumpHeader = new Button(composite, SWT.NONE); btnDumpHeader.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { SinFile sinf = new SinFile(new File(sourceFile.getText())); sinf.dumpHeader(); } catch (Exception ex) { } } }); btnDumpHeader.setText("Dump header"); btnDumpHeader.setEnabled(false); btnNewButton_1 = new Button(composite, SWT.NONE); btnNewButton_1.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { SinFile sinf = new SinFile(new File(sourceFile.getText())); ExtractSinDataJob ej = new ExtractSinDataJob("Sin dump job"); ej.setSin(sinf); ej.setMode("raw"); ej.schedule(); } catch (Exception ex) { } } }); btnNewButton_1.setText("Dump raw"); btnNewButton_1.setEnabled(false); btnDumpData = new Button(composite, SWT.NONE); btnDumpData.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { SinFile sinf = new SinFile(new File(sourceFile.getText())); ExtractSinDataJob ej = new ExtractSinDataJob("Sin dump job"); ej.setSin(sinf); ej.setMode("data"); ej.schedule(); } catch (Exception ex) { } } }); btnDumpData.setText("Extract data"); btnDumpData.setEnabled(false); btnAdvanced = new Button(composite, SWT.NONE); btnAdvanced.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { SinFile sin =new SinFile(new File(sourceFile.getText())); SinAdvanced sadv = new SinAdvanced(shlSinEditor,SWT.PRIMARY_MODAL | SWT.SHEET); sadv.open(sin); } catch (Exception ex) { log.error(ex.getMessage()); } } }); btnAdvanced.setText("Advanced"); btnAdvanced.setEnabled(false); } }
6,744
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
FTFSelector.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/FTFSelector.java
package org.flashtool.gui; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; import org.flashtool.flashsystem.Bundle; import org.flashtool.flashsystem.Category; import org.flashtool.gui.models.ContentContentProvider; import org.flashtool.gui.models.ContentLabelProvider; import org.flashtool.gui.models.Firmware; import org.flashtool.gui.models.MyTreeContentProvider; import org.flashtool.gui.models.MyTreeLabelProvider; import org.flashtool.gui.models.TreeDeviceCustomizationRelease; import org.flashtool.gui.models.TreeDevices; import org.flashtool.gui.tools.WidgetTask; import org.flashtool.system.DeviceEntry; import org.flashtool.system.GlobalConfig; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.widgets.Table; import java.util.Iterator; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; public class FTFSelector extends Dialog { protected Bundle result; protected Shell shlFirmwareSelector; private boolean simulate = false; private int maxbuffer = 0; private Text textSourceFolder; private Button btnSourcefolder; private Composite compositeSearch; private Composite compositeSettings; private Button btnCheckSimulate; private Button btnCheckFinal; private Label lblUSBBuffer; private Combo comboUSBBuffer; private Text textFilter; private Label lblFirmwares; private Table tableContent; private TableViewer tableViewerContent; private Button btnCancel; private Button btnFlash; private TreeDevices firms=null; private TreeViewer treeViewerFirmwares; private Tree treeFirmwares; private Firmware currentfirm=null; private Composite compositeWipeContent; private Composite compositeWipeTA; private Composite compositeExcludeContent; private Composite compositeExcludeTA; private Button btnFilter; private FormData fd_compositeExclude; public FTFSelector(Shell parent, int style) { super(parent, style); setText("Firmware selector"); } public Object open(String pathname, String ftfname) { createContents(); btnFlash = new Button(shlFirmwareSelector, SWT.NONE); FormData fd_btnFlash = new FormData(); fd_btnFlash.bottom = new FormAttachment(100, -10); btnFlash.setLayoutData(fd_btnFlash); btnFlash.setText("Flash"); btnCancel = new Button(shlFirmwareSelector, SWT.NONE); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100, -10); fd_btnCancel.bottom = new FormAttachment(100, -10); fd_btnFlash.right = new FormAttachment(btnCancel, -6); btnCancel.setLayoutData(fd_btnCancel); btnCancel.setText("Cancel"); feedContent(pathname, ftfname); setProviders(); setListeners(); updateContent(true); shlFirmwareSelector.open(); shlFirmwareSelector.layout(); Display display = getParent().getDisplay(); while (!shlFirmwareSelector.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } if (result!=null) { result.setSimulate(simulate); result.setMaxBuffer(maxbuffer); } return result; } private void createContents() { // Creation du Shell shlFirmwareSelector = new Shell(getParent(), getStyle()); shlFirmwareSelector.setSize(714, 520); shlFirmwareSelector.setText("Firmware Selector"); shlFirmwareSelector.setLayout(new FormLayout()); // Search bar compositeSearch = new Composite(shlFirmwareSelector, SWT.NONE); FormData fd_compositeSearch = new FormData(); fd_compositeSearch.left = new FormAttachment(0, 10); fd_compositeSearch.right = new FormAttachment(100, -10); fd_compositeSearch.top = new FormAttachment(0, 10); fd_compositeSearch.bottom = new FormAttachment(0, 50); compositeSearch.setLayoutData(fd_compositeSearch); compositeSearch.setLayout(new GridLayout(3, false)); Label lblSourceFolder = new Label(compositeSearch, SWT.NONE); lblSourceFolder.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblSourceFolder.setText("Source folder : "); textSourceFolder = new Text(compositeSearch, SWT.BORDER); textSourceFolder.setEditable(false); GridData gd_textSourceFolder = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); gd_textSourceFolder.widthHint = 517; textSourceFolder.setLayoutData(gd_textSourceFolder); btnSourcefolder = new Button(compositeSearch, SWT.NONE); btnSourcefolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); btnSourcefolder.setText(" ... "); // Settings bar compositeSettings = new Composite(shlFirmwareSelector, SWT.NONE); FormData fd_compositeSettings = new FormData(); fd_compositeSettings.right = new FormAttachment(100, -197); fd_compositeSettings.top = new FormAttachment(0, 430); fd_compositeSettings.left = new FormAttachment(0, 10); fd_compositeSettings.bottom = new FormAttachment(100, -10); compositeSettings.setLayoutData(fd_compositeSettings); compositeSettings.setLayout(new GridLayout(6, false)); btnCheckSimulate = new Button(compositeSettings, SWT.CHECK); btnCheckSimulate.setText("Simulate"); new Label(compositeSettings, SWT.NONE); btnCheckFinal = new Button(compositeSettings, SWT.CHECK); btnCheckFinal.setText("Disable final verification"); new Label(compositeSettings, SWT.NONE); lblUSBBuffer = new Label(compositeSettings, SWT.NONE); lblUSBBuffer.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblUSBBuffer.setText("USB buffer"); comboUSBBuffer = new Combo(compositeSettings, SWT.READ_ONLY); comboUSBBuffer.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); Composite compositeFirmwares = new Composite(shlFirmwareSelector, SWT.NONE); compositeFirmwares.setLayout(new GridLayout(1, false)); FormData fd_compositeFirmwares = new FormData(); fd_compositeFirmwares.bottom = new FormAttachment(compositeSettings, -6); fd_compositeFirmwares.left = new FormAttachment(0, 10); compositeFirmwares.setLayoutData(fd_compositeFirmwares); Composite compositeFilter = new Composite(shlFirmwareSelector, SWT.NONE); fd_compositeFirmwares.top = new FormAttachment(compositeFilter, 6); lblFirmwares = new Label(compositeFirmwares, SWT.NONE); lblFirmwares.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); lblFirmwares.setText("Firmwares"); treeViewerFirmwares = new TreeViewer(compositeFirmwares, SWT.BORDER); treeFirmwares = treeViewerFirmwares.getTree(); GridData gd_treeFirmwares = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gd_treeFirmwares.widthHint = 118; treeFirmwares.setLayoutData(gd_treeFirmwares); compositeFilter.setLayout(new GridLayout(3, false)); FormData fd_compositeFilter = new FormData(); fd_compositeFilter.top = new FormAttachment(compositeSearch, 6); fd_compositeFilter.right = new FormAttachment(100, -182); fd_compositeFilter.left = new FormAttachment(0, 182); compositeFilter.setLayoutData(fd_compositeFilter); Label lblFilter = new Label(compositeFilter, SWT.NONE); lblFilter.setText("Device filter : "); textFilter = new Text(compositeFilter, SWT.BORDER); textFilter.setEditable(false); textFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); btnFilter = new Button(compositeFilter, SWT.NONE); btnFilter.setText("Clear filter"); Composite compositeContent = new Composite(shlFirmwareSelector, SWT.NONE); fd_compositeFirmwares.right = new FormAttachment(compositeContent, -6); compositeContent.setLayout(new GridLayout(1, false)); FormData fd_compositeContent = new FormData(); fd_compositeContent.bottom = new FormAttachment(compositeSettings, -6); fd_compositeContent.top = new FormAttachment(compositeFilter, 6); fd_compositeContent.left = new FormAttachment(0, 225); compositeContent.setLayoutData(fd_compositeContent); Label lblContent = new Label(compositeContent, SWT.NONE); lblContent.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); lblContent.setText("Content"); tableViewerContent = new TableViewer(compositeContent, SWT.BORDER | SWT.FULL_SELECTION); tableContent = tableViewerContent.getTable(); tableContent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Composite compositeWipe = new Composite(shlFirmwareSelector, SWT.NONE); fd_compositeContent.right = new FormAttachment(compositeWipe, -6); compositeWipe.setLayout(new GridLayout(1, false)); FormData fd_compositeWipe = new FormData(); fd_compositeWipe.bottom = new FormAttachment(compositeSettings, -6); fd_compositeWipe.top = new FormAttachment(compositeFilter, 6); fd_compositeWipe.left = new FormAttachment(0, 401); compositeWipe.setLayoutData(fd_compositeWipe); Label lblWipe = new Label(compositeWipe, SWT.NONE); lblWipe.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); lblWipe.setText("Wipe"); Composite compositeExclude = new Composite(shlFirmwareSelector, SWT.NONE); fd_compositeWipe.right = new FormAttachment(compositeExclude, -6); Label lblNewLabel = new Label(compositeWipe, SWT.NONE); lblNewLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); lblNewLabel.setText("Sin"); ScrolledComposite scrolledCompositeWipe = new ScrolledComposite(compositeWipe, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); GridData gd_scrolledCompositeWipe = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1); gd_scrolledCompositeWipe.heightHint = 100; scrolledCompositeWipe.setLayoutData(gd_scrolledCompositeWipe); compositeWipeContent = new Composite(scrolledCompositeWipe, SWT.NONE); compositeWipeContent.setLayout(new GridLayout(1, false)); compositeWipeContent.setSize(compositeWipe.computeSize(SWT.DEFAULT, SWT.DEFAULT)); scrolledCompositeWipe.setContent(compositeWipeContent); Label lblWipeMiscTA = new Label(compositeWipe, SWT.NONE); lblWipeMiscTA.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); lblWipeMiscTA.setText("Misc TA"); ScrolledComposite scrolledCompositeWipeTA = new ScrolledComposite(compositeWipe, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); GridData gd_scrolledCompositeWipeTA = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1); gd_scrolledCompositeWipeTA.heightHint = 80; scrolledCompositeWipeTA.setLayoutData(gd_scrolledCompositeWipeTA); compositeWipeTA = new Composite(scrolledCompositeWipeTA, SWT.NONE); compositeWipeTA.setLayout(new GridLayout(1, false)); scrolledCompositeWipeTA.setContent(compositeWipeTA); compositeExclude.setLayout(new GridLayout(1, false)); fd_compositeExclude = new FormData(); fd_compositeExclude.top = new FormAttachment(compositeFilter, 6); fd_compositeExclude.left = new FormAttachment(0, 543); fd_compositeExclude.right = new FormAttachment(100, -10); fd_compositeExclude.bottom = new FormAttachment(compositeSettings, -6); compositeExclude.setLayoutData(fd_compositeExclude); Label lblExclude = new Label(compositeExclude, SWT.NONE); lblExclude.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); lblExclude.setText("Exclude"); Label lblNewLabel_1 = new Label(compositeExclude, SWT.NONE); lblNewLabel_1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); lblNewLabel_1.setText("Sin"); ScrolledComposite scrolledCompositeExclude = new ScrolledComposite(compositeExclude, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); GridData gd_scrolledCompositeExclude = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1); gd_scrolledCompositeExclude.heightHint = 100; scrolledCompositeExclude.setLayoutData(gd_scrolledCompositeExclude); compositeExcludeContent = new Composite(scrolledCompositeExclude, SWT.NONE); GridLayout layoutExclude = new GridLayout(); layoutExclude.numColumns = 1; compositeExcludeContent.setLayout(layoutExclude); compositeExcludeContent.setSize(compositeExcludeContent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); compositeExcludeContent.setSize(compositeExcludeContent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); scrolledCompositeExclude.setContent(compositeExcludeContent); Label lblNewLabel_2 = new Label(compositeExclude, SWT.NONE); lblNewLabel_2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); lblNewLabel_2.setText("Misc TA"); ScrolledComposite scrolledCompositeExcludeTA = new ScrolledComposite(compositeExclude, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); GridData gd_scrolledCompositeExcludeTA = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1); gd_scrolledCompositeExcludeTA.heightHint = 80; scrolledCompositeExcludeTA.setLayoutData(gd_scrolledCompositeExcludeTA); compositeExcludeTA = new Composite(scrolledCompositeExcludeTA, SWT.NONE); compositeExcludeTA.setLayout(new GridLayout(1, false)); scrolledCompositeExcludeTA.setContent(compositeExcludeTA); } public void feedContent(String pathname, String ftfname) { textSourceFolder.setText(pathname); comboUSBBuffer.setItems(new String[] {"4096K", "2048K", "1024K", "512K", "256K", "128K", "64K", "32K"}); comboUSBBuffer.select(3); maxbuffer=comboUSBBuffer.getSelectionIndex(); } public void updateContent(boolean folderchange) { if (folderchange) { firms = new TreeDevices(textSourceFolder.getText()); textFilter.setText(""); treeViewerFirmwares.setInput(firms); btnFlash.setEnabled(false); btnCheckFinal.setEnabled(false); btnCheckFinal.setSelection(false); } treeViewerFirmwares.refresh(); tableViewerContent.setInput(currentfirm); tableViewerContent.refresh(); updateCheckBoxes(); } public void updateCheckBoxes() { Control[] ctl = compositeWipeContent.getChildren(); for (int i = 0;i<ctl.length;i++) { ctl[i].dispose(); } ctl = compositeExcludeContent.getChildren(); for (int i = 0;i<ctl.length;i++) { ctl[i].dispose(); } ctl = compositeWipeTA.getChildren(); for (int i = 0;i<ctl.length;i++) { ctl[i].dispose(); } ctl = compositeExcludeTA.getChildren(); for (int i = 0;i<ctl.length;i++) { ctl[i].dispose(); } compositeWipeContent.setSize(compositeWipeContent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); compositeWipeContent.layout(); compositeWipeTA.setSize(compositeWipeTA.computeSize(SWT.DEFAULT, SWT.DEFAULT)); compositeWipeTA.layout(); compositeExcludeContent.setSize(compositeExcludeContent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); compositeExcludeContent.layout(); compositeExcludeTA.setSize(compositeExcludeTA.computeSize(SWT.DEFAULT, SWT.DEFAULT)); compositeExcludeTA.layout(); if (currentfirm!=null) { Iterator<Category> wipe = result.getMeta().getWipe().iterator(); while (wipe.hasNext()) { Category categ = wipe.next(); Button btnWipe = null; if (categ.isTa()) { btnWipe = new Button(compositeWipeTA, SWT.CHECK); } else { btnWipe = new Button(compositeWipeContent, SWT.CHECK); } btnWipe.setText(categ.getId()); btnWipe.setSelection(categ.isEnabled()); if (categ.getId().equals("SIMLOCK") && GlobalConfig.getProperty("devfeatures").equals("no")) btnWipe.setEnabled(false); if (categ.isTa()) { compositeWipeTA.setSize(compositeWipeTA.computeSize(SWT.DEFAULT, SWT.DEFAULT)); compositeWipeTA.layout(); } else { compositeWipeContent.setSize(compositeWipeContent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); compositeWipeContent.layout(); } btnWipe.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Button b = (Button)e.widget; if (b.getSelection()) { if (b.getText().equals("SIMLOCK")) WidgetTask.openOKBox(shlFirmwareSelector, "Including simlock can lead to loss of network"); currentfirm.enableCateg(b.getText()); } else currentfirm.disableCateg(b.getText()); tableViewerContent.setInput(currentfirm); tableViewerContent.refresh(); } }); } Iterator<Category> exclude = result.getMeta().getExclude().iterator(); while (exclude.hasNext()) { Category categ = exclude.next(); //if (!(categ.isSin() || categ.isBootDelivery())) continue; Button btnExclude = null; if (categ.isTa()) { btnExclude = new Button(compositeExcludeTA, SWT.CHECK); } else { btnExclude = new Button(compositeExcludeContent, SWT.CHECK); } btnExclude.setText(categ.getId()); btnExclude.setSelection(!categ.isEnabled()); compositeExcludeContent.setSize(compositeExcludeContent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); compositeExcludeContent.layout(); if (categ.isTa()) { compositeExcludeTA.setSize(compositeExcludeTA.computeSize(SWT.DEFAULT, SWT.DEFAULT)); compositeExcludeTA.layout(); } else { compositeExcludeContent.setSize(compositeExcludeContent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); compositeExcludeContent.layout(); } btnExclude.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Button b = (Button)e.widget; if (b.getSelection()) currentfirm.disableCateg(b.getText()); else { if (b.getText().equals("SIMLOCK")) WidgetTask.openOKBox(shlFirmwareSelector, "Including simlock can lead to loss of network"); currentfirm.enableCateg(b.getText()); } tableViewerContent.setInput(currentfirm); tableViewerContent.refresh(); } }); } } tableViewerContent.setInput(currentfirm); tableViewerContent.refresh(); } public void setProviders() { treeViewerFirmwares.setContentProvider(new MyTreeContentProvider()); treeViewerFirmwares.setLabelProvider(new MyTreeLabelProvider()); tableViewerContent.setContentProvider(new ContentContentProvider()); tableViewerContent.setLabelProvider(new ContentLabelProvider()); } public void setListeners() { shlFirmwareSelector.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { result = null; shlFirmwareSelector.dispose(); } }); btnSourcefolder.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DirectoryDialog dlg = new DirectoryDialog(shlFirmwareSelector); // Set the initial filter path according // to anything they've selected or typed in dlg.setFilterPath(textSourceFolder.getText()); // Change the title bar text dlg.setText("Directory chooser"); // Customizable message displayed in the dialog dlg.setMessage("Select a directory"); // Calling open() will open and run the dialog. // It will return the selected directory, or // null if user cancels String dir = dlg.open(); if (dir != null) { // Set the text box to the new selection if (!textSourceFolder.getText().equals(dir)) { textSourceFolder.setText(dir); updateContent(true); } } } }); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = null; shlFirmwareSelector.dispose(); } }); btnFlash.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { shlFirmwareSelector.dispose(); } }); treeFirmwares.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { if (treeFirmwares.getSelectionCount()==0) { currentfirm=null; result=null; btnFlash.setEnabled(false); btnCheckFinal.setSelection(false); btnCheckFinal.setEnabled(false); } else { TreeItem selection = treeFirmwares.getSelection()[0]; if (selection.getData() instanceof TreeDeviceCustomizationRelease) { TreeDeviceCustomizationRelease rel = (TreeDeviceCustomizationRelease)selection.getData(); currentfirm=rel.getFirmware(); result=currentfirm.getBundle(); btnFlash.setEnabled(true); btnCheckFinal.setEnabled(true); btnCheckFinal.setSelection(result.hasCmd25()); } else { btnFlash.setEnabled(false); btnCheckFinal.setEnabled(false); btnCheckFinal.setSelection(false); currentfirm=null; result=null; } } if (tableViewerContent.getInput()!=currentfirm) updateContent(false); } }); textFilter.addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { String res = WidgetTask.openDeviceSelector(shlFirmwareSelector); if (res.length()>0) { DeviceEntry ent = new DeviceEntry(res); textFilter.setText(ent.getName()); firms.setDeviceFilter(ent.getId()); updateContent(false); } } }); comboUSBBuffer.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { maxbuffer=comboUSBBuffer.getSelectionIndex(); } }); btnCheckSimulate.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { simulate = btnCheckSimulate.getSelection(); } }); btnFilter.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (textFilter.getText().length()>0) { textFilter.setText(""); firms.setDeviceFilter(""); updateContent(false); } } }); btnCheckFinal.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (btnCheckFinal.getSelection()) { WidgetTask.openOKBox(shlFirmwareSelector, "Warning, this option will not be used if a FSC script is found"); } if (result!=null) result.setCmd25(btnCheckFinal.getSelection()?"true":"false"); } }); } }
22,925
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
GifCLabel.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/GifCLabel.java
package org.flashtool.gui; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.events.*; import org.eclipse.swt.accessibility.*; /** * <p><b>This class supports gif animation in label and is derived from {@link GifCLabel} SWT class (see {@link #setGifImage(InputStream)} or {@link #setGifImage(String)})</b><br /> * <b>Changes by Sorceror, (a)sync.exec(...) call fix by YAMaiDie</b></p> */ public class GifCLabel extends Canvas { /** Gap between icon and text */ private static final int GAP = 5; /** Left and right margins */ private static final int DEFAULT_MARGIN = 3; /** a string inserted in the middle of text that has been shortened */ private static final String ELLIPSIS = "..."; //$NON-NLS-1$ // could use the ellipsis glyph on some platforms "\u2026" /** the alignment. Either CENTER, RIGHT, LEFT. Default is LEFT*/ private int align = SWT.LEFT; private int leftMargin = DEFAULT_MARGIN; private int topMargin = DEFAULT_MARGIN; private int rightMargin = DEFAULT_MARGIN; private int bottomMargin = DEFAULT_MARGIN; private String text; private Image image; private String appToolTipText; private boolean ignoreDispose; private Image backgroundImage; private Color[] gradientColors; private int[] gradientPercents; private boolean gradientVertical; private Color background; private GifThread thread = null; private static int DRAW_FLAGS = SWT.DRAW_MNEMONIC | SWT.DRAW_TAB | SWT.DRAW_TRANSPARENT | SWT.DRAW_DELIMITER; public GifCLabel(Composite parent, int style) { super(parent, checkStyle(style)); if ((style & (SWT.CENTER | SWT.RIGHT)) == 0) style |= SWT.LEFT; if ((style & SWT.CENTER) != 0) align = SWT.CENTER; if ((style & SWT.RIGHT) != 0) align = SWT.RIGHT; if ((style & SWT.LEFT) != 0) align = SWT.LEFT; addPaintListener(new PaintListener() { public void paintControl(PaintEvent event) { onPaint(event); } }); addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent event) { if (event.detail == SWT.TRAVERSE_MNEMONIC) { onMnemonic(event); } } }); addListener(SWT.Dispose, new Listener() { public void handleEvent(Event event) { onDispose(event); } }); initAccessible(); } private static int checkStyle (int style) { if ((style & SWT.BORDER) != 0) style |= SWT.SHADOW_IN; int mask = SWT.SHADOW_IN | SWT.SHADOW_OUT | SWT.SHADOW_NONE | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; style = style & mask; return style |= SWT.NO_FOCUS | SWT.DOUBLE_BUFFERED; } public Point computeSize(int wHint, int hHint, boolean changed) { checkWidget(); Point e = getTotalSize(image, text); if (wHint == SWT.DEFAULT){ e.x += leftMargin + rightMargin; } else { e.x = wHint; } if (hHint == SWT.DEFAULT) { e.y += topMargin + bottomMargin; } else { e.y = hHint; } return e; } private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) { gc.setForeground(bottomright); gc.drawLine(x+w, y, x+w, y+h); gc.drawLine(x, y+h, x+w, y+h); gc.setForeground(topleft); gc.drawLine(x, y, x+w-1, y); gc.drawLine(x, y, x, y+h-1); } char _findMnemonic (String string) { if (string == null) return '\0'; int index = 0; int length = string.length (); do { while (index < length && string.charAt (index) != '&') index++; if (++index >= length) return '\0'; if (string.charAt (index) != '&') return Character.toLowerCase (string.charAt (index)); index++; } while (index < length); return '\0'; } public int getAlignment() { //checkWidget(); return align; } public int getBottomMargin() { //checkWidget(); return bottomMargin; } public Image getImage() { //checkWidget(); return image; } public int getLeftMargin() { //checkWidget(); return leftMargin; } public int getRightMargin() { //checkWidget(); return rightMargin; } private Point getTotalSize(Image image, String text) { Point size = new Point(0, 0); if (image != null) { Rectangle r = image.getBounds(); size.x += r.width; size.y += r.height; } GC gc = new GC(this); if (text != null && text.length() > 0) { Point e = gc.textExtent(text, DRAW_FLAGS); size.x += e.x; size.y = Math.max(size.y, e.y); if (image != null) size.x += GAP; } else { size.y = Math.max(size.y, gc.getFontMetrics().getHeight()); } gc.dispose(); return size; } public int getStyle () { int style = super.getStyle(); switch (align) { case SWT.RIGHT: style |= SWT.RIGHT; break; case SWT.CENTER: style |= SWT.CENTER; break; case SWT.LEFT: style |= SWT.LEFT; break; } return style; } public String getText() { //checkWidget(); return text; } public String getToolTipText () { checkWidget(); return appToolTipText; } public int getTopMargin() { //checkWidget(); return topMargin; } private void initAccessible() { Accessible accessible = getAccessible(); accessible.addAccessibleListener(new AccessibleAdapter() { public void getName(AccessibleEvent e) { e.result = getText(); } public void getHelp(AccessibleEvent e) { e.result = getToolTipText(); } public void getKeyboardShortcut(AccessibleEvent e) { char mnemonic = _findMnemonic(GifCLabel.this.text); if (mnemonic != '\0') { e.result = "Alt+"+mnemonic; //$NON-NLS-1$ } } }); accessible.addAccessibleControlListener(new AccessibleControlAdapter() { public void getChildAtPoint(AccessibleControlEvent e) { e.childID = ACC.CHILDID_SELF; } public void getLocation(AccessibleControlEvent e) { Rectangle rect = getDisplay().map(getParent(), null, getBounds()); e.x = rect.x; e.y = rect.y; e.width = rect.width; e.height = rect.height; } public void getChildCount(AccessibleControlEvent e) { e.detail = 0; } public void getRole(AccessibleControlEvent e) { e.detail = ACC.ROLE_LABEL; } public void getState(AccessibleControlEvent e) { e.detail = ACC.STATE_READONLY; } }); } void onDispose(Event event) { /* make this handler run after other dispose listeners */ if (ignoreDispose) { ignoreDispose = false; return; } ignoreDispose = true; notifyListeners (event.type, event); event.type = SWT.NONE; gradientColors = null; gradientPercents = null; backgroundImage = null; text = null; image = null; appToolTipText = null; } void onMnemonic(TraverseEvent event) { char mnemonic = _findMnemonic(text); if (mnemonic == '\0') return; if (Character.toLowerCase(event.character) != mnemonic) return; Composite control = this.getParent(); while (control != null) { Control [] children = control.getChildren(); int index = 0; while (index < children.length) { if (children [index] == this) break; index++; } index++; if (index < children.length) { if (children [index].setFocus ()) { event.doit = true; event.detail = SWT.TRAVERSE_NONE; } } control = control.getParent(); } } void onPaint(PaintEvent event) { Rectangle rect = getClientArea(); if (rect.width == 0 || rect.height == 0) return; boolean shortenText = false; String t = text; Image img = image; int availableWidth = Math.max(0, rect.width - (leftMargin + rightMargin)); Point extent = getTotalSize(img, t); if (extent.x > availableWidth) { img = null; extent = getTotalSize(img, t); if (extent.x > availableWidth) { shortenText = true; } } GC gc = event.gc; String[] lines = text == null ? null : splitString(text); // shorten the text if (shortenText) { extent.x = 0; for(int i = 0; i < lines.length; i++) { Point e = gc.textExtent(lines[i], DRAW_FLAGS); if (e.x > availableWidth) { lines[i] = shortenText(gc, lines[i], availableWidth); extent.x = Math.max(extent.x, getTotalSize(null, lines[i]).x); } else { extent.x = Math.max(extent.x, e.x); } } if (appToolTipText == null) { super.setToolTipText(text); } } else { super.setToolTipText(appToolTipText); } // determine horizontal position int x = rect.x + leftMargin; if (align == SWT.CENTER) { x = (rect.width - extent.x)/2; } if (align == SWT.RIGHT) { x = rect.width - rightMargin - extent.x; } // draw a background image behind the text try { if (backgroundImage != null) { // draw a background image behind the text Rectangle imageRect = backgroundImage.getBounds(); // tile image to fill space gc.setBackground(getBackground()); gc.fillRectangle(rect); int xPos = 0; while (xPos < rect.width) { int yPos = 0; while (yPos < rect.height) { gc.drawImage(backgroundImage, xPos, yPos); yPos += imageRect.height; } xPos += imageRect.width; } } else if (gradientColors != null) { // draw a gradient behind the text final Color oldBackground = gc.getBackground(); if (gradientColors.length == 1) { if (gradientColors[0] != null) gc.setBackground(gradientColors[0]); gc.fillRectangle(0, 0, rect.width, rect.height); } else { final Color oldForeground = gc.getForeground(); Color lastColor = gradientColors[0]; if (lastColor == null) lastColor = oldBackground; int pos = 0; for (int i = 0; i < gradientPercents.length; ++i) { gc.setForeground(lastColor); lastColor = gradientColors[i + 1]; if (lastColor == null) lastColor = oldBackground; gc.setBackground(lastColor); if (gradientVertical) { final int gradientHeight = (gradientPercents[i] * rect.height / 100) - pos; gc.fillGradientRectangle(0, pos, rect.width, gradientHeight, true); pos += gradientHeight; } else { final int gradientWidth = (gradientPercents[i] * rect.width / 100) - pos; gc.fillGradientRectangle(pos, 0, gradientWidth, rect.height, false); pos += gradientWidth; } } if (gradientVertical && pos < rect.height) { gc.setBackground(getBackground()); gc.fillRectangle(0, pos, rect.width, rect.height - pos); } if (!gradientVertical && pos < rect.width) { gc.setBackground(getBackground()); gc.fillRectangle(pos, 0, rect.width - pos, rect.height); } gc.setForeground(oldForeground); } gc.setBackground(oldBackground); } else { if (background != null || (getStyle() & SWT.DOUBLE_BUFFERED) == 0) { gc.setBackground(getBackground()); gc.fillRectangle(rect); } } } catch (SWTException e) { if ((getStyle() & SWT.DOUBLE_BUFFERED) == 0) { gc.setBackground(getBackground()); gc.fillRectangle(rect); } } // draw border int style = getStyle(); if ((style & SWT.SHADOW_IN) != 0 || (style & SWT.SHADOW_OUT) != 0) { paintBorder(gc, rect); } Rectangle imageRect = null; int lineHeight = 0, textHeight = 0, imageHeight = 0; if (img != null) { imageRect = img.getBounds(); imageHeight = imageRect.height; } if (lines != null) { lineHeight = gc.getFontMetrics().getHeight(); textHeight = lines.length * lineHeight; } int imageY = 0, midPoint = 0, lineY = 0; if (imageHeight > textHeight ) { if (topMargin == DEFAULT_MARGIN && bottomMargin == DEFAULT_MARGIN) imageY = rect.y + (rect.height - imageHeight) / 2; else imageY = topMargin; midPoint = imageY + imageHeight/2; lineY = midPoint - textHeight / 2; } else { if (topMargin == DEFAULT_MARGIN && bottomMargin == DEFAULT_MARGIN) lineY = rect.y + (rect.height - textHeight) / 2; else lineY = topMargin; midPoint = lineY + textHeight/2; imageY = midPoint - imageHeight / 2; } // draw the image if (img != null) { gc.drawImage(img, 0, 0, imageRect.width, imageHeight, x, imageY, imageRect.width, imageHeight); x += imageRect.width + GAP; extent.x -= imageRect.width + GAP; } // draw the text if (lines != null) { gc.setForeground(getForeground()); for (int i = 0; i < lines.length; i++) { int lineX = x; if (lines.length > 1) { if (align == SWT.CENTER) { int lineWidth = gc.textExtent(lines[i], DRAW_FLAGS).x; lineX = x + Math.max(0, (extent.x - lineWidth) / 2); } if (align == SWT.RIGHT) { int lineWidth = gc.textExtent(lines[i], DRAW_FLAGS).x; lineX = Math.max(x, rect.x + rect.width - rightMargin - lineWidth); } } gc.drawText(lines[i], lineX, lineY, DRAW_FLAGS); lineY += lineHeight; } } } private void paintBorder(GC gc, Rectangle r) { Display disp= getDisplay(); Color c1 = null; Color c2 = null; int style = getStyle(); if ((style & SWT.SHADOW_IN) != 0) { c1 = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); c2 = disp.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW); } if ((style & SWT.SHADOW_OUT) != 0) { c1 = disp.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW); c2 = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); } if (c1 != null && c2 != null) { gc.setLineWidth(1); drawBevelRect(gc, r.x, r.y, r.width-1, r.height-1, c1, c2); } } public void setAlignment(int align) { checkWidget(); if (align != SWT.LEFT && align != SWT.RIGHT && align != SWT.CENTER) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } if (this.align != align) { this.align = align; redraw(); } } public void setBackground (Color color) { super.setBackground (color); // Are these settings the same as before? if (backgroundImage == null && gradientColors == null && gradientPercents == null) { if (color == null) { if (background == null) return; } else { if (color.equals(background)) return; } } background = color; backgroundImage = null; gradientColors = null; gradientPercents = null; redraw (); } public void setBackground(Color[] colors, int[] percents) { setBackground(colors, percents, false); } public void setBackground(Color[] colors, int[] percents, boolean vertical) { checkWidget(); if (colors != null) { if (percents == null || percents.length != colors.length - 1) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } if (getDisplay().getDepth() < 15) { // Don't use gradients on low color displays colors = new Color[] {colors[colors.length - 1]}; percents = new int[] { }; } for (int i = 0; i < percents.length; i++) { if (percents[i] < 0 || percents[i] > 100) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } if (i > 0 && percents[i] < percents[i-1]) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } } } // Are these settings the same as before? final Color background = getBackground(); if (backgroundImage == null) { if ((gradientColors != null) && (colors != null) && (gradientColors.length == colors.length)) { boolean same = false; for (int i = 0; i < gradientColors.length; i++) { same = (gradientColors[i] == colors[i]) || ((gradientColors[i] == null) && (colors[i] == background)) || ((gradientColors[i] == background) && (colors[i] == null)); if (!same) break; } if (same) { for (int i = 0; i < gradientPercents.length; i++) { same = gradientPercents[i] == percents[i]; if (!same) break; } } if (same && this.gradientVertical == vertical) return; } } else { backgroundImage = null; } // Store the new settings if (colors == null) { gradientColors = null; gradientPercents = null; gradientVertical = false; } else { gradientColors = new Color[colors.length]; for (int i = 0; i < colors.length; ++i) gradientColors[i] = (colors[i] != null) ? colors[i] : background; gradientPercents = new int[percents.length]; for (int i = 0; i < percents.length; ++i) gradientPercents[i] = percents[i]; gradientVertical = vertical; } // Refresh with the new settings redraw(); } public void setBackground(Image image) { checkWidget(); if (image == backgroundImage) return; if (image != null) { gradientColors = null; gradientPercents = null; } backgroundImage = image; redraw(); } public void setBottomMargin(int bottomMargin) { checkWidget(); if (this.bottomMargin == bottomMargin || bottomMargin < 0) return; this.bottomMargin = bottomMargin; redraw(); } public void setFont(Font font) { super.setFont(font); redraw(); } public void setImage(Image image) { checkWidget(); if(thread != null) { thread.stopRunning(); try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } } if (image != this.image) { this.image = image; redraw(); } } public void setGifImage(String path) { try { this.setGifImage(new FileInputStream(new File(path))); } catch (FileNotFoundException e) { this.image = null; return; } } public void setGifImage(InputStream inputStream) { checkWidget(); if(thread != null) thread.stopRunning(); ImageLoader loader = new ImageLoader(); try { loader.load(inputStream); } catch (Exception e) { this.image = null; return; } if (loader.data[0] != null) this.image = new Image(this.getDisplay(), loader.data[0]); if (loader.data.length > 1) { thread = new GifThread(loader); thread.start(); } redraw(); } @Override public void dispose() { super.dispose(); if(thread != null) thread.stopRunning(); } private class GifThread extends Thread { private int imageNumber = 0; private ImageLoader loader = null; private boolean run = true; public GifThread(ImageLoader loader) { this.loader = loader; } public void run() { while(run) { int delayTime = loader.data[imageNumber].delayTime; try { Thread.sleep(delayTime * 10); } catch (InterruptedException e) { e.printStackTrace(); } if(!GifCLabel.this.isDisposed()) { GifCLabel.this.getDisplay().asyncExec(new Runnable() { public void run() { if(!run){ return; } if(!GifCLabel.this.isDisposed()) { imageNumber = imageNumber == loader.data.length - 1 ? 0 : imageNumber + 1; if (!GifCLabel.this.image.isDisposed()) GifCLabel.this.image.dispose(); ImageData nextFrameData = loader.data[imageNumber]; GifCLabel.this.image = new Image(GifCLabel.this.getDisplay(), nextFrameData); GifCLabel.this.redraw(); } else stopRunning(); } }); } else stopRunning(); } } public void stopRunning() { run = false; } } public void setLeftMargin(int leftMargin) { checkWidget(); if (this.leftMargin == leftMargin || leftMargin < 0) return; this.leftMargin = leftMargin; redraw(); } public void setMargins (int leftMargin, int topMargin, int rightMargin, int bottomMargin) { checkWidget(); this.leftMargin = Math.max(0, leftMargin); this.topMargin = Math.max(0, topMargin); this.rightMargin = Math.max(0, rightMargin); this.bottomMargin = Math.max(0, bottomMargin); redraw(); } public void setRightMargin(int rightMargin) { checkWidget(); if (this.rightMargin == rightMargin || rightMargin < 0) return; this.rightMargin = rightMargin; redraw(); } public void setText(String text) { checkWidget(); if (text == null) text = ""; //$NON-NLS-1$ if (! text.equals(this.text)) { this.text = text; redraw(); } } public void setToolTipText (String string) { super.setToolTipText (string); appToolTipText = super.getToolTipText(); } public void setTopMargin(int topMargin) { checkWidget(); if (this.topMargin == topMargin || topMargin < 0) return; this.topMargin = topMargin; redraw(); } protected String shortenText(GC gc, String t, int width) { if (t == null) return null; int w = gc.textExtent(ELLIPSIS, DRAW_FLAGS).x; if (width<=w) return t; int l = t.length(); int max = l/2; int min = 0; int mid = (max+min)/2 - 1; if (mid <= 0) return t; TextLayout layout = new TextLayout (getDisplay()); layout.setText(t); mid = validateOffset(layout, mid); while (min < mid && mid < max) { String s1 = t.substring(0, mid); String s2 = t.substring(validateOffset(layout, l-mid), l); int l1 = gc.textExtent(s1, DRAW_FLAGS).x; int l2 = gc.textExtent(s2, DRAW_FLAGS).x; if (l1+w+l2 > width) { max = mid; mid = validateOffset(layout, (max+min)/2); } else if (l1+w+l2 < width) { min = mid; mid = validateOffset(layout, (max+min)/2); } else { min = max; } } String result = mid == 0 ? t : t.substring(0, mid) + ELLIPSIS + t.substring(validateOffset(layout, l-mid), l); layout.dispose(); return result; } int validateOffset(TextLayout layout, int offset) { int nextOffset = layout.getNextOffset(offset, SWT.MOVEMENT_CLUSTER); if (nextOffset != offset) return layout.getPreviousOffset(nextOffset, SWT.MOVEMENT_CLUSTER); return offset; } private String[] splitString(String text) { String[] lines = new String[1]; int start = 0, pos; do { pos = text.indexOf('\n', start); if (pos == -1) { lines[lines.length - 1] = text.substring(start); } else { boolean crlf = (pos > 0) && (text.charAt(pos - 1) == '\r'); lines[lines.length - 1] = text.substring(start, pos - (crlf ? 1 : 0)); start = pos + 1; String[] newLines = new String[lines.length+1]; System.arraycopy(lines, 0, newLines, 0, lines.length); lines = newLines; } } while (pos != -1); return lines; } }
24,663
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
BLUWizard.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/BLUWizard.java
package org.flashtool.gui; import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.IJobChangeListener; import org.eclipse.swt.program.Program; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.flashtool.flashsystem.Flasher; import org.flashtool.flashsystem.S1Command; import org.flashtool.gui.tools.BLUnlockJob; import org.flashtool.gui.tools.WidgetTask; import org.flashtool.gui.tools.WriteTAJob; import org.flashtool.parsers.ta.TAUnit; import org.flashtool.system.ULCodeFile; import lombok.extern.slf4j.Slf4j; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridData; @Slf4j public class BLUWizard extends Dialog { protected Object result; protected Shell shlBootloaderUnlockWizard; private Text textIMEI; private Text textULCODE; private Button btnGetUnlock; private Button btnUnlock; private Flasher _flash; private String _action; private String _serial; private Composite composite; private Label lblUnlockCode; private Label lblImei; private Button btnCancel; private Composite composite_1; private FormData fd_btnUnlock; private FormData fd_btnGetUnlock; /** * Create the dialog. * @param parent * @param style */ public BLUWizard(Shell parent, int style) { super(parent, style); setText("Device bootloader unlock"); } /** * Open the dialog. * @return the result */ public Object open(String serial, String imei, String ulcode,Flasher flash, String action) { _action = action; _flash = flash; _serial = serial; createContents(); if (ulcode.length()>0) { btnUnlock.setEnabled(true); if (_action.equals("R")) { btnUnlock.setText("Relock"); } btnGetUnlock.setEnabled(false); textULCODE.setEditable(false); } textIMEI.setText(imei); textULCODE.setText(ulcode); shlBootloaderUnlockWizard.open(); shlBootloaderUnlockWizard.layout(); Display display = getParent().getDisplay(); while (!shlBootloaderUnlockWizard.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlBootloaderUnlockWizard = new Shell(getParent(), getStyle()); shlBootloaderUnlockWizard.setText("Device bootloader unlock"); shlBootloaderUnlockWizard.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { result = ""; event.doit = true; } }); shlBootloaderUnlockWizard.setSize(326, 162); if (_action.equals("R")) shlBootloaderUnlockWizard.setText("BootLoader Relock Wizard"); else shlBootloaderUnlockWizard.setText("BootLoader Unlock Wizard"); shlBootloaderUnlockWizard.setLayout(new FormLayout()); btnGetUnlock = new Button(shlBootloaderUnlockWizard, SWT.NONE); fd_btnGetUnlock = new FormData(); fd_btnGetUnlock.left = new FormAttachment(0, 10); fd_btnGetUnlock.bottom = new FormAttachment(100, -10); btnGetUnlock.setLayoutData(fd_btnGetUnlock); btnGetUnlock.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Program.launch("http://unlockbootloader.sonymobile.com/"); } }); btnGetUnlock.setText("Get Unlock Code"); btnUnlock = new Button(shlBootloaderUnlockWizard, SWT.NONE); fd_btnUnlock = new FormData(); fd_btnUnlock.top = new FormAttachment(btnGetUnlock, 0, SWT.TOP); fd_btnUnlock.left = new FormAttachment(btnGetUnlock, 2); fd_btnUnlock.right = new FormAttachment(100, -128); btnUnlock.setLayoutData(fd_btnUnlock); btnUnlock.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (textULCODE.getText().length()==0) { showErrorMessageBox("Your must enter an unlock code"); return; } if (_flash==null) { BLUnlockJob bj = new BLUnlockJob("Unlock Job"); final String ulcode = textULCODE.getText(); bj.setULCode(ulcode); bj.addJobChangeListener(new IJobChangeListener() { public void aboutToRun(IJobChangeEvent event) {} public void awake(IJobChangeEvent event) {} public void running(IJobChangeEvent event) {} public void scheduled(IJobChangeEvent event) {} public void sleeping(IJobChangeEvent event) {} public void done(IJobChangeEvent event) { BLUnlockJob res = (BLUnlockJob) event.getJob(); WidgetTask.setEnabled(btnUnlock,!res.unlockSuccess()); WidgetTask.setEnabled(btnUnlock, !res.unlockSuccess()); if (res.unlockSuccess()) { try { ULCodeFile uc = new ULCodeFile(_serial); uc.setCode(ulcode); } catch (Exception e) { e.printStackTrace(); } WidgetTask.setButtonText(btnCancel, "Close"); } else { log.warn("Maybe the OEM is not enabled"); } } }); bj.schedule(); btnUnlock.setEnabled(false); } else { if (_action.equals("R")) { TAUnit ta = new TAUnit(2226, null); log.info("Relocking device"); WriteTAJob tj = new WriteTAJob("Write TA"); tj.addJobChangeListener(new IJobChangeListener() { public void aboutToRun(IJobChangeEvent event) {} public void awake(IJobChangeEvent event) {} public void running(IJobChangeEvent event) {} public void scheduled(IJobChangeEvent event) {} public void sleeping(IJobChangeEvent event) {} public void done(IJobChangeEvent event) { log.info("Relock finished"); WriteTAJob res = (WriteTAJob) event.getJob(); WidgetTask.setEnabled(btnUnlock, !res.writeSuccess()); if (res.writeSuccess()) { WidgetTask.setButtonText(btnCancel, "Close"); } } }); tj.setFlash(_flash); tj.setTA(ta); tj.schedule(); } else { TAUnit ta = new TAUnit(2226, textULCODE.getText().getBytes()); log.info("Unlocking device"); WriteTAJob tj = new WriteTAJob("Write TA"); tj.addJobChangeListener(new IJobChangeListener() { public void aboutToRun(IJobChangeEvent event) {} public void awake(IJobChangeEvent event) {} public void running(IJobChangeEvent event) {} public void scheduled(IJobChangeEvent event) {} public void sleeping(IJobChangeEvent event) {} public void done(IJobChangeEvent event) { log.info("Unlock finished"); WriteTAJob res = (WriteTAJob) event.getJob(); WidgetTask.setEnabled(btnUnlock, !res.writeSuccess()); if (res.writeSuccess()) { WidgetTask.setButtonText(btnCancel, "Close"); } } }); tj.setFlash(_flash); tj.setTA(ta); tj.schedule(); } } } }); btnUnlock.setText("Unlock"); btnCancel = new Button(shlBootloaderUnlockWizard, SWT.NONE); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100, -10); fd_btnCancel.bottom = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { shlBootloaderUnlockWizard.dispose(); } }); btnCancel.setText("Cancel"); composite = new Composite(shlBootloaderUnlockWizard, SWT.NONE); composite.setLayout(new GridLayout(2, false)); FormData fd_composite = new FormData(); fd_composite.top = new FormAttachment(0, 10); fd_composite.right = new FormAttachment(100, -10); fd_composite.left = new FormAttachment(0, 10); composite.setLayoutData(fd_composite); lblImei = new Label(composite, SWT.NONE); GridData gd_lblImei = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblImei.widthHint = 85; lblImei.setLayoutData(gd_lblImei); lblImei.setText("IMEI : "); textIMEI = new Text(composite, SWT.BORDER); textIMEI.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); textIMEI.setEditable(false); composite_1 = new Composite(shlBootloaderUnlockWizard, SWT.NONE); fd_composite.left = new FormAttachment(composite_1, 0, SWT.LEFT); composite_1.setLayout(new GridLayout(2, false)); FormData fd_composite_1 = new FormData(); fd_composite_1.top = new FormAttachment(composite, 6); fd_composite_1.left = new FormAttachment(btnGetUnlock, 0, SWT.LEFT); fd_composite_1.right = new FormAttachment(100, -10); composite_1.setLayoutData(fd_composite_1); lblUnlockCode = new Label(composite_1, SWT.NONE); GridData gd_lblUnlockCode = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblUnlockCode.widthHint = 85; lblUnlockCode.setLayoutData(gd_lblUnlockCode); lblUnlockCode.setText("Unlock Code :"); textULCODE = new Text(composite_1, SWT.BORDER); textULCODE.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); } public void showErrorMessageBox(String message) { MessageBox mb = new MessageBox(shlBootloaderUnlockWizard,SWT.ICON_ERROR|SWT.OK); mb.setText("Errorr"); mb.setMessage(message); int result = mb.open(); } }
9,633
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
BusyboxSelector.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/BusyboxSelector.java
package org.flashtool.gui; import java.io.File; import java.util.Vector; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.flashtool.system.OS; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.List; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.Viewer; public class BusyboxSelector extends Dialog { protected Object result; protected Shell shlBusyboxSelector; private Button btnCancel; private List listBusybox; /** * Create the dialog. * @param parent * @param style */ public BusyboxSelector(Shell parent, int style) { super(parent, style); setText("Busybox Selector"); } /** * Open the dialog. * @return the result */ public Object open() { createContents(); shlBusyboxSelector.open(); shlBusyboxSelector.layout(); Display display = getParent().getDisplay(); while (!shlBusyboxSelector.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlBusyboxSelector = new Shell(getParent(), getStyle()); shlBusyboxSelector.setSize(265, 434); shlBusyboxSelector.setText("Busybox Selector"); shlBusyboxSelector.setLayout(new FormLayout()); btnCancel = new Button(shlBusyboxSelector, SWT.NONE); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100, -10); fd_btnCancel.bottom = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = null; shlBusyboxSelector.dispose(); } }); btnCancel.setText("Cancel"); ListViewer listBusyboxViewer = new ListViewer(shlBusyboxSelector, SWT.BORDER | SWT.V_SCROLL); listBusybox = listBusyboxViewer.getList(); FormData fd_listBusybox = new FormData(); fd_listBusybox.bottom = new FormAttachment(btnCancel, -6); fd_listBusybox.top = new FormAttachment(0, 10); fd_listBusybox.right = new FormAttachment(100, -10); fd_listBusybox.left = new FormAttachment(0, 10); listBusybox.setLayoutData(fd_listBusybox); listBusybox.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { int selected = listBusybox.getSelectionIndex(); String string = listBusybox.getItem(selected); result = string; shlBusyboxSelector.dispose(); } }); listBusyboxViewer.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector)inputElement; return v.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }); listBusyboxViewer.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return ((File)element).getName(); } }); Vector<File> folders = new Vector(); File srcdir = new File(OS.getFolderDevices()+File.separator+"busybox"); File[] chld = srcdir.listFiles(); for(int i = 0; i < chld.length; i++) { if (chld[i].isDirectory()) folders.add(chld[i]); } listBusyboxViewer.setInput(folders); } }
4,016
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
ApkInstaller.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/ApkInstaller.java
package org.flashtool.gui; import java.io.File; import java.util.Vector; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.List; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridData; public class ApkInstaller extends Dialog { protected Shell shlApkInstaller; private Text txtSourceFolder; private Button btnInstall; ListViewer listViewerApk; Vector files = new Vector(); String result = null; /** * Create the dialog. * @param parent * @param style */ public ApkInstaller(Shell parent, int style) { super(parent, style); } /** * Open the dialog. * @return the result */ public String open() { createContents(); shlApkInstaller.open(); shlApkInstaller.layout(); Display display = getParent().getDisplay(); while (!shlApkInstaller.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlApkInstaller = new Shell(getParent(), getStyle()); shlApkInstaller.setSize(539, 312); shlApkInstaller.setText("Apk Installer"); shlApkInstaller.setLayout(new FormLayout()); listViewerApk = new ListViewer(shlApkInstaller, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI); List listApk = listViewerApk.getList(); listApk.addSelectionListener(new SelectionListener () { @Override public void widgetSelected(SelectionEvent e) { List l = (List) e.widget; l.deselectAll(); } @Override public void widgetDefaultSelected(SelectionEvent e) {} }); FormData fd_listApk = new FormData(); fd_listApk.left = new FormAttachment(0, 10); fd_listApk.right = new FormAttachment(100, -10); listApk.setLayoutData(fd_listApk); listViewerApk.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector)inputElement; return v.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }); listViewerApk.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return ((File)element).getName(); } }); Label lblAvailableFiles = new Label(shlApkInstaller, SWT.NONE); FormData fd_lblAvailableFiles = new FormData(); fd_lblAvailableFiles.left = new FormAttachment(0, 10); lblAvailableFiles.setLayoutData(fd_lblAvailableFiles); lblAvailableFiles.setText("Available files :"); Button btnCancel = new Button(shlApkInstaller, SWT.NONE); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result=""; shlApkInstaller.dispose(); } }); btnCancel.setText("Cancel"); fd_listApk.right = new FormAttachment(100, -10); fd_listApk.top = new FormAttachment(lblAvailableFiles, 6); fd_listApk.bottom = new FormAttachment(btnCancel, -6,SWT.TOP); btnInstall = new Button(shlApkInstaller, SWT.NONE); btnInstall.setEnabled(false); fd_btnCancel.bottom = new FormAttachment(100, -10); FormData fd_btnInstall = new FormData(); fd_btnInstall.bottom = new FormAttachment(100, -10); fd_btnInstall.right = new FormAttachment(btnCancel, -6); btnInstall.setLayoutData(fd_btnInstall); btnInstall.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (files.size()>0) result=txtSourceFolder.getText(); shlApkInstaller.dispose(); } }); btnInstall.setText("Install"); Composite compositeFolder = new Composite(shlApkInstaller, SWT.NONE); compositeFolder.setLayout(new GridLayout(3, false)); FormData fd_compositeFolder = new FormData(); fd_compositeFolder.right = new FormAttachment(100, -10); fd_compositeFolder.left = new FormAttachment(0, 10); fd_compositeFolder.top = new FormAttachment(0, 10); compositeFolder.setLayoutData(fd_compositeFolder); fd_lblAvailableFiles.top = new FormAttachment(compositeFolder, 10,SWT.BOTTOM); Label lblSourceFolder = new Label(compositeFolder, SWT.NONE); GridData gd_lblSourceFolder = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblSourceFolder.widthHint = 92; lblSourceFolder.setLayoutData(gd_lblSourceFolder); lblSourceFolder.setText("Source Folder : "); txtSourceFolder = new Text(compositeFolder, SWT.BORDER); GridData gd_txtSourceFolder = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_txtSourceFolder.widthHint = 359; txtSourceFolder.setLayoutData(gd_txtSourceFolder); Button btnSourceFolder = new Button(compositeFolder, SWT.NONE); GridData gd_btnSourceFolder = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1); gd_btnSourceFolder.widthHint = 85; btnSourceFolder.setLayoutData(gd_btnSourceFolder); btnSourceFolder.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DirectoryDialog dlg = new DirectoryDialog(shlApkInstaller); // Set the initial filter path according // to anything they've selected or typed in dlg.setFilterPath(txtSourceFolder.getText()); // Change the title bar text dlg.setText("Directory chooser"); // Customizable message displayed in the dialog dlg.setMessage("Select a directory"); // Calling open() will open and run the dialog. // It will return the selected directory, or // null if user cancels String dir = dlg.open(); if (dir != null) { // Set the text box to the new selection if (!txtSourceFolder.getText().equals(dir)) { txtSourceFolder.setText(dir); files = new Vector(); File srcdir = new File(txtSourceFolder.getText()); File[] chld = srcdir.listFiles(); for(int i = 0; i < chld.length; i++) { if (chld[i].getName().toUpperCase().endsWith("APK")) files.add(chld[i]); } btnInstall.setEnabled(files.size()>0); listViewerApk.setInput(files); } } } }); btnSourceFolder.setText("..."); btnSourceFolder.setFont(new Font(Display.getCurrent(),"Arial",11,SWT.NONE)); } }
7,475
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
WaitDeviceForFastboot.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/WaitDeviceForFastboot.java
package org.flashtool.gui; import org.eclipse.core.runtime.Status; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.flashtool.gui.tools.SearchFastbootJob; import org.flashtool.gui.tools.WidgetTask; import lombok.extern.slf4j.Slf4j; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.GridData; @Slf4j public class WaitDeviceForFastboot extends Dialog { protected Object result; protected Shell shlWaitForFastbootmode; protected SearchFastbootJob job; /** * Create the dialog. * @param parent * @param style */ public WaitDeviceForFastboot(Shell parent, int style) { super(parent, style); setText("Wait for Fastboot mode"); } /** * Open the dialog. * @return the result */ public Object open() { createContents(); shlWaitForFastbootmode.open(); shlWaitForFastbootmode.layout(); shlWaitForFastbootmode.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { job.stopSearch(); result = new String("Canceled"); } }); Display display = getParent().getDisplay(); job = new SearchFastbootJob("Search Fastboot Job"); job.schedule(); while (!shlWaitForFastbootmode.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } if (job.getState() == Status.OK) { result = new String("OK"); shlWaitForFastbootmode.dispose(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlWaitForFastbootmode = new Shell(getParent(), getStyle()); shlWaitForFastbootmode.setSize(500, 600); shlWaitForFastbootmode.setText("Wait for Fastboot Mode"); shlWaitForFastbootmode.setLayout(new FormLayout()); Composite composite2012 = new Composite(shlWaitForFastbootmode, SWT.NONE); FormData fd_composite2012 = new FormData(); fd_composite2012.left = new FormAttachment(0, 10); fd_composite2012.top = new FormAttachment(0, 77); fd_composite2012.bottom = new FormAttachment(0, 202); composite2012.setLayoutData(fd_composite2012); composite2012.setLayout(new GridLayout(1, false)); // 2012 Line Of Xperias Text Label lblNewLabel00 = new Label(composite2012, SWT.NONE); lblNewLabel00.setText("2012"); Label lblNewLabel01 = new Label(composite2012, SWT.NONE); lblNewLabel01.setText("1. Unplug the device"); Label lblNewLabel02 = new Label(composite2012, SWT.NONE); lblNewLabel02.setText("2. Power off the device"); Label lblNewLabel03 = new Label(composite2012, SWT.NONE); lblNewLabel03.setText("3. Press the volume UP button"); Label lblNewLabel05 = new Label(composite2012, SWT.NONE); lblNewLabel05.setText("4. Plug the USB cable"); Label lblNewLabel_4 = new Label(composite2012, SWT.NONE); lblNewLabel_4.setText("-Volume UP for Xperia Ray"); Composite composite2012GIF = new Composite(shlWaitForFastbootmode, SWT.NONE); fd_composite2012.right = new FormAttachment(composite2012GIF, -6); FormData fd_composite2012GIF = new FormData(); fd_composite2012GIF.left = new FormAttachment(0, 206); fd_composite2012GIF.right = new FormAttachment(100, -10); fd_composite2012GIF.top = new FormAttachment(0, 10); composite2012GIF.setLayoutData(fd_composite2012GIF); composite2012GIF.setLayout(new FormLayout()); final GifCLabel lbl = new GifCLabel(composite2012GIF, SWT.CENTER); FormData fd_lbl = new FormData(); fd_lbl.top = new FormAttachment(0); fd_lbl.left = new FormAttachment(0); fd_lbl.right = new FormAttachment(100); fd_lbl.bottom = new FormAttachment(0, 240); lbl.setLayoutData(fd_lbl); lbl.setText(""); lbl.setGifImage(this.getClass().getResourceAsStream("/gui/ressources/fastbootmode2012.gif")); lbl.setLayout(new FormLayout()); Composite composite2011GIF = new Composite(shlWaitForFastbootmode, SWT.NONE); fd_composite2012GIF.bottom = new FormAttachment(100, -321); FormData fd_composite2011GIF = new FormData(); fd_composite2011GIF.right = new FormAttachment(100, -10); fd_composite2011GIF.top = new FormAttachment(composite2012GIF, 6); composite2011GIF.setLayoutData(fd_composite2011GIF); composite2011GIF.setLayout(new FormLayout()); final GifCLabel lbl2 = new GifCLabel(composite2011GIF, SWT.CENTER); FormData fd_lbl2 = new FormData(); fd_lbl2.top = new FormAttachment(0); fd_lbl2.left = new FormAttachment(0); fd_lbl2.right = new FormAttachment(100); fd_lbl2.bottom = new FormAttachment(0, 271); lbl2.setLayoutData(fd_lbl2); lbl2.setText(""); lbl2.setGifImage(this.getClass().getResourceAsStream("/gui/ressources/fastbootmode2011.gif")); lbl2.setLayout(new FormLayout()); Button btnCancel = new Button(shlWaitForFastbootmode, SWT.NONE); fd_composite2011GIF.bottom = new FormAttachment(btnCancel, -9); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100,-10); fd_btnCancel.bottom = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { job.stopSearch(); result = new String("Canceled"); shlWaitForFastbootmode.dispose(); } }); btnCancel.setText("Cancel"); Composite composite2011 = new Composite(shlWaitForFastbootmode, SWT.NONE); fd_composite2011GIF.left = new FormAttachment(0, 206); FormData fd_composite2011 = new FormData(); fd_composite2011.bottom = new FormAttachment(100, -141); fd_composite2011.top = new FormAttachment(composite2012, 123); fd_composite2011.right = new FormAttachment(composite2011GIF, -6); fd_composite2011.left = new FormAttachment(0, 10); composite2011.setLayoutData(fd_composite2011); composite2011.setLayout(new GridLayout(1, false)); // Xperia 2011 Lines of Xperia Text Label lblNewLabel = new Label(composite2011, SWT.NONE); GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblNewLabel.widthHint = 186; lblNewLabel.setLayoutData(gd_lblNewLabel); lblNewLabel.setText("2011"); Label lblNewLabel_1 = new Label(composite2011, SWT.NONE); lblNewLabel_1.setText("1. Unplug the device"); Label lblNewLabel_2 = new Label(composite2011, SWT.NONE); lblNewLabel_2.setText("2. Power off the device"); Label lblNewLabel_3 = new Label(composite2011, SWT.NONE); lblNewLabel_3.setText("3. Press the menu button-"); Label lblNewLabel_5 = new Label(composite2011, SWT.NONE); lblNewLabel_5.setText("4. Plug the USB cable"); } }
7,014
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
WaitForDevicesSync.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/WaitForDevicesSync.java
package org.flashtool.gui; import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.IJobChangeListener; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.flashtool.gui.tools.DevicesSyncJob; import org.flashtool.gui.tools.WidgetTask; import lombok.extern.slf4j.Slf4j; @Slf4j public class WaitForDevicesSync extends Dialog { protected Object result; protected Shell shlWaiForDevicesSync; protected boolean canClose = false; protected Dialog mydial; /** * Create the dialog. * @param parent * @param style */ public WaitForDevicesSync(Shell parent, int style) { super(parent, style); setText("Syncing devices from Github"); mydial = this; } /** * Open the dialog. * @return the result */ public Object open() { createContents(); Label lblNewLabel = new Label(shlWaiForDevicesSync, SWT.NONE); lblNewLabel.setBounds(10, 32, 323, 20); lblNewLabel.setText("Please wait until the end of process"); shlWaiForDevicesSync.open(); shlWaiForDevicesSync.layout(); Display display = getParent().getDisplay(); while (!shlWaiForDevicesSync.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlWaiForDevicesSync = new Shell(getParent(), getStyle()); shlWaiForDevicesSync.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { if (canClose) { result = ""; event.doit = true; } else { WidgetTask.openOKBox(shlWaiForDevicesSync, "Wait for end of process"); event.doit = false; } } }); shlWaiForDevicesSync.setSize(365, 128); shlWaiForDevicesSync.setText("Syncing devices from Github"); DevicesSyncJob sync = new DevicesSyncJob("GitSync"); sync.addJobChangeListener(new IJobChangeListener() { public void aboutToRun(IJobChangeEvent event) { } public void awake(IJobChangeEvent event) { } public void done(IJobChangeEvent event) { canClose=true; Display.getDefault().asyncExec( new Runnable() { public void run() { shlWaiForDevicesSync.dispose(); } } ); } public void running(IJobChangeEvent event) { } public void scheduled(IJobChangeEvent event) { } public void sleeping(IJobChangeEvent event) { } }); sync.schedule(); } }
2,847
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
ProfileSave.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/ProfileSave.java
package org.flashtool.gui; import java.io.File; import java.util.Vector; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.widgets.Text; import org.flashtool.gui.tools.DeviceApps; import org.flashtool.gui.tools.WidgetTask; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.List; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; public class ProfileSave extends Dialog { protected Shell shlProfileSave; private Text txtProfileName; private Button btnsave; String result = null; DeviceApps _apps = null; public ProfileSave(Shell parent, int style) { super(parent, style); } /** * Open the dialog. * @return the result */ public String open(DeviceApps apps) { _apps=apps; createContents(); shlProfileSave.open(); shlProfileSave.layout(); Display display = getParent().getDisplay(); while (!shlProfileSave.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlProfileSave = new Shell(getParent(), getStyle()); shlProfileSave.setSize(421, 123); shlProfileSave.setText("Profile Name"); shlProfileSave.setLayout(new FormLayout()); Button btnCancel = new Button(shlProfileSave, SWT.NONE); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100, -10); fd_btnCancel.bottom = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result=""; shlProfileSave.dispose(); } }); btnCancel.setText("Cancel"); btnsave = new Button(shlProfileSave, SWT.NONE); btnsave.setEnabled(false); FormData fd_btnsave = new FormData(); fd_btnsave.bottom = new FormAttachment(100,-10); fd_btnsave.right = new FormAttachment(btnCancel, -6); btnsave.setLayoutData(fd_btnsave); btnsave.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { if (_apps.getProfiles().contains(txtProfileName.getText().toLowerCase())) throw new Exception("This profile already exists."); if (txtProfileName.getText().toLowerCase().contains(" ")) throw new Exception("Name cannot contain spaces."); _apps.saveProfile(txtProfileName.getText().toLowerCase()); _apps.setProfile(txtProfileName.getText().toLowerCase()); shlProfileSave.dispose(); } catch (Exception ex) { WidgetTask.openOKBox(shlProfileSave, ex.getMessage()); } } }); btnsave.setText("Save"); Composite composite = new Composite(shlProfileSave, SWT.NONE); composite.setLayout(new GridLayout(2, false)); FormData fd_composite = new FormData(); fd_composite.left = new FormAttachment(0, 10); fd_composite.top = new FormAttachment(0, 10); fd_composite.right = new FormAttachment(100, -10); composite.setLayoutData(fd_composite); Label lblName = new Label(composite, SWT.NONE); GridData gd_lblName = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblName.widthHint = 92; lblName.setLayoutData(gd_lblName); lblName.setText("Profile name :"); txtProfileName = new Text(composite, SWT.BORDER); txtProfileName.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (txtProfileName.getText().length()>0) { btnsave.setEnabled(true); } else btnsave.setEnabled(false); } }); GridData gd_txtProfileName = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); gd_txtProfileName.widthHint = 270; txtProfileName.setLayoutData(gd_txtProfileName); } }
4,581
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
TARestore.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/TARestore.java
package org.flashtool.gui; import java.io.File; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.Vector; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.flashtool.flashsystem.S1Command; import org.flashtool.gui.models.TABag; import org.flashtool.gui.models.TADevice; import org.flashtool.parsers.ta.TAUnit; import org.flashtool.system.DeviceEntry; import org.flashtool.system.Devices; import org.flashtool.system.OS; import org.flashtool.system.TextFile; import org.flashtool.util.HexDump; import lombok.extern.slf4j.Slf4j; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.custom.CTabFolder; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridData; @Slf4j public class TARestore extends Dialog { protected Shell shlTARestore; ListViewer listViewerTAUnits; private List listTAUnits; private Button btnLtoR; private Label lblTAlist; private Label lblTAFlash; private Button btnCancel; private Button btnFlash; private ListViewer listViewerTAUnitsToFlash; private Combo comboBackupset; private Combo comboPartition; private HashMap<String,Vector<TABag>> backupset = new HashMap<String, Vector<TABag>>(); private Vector<TAUnit> available; private Vector<TAUnit> toflash; private TADevice result; CTabItemWithHexViewer hexviewer; String device = ""; String serial = ""; DeviceEntry id = null; /** * Create the dialog. * @param parent * @param style */ public TARestore(Shell parent, int style) { super(parent, style); setText("SWT Dialog"); } /** * Open the dialog. * @return the result */ public Object open(HashMap<String,Vector<TABag>> backupset) { this.backupset = backupset; result = new TADevice(); createContents(); shlTARestore.open(); shlTARestore.layout(); Display display = getParent().getDisplay(); while (!shlTARestore.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlTARestore = new Shell(getParent(), getStyle()); shlTARestore.setSize(661, 500); shlTARestore.setText("TA Restore"); shlTARestore.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { result = null; event.doit = true; } }); shlTARestore.setLayout(new FormLayout()); Composite composite = new Composite(shlTARestore, SWT.NONE); composite.setLayout(new GridLayout(4, false)); FormData fd_composite = new FormData(); fd_composite.top = new FormAttachment(0, 10); fd_composite.left = new FormAttachment(0,115); fd_composite.right = new FormAttachment(100,-115); composite.setLayoutData(fd_composite); lblTAlist = new Label(shlTARestore, SWT.NONE); FormData fd_lblTAlist = new FormData(); lblTAlist.setLayoutData(fd_lblTAlist); lblTAlist.setText("TA Unit list :"); lblTAFlash = new Label(shlTARestore, SWT.NONE); FormData fd_lblTAFlash = new FormData(); ; lblTAFlash.setLayoutData(fd_lblTAFlash); lblTAFlash.setText("TA Unit to flash :"); listViewerTAUnits = new ListViewer(shlTARestore, SWT.BORDER | SWT.V_SCROLL); listViewerTAUnits.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent arg0) { IStructuredSelection selection = (IStructuredSelection)listViewerTAUnits.getSelection(); if (selection.size()==1) { listViewerTAUnitsToFlash.setSelection(StructuredSelection.EMPTY); TAUnit u = (TAUnit)selection.getFirstElement(); hexviewer.loadContent(u.getUnitData()); } } }); listTAUnits = listViewerTAUnits.getList(); Menu menu1 = new Menu(listTAUnits); MenuItem item = new MenuItem(menu1, SWT.PUSH); item.setText("Save Unit to file"); item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection)listViewerTAUnits.getSelection(); Iterator i = selection.iterator(); while (i.hasNext()) { TAUnit u = (TAUnit)i.next(); try { String folder = OS.getFolderRegisteredDevices()+File.separator+serial+File.separator+"s1ta"; new File(folder).mkdir(); TextFile t = new TextFile(folder+File.separator+u.getUnitHex()+".ta","ISO8859-15"); t.open(false); t.writeln(HexDump.toHex((byte)Integer.parseInt(comboPartition.getText()))); t.writeln(u.toString()); t.close(); log.info("Unit saved to "+folder+File.separator+u.getUnitHex()+".ta"); } catch (Exception ex) {} } } }); listTAUnits.setMenu(menu1); fd_lblTAlist.left = new FormAttachment(listTAUnits, 0, SWT.LEFT); FormData fd_listTAUnits = new FormData(); fd_listTAUnits.top = new FormAttachment(lblTAlist, 6); fd_listTAUnits.left = new FormAttachment(composite, 0, SWT.LEFT); fd_listTAUnits.width = 100; listTAUnits.setLayoutData(fd_listTAUnits); listViewerTAUnits.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector)inputElement; return v.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }); listViewerTAUnits.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return ((TAUnit)element).getUnitHex(); } }); listViewerTAUnits.setSorter(new ViewerSorter(){ public int compare(Viewer viewer, Object e1, Object e2) { return ((TAUnit)e1).getUnitHex().compareTo(((TAUnit)e2).getUnitHex()); } }); listViewerTAUnitsToFlash = new ListViewer(shlTARestore, SWT.BORDER | SWT.V_SCROLL); List listTAUnitsToFlash = listViewerTAUnitsToFlash.getList(); fd_lblTAFlash.left = new FormAttachment(listTAUnitsToFlash, 0, SWT.LEFT); FormData fd_listTAUnitsToFlash = new FormData(); fd_listTAUnitsToFlash.top = new FormAttachment(lblTAFlash, 6); fd_listTAUnitsToFlash.right = new FormAttachment(composite, 0, SWT.RIGHT); fd_listTAUnitsToFlash.width = 100; listTAUnitsToFlash.setLayoutData(fd_listTAUnitsToFlash); listViewerTAUnitsToFlash.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector)inputElement; return v.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }); listViewerTAUnitsToFlash.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return ((TAUnit)element).getUnitHex(); } }); listViewerTAUnitsToFlash.setSorter(new ViewerSorter(){ public int compare(Viewer viewer, Object e1, Object e2) { return ((TAUnit)e1).getUnitHex().compareTo(((TAUnit)e2).getUnitHex()); } }); listViewerTAUnitsToFlash.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent arg0) { IStructuredSelection selection = (IStructuredSelection)listViewerTAUnitsToFlash.getSelection(); if (selection.size()==1) { listViewerTAUnits.setSelection(StructuredSelection.EMPTY); TAUnit u = (TAUnit)selection.getFirstElement(); hexviewer.loadContent(u.getUnitData()); } } }); btnLtoR = new Button(shlTARestore, SWT.NONE); FormData fd_btnLtoR = new FormData(); fd_btnLtoR.top = new FormAttachment(composite, 57); fd_btnLtoR.left = new FormAttachment(listTAUnits, 69); btnLtoR.setLayoutData(fd_btnLtoR); btnLtoR.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection)listViewerTAUnits.getSelection(); Iterator i = selection.iterator(); hexviewer.loadContent(new byte[]{}); while (i.hasNext()) { TAUnit u = (TAUnit)i.next(); available.remove(u); toflash.add(u); } listViewerTAUnits.refresh(); listViewerTAUnitsToFlash.refresh(); } }); btnLtoR.setText("->"); Button btnRtoL = new Button(shlTARestore, SWT.NONE); FormData fd_btnRtoL = new FormData(); fd_btnRtoL.top = new FormAttachment(btnLtoR, 6); fd_btnRtoL.right = new FormAttachment(btnLtoR, 0, SWT.RIGHT); btnRtoL.setLayoutData(fd_btnRtoL); btnRtoL.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection)listViewerTAUnitsToFlash.getSelection(); Iterator i = selection.iterator(); hexviewer.loadContent(new byte[]{}); while (i.hasNext()) { TAUnit u = (TAUnit)i.next(); available.add(u); toflash.remove(u); } listViewerTAUnits.refresh(); listViewerTAUnitsToFlash.refresh(); } }); btnRtoL.setText("<-"); btnFlash = new Button(shlTARestore, SWT.NONE); btnFlash.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { shlTARestore.dispose(); } }); btnFlash.setText("Flash"); btnCancel = new Button(shlTARestore, SWT.NONE); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100, -10); fd_btnCancel.bottom = new FormAttachment(100,-10); FormData fd_btnFlash = new FormData(); fd_btnFlash.bottom = new FormAttachment(100,-10); fd_btnFlash.right = new FormAttachment(btnCancel, -6); btnFlash.setLayoutData(fd_btnFlash); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = null; shlTARestore.dispose(); } }); btnCancel.setText("Cancel"); CTabFolder tabFolder = new CTabFolder(shlTARestore, SWT.NONE); fd_listTAUnits.bottom = new FormAttachment(tabFolder, -6); fd_listTAUnitsToFlash.bottom = new FormAttachment(tabFolder, -6); FormData fd_tabFolder = new FormData(); fd_tabFolder.left = new FormAttachment(0, 10); fd_tabFolder.right = new FormAttachment(100, -10); fd_tabFolder.bottom = new FormAttachment(btnCancel, -8); fd_tabFolder.top = new FormAttachment(0, 200); tabFolder.setLayoutData(fd_tabFolder); hexviewer = new CTabItemWithHexViewer(tabFolder,"TA unit content",SWT.BORDER); Label lblBackupset = new Label(composite, SWT.NONE); lblBackupset.setAlignment(SWT.RIGHT); GridData gd_lblBackupset = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblBackupset.widthHint = 74; lblBackupset.setLayoutData(gd_lblBackupset); lblBackupset.setText("Backupset :"); fd_lblTAlist.top = new FormAttachment(composite,6); fd_lblTAFlash.top = new FormAttachment(composite, 6); comboBackupset = new Combo(composite, SWT.READ_ONLY); GridData gd_comboBackupset = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_comboBackupset.widthHint = 174; comboBackupset.setLayoutData(gd_comboBackupset); Label lblPartition = new Label(composite, SWT.NONE); lblPartition.setAlignment(SWT.RIGHT); lblPartition.setText("Partition :"); GridData gd_lblPartition = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); gd_lblPartition.widthHint = 76; lblPartition.setLayoutData(gd_lblPartition); comboPartition = new Combo(composite, SWT.READ_ONLY); comboPartition.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { refreshUnits(); } }); comboBackupset.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { refreshPartitions(); } }); comboBackupset.select(0); if (backupset.size()>0) { Iterator keys = backupset.keySet().iterator(); while (keys.hasNext()) { comboBackupset.add((String)keys.next()); } comboBackupset.select(0); refreshPartitions(); device = result.getModel(); serial = result.getSerial(); if (device.length()>0) { id = Devices.getDeviceFromVariant(device); if (id!=null) shlTARestore.setText("TA Restore - "+id.getName()+" ("+device+")"); } } } public void refreshPartitions() { result.addBags(backupset.get(comboBackupset.getText())); comboPartition.removeAll(); String [] comboarray = new String[result.getBags().size()]; for (int i = 0; i<result.getBags().size(); i++) { comboarray[i]=String.valueOf(result.getBags().get(i).partition); } Arrays.sort(comboarray); comboPartition.setItems(comboarray); comboPartition.select(0); refreshUnits(); } public void refreshUnits() { try { TABag b = getPartition(Integer.parseInt(comboPartition.getText())); available = b.available; toflash = b.toflash; listViewerTAUnits.setInput(available); listViewerTAUnits.refresh(); listViewerTAUnitsToFlash.setInput(toflash); listViewerTAUnitsToFlash.refresh(); hexviewer.loadContent(new byte[]{}); } catch (Exception e) { e.printStackTrace(); } } public TABag getPartition(int partition) { for (int i=0;i<result.getBags().size();i++) { if (result.getBags().get(i).partition==partition) return result.getBags().get(i); } return null; } public void showErrorMessageBox(String message) { MessageBox mb = new MessageBox(shlTARestore,SWT.ICON_ERROR|SWT.OK); mb.setText("Errorr"); mb.setMessage(message); int result = mb.open(); } }
14,956
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
TABackupSelector.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/TABackupSelector.java
package org.flashtool.gui; import java.io.File; import java.util.Vector; import java.util.jar.Attributes; import java.util.jar.JarFile; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.flashtool.flashsystem.S1Command; import org.flashtool.system.Devices; import org.flashtool.system.OS; import lombok.extern.slf4j.Slf4j; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.List; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.Viewer; @Slf4j public class TABackupSelector extends Dialog { protected Object result; protected Shell shlTABackupSelector; private Button btnCancel; private List listTA; /** * Create the dialog. * @param parent * @param style */ public TABackupSelector(Shell parent, int style) { super(parent, style); } /** * Open the dialog. * @return the result */ public Object open() { createContents(); shlTABackupSelector.open(); shlTABackupSelector.layout(); Display display = getParent().getDisplay(); while (!shlTABackupSelector.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlTABackupSelector = new Shell(getParent(), getStyle()); shlTABackupSelector.setSize(354, 434); shlTABackupSelector.setText("TA Backup Selector"); shlTABackupSelector.setLayout(new FormLayout()); btnCancel = new Button(shlTABackupSelector, SWT.NONE); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100, -10); fd_btnCancel.bottom = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = ""; shlTABackupSelector.dispose(); } }); btnCancel.setText("Cancel"); ListViewer listTAViewer = new ListViewer(shlTABackupSelector, SWT.BORDER | SWT.V_SCROLL); listTA = listTAViewer.getList(); FormData fd_listTA = new FormData(); fd_listTA.bottom = new FormAttachment(btnCancel, -6, SWT.TOP); fd_listTA.top = new FormAttachment(0, 10); fd_listTA.right = new FormAttachment(100, -10); fd_listTA.left = new FormAttachment(0, 10); listTA.setLayoutData(fd_listTA); listTA.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { int selected = listTA.getSelectionIndex(); String string = listTA.getItem(selected); result = string; shlTABackupSelector.dispose(); } }); listTAViewer.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector)inputElement; return v.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }); listTAViewer.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return ((String)element); } }); Vector<String> tabackups = new Vector(); String serial = Devices.getCurrent().getSerial(); String folder = OS.getFolderRegisteredDevices()+File.separator+serial+File.separator+"rawta"; File srcdir = new File(folder); File[] chld = srcdir.listFiles(); for(int i = 0; i < chld.length; i++) { if (chld[i].getName().endsWith(".fta")) { try { JarFile jf = new JarFile(chld[i]); Attributes attr = jf.getManifest().getMainAttributes(); if (attr.getValue("serial").equals(Devices.getCurrent().getSerial())) { tabackups.add(attr.getValue("timestamp")+ " : " + attr.getValue("build")); } else { log.info("File skipped : "+chld[i].getName()+". Not for your device"); } jf.close(); } catch (Exception e) { log.error("This file : " + chld[i].getName()+" is corrupted"); } } } listTAViewer.setInput(tabackups); } }
4,707
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
WaitForXperiFirm.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/WaitForXperiFirm.java
package org.flashtool.gui; import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.IJobChangeListener; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.flashtool.gui.tools.WidgetTask; import org.flashtool.gui.tools.XperiFirmJob; import lombok.extern.slf4j.Slf4j; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Label; @Slf4j public class WaitForXperiFirm extends Dialog { protected Object result; protected Shell shlWaiForXperiFirm; protected boolean canClose = false; protected Dialog mydial; /** * Create the dialog. * @param parent * @param style */ public WaitForXperiFirm(Shell parent, int style) { super(parent, style); setText("XperiFirm running"); mydial = this; } /** * Open the dialog. * @return the result */ public Object open() { createContents(); Label lblNewLabel = new Label(shlWaiForXperiFirm, SWT.NONE); lblNewLabel.setBounds(10, 32, 323, 18); lblNewLabel.setText("Please wait until the end of process"); shlWaiForXperiFirm.open(); shlWaiForXperiFirm.layout(); Display display = getParent().getDisplay(); while (!shlWaiForXperiFirm.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlWaiForXperiFirm = new Shell(getParent(), getStyle()); shlWaiForXperiFirm.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { if (canClose) { result = ""; event.doit = true; } else { WidgetTask.openOKBox(shlWaiForXperiFirm, "Wait for end of process"); event.doit = false; } } }); shlWaiForXperiFirm.setSize(365, 130); shlWaiForXperiFirm.setText("Running XperiFirm"); XperiFirmJob xj = new XperiFirmJob("XperiFirm"); xj.setShell(shlWaiForXperiFirm); xj.addJobChangeListener(new IJobChangeListener() { public void aboutToRun(IJobChangeEvent event) { } public void awake(IJobChangeEvent event) { } public void done(IJobChangeEvent event) { canClose=true; Display.getDefault().asyncExec( new Runnable() { public void run() { shlWaiForXperiFirm.dispose(); } } ); } public void running(IJobChangeEvent event) { } public void scheduled(IJobChangeEvent event) { } public void sleeping(IJobChangeEvent event) { } }); xj.schedule(); } }
2,657
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
BootModeSelector.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/BootModeSelector.java
package org.flashtool.gui; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.GridData; public class BootModeSelector extends Dialog { protected Object result; protected Shell shell; Button btnFlashmode; private Button btnFastboot; private Button btnCancel; /** * Create the dialog. * @param parent * @param style */ public BootModeSelector(Shell parent, int style) { super(parent, style); setText("Bootmode chooser"); } /** * Open the dialog. * @return the result */ public Object open() { createContents(); Composite compositeSelector = new Composite(shell, SWT.NONE); FormData fd_compositeSelector = new FormData(); fd_compositeSelector.top = new FormAttachment(0, 10); fd_compositeSelector.left = new FormAttachment(0, 10); compositeSelector.setLayoutData(fd_compositeSelector); compositeSelector.setLayout(new GridLayout(1, false)); btnFlashmode = new Button(compositeSelector, SWT.RADIO); btnFlashmode.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); btnFlashmode.setText("Flashmode"); btnFlashmode.setSelection(true); btnFastboot = new Button(compositeSelector, SWT.RADIO); btnFastboot.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); btnFastboot.setText("Fastboot mode"); Button btnOK = new Button(shell, SWT.NONE); FormData fd_btnOK = new FormData(); btnOK.setLayoutData(fd_btnOK); btnOK.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (btnFlashmode.getSelection()) result="flashmode"; else result="fastboot"; shell.dispose(); } }); btnOK.setText("Ok"); btnCancel = new Button(shell, SWT.NONE); fd_btnOK.bottom = new FormAttachment(btnCancel, 0, SWT.BOTTOM); fd_btnOK.right = new FormAttachment(btnCancel, -6); FormData fd_btnCancel = new FormData(); fd_btnCancel.bottom = new FormAttachment(100, -10); fd_btnCancel.right = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = ""; shell.dispose(); } }); btnCancel.setText("Cancel"); shell.open(); shell.layout(); Display display = getParent().getDisplay(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shell = new Shell(getParent(), getStyle()); shell.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { result = ""; event.doit = true; } }); shell.setSize(272, 138); shell.setText(getText()); shell.setLayout(new FormLayout()); } }
3,362
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
SinAdvanced.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/SinAdvanced.java
package org.flashtool.gui; import java.io.IOException; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Text; import org.flashtool.flashsystem.S1Command; import org.flashtool.gui.tools.CreateSinAsJob; import org.flashtool.parsers.sin.SinFile; import org.flashtool.util.HexDump; import lombok.extern.slf4j.Slf4j; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridData; @Slf4j public class SinAdvanced extends Dialog { protected Object result; protected Shell shlSinEditor; private Text textVersion; private Text textPartition; private Text textSpare; private Text textContent; private SinFile _sin; /** * Create the dialog. * @param parent * @param style */ public SinAdvanced(Shell parent, int style) { super(parent, style); setText("SWT Dialog"); } /** * Open the dialog. * @return the result */ public Object open(SinFile sin) { _sin = sin; createContents(); try { Button btnClose = new Button(shlSinEditor, SWT.NONE); btnClose.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { shlSinEditor.dispose(); } }); FormData fd_btnClose = new FormData(); fd_btnClose.bottom = new FormAttachment(100, -10); fd_btnClose.right = new FormAttachment(100, -10); btnClose.setLayoutData(fd_btnClose); btnClose.setText("Close"); Button btnCreateSinAs = new Button(shlSinEditor, SWT.NONE); btnCreateSinAs.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog dlg = new FileDialog(shlSinEditor); // Set the initial filter path according // to anything they've selected or typed in dlg.setFilterExtensions(new String[]{"*.yaffs2"}); // Change the title bar text dlg.setText("YAFFS2 File Chooser"); // Calling open() will open and run the dialog. // It will return the selected directory, or // null if user cancels String file = dlg.open(); CreateSinAsJob cj = new CreateSinAsJob("Create SIN"); cj.setFile(file); cj.setPartition(textPartition.getText()); cj.setSpare(HexDump.toHex(_sin.getPartitionType())); cj.schedule(); if (file!=null) shlSinEditor.dispose(); } }); FormData fd_btnCreateSinAs = new FormData(); fd_btnCreateSinAs.bottom = new FormAttachment(100, -10); fd_btnCreateSinAs.right = new FormAttachment(btnClose, -6); btnCreateSinAs.setLayoutData(fd_btnCreateSinAs); btnCreateSinAs.setText("Create Sin As"); btnCreateSinAs.setEnabled(_sin.getVersion()==1); Composite composite = new Composite(shlSinEditor, SWT.NONE); composite.setLayout(new GridLayout(1, false)); FormData fd_composite = new FormData(); fd_composite.right = new FormAttachment(100, -10); fd_composite.left = new FormAttachment(0, 10); fd_composite.top = new FormAttachment(0, 10); composite.setLayoutData(fd_composite); Label lblSinVersion = new Label(composite, SWT.NONE); lblSinVersion.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); lblSinVersion.setText("Sin version :"); textVersion = new Text(composite, SWT.BORDER); textVersion.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); textVersion.setEditable(false); textVersion.setText(Integer.toString(_sin.getVersion())); Label lblPartition = new Label(composite, SWT.NONE); lblPartition.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); lblPartition.setText("Partition Info :"); textPartition = new Text(composite, SWT.BORDER); GridData gd_textPartition = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_textPartition.widthHint = 121; textPartition.setLayoutData(gd_textPartition); textPartition.setEditable(false); textPartition.setText(_sin.hasPartitionInfo()?HexDump.toHex(_sin.getPartitionInfo()):""); Label lblSpare = new Label(composite, SWT.NONE); lblSpare.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); lblSpare.setText("Partition Type :"); textSpare = new Text(composite, SWT.BORDER); textSpare.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); textSpare.setEditable(false); textSpare.setText(_sin.getPartypeString()); Label lblContentType = new Label(composite, SWT.NONE); lblContentType.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); lblContentType.setText("Content Type :"); textContent = new Text(composite, SWT.BORDER); textContent.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); textContent.setEditable(false); textContent.setText(_sin.getDataType()); } catch (Exception e) {} shlSinEditor.open(); shlSinEditor.layout(); Display display = getParent().getDisplay(); while (!shlSinEditor.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlSinEditor = new Shell(getParent(), getStyle()); shlSinEditor.setSize(299, 314); shlSinEditor.setText("Advanced Sin Editor"); shlSinEditor.setLayout(new FormLayout()); } }
5,779
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
USBLogviewer.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/USBLogviewer.java
package org.flashtool.gui; import java.io.File; import java.util.Enumeration; import java.util.Iterator; import java.util.Properties; import java.util.Vector; import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.IJobChangeListener; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Text; import org.flashtool.gui.models.TableLine; import org.flashtool.gui.models.TableSorter; import org.flashtool.gui.models.VectorContentProvider; import org.flashtool.gui.models.VectorLabelProvider; import org.flashtool.gui.tools.USBParseJob; import org.flashtool.parsers.simpleusblogger.Session; //import org.eclipse.ui.forms.widgets.FormToolkit; import org.flashtool.system.DeviceEntry; import org.flashtool.system.Devices; import org.flashtool.system.TextFile; import lombok.extern.slf4j.Slf4j; @Slf4j public class USBLogviewer extends Dialog { protected Object result; protected Shell shlUSBLogviewer; private Table table; private TableViewer tableViewer; private Text textSinFolder; private Button btnClose; private Composite compositeTable; //private final FormToolkit formToolkit = new FormToolkit(Display.getDefault()); private Label lblLogfile; private Text textLogFile; private Button btnParse; private Button btnLogFile; private Button btnSourceFolder; private Label lblSavedPath; /** * Create the dialog. * @param parent * @param style */ public USBLogviewer(Shell parent, int style) { super(parent, style); setText("Device Selector"); } /** * Open the dialog. * @return the result */ public Object open() { createContents(); createTriggers(); lblSavedPath = new Label(shlUSBLogviewer, SWT.NONE); FormData fd_lblSavedPath = new FormData(); fd_lblSavedPath.right = new FormAttachment(btnParse, -6); fd_lblSavedPath.bottom = new FormAttachment(100, -15); fd_lblSavedPath.left = new FormAttachment(0, 10); lblSavedPath.setLayoutData(fd_lblSavedPath); shlUSBLogviewer.open(); shlUSBLogviewer.layout(); Display display = getParent().getDisplay(); while (!shlUSBLogviewer.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlUSBLogviewer = new Shell(getParent(), getStyle()); shlUSBLogviewer.setSize(710, 475); shlUSBLogviewer.setText("USB Log Viewer"); shlUSBLogviewer.setLayout(new FormLayout()); btnClose = new Button(shlUSBLogviewer, SWT.NONE); FormData fd_btnClose = new FormData(); fd_btnClose.bottom = new FormAttachment(100, -10); fd_btnClose.right = new FormAttachment(100, -10); btnClose.setLayoutData(fd_btnClose); btnClose.setText("Close"); compositeTable = new Composite(shlUSBLogviewer, SWT.NONE); compositeTable.setLayout(new FillLayout(SWT.HORIZONTAL)); FormData fd_compositeTable = new FormData(); fd_compositeTable.right = new FormAttachment(100, -10); fd_compositeTable.left = new FormAttachment(0, 10); fd_compositeTable.bottom = new FormAttachment(btnClose, -6); compositeTable.setLayoutData(fd_compositeTable); tableViewer = new TableViewer(compositeTable,SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.SINGLE); tableViewer.setContentProvider(new VectorContentProvider()); tableViewer.setLabelProvider(new VectorLabelProvider()); table = tableViewer.getTable(); TableColumn[] columns = new TableColumn[2]; columns[0] = new TableColumn(table, SWT.NONE); columns[0].setText("Action"); columns[1] = new TableColumn(table, SWT.NONE); columns[1].setText("Parameter"); table.setHeaderVisible(true); table.setLinesVisible(true); TableSorter sort = new TableSorter(tableViewer); Composite compositeSource = new Composite(shlUSBLogviewer, SWT.NONE); compositeSource.setLayout(new GridLayout(3, false)); FormData fd_compositeSource = new FormData(); fd_compositeSource.top = new FormAttachment(0, 10); fd_compositeSource.left = new FormAttachment(0, 10); fd_compositeSource.right = new FormAttachment(100, -10); compositeSource.setLayoutData(fd_compositeSource); fd_compositeTable.top = new FormAttachment(compositeSource, 6); lblLogfile = new Label(compositeSource, SWT.BORDER); lblLogfile.setText("USB Log file :"); textLogFile = new Text(compositeSource, SWT.BORDER); textLogFile.setEditable(false); GridData gd_textLogFile = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); gd_textLogFile.widthHint = 471; textLogFile.setLayoutData(gd_textLogFile); btnLogFile = new Button(compositeSource, SWT.NONE); btnLogFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); btnLogFile.setText("..."); Label lblSinfolder = new Label(compositeSource, SWT.NONE); GridData gd_lblSinfolder = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); gd_lblSinfolder.widthHint = 110; lblSinfolder.setLayoutData(gd_lblSinfolder); lblSinfolder.setText("Source folder :"); textSinFolder = new Text(compositeSource, SWT.BORDER); textSinFolder.setEditable(false); GridData gd_textSinFolder = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_textSinFolder.widthHint = 509; textSinFolder.setLayoutData(gd_textSinFolder); btnSourceFolder = new Button(compositeSource, SWT.NONE); GridData gd_btnSourceFolder = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_btnSourceFolder.widthHint = 46; btnSourceFolder.setLayoutData(gd_btnSourceFolder); btnSourceFolder.setText("..."); btnParse = new Button(shlUSBLogviewer, SWT.NONE); FormData fd_btnParse = new FormData(); fd_btnParse.bottom = new FormAttachment(100,-10); fd_btnParse.right = new FormAttachment(btnClose, -6); btnParse.setLayoutData(fd_btnParse); btnParse.setText("Parse"); } public void createTriggers() { btnClose.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = null; shlUSBLogviewer.dispose(); } }); table.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { TableItem[] selection = table.getSelection(); String string = selection[0].getText(0); result = string; shlUSBLogviewer.dispose(); } }); btnSourceFolder.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DirectoryDialog dlg = new DirectoryDialog(shlUSBLogviewer); // Set the initial filter path according // to anything they've selected or typed in dlg.setFilterPath(textSinFolder.getText()); // Change the title bar text dlg.setText("Directory chooser"); // Customizable message displayed in the dialog dlg.setMessage("Select a directory"); // Calling open() will open and run the dialog. // It will return the selected directory, or // null if user cancels String dir = dlg.open(); if (dir != null) { // Set the text box to the new selection if (!textSinFolder.getText().equals(dir)) { textSinFolder.setText(dir); tableViewer.setInput(new Vector()); tableViewer.refresh(); lblSavedPath.setText(""); } } } }); btnLogFile.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog dlg = new FileDialog(shlUSBLogviewer); // Set the initial filter path according // to anything they've selected or typed in dlg.setFilterPath(textLogFile.getText()); // Change the title bar text dlg.setText("TMS File chooser"); dlg.setFilterExtensions(new String[] {"*.tms"}); // Calling open() will open and run the dialog. // It will return the selected directory, or // null if user cancels String dir = dlg.open(); if (dir != null) { // Set the text box to the new selection if (!textLogFile.getText().equals(dir)) { textLogFile.setText(dir); String filename = new File(dir).getName(); textSinFolder.setText(new File(dir).getParentFile().getAbsolutePath()+File.separator+filename.substring(0, filename.indexOf("."))+"_decrypted"); lblSavedPath.setText(""); tableViewer.setInput(new Vector()); tableViewer.refresh(); } } } }); btnParse.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { WaitForUSBParser parse = new WaitForUSBParser(shlUSBLogviewer,SWT.PRIMARY_MODAL | SWT.SHEET); Session sess = (Session)parse.open(textLogFile.getText(),textSinFolder.getText()); lblSavedPath.setText("Script saved to "+sess.saveScript()); Display.getDefault().asyncExec( new Runnable() { public void run() { tableViewer.setInput(sess.getScript()); for (int nbcols=0;nbcols<table.getColumnCount();nbcols++) table.getColumn(nbcols).pack(); tableViewer.refresh(); } } ); } }); } }
10,213
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
About.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/About.java
package org.flashtool.gui; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Enumeration; import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.jar.Manifest; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.flashtool.system.OS; import lombok.extern.slf4j.Slf4j; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Link; import org.eclipse.swt.program.Program; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridData; @Slf4j public class About extends Dialog { protected Object result; protected Shell shlAbout; public static String build = About.class.getPackage().getImplementationVersion(); private Label lblNewLabel; private Label lblNewLabel_2; private Label lblNewLabel_1; private Label lblNewLabel_3; private Label lblNewLabel_4; /** * Create the dialog. * @param parent * @param style */ public About(Shell parent, int style) { super(parent, style); setText("About"); } /** * Open the dialog. * @return the result */ public Object open() { createContents(); Composite composite = new Composite(shlAbout, SWT.NONE); composite.setLayout(new GridLayout(1, false)); FormData fd_composite = new FormData(); fd_composite.top = new FormAttachment(0, 10); fd_composite.left = new FormAttachment(0, 10); fd_composite.right = new FormAttachment(100, -10); composite.setLayoutData(fd_composite); lblNewLabel = new Label(composite, SWT.NONE); lblNewLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1)); lblNewLabel.setAlignment(SWT.CENTER); lblNewLabel.setText("Xperia flashing tool "+OS.getChannel()); lblNewLabel_2 = new Label(composite, SWT.NONE); lblNewLabel_2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); lblNewLabel_2.setAlignment(SWT.CENTER); lblNewLabel_2.setText(getVersion()); lblNewLabel_1 = new Label(composite, SWT.NONE); lblNewLabel_1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); lblNewLabel_1.setAlignment(SWT.CENTER); lblNewLabel_1.setText("Java Version " + System.getProperty("java.version") + " " + System.getProperty("sun.arch.data.model") + "bits Edition"); lblNewLabel_3 = new Label(composite, SWT.NONE); lblNewLabel_3.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); lblNewLabel_3.setAlignment(SWT.CENTER); lblNewLabel_3.setText("OS Version "+OS.getVersion()); lblNewLabel_4 = new Label(composite, SWT.NONE); lblNewLabel_4.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); lblNewLabel_4.setAlignment(SWT.CENTER); lblNewLabel_4.setText("By Androxyde"); Label lblManyThanksTo = new Label(composite, SWT.NONE); lblManyThanksTo.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); lblManyThanksTo.setAlignment(SWT.CENTER); lblManyThanksTo.setText("Many thanks to contributors : Bin4ry, DooMLoRD, [NUT],"); Label lblDevshaft = new Label(composite, SWT.NONE); lblDevshaft.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); lblDevshaft.setAlignment(SWT.CENTER); lblDevshaft.setText("DevShaft, IaguCool"); Link link = new Link(composite, SWT.NONE); link.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Program.launch("http://www.flashtool.net"); } }); link.setText("<a href=\"http://androxyde.github.com\">Homepage</a>"); shlAbout.open(); shlAbout.layout(); Display display = getParent().getDisplay(); while (!shlAbout.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlAbout = new Shell(getParent(), getStyle()); shlAbout.setSize(430, 260); shlAbout.setText("About"); shlAbout.setLayout(new FormLayout()); Button btnNewButton = new Button(shlAbout, SWT.NONE); btnNewButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { shlAbout.dispose(); } }); FormData fd_btnNewButton = new FormData(); fd_btnNewButton.bottom = new FormAttachment(100, -10); fd_btnNewButton.right = new FormAttachment(100, -10); btnNewButton.setLayoutData(fd_btnNewButton); btnNewButton.setText("Close"); } public static String getVersion() { if (build == null) return " run from eclipse"; return build; } public static String getManifestInfo() { Enumeration resEnum; try { resEnum = Thread.currentThread().getContextClassLoader().getResources(JarFile.MANIFEST_NAME); while (resEnum.hasMoreElements()) { try { URL url = (URL)resEnum.nextElement(); InputStream is = url.openStream(); if (is != null) { Manifest manifest = new Manifest(is); Attributes mainAttribs = manifest.getMainAttributes(); String version = mainAttribs.getValue("Implementation-Version"); if(version != null) { return version; } } } catch (Exception e) { // Silently ignore wrong manifests on classpath? } } } catch (IOException e1) { // Silently ignore wrong manifests on classpath? } return null; } }
6,014
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
Test.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/Test.java
package org.flashtool.gui; import java.io.File; import java.io.FileInputStream; import org.flashtool.parsers.sin.SinFile; import com.igormaznitsa.jbbp.io.JBBPBitInputStream; import com.igormaznitsa.jbbp.io.JBBPByteOrder; import lombok.extern.slf4j.Slf4j; @Slf4j public class Test { public static void main(String[] args) throws Exception { File f = new File("/tmp/emmc.infos"); FileInputStream fin = new FileInputStream(f); JBBPBitInputStream emmcStream = new JBBPBitInputStream(fin); emmcStream.skip(0xd0); long lunSize1=emmcStream.readInt(JBBPByteOrder.LITTLE_ENDIAN); long lunSize=emmcStream.readInt(JBBPByteOrder.LITTLE_ENDIAN); lunSize+=lunSize1; //lunSize=249880576; //lunSize=244285440; System.out.println("Read size1 : "+lunSize1); System.out.println("Read size : "+lunSize); lunSize*=512; System.out.println("After Sector size : "+lunSize); lunSize/=1024; System.out.println("After /1024 : "+lunSize); lunSize-=4096; System.out.println("Minus 4096 : "+lunSize); } }
1,017
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
HomeSelector.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/HomeSelector.java
package org.flashtool.gui; import java.io.File; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Button; import org.flashtool.windowbuilder.swt.SWTResourceManager; import lombok.extern.slf4j.Slf4j; import org.flashtool.flashsystem.S1Command; import org.flashtool.gui.tools.WidgetTask; import org.flashtool.system.GlobalConfig; import org.flashtool.system.OS; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @Slf4j public class HomeSelector extends Dialog { protected Object result; protected Shell shlHomeSelector; private Text sourceFolder; private Button btnAccept; private boolean cancelable = true; /** * Create the dialog. * @param parent * @param style */ public HomeSelector(Shell parent, int style) { super(parent, style); setText("SWT Dialog"); } /** * Open the dialog. * @return the result */ public Object open(boolean pcancelable) { cancelable = pcancelable; createContents(); shlHomeSelector.open(); shlHomeSelector.layout(); Display display = getParent().getDisplay(); while (!shlHomeSelector.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents() { shlHomeSelector = new Shell(getParent(), getStyle()); shlHomeSelector.setSize(545, 142); shlHomeSelector.setText("User Home Selector"); shlHomeSelector.setLayout(new FormLayout()); shlHomeSelector.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { if (cancelable) { result = ""; event.doit = true; } else { WidgetTask.openOKBox(shlHomeSelector, "You must choose a user home folder"); event.doit = false; } } }); Composite composite = new Composite(shlHomeSelector, SWT.NONE); composite.setLayout(new GridLayout(3, false)); FormData fd_composite = new FormData(); fd_composite.top = new FormAttachment(0, 10); fd_composite.right = new FormAttachment(100, -9); composite.setLayoutData(fd_composite); Label lblHomeFolder = new Label(composite, SWT.NONE); GridData gd_lblHomeFolder = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); gd_lblHomeFolder.widthHint = 62; lblHomeFolder.setLayoutData(gd_lblHomeFolder); lblHomeFolder.setText("Folder :"); sourceFolder = new Text(composite, SWT.BORDER); sourceFolder.setEditable(false); sourceFolder.setText(GlobalConfig.getProperty("user.flashtool")); GridData gd_sourceFolder = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_sourceFolder.widthHint = 385; sourceFolder.setLayoutData(gd_sourceFolder); Button btnFolderChoose = new Button(composite, SWT.NONE); btnFolderChoose.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DirectoryDialog dlg = new DirectoryDialog(shlHomeSelector); // Set the initial filter path according // to anything they've selected or typed in dlg.setFilterPath(sourceFolder.getText()); // Change the title bar text dlg.setText("Home User Folder Chooser"); // Calling open() will open and run the dialog. // It will return the selected directory, or // null if user cancels String dir = dlg.open(); if (dir != null) { // Set the text box to the new selection if (!sourceFolder.getText().equals(dir)) { try { sourceFolder.setText(dir); } catch (Exception ex) { ex.printStackTrace(); } } } } }); GridData gd_btnFolderChoose = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gd_btnFolderChoose.widthHint = 34; btnFolderChoose.setLayoutData(gd_btnFolderChoose); btnFolderChoose.setText("..."); btnFolderChoose.setFont(SWTResourceManager.getFont("Arial", 11, SWT.NORMAL)); Button btnCancel = new Button(shlHomeSelector, SWT.NONE); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (cancelable) { result = ""; shlHomeSelector.dispose(); } else { WidgetTask.openOKBox(shlHomeSelector, "You must choose a user home folder"); } } }); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100,-10); fd_btnCancel.bottom = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.setText("Cancel"); btnAccept = new Button(shlHomeSelector, SWT.NONE); btnAccept.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result=sourceFolder.getText(); if (!((String)result).startsWith(OS.getWorkDir()+File.separator)) shlHomeSelector.dispose(); else WidgetTask.openOKBox(shlHomeSelector, "User home folder must be out of Flashtool application folder"); } }); FormData fd_btnAccept = new FormData(); fd_btnAccept.bottom = new FormAttachment(100, -10); fd_btnAccept.right = new FormAttachment(btnCancel, -6); btnAccept.setLayoutData(fd_btnAccept); btnAccept.setText("Accept"); } }
5,925
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
FileSelector.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/FileSelector.java
package org.flashtool.gui; import java.io.File; import java.util.Vector; import java.util.jar.Attributes; import java.util.jar.JarFile; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.List; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.flashtool.flashsystem.S1Command; import org.flashtool.system.Devices; import org.flashtool.system.OS; import lombok.extern.slf4j.Slf4j; @Slf4j public class FileSelector extends Dialog { protected Object result; protected Shell shlTABackupSelector; private Button btnCancel; private List listFiles; private Label lblNewLabel; private Label lblNewLabel_1; /** * Create the dialog. * @param parent * @param style */ public FileSelector(Shell parent, int style) { super(parent, style); } /** * Open the dialog. * @return the result */ public Object open(Vector<String> vFiles) { createContents(vFiles); shlTABackupSelector.open(); shlTABackupSelector.layout(); shlTABackupSelector.setSize(390, 434); lblNewLabel = new Label(shlTABackupSelector, SWT.NONE); FormData fd_lblNewLabel = new FormData(); fd_lblNewLabel.right = new FormAttachment(btnCancel, 0, SWT.RIGHT); fd_lblNewLabel.top = new FormAttachment(0, 10); fd_lblNewLabel.left = new FormAttachment(listFiles, 0, SWT.LEFT); lblNewLabel.setLayoutData(fd_lblNewLabel); lblNewLabel.setText("Multiple files have been found for this partition"); lblNewLabel_1 = new Label(shlTABackupSelector, SWT.NONE); FormData fd_lblNewLabel_1 = new FormData(); fd_lblNewLabel_1.top = new FormAttachment(lblNewLabel, 6); fd_lblNewLabel_1.left = new FormAttachment(0, 10); lblNewLabel_1.setLayoutData(fd_lblNewLabel_1); lblNewLabel_1.setText("Please choose the right one"); Display display = getParent().getDisplay(); while (!shlTABackupSelector.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return result; } /** * Create contents of the dialog. */ private void createContents(Vector<String> vFiles) { shlTABackupSelector = new Shell(getParent(), getStyle()); shlTABackupSelector.setText("Partition Image Selector"); shlTABackupSelector.setLayout(new FormLayout()); btnCancel = new Button(shlTABackupSelector, SWT.NONE); FormData fd_btnCancel = new FormData(); fd_btnCancel.right = new FormAttachment(100, -10); fd_btnCancel.bottom = new FormAttachment(100, -10); btnCancel.setLayoutData(fd_btnCancel); btnCancel.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = ""; shlTABackupSelector.dispose(); } }); btnCancel.setText("Cancel"); ListViewer listTAViewer = new ListViewer(shlTABackupSelector, SWT.BORDER | SWT.V_SCROLL); listFiles = listTAViewer.getList(); FormData fd_listTA = new FormData(); fd_listTA.bottom = new FormAttachment(btnCancel, -6, SWT.TOP); fd_listTA.top = new FormAttachment(0, 81); fd_listTA.right = new FormAttachment(100, -10); fd_listTA.left = new FormAttachment(0, 10); listFiles.setLayoutData(fd_listTA); listFiles.addListener(SWT.DefaultSelection, new Listener() { public void handleEvent(Event e) { int selected = listFiles.getSelectionIndex(); String string = listFiles.getItem(selected); result = string; shlTABackupSelector.dispose(); } }); listTAViewer.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { Vector v = (Vector)inputElement; return v.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }); listTAViewer.setLabelProvider(new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return ((String)element); } }); listTAViewer.setInput(vFiles); } }
4,789
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
TreeDeviceCustomization.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/TreeDeviceCustomization.java
package org.flashtool.gui.models; import java.io.File; import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.jar.JarFile; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class TreeDeviceCustomization { private List<TreeDeviceCustomizationRelease> devicevariantcustreleases = new LinkedList<TreeDeviceCustomizationRelease>(); String customization=""; public TreeDeviceCustomization(String cust, File f, JarFile jf) throws IOException, Exception { customization=cust; addRelease(f, jf); } public void addRelease(File f, JarFile jf) throws IOException, Exception { String version = jf.getManifest().getMainAttributes().getValue("version"); TreeDeviceCustomizationRelease v = new TreeDeviceCustomizationRelease(version, f, jf); devicevariantcustreleases.add(v); } public String getCustomization() { return customization; } public boolean contains(String release) { Iterator<TreeDeviceCustomizationRelease> irel = devicevariantcustreleases.iterator(); while (irel.hasNext()) { TreeDeviceCustomizationRelease rel = irel.next(); if (rel.getRelease().equals(release)) return true; } return false; } public TreeDeviceCustomizationRelease get(String release) { Iterator<TreeDeviceCustomizationRelease> irel = devicevariantcustreleases.iterator(); while (irel.hasNext()) { TreeDeviceCustomizationRelease rel = irel.next(); if (rel.getRelease().equals(release)) return rel; } return null; } public List<TreeDeviceCustomizationRelease> getReleases() { return devicevariantcustreleases; } }
1,678
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
VectorContentProvider.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/VectorContentProvider.java
package org.flashtool.gui.models; import java.util.Vector; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.Viewer; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class VectorContentProvider implements IStructuredContentProvider { public Object[] getElements(Object inputElement) { Vector v = (Vector)inputElement; return v.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }
614
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
CategoriesModel.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/CategoriesModel.java
package org.flashtool.gui.models; import java.io.File; import java.util.ArrayList; import java.util.Enumeration; import java.util.Iterator; import java.util.List; import org.flashtool.flashsystem.BundleMetaData; import org.flashtool.flashsystem.Category; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class CategoriesModel { List<Category> categories; public CategoriesModel(BundleMetaData meta) { refresh(meta); } public void refresh(BundleMetaData meta) { categories = new ArrayList<Category>(); Iterator<Category> c = meta.getAllEntries(false).iterator(); while (c.hasNext()) { Category category = c.next(); categories.add(category); } if (meta.getLoader()!=null) categories.add(meta.getLoader()); } public List<Category> getCategories() { return categories; } }
848
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
TreeDeviceVariant.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/TreeDeviceVariant.java
package org.flashtool.gui.models; import java.io.File; import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.jar.JarFile; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class TreeDeviceVariant { private List<TreeDeviceCustomization> devicevariantcust = new LinkedList<TreeDeviceCustomization>(); String devicevariant; public TreeDeviceVariant(String variantname, File f, JarFile jf) throws IOException, Exception { devicevariant=variantname; addCustomization(f,jf); } public String getVariant() { return devicevariant; } public void addCustomization(File f, JarFile jf) throws IOException, Exception { String cust = jf.getManifest().getMainAttributes().getValue("branding"); if (contains(cust)) { TreeDeviceCustomization v = get(cust); v.addRelease(f, jf); } else { TreeDeviceCustomization v = new TreeDeviceCustomization(cust, f, jf); devicevariantcust.add(v); } } public boolean contains(String customization) { Iterator<TreeDeviceCustomization> icust = devicevariantcust.iterator(); while (icust.hasNext()) { TreeDeviceCustomization cust = icust.next(); if (cust.getCustomization().equals(customization)) return true; } return false; } public TreeDeviceCustomization get(String customization) { Iterator<TreeDeviceCustomization> icust = devicevariantcust.iterator(); while (icust.hasNext()) { TreeDeviceCustomization cust = icust.next(); if (cust.getCustomization().equals(customization)) return cust; } return null; } public List<TreeDeviceCustomization> getCustomizations() { return devicevariantcust; } }
1,730
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
TableSorter.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/TableSorter.java
package org.flashtool.gui.models; import java.util.Arrays; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class TableSorter { private final TableViewer tableViewer; public TableSorter(TableViewer tableViewer) { this.tableViewer = tableViewer; addColumnSelectionListeners(tableViewer); tableViewer.setComparator(new ViewerComparator() { public int compare(Viewer viewer, Object e1, Object e2) { return compareElements(e1, e2); } }); } private void addColumnSelectionListeners(TableViewer tableViewer) { TableColumn[] columns = tableViewer.getTable().getColumns(); for (int i = 0; i < columns.length; i++) { addColumnSelectionListener(columns[i]); } } private void addColumnSelectionListener(TableColumn column) { column.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { tableColumnClicked((TableColumn) e.widget); } }); } private void tableColumnClicked(TableColumn column) { Table table = column.getParent(); if (column.equals(table.getSortColumn())) { table.setSortDirection(table.getSortDirection() == SWT.UP ? SWT.DOWN : SWT.UP); } else { table.setSortColumn(column); table.setSortDirection(SWT.UP); } tableViewer.refresh(); } private int compareElements(Object e1, Object e2) { Table table = tableViewer.getTable(); int index = Arrays.asList(table.getColumns()).indexOf(table.getSortColumn()); int result = 0; if (index != -1) { Comparable c1 = ((TableLine)e1).getValueOf(index); Comparable c2 = ((TableLine)e2).getValueOf(index); result = c1.compareTo(c2); } return table.getSortDirection() == SWT.UP ? result : -result; } }
2,056
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
VectorLabelProvider.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/VectorLabelProvider.java
package org.flashtool.gui.models; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.swt.graphics.Image; import org.flashtool.gui.TARestore; import org.flashtool.system.PropertiesFile; import lombok.extern.slf4j.Slf4j; @Slf4j public class VectorLabelProvider implements ITableLabelProvider { // Constructs a PlayerLabelProvider public VectorLabelProvider() { } public Image getColumnImage(Object arg0, int arg1) { return null; } /** * Gets the text for the specified column * * @param arg0 * the player * @param arg1 * the column * @return String */ public String getColumnText(Object arg0, int arg1) { if (arg0 instanceof TableLine) { TableLine line = (TableLine) arg0; return line.getValueOf(arg1); } return ""; } /** * Adds a listener * * @param arg0 * the listener */ public void addListener(ILabelProviderListener arg0) { // Throw it away } /** * Dispose any created resources */ public void dispose() { } /** * Returns whether the specified property, if changed, would affect the * label * * @param arg0 * the player * @param arg1 * the property * @return boolean */ public boolean isLabelProperty(Object arg0, String arg1) { return false; } /** * Removes the specified listener * * @param arg0 * the listener */ public void removeListener(ILabelProviderListener arg0) { // Do nothing } }
1,671
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
MyTreeLabelProvider.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/MyTreeLabelProvider.java
package org.flashtool.gui.models; import org.eclipse.jface.viewers.LabelProvider; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class MyTreeLabelProvider extends LabelProvider { @Override public String getText(Object element) { if (element instanceof TreeDevice) { return ((TreeDevice) element).getDeviceName(); } else if (element instanceof TreeDeviceVariant) { return ((TreeDeviceVariant) element).getVariant(); } else if (element instanceof TreeDeviceCustomization) { return ((TreeDeviceCustomization) element).getCustomization(); } if (element instanceof TreeDeviceCustomizationRelease) { return ((TreeDeviceCustomizationRelease) element).getRelease(); } return null; } }
817
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
PropertiesFileContentProvider.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/PropertiesFileContentProvider.java
package org.flashtool.gui.models; import java.util.Vector; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.Viewer; import org.flashtool.gui.TARestore; import org.flashtool.system.PropertiesFile; import lombok.extern.slf4j.Slf4j; @Slf4j public class PropertiesFileContentProvider implements IStructuredContentProvider { public Object[] getElements(Object inputElement) { PropertiesFile v = (PropertiesFile)inputElement; return v.toArray(); } public void dispose() { } public void inputChanged( Viewer viewer, Object oldInput, Object newInput) { } }
682
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
Firmware.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/Firmware.java
package org.flashtool.gui.models; import java.io.File; import java.util.Collections; import java.util.Enumeration; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import org.flashtool.flashsystem.Bundle; import org.flashtool.flashsystem.BundleEntry; import org.flashtool.flashsystem.Category; import org.flashtool.gui.TARestore; import org.flashtool.system.Devices; import lombok.extern.slf4j.Slf4j; @Slf4j public class Firmware { private String fileName; private String device; private String device_name; private String version; private String branding; private Firmwares firmwares; private Bundle bundle; private List content; public Firmware() { content = new LinkedList(); } public Firmware(String pfilename, String pdevice, String pversion, String pbranding) throws Exception { fileName = pfilename; device = pdevice; device_name = Devices.getVariantName(pdevice); version = pversion; branding = pbranding; content = new LinkedList(); bundle = new Bundle(pfilename,Bundle.JARTYPE); Iterator<Category> i = bundle.getMeta().getAllEntries(true).iterator(); while (i.hasNext()) { Category c = i.next(); Iterator<BundleEntry> ic = c.getEntries().iterator(); while (ic.hasNext()) add(new Content(ic.next().getName())); } } public String getFilename() { return (new File(fileName)).getName(); } public String getDevice() { return device; } public String getDeviceName() { return device_name; } public String getVersion() { return version; } public String getBranding() { return branding; } public Bundle getBundle() { return bundle; } public boolean add(Content fcontent) { boolean added = content.add(fcontent); if (added) fcontent.setFirmware(this); return added; } public void disableCateg(String categ) { bundle.getMeta().setCategEnabled(categ, false); content.clear(); Iterator<Category> i = bundle.getMeta().getAllEntries(true).iterator(); while (i.hasNext()) { Category c = i.next(); Iterator<BundleEntry> ic = c.getEntries().iterator(); while (ic.hasNext()) add(new Content(ic.next().getName())); } } public void enableCateg(String categ) { bundle.getMeta().setCategEnabled(categ, true); content.clear(); Iterator<Category> i = bundle.getMeta().getAllEntries(true).iterator(); while (i.hasNext()) { Category c = i.next(); Iterator<BundleEntry> ic = c.getEntries().iterator(); while (ic.hasNext()) add(new Content(ic.next().getName())); } } /** * Gets the players * * @return List */ public List getContent() { return Collections.unmodifiableList(content); } public void setFirmwares(Firmwares f) { firmwares=f; } }
2,907
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
TABag.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/TABag.java
package org.flashtool.gui.models; import java.io.File; import java.util.Vector; import org.flashtool.gui.TARestore; import org.flashtool.parsers.ta.TAFileParser; import org.flashtool.parsers.ta.TAUnit; import lombok.extern.slf4j.Slf4j; @Slf4j public class TABag { public Vector<TAUnit> available; public Vector<TAUnit> toflash; public int partition=0; public TABag(File file) { try { TAFileParser taf = new TAFileParser(file); available = taf.entries(); toflash = new Vector<TAUnit>(); partition = taf.getPartition(); } catch (Exception e) {} } public TABag(int partition) { this.partition = partition; available = new Vector<TAUnit>(); toflash = new Vector<TAUnit>(); } public void addUnit(TAUnit unit) { available.add(unit); } }
770
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
Firmwares.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/Firmwares.java
package org.flashtool.gui.models; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import org.flashtool.gui.TARestore; import org.flashtool.system.DeviceEntry; import org.flashtool.system.Devices; import lombok.extern.slf4j.Slf4j; @Slf4j public class Firmwares { private List firmwares; String devid = ""; public Firmwares() { firmwares = new LinkedList(); } public void setDevice(String id) { devid = id; } public boolean add(Firmware firm) { boolean added = firmwares.add(firm); if (added) firm.setFirmwares(this); return added; } /** * Gets the players * * @return List */ public List<Firmware> getContent() { LinkedList filteredfirmwares = new LinkedList(); if (devid.length()>0) { DeviceEntry entry = Devices.getDevice(devid); Iterator i = firmwares.listIterator(); while (i.hasNext()) { Firmware f = (Firmware)i.next(); if (entry.getVariantList().contains(f.getDevice())) filteredfirmwares.add(f); } return filteredfirmwares; } else return Collections.unmodifiableList(firmwares); } public boolean hasFirmwares() { return !getContent().isEmpty(); } }
1,290
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
FirmwaresModel.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/FirmwaresModel.java
package org.flashtool.gui.models; import java.io.File; import java.util.jar.JarFile; import org.flashtool.gui.TARestore; import org.flashtool.gui.tools.FtfFilter; import lombok.extern.slf4j.Slf4j; @Slf4j public class FirmwaresModel { public Firmwares firmwares; public FirmwaresModel(String srcFolder) { File dir = new File(srcFolder); File[] chld = dir.listFiles(new FtfFilter("")); firmwares = new Firmwares(); for(int i = 0; i < chld.length; i++) { try { JarFile jf = new JarFile(chld[i]); firmwares.add(new Firmware(chld[i].getAbsolutePath(),jf.getManifest().getMainAttributes().getValue("device"), jf.getManifest().getMainAttributes().getValue("version"), jf.getManifest().getMainAttributes().getValue("branding"))); } catch (Exception e) { e.printStackTrace();} } } public Firmware getFirstFirmware() { if (!firmwares.hasFirmwares()) return new Firmware(); else { return firmwares.getContent().get(0); } } }
1,001
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
SinfilesLabelProvider.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/SinfilesLabelProvider.java
package org.flashtool.gui.models; import java.io.File; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Image; import org.flashtool.flashsystem.BundleEntry; import org.flashtool.flashsystem.Category; import org.flashtool.gui.TARestore; import org.flashtool.windowbuilder.swt.SWTResourceManager; import lombok.extern.slf4j.Slf4j; @Slf4j public class SinfilesLabelProvider extends LabelProvider { private static final Image FOLDER = SWTResourceManager.getImage(SinfilesLabelProvider.class,"/gui/ressources/folder.gif"); private static final Image FILE = SWTResourceManager.getImage(SinfilesLabelProvider.class,"/gui/ressources/file.gif"); @Override public String getText(Object element) { if (element instanceof Category) { Category category = (Category) element; return category.getId(); } return ((BundleEntry) element).getInternal(); } @Override public Image getImage(Object element) { if (element instanceof Category) { return FOLDER; } return FILE; } }
1,066
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
TreeDeviceCustomizationRelease.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/TreeDeviceCustomizationRelease.java
package org.flashtool.gui.models; import java.io.File; import java.io.IOException; import java.util.jar.JarFile; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class TreeDeviceCustomizationRelease { String release=""; Firmware firm=null; public TreeDeviceCustomizationRelease(String rel, File f, JarFile jf) throws IOException, Exception { release=rel; firm=new Firmware(f.getAbsolutePath(), jf.getManifest().getMainAttributes().getValue("device"), jf.getManifest().getMainAttributes().getValue("version"), jf.getManifest().getMainAttributes().getValue("branding")); } public String getRelease() { return release; } public Firmware getFirmware() { return firm; } }
727
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
CategoriesContentProvider.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/CategoriesContentProvider.java
package org.flashtool.gui.models; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; import org.flashtool.flashsystem.Category; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class CategoriesContentProvider implements ITreeContentProvider { private CategoriesModel model; @Override public void dispose() { } @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { this.model = (CategoriesModel) newInput; } @Override public Object[] getElements(Object inputElement) { return model.getCategories().toArray(); } @Override public Object[] getChildren(Object parentElement) { if (parentElement instanceof Category) { Category category = (Category) parentElement; return category.getEntries().toArray(); } return null; } @Override public Object getParent(Object element) { return null; } @Override public boolean hasChildren(Object element) { if (element instanceof Category) { return true; } return false; } }
1,152
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
TreeDevices.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/TreeDevices.java
package org.flashtool.gui.models; import java.io.File; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.jar.JarFile; import org.flashtool.gui.TARestore; import org.flashtool.gui.tools.FtfFilter; import org.flashtool.system.DeviceEntry; import org.flashtool.system.Devices; import lombok.extern.slf4j.Slf4j; @Slf4j public class TreeDevices { private List<TreeDevice> devices; String devicefilter = ""; public TreeDevices(String srcFolder) { devices = new LinkedList<TreeDevice>(); File dir = new File(srcFolder); File[] chld = dir.listFiles(new FtfFilter("")); for(int i = 0; i < chld.length; i++) { try { JarFile jf = new JarFile(chld[i]); String model = jf.getManifest().getMainAttributes().getValue("device"); DeviceEntry ent = Devices.getDeviceFromVariant(model); if (ent!=null) { if (contains(ent.getId())) { TreeDevice dev = get(ent.getId()); dev.addVariant(chld[i],jf); } else { TreeDevice dev=new TreeDevice(ent.getId(),ent.getName(),chld[i],jf); devices.add(dev); } } jf.close(); } catch (Exception e) { e.printStackTrace(); } } } public void setDeviceFilter(String id) { devicefilter = id; } public List<TreeDevice> getContent() { LinkedList<TreeDevice> filtereddevices = new LinkedList<TreeDevice>(); if (devicefilter.length()>0) { DeviceEntry entry = Devices.getDevice(devicefilter); Iterator<TreeDevice> i = devices.listIterator(); while (i.hasNext()) { TreeDevice f = i.next(); if (f.getDevice().equals(devicefilter)) filtereddevices.add(f); } return filtereddevices; } else return devices; } public boolean hasDevices() { return !getContent().isEmpty(); } public boolean contains(String devid) { Iterator<TreeDevice> idev = devices.iterator(); while (idev.hasNext()) { TreeDevice dev = idev.next(); if (dev.getDevice().equals(devid)) return true; } return false; } public TreeDevice get(String devid) { Iterator<TreeDevice> idev = devices.iterator(); while (idev.hasNext()) { TreeDevice dev = idev.next(); if (dev.getDevice().equals(devid)) return dev; } return null; } }
2,384
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
TADevice.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/TADevice.java
package org.flashtool.gui.models; import java.util.Iterator; import java.util.Vector; import org.flashtool.gui.TARestore; import org.flashtool.parsers.ta.TAUnit; import lombok.extern.slf4j.Slf4j; @Slf4j public class TADevice { String model = ""; String serial = ""; Vector<TABag> tabags=null; public TADevice() { } public void addBags(Vector<TABag> bags) { tabags = bags; for (int i=0;i<tabags.size();i++) { if (tabags.get(i).partition==2) { Iterator<TAUnit> iu = bags.get(i).available.iterator(); while (iu.hasNext()) { TAUnit u = iu.next(); if (u.getUnitHex().equals("000008A2")) model = new String(u.getUnitData()); if (u.getUnitHex().equals("00001324")) serial = new String(u.getUnitData()); } } } } public Vector<TABag> getBags() { return tabags; } public String getModel() { return model; } public String getSerial() { return serial; } }
917
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
MyTreeContentProvider.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/MyTreeContentProvider.java
package org.flashtool.gui.models; import java.util.List; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class MyTreeContentProvider implements ITreeContentProvider { private static final Object[] EMPTY_ARRAY = new Object[0]; //Called just for the first-level objects. //Here we provide a list of objects @Override public Object[] getElements(Object inputElement) { if (inputElement instanceof TreeDevices) return ((TreeDevices) inputElement).getContent().toArray(); else return EMPTY_ARRAY; } //Queried to know if the current node has children @Override public boolean hasChildren(Object element) { if (element instanceof TreeDevices || element instanceof TreeDevice || element instanceof TreeDeviceVariant || element instanceof TreeDeviceCustomization) { return true; } return false; } //Queried to load the children of a given node @Override public Object[] getChildren(Object parentElement) { if (parentElement instanceof TreeDevices) { TreeDevices devices = (TreeDevices) parentElement; return devices.getContent().toArray(); } if (parentElement instanceof TreeDevice) { TreeDevice device = (TreeDevice) parentElement; return device.getVariants().toArray(); } if (parentElement instanceof TreeDeviceVariant) { TreeDeviceVariant variant = (TreeDeviceVariant) parentElement; return variant.getCustomizations().toArray(); } if (parentElement instanceof TreeDeviceCustomization) { TreeDeviceCustomization cust = (TreeDeviceCustomization) parentElement; return cust.getReleases().toArray(); } return EMPTY_ARRAY; } @Override public void dispose() { } @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } @Override public Object getParent(Object element) { return null; } }
2,133
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
FirmwareContentProvider.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/FirmwareContentProvider.java
package org.flashtool.gui.models; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.Viewer; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class FirmwareContentProvider implements IStructuredContentProvider { /** * Gets the elements for the table * * @param arg0 * the model * @return Object[] */ public Object[] getElements(Object arg0) { // Returns all the players in the specified team return ((Firmwares)arg0).getContent().toArray(); } /** * Disposes any resources */ public void dispose() { // We don't create any resources, so we don't dispose any } /** * Called when the input changes * * @param arg0 * the parent viewer * @param arg1 * the old input * @param arg2 * the new input */ public void inputChanged(Viewer arg0, Object arg1, Object arg2) { // Nothing to do } }
1,025
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
ContentLabelProvider.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/ContentLabelProvider.java
package org.flashtool.gui.models; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.swt.graphics.Image; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class ContentLabelProvider implements ITableLabelProvider { // Constructs a PlayerLabelProvider public ContentLabelProvider() { } public Image getColumnImage(Object arg0, int arg1) { return null; } /** * Gets the text for the specified column * * @param arg0 * the player * @param arg1 * the column * @return String */ public String getColumnText(Object arg0, int arg1) { Content content = (Content) arg0; String text = ""; switch (arg1) { case 0: text = content.getEntry(); break; } return text; } /** * Adds a listener * * @param arg0 * the listener */ public void addListener(ILabelProviderListener arg0) { // Throw it away } /** * Dispose any created resources */ public void dispose() { } /** * Returns whether the specified property, if changed, would affect the * label * * @param arg0 * the player * @param arg1 * the property * @return boolean */ public boolean isLabelProperty(Object arg0, String arg1) { return false; } /** * Removes the specified listener * * @param arg0 * the listener */ public void removeListener(ILabelProviderListener arg0) { // Do nothing } }
1,665
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
ContentContentProvider.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/ContentContentProvider.java
package org.flashtool.gui.models; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.Viewer; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class ContentContentProvider implements IStructuredContentProvider { /** * Gets the elements for the table * * @param arg0 * the model * @return Object[] */ public Object[] getElements(Object arg0) { return ((Firmware)arg0).getContent().toArray(); } /** * Disposes any resources */ public void dispose() { } /** * Called when the input changes * * @param arg0 * the parent viewer * @param arg1 * the old input * @param arg2 * the new input */ public void inputChanged(Viewer arg0, Object arg1, Object arg2) { } }
883
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
TreeDevice.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/TreeDevice.java
package org.flashtool.gui.models; import java.io.File; import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.jar.JarFile; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class TreeDevice { String deviceid=""; String devicename=""; private List<TreeDeviceVariant> devicevariants = new LinkedList<TreeDeviceVariant>(); public TreeDevice(String id, String name, File f, JarFile jf) throws IOException, Exception { deviceid=id; devicename=name; addVariant(f,jf); } String getDevice() { return deviceid; } String getDeviceName() { return devicename; } public void addVariant(File f, JarFile jf) throws IOException, Exception { String model = jf.getManifest().getMainAttributes().getValue("device"); if (contains(model)) { TreeDeviceVariant v = get(model); v.addCustomization(f,jf); } else { TreeDeviceVariant v = new TreeDeviceVariant(model,f,jf); devicevariants.add(v); } } public boolean contains(String variantname) { Iterator<TreeDeviceVariant> ivariant = devicevariants.iterator(); while (ivariant.hasNext()) { TreeDeviceVariant variant = ivariant.next(); if (variant.getVariant().equals(variantname)) return true; } return false; } public TreeDeviceVariant get(String variantname) { Iterator<TreeDeviceVariant> ivariant = devicevariants.iterator(); while (ivariant.hasNext()) { TreeDeviceVariant variant = ivariant.next(); if (variant.getVariant().equals(variantname)) return variant; } return null; } public List<TreeDeviceVariant> getVariants() { return devicevariants; } }
1,707
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
Content.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/Content.java
package org.flashtool.gui.models; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; /** * This class represents a player */ @Slf4j public class Content { private Firmware firmware; private String entry; /** * Constructs an empty Player */ public Content() { this(null); } public Content(String entry) { setEntry(entry); } public void setFirmware(Firmware team) { this.firmware = firmware; } public Firmware getFirmware() { return firmware; } public void setEntry(String entry) { this.entry = entry; } public String getEntry() { return entry; } }
646
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
FirmwareLabelProvider.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/FirmwareLabelProvider.java
package org.flashtool.gui.models; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.swt.graphics.Image; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class FirmwareLabelProvider implements ITableLabelProvider { // Constructs a PlayerLabelProvider public FirmwareLabelProvider() { } public Image getColumnImage(Object arg0, int arg1) { return null; } /** * Gets the text for the specified column * * @param arg0 * the player * @param arg1 * the column * @return String */ public String getColumnText(Object arg0, int arg1) { Firmware firmware = (Firmware) arg0; String text = ""; switch (arg1) { case 0: text = firmware.getFilename(); break; case 1: text = firmware.getDeviceName(); break; case 2: text = firmware.getVersion(); break; case 3: text = firmware.getBranding(); break; } return text; } /** * Adds a listener * * @param arg0 * the listener */ public void addListener(ILabelProviderListener arg0) { // Throw it away } /** * Dispose any created resources */ public void dispose() { } /** * Returns whether the specified property, if changed, would affect the * label * * @param arg0 * the player * @param arg1 * the property * @return boolean */ public boolean isLabelProperty(Object arg0, String arg1) { return false; } /** * Removes the specified listener * * @param arg0 * the listener */ public void removeListener(ILabelProviderListener arg0) { // Do nothing } }
1,870
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
TableLine.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/models/TableLine.java
package org.flashtool.gui.models; import java.util.Vector; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class TableLine { private Vector<String> line = new Vector<String>(); public TableLine() { } public String getValueOf(int index) { return line.get(index); } public void setValueOf(int index, String value) { line.set(index, value); } public void add(String value) { line.add(value); } public String toString() { String result=""; for (int i=0;i<line.size();i++) result+=line.get(i)+" "; return result.trim(); } }
628
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
XperiFirmJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/XperiFirmJob.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.widgets.Shell; import org.flashtool.gui.TARestore; import org.flashtool.util.XperiFirm; import lombok.extern.slf4j.Slf4j; @Slf4j public class XperiFirmJob extends Job { Shell _parent; public XperiFirmJob(String name) { super(name); } public void setShell(Shell s) { _parent = s; } protected IStatus run(IProgressMonitor monitor) { try { XperiFirm.run(_parent); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); return Status.CANCEL_STATUS; } } }
765
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
MsgBox.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/MsgBox.java
package org.flashtool.gui.tools; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.flashtool.gui.TARestore; import org.flashtool.gui.tools.WidgetTask.Result; import lombok.extern.slf4j.Slf4j; @Slf4j public class MsgBox { static Shell current = null; public static void error(String message) { Shell curshell = null; try { curshell = Display.getCurrent().getActiveShell(); if (curshell == null) curshell = current; } catch (Exception e) { curshell = current; } MessageBox mb = new MessageBox(curshell,SWT.ICON_ERROR|SWT.OK); mb.setText("Error"); mb.setMessage(message); mb.open(); } public static int question(final String question) { Shell curshell = null; try { curshell = Display.getCurrent().getActiveShell(); if (curshell == null) curshell = current; } catch (Exception e) { curshell = current; } final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { MessageBox mb = new MessageBox(current,SWT.ICON_QUESTION|SWT.YES|SWT.NO); mb.setText("Question"); mb.setMessage(question); res.setResult(mb.open()); } } ); return (Integer)res.getResult(); } public static void setCurrentShell(Shell s) { current = s; } }
1,380
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
XMLBootDelivery.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/XMLBootDelivery.java
package org.flashtool.gui.tools; import org.flashtool.gui.TARestore; import org.jdom2.input.SAXBuilder; import lombok.extern.slf4j.Slf4j; import org.jdom2.Document; import org.jdom2.JDOMException; import org.jdom2.Element; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Enumeration; import java.util.Iterator; import java.util.Properties; import java.util.Vector; @Slf4j public class XMLBootDelivery { private Vector<XMLBootConfig> bootconfigs = new Vector<XMLBootConfig>(); private String bootversion; public XMLBootDelivery(File xmlsource) throws IOException, JDOMException { SAXBuilder builder = new SAXBuilder(); FileInputStream fin = new FileInputStream(xmlsource); Document document = builder.build(fin); String spaceid = document.getRootElement().getAttribute("SPACE_ID").getValue(); bootversion = document.getRootElement().getAttribute("VERSION").getValue().replaceAll(spaceid, "").trim(); if (bootversion.startsWith("_")) bootversion = bootversion.substring(1); Iterator<Element> i=document.getRootElement().getChildren().iterator(); while (i.hasNext()) { Element e = i.next(); XMLBootConfig c = new XMLBootConfig(e.getAttributeValue("NAME")); if (e.getChild("BOOT_CONFIG").getChild("FILE") != null) { c.setTA(e.getChild("BOOT_CONFIG").getChild("FILE").getAttributeValue("PATH")); } Iterator<Element> files = e.getChild("BOOT_IMAGES").getChildren().iterator(); while (files.hasNext()) { c.addFile(files.next().getAttributeValue("PATH")); } c.setAttributes(e.getChild("ATTRIBUTES").getAttributeValue("VALUE")); bootconfigs.add(c); } fin.close(); } public boolean mustUpdate(String bootver) { log.info("Phone boot version : "+bootver+". Boot delivery version : "+getBootVersion()); bootver = bootver.toUpperCase(); String deliveryver = getBootVersion().toUpperCase(); if (bootver.equals(deliveryver)) return false; return true; } public String getBootVersion() { return bootversion; } public Enumeration<XMLBootConfig> getBootConfigs() { return bootconfigs.elements(); } public Enumeration<Object> getFiles() { Properties flist = new Properties(); Enumeration<XMLBootConfig> e = bootconfigs.elements(); while (e.hasMoreElements()) { XMLBootConfig bc = e.nextElement(); if (bc.getTA().length()>0) flist.setProperty(bc.getTA(), bc.getTA()); Iterator<String>fl = bc.getFiles().iterator(); while (fl.hasNext()) { String f = fl.next(); flist.setProperty(f, f); } } return flist.keys(); } }
2,579
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
DeviceApps.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/DeviceApps.java
package org.flashtool.gui.tools; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Properties; import java.util.Set; import java.util.Vector; import org.flashtool.gui.TARestore; import org.flashtool.jna.adb.AdbUtility; import org.flashtool.system.Devices; import org.flashtool.system.OS; import org.flashtool.system.PropertiesFile; import lombok.extern.slf4j.Slf4j; @Slf4j public class DeviceApps { private static String fsep = OS.getFileSeparator(); private PropertiesFile deviceList; private PropertiesFile customList; //private Properties x10List = new Properties(); private PropertiesFile safeList; private HashSet<String> currentList; private String currentProfile=""; private Properties realnames = new Properties(); private HashMap<String,PropertiesFile> Allsafelist = new HashMap<String,PropertiesFile>(); // Copies src file to dst file. // If the dst file does not exist, it is created private void copyToAppsSaved(File src) throws IOException { File dst = new File(Devices.getCurrent().getAppsDir()+fsep+src.getName()); if (!dst.exists()) { InputStream in = new FileInputStream(src); OutputStream out = new FileOutputStream(dst); // Transfer bytes from in to out byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); } } public Properties deviceList() { return deviceList.getProperties(); } public Properties customList() { return customList.getProperties(); } public void addApk(File apk, String desc) { try { copyToAppsSaved(apk); customList.setProperty(apk.getName(), desc); customList.write("UTF-8"); realnames.setProperty(desc, apk.getName()); rescan(); } catch (Exception e) { } } public void modApk(String apkname, String desc) { if (customList.getProperties().containsKey(apkname)) { customList.setProperty(apkname,desc); customList.write("UTF-8"); } if (deviceList.getProperties().containsKey(apkname)) { deviceList.setProperty(apkname,desc); deviceList.write("UTF-8"); } realnames.setProperty(desc, apkname); rescan(); } private void rescan() { File[] dirlist = (new File(Devices.getCurrent().getCleanDir())).listFiles(); for (int i=0;i<dirlist.length;i++) { if (dirlist[i].getName().contains("safelist")) { String key = dirlist[i].getName().replace((CharSequence)"safelist", (CharSequence)""); key=key.replace((CharSequence)".properties", (CharSequence)""); if (!Allsafelist.containsKey(key.toLowerCase())) Allsafelist.put(key.toLowerCase(),new PropertiesFile("",dirlist[i].getPath())); } } } public String getCurrentProfile() { return currentProfile; } public void updateFromDevice() { Iterator ic = currentList.iterator(); boolean modded = false; while (ic.hasNext()) { String next = (String)ic.next(); if (!deviceList.getProperties().containsKey(next)) { if (!modded) modded=true; deviceList.setProperty(next, next); } } if (modded) deviceList.write("UTF-8"); } public void updateFromSaved() { File[] list = new File(Devices.getCurrent().getAppsDir()).listFiles(); boolean modded = false; for (int i=0;i<list.length;i++) { String apk = list[i].getName(); if (!deviceList.getProperties().containsKey(apk)) { if (!modded) modded=true; deviceList.setProperty(apk, apk); } } if (modded) deviceList.write("UTF-8"); } public void feedMeta() { Enumeration<Object> e = deviceList.getProperties().keys(); while (e.hasMoreElements()) { String key = (String)e.nextElement(); realnames.setProperty(deviceList.getProperty(key),key); } } public DeviceApps() { try { new File(Devices.getCurrent().getCleanDir()).mkdirs(); new File(Devices.getCurrent().getAppsDir()).mkdirs(); deviceList=new PropertiesFile("",Devices.getCurrent().getCleanDir()+fsep+"devicelist.properties"); customList=new PropertiesFile("",Devices.getCurrent().getCleanDir()+fsep+"customlist.properties"); currentList = AdbUtility.listSysApps(); updateFromDevice(); updateFromSaved(); feedMeta(); currentProfile="default"; if (!new File(Devices.getCurrent().getCleanDir()+fsep+"safelist"+currentProfile+".properties").exists()) { safeList = new PropertiesFile(); Iterator icur = deviceList.getProperties().keySet().iterator(); while (icur.hasNext()) { String key = (String)icur.next(); safeList.setProperty(key, "unsafe"); } Allsafelist.put(currentProfile,safeList); } else { safeList=new PropertiesFile("",Devices.getCurrent().getCleanDir()+fsep+"safelist"+currentProfile+".properties"); Iterator icur = deviceList.getProperties().keySet().iterator(); while (icur.hasNext()) { String key = (String)icur.next(); if (!safeList.getProperties().containsKey(key)) safeList.setProperty(key, "unsafe"); } Allsafelist.put(currentProfile,safeList); } saveProfile(currentProfile); } catch (Exception e) { e.printStackTrace(); } } public void setProfile(String profile) { currentProfile=profile; safeList = Allsafelist.get(profile); fillSet(); deviceList.write("UTF-8"); customList.write("UTF-8"); } public void saveProfile() { safeList.write(Devices.getCurrent().getCleanDir()+fsep+"safelist"+currentProfile+".properties","UTF-8"); } public void saveProfile(String name) { Allsafelist.get(currentProfile).write(Devices.getCurrent().getCleanDir()+fsep+"safelist"+name+".properties","UTF-8"); rescan(); setProfile(name.toLowerCase()); } private void fillSet() { try { Iterator<String> i = currentList.iterator(); while (i.hasNext()) { String apk = i.next(); if (safeList.getProperty(apk)==null) { safeList.setProperty(apk,"unsafe"); } } Enumeration<Object> e = safeList.getProperties().keys(); while (e.hasMoreElements()) { String apk = (String)e.nextElement(); } Iterator<Object> i1 = deviceList.keySet().iterator(); while (i1.hasNext()) { String key = (String)i1.next(); realnames.setProperty(deviceList.getProperty(key), key); } } catch (Exception e) { } } public Set<String> getProfiles() { return Allsafelist.keySet(); } public HashSet<String> getCurrent() { return currentList; } public String getRealName(String apk) { return deviceList.getProperty(apk); } public String getApkName(String realName) { return realnames.getProperty(realName); } public void setSafe(String apkName) { safeList.setProperty(apkName, "safe"); if (apkName.endsWith(".apk")) { String odex = apkName.replace(".apk",".odex"); if (safeList.keySet().contains(odex)) safeList.setProperty(odex, "safe"); } } public void setUnsafe(String apkName) { safeList.setProperty(apkName, "unsafe"); if (apkName.endsWith(".apk")) { String odex = apkName.replace(".apk",".odex"); if (safeList.keySet().contains(odex)) safeList.setProperty(odex, "unsafe"); } } public Vector<String> getToBeRemoved(boolean withodex) { Vector<String> v = new Vector<String>(); Iterator<String> ic = currentList.iterator(); while (ic.hasNext()) { String apk=ic.next(); if (apk.endsWith(".apk") || withodex==true) if (safeList.getProperty(apk).equals("safe")) v.add(deviceList.getProperty(apk)); } return v; } public Vector<String> getRemoved(boolean withodex) { Vector<String> v = new Vector<String>(); Iterator<Object> il = safeList.keySet().iterator(); while (il.hasNext()) { String apk=(String)il.next(); if (apk.endsWith(".apk") || withodex==true) if (!currentList.contains(apk) && safeList.getProperty(apk).equals("safe")) { if (new File((Devices.getCurrent().getAppsDir()+fsep+apk)).exists()) v.add(deviceList.getProperty(apk)); } } return v; } public Vector<String> getToBeInstalled(boolean withodex) { Vector<String> v = new Vector<String>(); Iterator<Object> il = safeList.keySet().iterator(); while (il.hasNext()) { String apk=(String)il.next(); if (apk.endsWith(".apk") || withodex==true) if (!currentList.contains(apk) && safeList.getProperty(apk).equals("unsafe")) { if (new File((Devices.getCurrent().getAppsDir()+fsep+apk)).exists()) v.add(deviceList.getProperty(apk)); } } return v; } public Vector<String> getInstalled(boolean withodex) { Vector<String> v = new Vector<String>(); Iterator<String> ic = currentList.iterator(); while (ic.hasNext()) { String apk=ic.next(); if (apk.endsWith(".apk") || withodex==true) if (safeList.getProperty(apk).equals("unsafe")) v.add(deviceList.getProperty(apk)); } return v; } }
8,936
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
WidgetTask.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/WidgetTask.java
package org.flashtool.gui.tools; import java.util.Properties; import java.util.Vector; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.ToolItem; import org.flashtool.flashsystem.Flasher; import org.flashtool.gui.BLUWizard; import org.flashtool.gui.BootModeSelector; import org.flashtool.gui.BundleCreator; import org.flashtool.gui.BusyboxSelector; import org.flashtool.gui.DeviceSelector; import org.flashtool.gui.FileSelector; import org.flashtool.gui.LoaderSelect; import org.flashtool.gui.RootPackageSelector; import org.flashtool.gui.TABackupSelector; import org.flashtool.gui.TARestore; import org.flashtool.gui.VariantSelector; import org.flashtool.gui.WaitDeviceForFastboot; import org.flashtool.gui.WaitDeviceForFlashmode; import org.flashtool.system.Devices; import lombok.extern.slf4j.Slf4j; @Slf4j public class WidgetTask { public static void setEnabled(final ToolItem item, final boolean status) { Display.getDefault().asyncExec( new Runnable() { public void run() { item.setEnabled(status); } } ); } public static void setButtonText(final Button item, final String text) { Display.getDefault().asyncExec( new Runnable() { public void run() { item.setText(text); } } ); } public static void setMenuName(final MenuItem item, final String text) { Display.getDefault().syncExec( new Runnable() { public void run() { item.setText(text); } } ); } public static void setEnabled(final MenuItem item, final boolean status) { Display.getDefault().asyncExec( new Runnable() { public void run() { WidgetTask.setMenuEnabled(item, status); } } ); } private static void setMenuEnabled(MenuItem item, boolean status) { if (item.getMenu()!=null) {; MenuItem[] mit = item.getMenu().getItems(); for (int i=0;i<mit.length;i++) WidgetTask.setMenuEnabled(mit[i],status); } item.setEnabled(status); } public static void setEnabled(final Button item, final boolean status) { Display.getDefault().asyncExec( new Runnable() { public void run() { item.setEnabled(status); } } ); } public static String openDeviceSelector(final Shell parent) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { DeviceSelector dial = new DeviceSelector(parent,SWT.PRIMARY_MODAL | SWT.SHEET); Object obj = dial.open(); if (obj==null) obj = new String(""); res.setResult(obj); } } ); return (String)res.getResult(); } public static String getPartition(Vector<String> vFiles, final Shell parent) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { FileSelector fs = new FileSelector(parent, SWT.PRIMARY_MODAL | SWT.SHEET); Object obj = fs.open(vFiles); if (obj==null) obj = new String(""); res.setResult(obj); } } ); return (String)res.getResult(); } public static String openVariantSelector(final String devid, final Shell parent) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { VariantSelector vs = new VariantSelector(parent,SWT.PRIMARY_MODAL | SWT.SHEET); String obj = (String)vs.open(Devices.getDevice(devid).getVariantList()); if (obj==null) obj = new String(devid); res.setResult(obj); } } ); return (String)res.getResult(); } public static String openBusyboxSelector(final Shell parent) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { BusyboxSelector dial = new BusyboxSelector(parent,SWT.PRIMARY_MODAL | SWT.SHEET); Object obj = dial.open(); if (obj==null) obj = new String(""); res.setResult(obj); } } ); return (String)res.getResult(); } public static String openDeviceSelector(final Shell parent, final Properties p) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { DeviceSelector dial = new DeviceSelector(parent,SWT.PRIMARY_MODAL | SWT.SHEET); Object obj = dial.open(p); if (obj==null) obj = new String(""); res.setResult(obj); } } ); return (String)res.getResult(); } public static String openLoaderSelect(final Shell parent) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { LoaderSelect dial = new LoaderSelect(parent,SWT.PRIMARY_MODAL | SWT.SHEET); Object obj = dial.open(); res.setResult(obj); } } ); return (String)res.getResult(); } public static String openBundleCreator(final Shell parent, final String folder) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { BundleCreator cre = new BundleCreator(parent,SWT.PRIMARY_MODAL | SWT.SHEET); Object obj = cre.open(folder); res.setResult(obj); } } ); return (String)res.getResult(); } public static String openBLWizard(final Shell parent, final String serial, final String imei, final String ulcode, final Flasher flash, final String mode) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { BLUWizard wiz = new BLUWizard(parent,SWT.PRIMARY_MODAL | SWT.SHEET); Object obj = wiz.open(serial,imei,ulcode,flash,mode); res.setResult(obj); } } ); return (String)res.getResult(); } public static String openBootModeSelector(final Shell parent) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { BootModeSelector dial = new BootModeSelector(parent,SWT.PRIMARY_MODAL | SWT.SHEET); Object obj = dial.open(); res.setResult(obj); } } ); return (String)res.getResult(); } public static String openRootPackageSelector(final Shell parent) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { RootPackageSelector dial = new RootPackageSelector(parent,SWT.PRIMARY_MODAL | SWT.SHEET); Object obj = dial.open(); res.setResult(obj); } } ); return (String)res.getResult(); } /* public static String openTABackupSets(final Shell parent) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { TABackupSet dial = new TABackupSet(parent,SWT.PRIMARY_MODAL | SWT.SHEET); Object obj = dial.open(); res.setResult(obj); } } ); return (String)res.getResult(); }*/ public static String openTABackupSelector(final Shell parent) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { TABackupSelector dial = new TABackupSelector(parent,SWT.PRIMARY_MODAL | SWT.SHEET); Object obj = dial.open(); res.setResult(obj); } } ); return (String)res.getResult(); } public static String openWaitDeviceForFlashmode(final Shell parent) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { WaitDeviceForFlashmode dial = new WaitDeviceForFlashmode(parent,SWT.PRIMARY_MODAL | SWT.SHEET); Object obj = dial.open(); res.setResult(obj); } } ); return (String)res.getResult(); } public static String openWaitDeviceForFastboot(final Shell parent) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { WaitDeviceForFastboot dial = new WaitDeviceForFastboot(parent,SWT.PRIMARY_MODAL | SWT.SHEET); Object obj = dial.open(); res.setResult(obj); } } ); return (String)res.getResult(); } public static String openOKBox(final Shell parent,final String message) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { MessageBox mb = new MessageBox(parent,SWT.ICON_INFORMATION|SWT.OK); mb.setText("Information"); mb.setMessage(message); int result = mb.open(); res.setResult(String.valueOf(result)); } } ); return (String)res.getResult(); } public static String openYESNOBox(final Shell parent,final String message) { final Result res = new Result(); Display.getDefault().syncExec( new Runnable() { public void run() { MessageBox mb = new MessageBox(parent,SWT.ICON_INFORMATION|SWT.YES|SWT.NO); mb.setText("Question"); mb.setMessage(message); int result = mb.open(); res.setResult(String.valueOf(result)); } } ); return (String)res.getResult(); } public static class Result { private Object _res=null; public Object getResult() { return _res; } public void setResult(Object res) { _res = res; } } }
9,461
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
ExtractSinDataJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/ExtractSinDataJob.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.gui.TARestore; import org.flashtool.parsers.sin.SinFile; import lombok.extern.slf4j.Slf4j; @Slf4j public class ExtractSinDataJob extends Job { boolean canceled = false; SinFile sin; private String mode="raw"; public ExtractSinDataJob(String name) { super(name); } public void setSin(SinFile f) { sin=f; } public void setMode(String m) { mode = m; } protected IStatus run(IProgressMonitor monitor) { try { if (mode.equals("data")) { log.info("Starting data extraction"); sin.dumpImage(); } else if (mode.equals("raw")) log.error("this feature is not implemented"); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); return Status.CANCEL_STATUS; } } }
1,014
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
WriteTAJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/WriteTAJob.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.flashsystem.Flasher; import org.flashtool.gui.TARestore; import org.flashtool.parsers.ta.TAUnit; import lombok.extern.slf4j.Slf4j; @Slf4j public class WriteTAJob extends Job { Flasher flash = null; TAUnit ta = null; boolean canceled = false; boolean success = false; public boolean writeSuccess() { return success; } public WriteTAJob(String name) { super(name); } public void setFlash(Flasher f) { flash=f; } public void setTA(TAUnit t) { ta=t; } protected IStatus run(IProgressMonitor monitor) { try { flash.writeTA(2,ta); success=true; return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); return Status.CANCEL_STATUS; } } }
953
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
XMLPartitionDelivery.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/XMLPartitionDelivery.java
package org.flashtool.gui.tools; import org.eclipse.swt.widgets.Shell; import org.flashtool.flashsystem.CommandFlasher.EmmcInfos; import org.flashtool.flashsystem.CommandFlasher.UfsInfos; import org.flashtool.parsers.sin.SinFile; import org.jdom2.input.SAXBuilder; import lombok.extern.slf4j.Slf4j; import org.jdom2.Document; import org.jdom2.JDOMException; import org.jdom2.Element; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Enumeration; import java.util.Iterator; import java.util.Vector; @Slf4j public class XMLPartitionDelivery { private Vector<String> partitions = new Vector<String>(); String folder = ""; UfsInfos ufs_infos = null; EmmcInfos emmc_infos=null; public XMLPartitionDelivery(File xmlsource) throws IOException, JDOMException { SAXBuilder builder = new SAXBuilder(); FileInputStream fin = new FileInputStream(xmlsource); Document document = builder.build(fin); document.getRootElement().getChild("PARTITION_IMAGES"); //String spaceid = document.getRootElement().getAttribute("SPACE_ID").getValue(); Iterator<Element> i=document.getRootElement().getChild("PARTITION_IMAGES").getChildren().iterator(); while (i.hasNext()) { Element e = i.next(); partitions.addElement(e.getAttributeValue("PATH")); } fin.close(); } public void setEmmcInfos(EmmcInfos infos) { emmc_infos = infos; } public void setUfsInfos(UfsInfos infos) { ufs_infos = infos; } public String getMatchingFile(String match, Shell shell) { Vector<String> matched = new Vector<String>(); Vector<String> keep = new Vector<String>(); for (String name:partitions) { if (SinFile.getShortName(name).equals(match)) matched.add(name); } if (matched.size()>0) { if (emmc_infos!=null) { for (String f:matched) { if (f.contains(String.valueOf(emmc_infos.getDiskSize()))) keep.add(f); } } else if (ufs_infos!=null) { String size=""; if (match.contains("LUN0")) size=String.valueOf(ufs_infos.getLunSize(0)); if (match.contains("LUN1")) size=String.valueOf(ufs_infos.getLunSize(1)); if (match.contains("LUN2")) size=String.valueOf(ufs_infos.getLunSize(2)); if (match.contains("LUN3")) size=String.valueOf(ufs_infos.getLunSize(3)); if (match.contains("LUN4")) size=String.valueOf(ufs_infos.getLunSize(4)); if (match.contains("LUN5")) size=String.valueOf(ufs_infos.getLunSize(5)); if (match.contains("LUN6")) size=String.valueOf(ufs_infos.getLunSize(6)); for (String f : matched) { if (f.contains(size)) { keep.add(f); } } if (keep.size()>0) { matched.clear(); matched=keep; } } } if (matched.size()==1) return (folder.length()>0?folder+"/":"")+matched.get(0); if (matched.size()>0) { String result=WidgetTask.getPartition(matched, shell); if (result.length() > 0) return (folder.length()>0?folder+"/":"")+result; else return null; } return null; } public void setFolder(String folder) { this.folder=folder+File.separator+"partition"; } public Enumeration<String> getFiles() { return partitions.elements(); } }
3,167
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
BLUnlockJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/BLUnlockJob.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.gui.TARestore; import org.flashtool.jna.adb.FastbootUtility; import org.flashtool.system.RunOutputs; import lombok.extern.slf4j.Slf4j; @Slf4j public class BLUnlockJob extends Job { String ulcode; boolean canceled = false; boolean unlocksuccess = true; public boolean unlockSuccess() { return unlocksuccess; } public BLUnlockJob(String name) { super(name); } public void setULCode(String code) { ulcode = code; } protected IStatus run(IProgressMonitor monitor) { try { if (FastbootUtility.getDevices().hasMoreElements()) { RunOutputs out = FastbootUtility.unlock(ulcode); if (out.getStdErr().contains("FAIL") || out.getStdOut().contains("FAIL")) unlocksuccess = false; if (unlocksuccess) { log.info("Device will reboot into system now"); FastbootUtility.rebootDevice(); } } else { log.error("Your device must be in fastboot mode"); log.error("Please restart it in fastboot mode"); } return Status.OK_STATUS; } catch (Exception exc) { log.error(exc.getMessage()); exc.printStackTrace(); return Status.CANCEL_STATUS; } } }
1,372
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
VersionCheckerJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/VersionCheckerJob.java
package org.flashtool.gui.tools; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.Iterator; import java.util.Properties; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.widgets.Display; import org.flashtool.gui.About; import org.flashtool.gui.TARestore; import org.flashtool.system.OS; import org.flashtool.system.Proxy; import org.jdom2.Document; import org.jdom2.Element; import org.jdom2.input.SAXBuilder; import lombok.extern.slf4j.Slf4j; @Slf4j public class VersionCheckerJob extends Job { static org.eclipse.swt.widgets.Shell _s = null; private boolean aborted=false; private boolean ended = false; private InputStream ustream=null; private HttpURLConnection uconn=null; public VersionCheckerJob(String name) { super(name); } public void setMessageFrame(org.eclipse.swt.widgets.Shell s) { _s = s; } public String getLatestRelease() { try { SAXBuilder builder = new SAXBuilder(); Document doc = null; log.debug("Resolving github"); if (Proxy.canResolve("github.com")) { log.debug("Finished resolving github. Result : Success"); URL u; if (About.build==null) throw new Exception("no version"); if (OS.getChannel().equals("beta")) u = new URL("https://github.com/Androxyde/Flashtool/raw/master/ant/deploy-beta.xml"); else u = new URL("https://github.com/Androxyde/Flashtool/raw/master/gradle.properties"); log.debug("opening connection"); if (!aborted) uconn = (HttpURLConnection) u.openConnection(); if (!aborted) uconn.setConnectTimeout(5 * 1000); if (!aborted) uconn.setRequestMethod("GET"); if (!aborted) uconn.connect(); log.debug("Getting stream on connection"); if (!aborted) ustream = uconn.getInputStream(); if (ustream!=null) log.debug("stream opened"); Properties p = new Properties(); p.load(ustream); ustream.close(); return p.getProperty("flashtoolVersion"); } else { log.debug("Finished resolving github. Result : Failed"); return ""; } } catch (Exception e) { return "noversion"; } } protected IStatus run(IProgressMonitor monitor) { String netrelease = ""; int nbretry = 0; while (netrelease.length()==0 && !aborted) { log.debug("Fetching latest release from github"); netrelease = getLatestRelease(); if (netrelease.length()==0) { if (!aborted) log.debug("Url content not fetched. Retrying "+nbretry+" of 10"); nbretry++; if (nbretry<10) { try { Thread.sleep(1000); } catch (Exception e1) {} } else aborted=true; } } log.debug("out of loop"); final String latest = netrelease; log.debug("Latest : " + latest); log.debug("Current build : "+About.build); ended = true; if (About.build!=null) { if (latest.length()>0 && !About.build.contains(latest)) { if (_s!=null) { Display.getDefault().syncExec( new Runnable() { public void run() { _s.setText(_s.getText()+" --- New version "+latest+" available ---"); } } ); } } } return Status.OK_STATUS; } public void done() { if (!ended) { ended = true; log.debug("aborting job"); aborted=true; if (uconn!=null) try { log.debug("closing connection"); uconn.disconnect(); } catch (Exception e) { log.debug("Error : "+e.getMessage()); } } } }
3,723
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
Yaffs2Job.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/Yaffs2Job.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.gui.TARestore; import org.flashtool.system.OS; import lombok.extern.slf4j.Slf4j; @Slf4j public class Yaffs2Job extends Job { String _fname = ""; public void setFilename(String fname) { _fname = fname; } public Yaffs2Job(String name) { super(name); } protected IStatus run(IProgressMonitor monitor) { try { int index = _fname.lastIndexOf(".yaffs2"); String folder = _fname.substring(0, index)+"_content"; log.info("Extracting " + _fname + " to " + folder); OS.unyaffs(_fname, folder); log.info("Extraction finished"); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); return Status.CANCEL_STATUS; } } }
934
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
XMLRebrand.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/XMLRebrand.java
package org.flashtool.gui.tools; import org.jdom2.input.SAXBuilder; import lombok.extern.slf4j.Slf4j; import org.flashtool.gui.TARestore; import org.jdom2.Document; import org.jdom2.JDOMException; import org.jdom2.Element; import java.io.File; import java.io.IOException; import java.util.Enumeration; import java.util.Iterator; import java.util.Vector; @Slf4j public class XMLRebrand { private Document document; public XMLRebrand(File xmlsource) throws IOException, JDOMException { SAXBuilder builder = new SAXBuilder(); document = builder.build(xmlsource); } public Enumeration<String> getDevices() { Vector<String> devs = new Vector<String>(); Iterator<Element> i=document.getRootElement().getChildren().iterator(); while (i.hasNext()) { Element elem = i.next(); devs.add(elem.getAttributeValue("name")); } return devs.elements(); } public Enumeration<String> getBrands(String device) { Vector<String> brands = new Vector<String>(); Iterator<Element> i=document.getRootElement().getChildren().iterator(); while (i.hasNext()) { Element elem = i.next(); if (elem.getAttributeValue("name").equals(device)) { Iterator<Element> i1=elem.getChildren().iterator(); while (i1.hasNext()) { Element elem1 = i1.next(); brands.add(elem1.getAttributeValue("name")); } return brands.elements(); } } return null; } public boolean hasId(String device,String id) { boolean hasid = false; Iterator<Element> i=document.getRootElement().getChildren().iterator(); while (i.hasNext()) { Element elem = i.next(); if (elem.getAttributeValue("name").equals(device)) { Iterator<Element> i1=elem.getChildren().iterator(); while (i1.hasNext()) { Element elem1 = i1.next(); if (elem1.getAttributeValue("value").equals(id)) hasid = true; } } } return hasid; } public String getId(String device, String brand) { Iterator<Element> i=document.getRootElement().getChildren().iterator(); while (i.hasNext()) { Element elem = i.next(); if (elem.getAttributeValue("name").equals(device)) { Iterator<Element> i1=elem.getChildren().iterator(); while (i1.hasNext()) { Element elem1 = i1.next(); if (elem1.getAttributeValue("name").equals(brand)) return elem1.getAttributeValue("value"); } } } return null; } }
2,474
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
RawTAJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/RawTAJob.java
package org.flashtool.gui.tools; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Enumeration; import java.util.Properties; import java.util.jar.Attributes; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; import java.util.zip.Deflater; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.widgets.Shell; import org.flashtool.gui.TARestore; import org.flashtool.jna.adb.AdbUtility; import org.flashtool.system.Devices; import org.flashtool.system.OS; import lombok.extern.slf4j.Slf4j; @Slf4j public class RawTAJob extends Job { String _action = ""; Shell _shell; String phonetemp = "/data/local/tmp"; String tafilename = "ta.dd"; String tafilenamebefore="tabefore.dd"; public void setAction(String action) { _action = action; } public void setShell(Shell shell) { _shell = shell; } public RawTAJob(String name) { super(name); } protected IStatus run(IProgressMonitor monitor) { try { if (_action.equals("doBackup")) doBackup(); if (_action.equals("doRestore")) doRestore(); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); return Status.CANCEL_STATUS; } } public void doBackup() { String serial = Devices.getCurrent().getSerial(); String folder = OS.getFolderRegisteredDevices()+File.separator+serial+File.separator+"rawta"; try { if (Devices.getCurrent().hasRoot()) { if (!Devices.getCurrent().isBusyboxInstalled(false)) Devices.getCurrent().doBusyboxHelper(); new File(folder).mkdirs(); String partition = AdbUtility.run("su -c 'export PATH=$PATH:/data/local/tmp;busybox find /dev/block/platform -name TA'"); if (!AdbUtility.existsRoot(partition)) { partition = AdbUtility.run("export PATH=$PATH:/data/local/tmp;busybox cat /proc/partitions|busybox grep -w 2048|busybox awk '{print $4}'"); if (partition.length()==0) throw new Exception("Your phone is not compatible"); partition = "/dev/block/"+partition; } log.info("Begin backup of "+partition); long transferred = AdbUtility.rawBackup(partition, phonetemp+File.separator+tafilename); if (transferred == 0L) throw new Exception("Erreur when doing raw backup"); Properties hash = new Properties(); hash.setProperty("partition", AdbUtility.getMD5(partition)); AdbUtility.pull(phonetemp+File.separator+tafilename, folder); AdbUtility.run("rm -f "+phonetemp+File.separator+tafilename); hash.setProperty("local", OS.getMD5(new File(folder+File.separator+tafilename)).toUpperCase()); log.info("End of backup"); if (hash.getProperty("local").equals(hash.getProperty("partition"))) { log.info("Backup is OK"); createFTA(partition, folder); } else throw new Exception("Backup is not OK"); } else { log.info("Device not rooted. Trying to backup ta using dirtycow exploit"); AdbUtility.run("rm -f /data/local/tmp/*"); String platform = Devices.getCurrent().getArch(); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"dirtycow"+File.separator+"backupTA.sh", "/data/local/tmp/"); AdbUtility.run("chmod 755 /data/local/tmp/backupTA.sh"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"dirtycow"+File.separator+"dirtycow"+platform, "/data/local/tmp/dirtycow"); AdbUtility.run("chmod 755 /data/local/tmp/dirtycow"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"dirtycow"+File.separator+"dumpta"+platform, "/data/local/tmp/dumpta"); AdbUtility.run("chmod 755 /data/local/tmp/dumpta"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"dirtycow"+File.separator+"exploitta"+platform, "/data/local/tmp/exploitta"); AdbUtility.run("chmod 755 /data/local/tmp/exploitta"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"dirtycow"+File.separator+"run-as"+platform, "/data/local/tmp/run-as"); AdbUtility.run("chmod 755 /data/local/tmp/run-as"); AdbUtility.run("cd /data/local/tmp && ./backupTA.sh "+tafilename); if (AdbUtility.exists("/data/local/tmp/"+tafilename)) { new File(folder).mkdirs(); AdbUtility.pull("/data/local/tmp/"+tafilename, folder); } AdbUtility.run("rm -f /data/local/tmp/*"); AdbUtility.run("rm -f /sdcard/dumpta"); File tafile=new File(folder+File.separator+tafilename); if (tafile.exists()) { if (tafile.length()==(2*1024*1024)) { createFTA("", folder); } else { log.error("dirtycow expoit failed. No ta backup done"); } } else { log.error("dirtycow expoit failed. No ta backup done"); } } } catch (Exception ex) { new File(folder+tafilename).delete(); try { AdbUtility.run("rm -f "+phonetemp+File.separator+tafilename); } catch (Exception ex1) {} log.error(ex.getMessage()); } } public void doRestore() { String serial = Devices.getCurrent().getSerial(); String folder = OS.getFolderRegisteredDevices()+File.separator+serial+File.separator+"rawta"; String folderprepared = folder+File.separator+"prepared"; try { if (!Devices.getCurrent().isBusyboxInstalled(false)) Devices.getCurrent().doBusyboxHelper(); File srcdir = new File(folder); String backupset=""; if (srcdir.exists()) { File[] chld = srcdir.listFiles(); if (chld.length>0) backupset = WidgetTask.openTABackupSelector(_shell); else log.info("No backup"); } else log.info("No backup"); if (backupset.length()==0) { throw new Exception("Operation canceled"); } backupset = backupset.split(":")[0].trim(); backupset = folder+File.separator+backupset+".fta"; JarFile jf = new JarFile(new File(backupset)); Attributes attr = jf.getManifest().getMainAttributes(); String partition = attr.getValue("partition"); File prepared = new File(folderprepared); if (prepared.exists()) { OS.deleteDirectory(prepared); if (prepared.exists()) { jf.close(); throw new Exception("Cannot delete previous folder : "+prepared.getAbsolutePath()); } } prepared.mkdirs(); Enumeration<JarEntry> ents = jf.entries(); while (ents.hasMoreElements()) { JarEntry entry = ents.nextElement(); if (!entry.getName().startsWith("META")) saveEntry(jf,entry, folderprepared); } Properties hash = new Properties(); hash.setProperty("stored", attr.getValue("md5")); if (!new File(folderprepared+File.separator+tafilename).exists()) throw new Exception(folderprepared+File.separator+tafilename+" does not exist"); hash.setProperty("local", OS.getMD5(new File(folderprepared+File.separator+tafilename)).toUpperCase()); if (!hash.getProperty("stored").equals(hash.getProperty("local"))) throw new Exception("Error during extraction. Bundle is corrupted"); AdbUtility.push(folderprepared+File.separator+tafilename,phonetemp); hash.setProperty("remote", AdbUtility.getMD5(phonetemp+"/"+tafilename)); if (!hash.getProperty("local").equals(hash.getProperty("remote"))) throw new Exception("Local file and remote file do not match"); hash.setProperty("partitionbefore", AdbUtility.getMD5(partition)); if (hash.getProperty("remote").equals(hash.getProperty("partitionbefore"))) throw new Exception("Backup and current partition match. Nothing to be done. Aborting"); log.info("Making a backup on device before flashing."); long transferred = AdbUtility.rawBackup(partition, phonetemp+"/"+tafilenamebefore); if (transferred == 0) throw new Exception("Failed to take a backup before flashing new TA. Aborting"); log.info("Flashing new TA."); transferred = AdbUtility.rawBackup(phonetemp+"/"+tafilename, partition); hash.setProperty("partitionafter", AdbUtility.getMD5(partition)); if (!hash.getProperty("remote").equals(hash.getProperty("partitionafter"))) { log.error("Error flashing new TA. Reverting back to the previous TA."); transferred = AdbUtility.rawBackup(phonetemp+"/"+tafilenamebefore, partition); if (transferred == 0L) throw new Exception("Failed to restore previous TA"); log.info("Restore previous TA OK"); } else { log.info("Restore is OK"); Devices.getCurrent().reboot(); } } catch (Exception e) { log.error(e.getMessage()); } } public void createFTA(String partition, String folder) { File tadd = new File(folder+File.separator+tafilename); String timestamp = OS.getTimeStamp(); File fta = new File(folder+File.separator+timestamp+".fta"); byte buffer[] = new byte[10240]; StringBuffer sbuf = new StringBuffer(); sbuf.append("Manifest-Version: 1.0\n"); sbuf.append("Created-By: FlashTool\n"); sbuf.append("serial: "+Devices.getCurrent().getSerial()+"\n"); sbuf.append("build: "+Devices.getCurrent().getBuildId()+"\n"); sbuf.append("partition: "+partition+"\n"); sbuf.append("md5: "+OS.getMD5(tadd).toUpperCase()+"\n"); sbuf.append("timestamp: "+timestamp+"\n"); try { Manifest manifest = new Manifest(new ByteArrayInputStream(sbuf.toString().getBytes("UTF-8"))); FileOutputStream stream = new FileOutputStream(fta); JarOutputStream out = new JarOutputStream(stream, manifest); out.setLevel(Deflater.BEST_SPEED); log.info("Creating backupset bundle"); JarEntry jarAdd = new JarEntry(tafilename); out.putNextEntry(jarAdd); InputStream in = new FileInputStream(tadd); while (true) { int nRead = in.read(buffer, 0, buffer.length); if (nRead <= 0) break; out.write(buffer, 0, nRead); } in.close(); out.flush(); out.close(); stream.flush(); stream.close(); tadd.delete(); log.info("Bundle "+fta.getAbsolutePath()+" creation finished"); } catch (Exception e) { log.error(e.getMessage()); } } private void saveEntry(JarFile jar, JarEntry entry, String folder) throws IOException { log.debug("Saving entry "+entry.getName()+" to disk"); InputStream in = jar.getInputStream(entry); String outname = folder+File.separator+entry.getName(); log.debug("Writing Entry to "+outname); OutputStream out = new BufferedOutputStream(new FileOutputStream(outname)); byte[] buffer = new byte[10240]; int len; while((len = in.read(buffer)) >= 0) out.write(buffer, 0, len); in.close(); out.close(); } }
10,861
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
CreateSinAsJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/CreateSinAsJob.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.gui.TARestore; import org.flashtool.system.OS; import org.flashtool.system.ProcessBuilderWrapper; import lombok.extern.slf4j.Slf4j; @Slf4j public class CreateSinAsJob extends Job { boolean canceled = false; String file; String partition; String spareinfo; public CreateSinAsJob(String name) { super(name); } public void setFile(String f) { file=f; } public void setPartition(String part) { partition = part; } public void setSpare(String spare) { spareinfo = spare; } protected IStatus run(IProgressMonitor monitor) { if (file != null) { try { log.info("Generating sin file to "+file+".sin"); log.info("Please wait"); if (spareinfo.equals("09")) { ProcessBuilderWrapper command = new ProcessBuilderWrapper(new String[] {OS.getPathBin2Sin(),file, partition, "0x"+spareinfo,"0x20000"},false); } else { ProcessBuilderWrapper command = new ProcessBuilderWrapper(new String[] {OS.getPathBin2Sin(),file, partition, "0x"+spareinfo,"0x20000", "0x1000"},false); } log.info("Sin file creation finished"); return Status.OK_STATUS; } catch (Exception ex) { log.error(ex.getMessage()); return Status.CANCEL_STATUS; } } else { log.info("Create SIN As canceled (no selected data input"); return Status.CANCEL_STATUS; } } }
1,593
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
APKInstallJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/APKInstallJob.java
package org.flashtool.gui.tools; import java.io.File; import java.io.FilenameFilter; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.gui.TARestore; import org.flashtool.jna.adb.AdbUtility; import org.flashtool.logger.LogProgress; import lombok.extern.slf4j.Slf4j; @Slf4j class APKFilter implements FilenameFilter { public boolean accept(File dir, String name) { return (name.toUpperCase().endsWith(".APK")); } } @Slf4j public class APKInstallJob extends Job { String instpath; public APKInstallJob(String name) { super(name); } public void setFolder(String path) { instpath = path; } protected IStatus run(IProgressMonitor monitor) { try { File files = new File(instpath); File[] chld = files.listFiles(new APKFilter()); LogProgress.initProgress(chld.length); for(int i = 0; i < chld.length; i++){ if (chld[i].getName().toUpperCase().endsWith(".APK")) AdbUtility.install(chld[i].getPath()); LogProgress.updateProgress(); } LogProgress.initProgress(0); log.info("APK Installation finished"); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage()); LogProgress.initProgress(0); return Status.CANCEL_STATUS; } } }
1,423
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
RootJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/RootJob.java
package org.flashtool.gui.tools; import java.io.File; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.widgets.Shell; import org.flashtool.gui.TARestore; import org.flashtool.jna.adb.AdbUtility; import org.flashtool.system.Devices; import org.flashtool.system.FTShell; import org.flashtool.system.GlobalConfig; import org.flashtool.system.OS; import lombok.extern.slf4j.Slf4j; @Slf4j public class RootJob extends Job { boolean canceled = false; String _action = ""; String pck = ""; Shell _parent; public RootJob(String name) { super(name); } public void setParentShell(Shell s) { _parent = s; } public void setAction(String action) { _action = action; } public void setRootPackage(String ppck) { if (ppck == null) pck=""; else pck = ppck; } protected IStatus run(IProgressMonitor monitor) { try { if (_action.equals("doRootpsneuter")) doRootpsneuter(); if (_action.equals("doRootzergRush")) doRootzergRush(); if (_action.equals("doRootEmulator")) doRootEmulator(); if (_action.equals("doRootAdbRestore")) doRootAdbRestore(); if (_action.equals("doRootServiceMenu")) doRootServiceMenu(); if (_action.equals("doRootRunRootShell")) doRootRunRootShell(); if (_action.equals("doRootTowelroot")) doRootTowelroot(); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); return Status.CANCEL_STATUS; } } public void doRootzergRush() { if (pck.length()>0) { try { OS.decrypt(new File(OS.getFolderCustom()+File.separator+"root"+File.separator+"ZergRush"+File.separator+"zergrush.tar.uue.enc")); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"ZergRush"+File.separator+"zergrush.tar.uue",GlobalConfig.getProperty("deviceworkdir")); new File(OS.getFolderCustom()+File.separator+"root"+File.separator+"ZergRush"+File.separator+"zergrush.tar.uue").delete(); doPushRootFiles(pck,false); FTShell shell = new FTShell("rootit"); log.info("Running part1 of Root Exploit, please wait"); shell.run(true); Devices.waitForReboot(true); if (AdbUtility.hasRootNative(true)) { log.info("Running part2 of Root Exploit"); shell = new FTShell("rootit2"); shell.run(false); log.info("Finished!."); log.info("Root should be available after reboot!"); } else { log.error("The part1 exploit did not work"); log.info("Cleaning files"); AdbUtility.run("rm /data/local/tmp/zergrush"); AdbUtility.run("rm /data/local/tmp/busybox"); AdbUtility.run("rm /data/local/tmp/Superuser.apk"); AdbUtility.run("rm /data/local/tmp/su"); AdbUtility.run("rm /data/local/tmp/rootit"); AdbUtility.run("rm /data/local/tmp/rootit2"); } } catch (Exception e) { log.error(e.getMessage()); } } } public void doRootpsneuter() { try { if (pck.length()>0) { OS.decrypt(new File(OS.getFolderCustom()+File.separator+"root"+File.separator+"PsNeuter"+File.separator+"psneuter.tar.uue.enc")); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"PsNeuter"+File.separator+"psneuter.tar.uue",GlobalConfig.getProperty("deviceworkdir")); new File(OS.getFolderCustom()+File.separator+"root"+File.separator+"PsNeuter"+File.separator+"psneuter.tar.uue").delete(); doPushRootFiles(pck,false); FTShell shell = new FTShell("rootit"); log.info("Running part1 of Root Exploit, please wait"); shell.run(false); Devices.waitForReboot(true); if (AdbUtility.hasRootNative(true)) { log.info("Running part2 of Root Exploit"); shell = new FTShell("rootit2"); shell.run(false); log.info("Finished!."); log.info("Root should be available after reboot!"); } else { log.error("The part1 exploit did not work"); log.info("Cleaning files"); AdbUtility.run("rm /data/local/tmp/psneuter"); AdbUtility.run("rm /data/local/tmp/busybox"); AdbUtility.run("rm /data/local/tmp/Superuser.apk"); AdbUtility.run("rm /data/local/tmp/su"); AdbUtility.run("rm /data/local/tmp/rootit"); AdbUtility.run("rm /data/local/tmp/rootit2"); } } } catch (Exception e) { log.error(e.getMessage()); } } public void doRootEmulator() { try { if (pck.length()>0) { log.info("Preparing first part of the hack"); AdbUtility.run("cd /data/local && mkdir tmp"); AdbUtility.run("cd /data/local/tmp/ && rm *"); AdbUtility.run("mv /data/local/tmp /data/local/tmp.bak"); AdbUtility.run("ln -s /data /data/local/tmp"); log.info("Rebooting device. Please wait"); Devices.getCurrent().reboot(); Devices.waitForReboot(false); log.info("Preparing second part of the hack"); AdbUtility.run("rm /data/local.prop"); AdbUtility.run("echo \"ro.kernel.qemu=1\" > /data/local.prop"); log.info("Rebooting device. Please wait"); Devices.getCurrent().reboot(); Devices.waitForReboot(false); if (AdbUtility.hasRootNative(true)) { log.info("Now you have root"); log.info("Remounting system r/w"); AdbUtility.run("mount -o remount,rw /system"); log.info("Installing root package"); doPushRootFiles(pck,true); log.info("Cleaning hack"); AdbUtility.run("rm /data/local.prop"); AdbUtility.run("rm /data/local/tmp"); AdbUtility.run("mv /data/local/tmp.bak /data/local/tmp"); log.info("Rebooting device. Please wait. Your device is now rooted"); Devices.getCurrent().reboot(); } else { AdbUtility.run("rm /data/local.prop"); AdbUtility.run("rm /data/local/tmp"); AdbUtility.run("mv /data/local/tmp.bak /data/local/tmp"); log.info("Hack did not work. Cleaning and rebooting"); Devices.getCurrent().reboot(); } } } catch (Exception e) { e.printStackTrace(); } } public void doRootAdbRestore() { try { if (pck.length()>0) { doPushRootFiles(pck,false); String backuppackage = AdbUtility.run("pm list package -f com.sonyericsson.backuprestore"); if (backuppackage.contains("backuprestore")) { AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"AdbRestore"+File.separator+"RootMe.tar", GlobalConfig.getProperty("deviceworkdir")+"/RootMe.tar"); AdbUtility.run("mkdir /mnt/sdcard/.semc-fullbackup > /dev/null 2>&1"); AdbUtility.run("rm -r /mnt/sdcard/.semc-fullbackup/RootMe* > /dev/null 2>&1"); AdbUtility.run("cd /mnt/sdcard/.semc-fullbackup;/data/local/tmp/busybox tar xf /data/local/tmp/RootMe.tar"); AdbUtility.run("am start com.sonyericsson.vendor.backuprestore/.ui.BackupActivity"); log.info("Now open your device and restore \"RootMe\" backup. Waiting ..."); } else { AdbUtility.restore(OS.getFolderCustom()+File.separator+"root"+File.separator+"AdbRestore"+File.separator+"fakebackup.ab"); log.info("Please look at your device and click RESTORE!"); } String delay = "60"; log.info("You have "+delay+" seconds to follow the restore advice"); FTShell exploit = new FTShell("adbrestoreexploit"); exploit.setProperty("DELAY", delay); String result = exploit.run(false); if (result.contains("Success")) { log.info("Restore worked fine. Rebooting device. Please wait ..."); Devices.getCurrent().reboot(); Devices.waitForReboot(false); if (AdbUtility.hasRootNative(true)) { log.info("Root achieved. Installing root files. Device will reboot. Please wait."); doInstallRootFiles(); Devices.waitForReboot(false); log.info("Cleaning hack files"); AdbUtility.run("rm /data/local/tmp/busybox;rm -r /mnt/sdcard/.semc-fullbackup/RootMe;rm /data/local/tmp/RootMe.tar;rm /data/local/tmp/su;rm /data/local/tmp/Superuser.apk;rm /data/local/tmp/adbrestoreexploit"); log.info("Finished."); } else { log.info("Root hack did not work."); log.info("Cleaning hack files"); AdbUtility.run("rm /data/local/tmp/busybox;rm -r /mnt/sdcard/.semc-fullbackup/RootMe;rm /data/local/tmp/RootMe.tar;rm /data/local/tmp/su;rm /data/local/tmp/Superuser.apk;rm /data/local/tmp/adbrestoreexploit"); } log.info("Rebooting device. Please wait."); Devices.getCurrent().reboot(); } else { log.info("Root hack did not work. Cleaning hack files"); AdbUtility.run("rm /data/local/tmp/busybox;rm -r /mnt/sdcard/.semc-fullbackup/RootMe;rm /data/local/tmp/RootMe.tar;rm /data/local/tmp/su;rm /data/local/tmp/Superuser.apk;rm /data/local/tmp/adbrestoreexploit"); } } else { log.info("Canceled"); } } catch (Exception e) { log.error(e.getMessage()); } } public void doRootServiceMenu() { try { if (pck.length()>0) { doPushRootFiles(pck,false); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"ServiceMenu"+File.separator+"onload.sh", "/data/local/tmp/"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"ServiceMenu"+File.separator+"getroot.sh", "/data/local/tmp/"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"ServiceMenu"+File.separator+"install-recovery.sh", "/data/local/tmp/"); AdbUtility.run("chmod 755 /data/local/tmp/onload.sh"); AdbUtility.run("chmod 755 /data/local/tmp/getroot.sh"); String semcpath = ""; if (AdbUtility.exists("/mnt/ext_card/default-capability.xml")) semcpath = "/mnt/ext_card/.semc-fullbackup"; else semcpath = "/mnt/ext_card/.semc-fullbackup"; String backuppackage = AdbUtility.run("pm list package -f com.sonyericsson.backuprestore"); if (backuppackage.contains("backuprestore")) { AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"ServiceMenu"+File.separator+"RootMe.tar", GlobalConfig.getProperty("deviceworkdir")+"/RootMe.tar"); AdbUtility.run("mkdir "+semcpath+" > /dev/null 2>&1"); AdbUtility.run("rm -r "+semcpath+"/RootMe* > /dev/null 2>&1"); AdbUtility.run("cd "+semcpath+" && /data/local/tmp/busybox tar xf /data/local/tmp/RootMe.tar"); AdbUtility.run("am start com.sonyericsson.vendor.backuprestore/.ui.BackupActivity"); AdbUtility.run("am start com.sonyericsson.vendor.backuprestore/.ui.phone.PhoneMainActivity"); WidgetTask.openOKBox(_parent, "Please look at your device and goto restore tab.\nChoose RootMe backup.\nRestore and Press OK when done!"); AdbUtility.run("rm -r "+semcpath+"/RootMe* > /dev/null 2>&1"); } else { AdbUtility.restore(OS.getFolderCustom()+File.separator+"root"+File.separator+"ServiceMenu"+File.separator+"usbux.ab"); WidgetTask.openOKBox(_parent, "Please look at your device and click RESTORE. Press OK when done!"); } AdbUtility.run("am start -a android.intent.action.MAIN -n com.sonyericsson.android.servicemenu/.ServiceMainMenu"); log.info("Look at your phone. Choose Service Test, then Display."); log.info("Waiting for uevent_helper rw"); AdbUtility.run("while : ; do [ -w /sys/kernel/uevent_helper ] && exit; done"); log.info("Waiting for rooted shell"); AdbUtility.run("echo /data/local/tmp/getroot.sh > /sys/kernel/uevent_helper"); AdbUtility.run("while : ; do [ -f /dev/sh ] && exit; done"); log.info("Root achieved. Installing root files. Device will reboot. Please wait."); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"ServiceMenu"+File.separator+"installsu.sh", "/data/local/tmp/"); AdbUtility.run("chmod 755 /data/local/tmp/installsu.sh"); AdbUtility.run("/dev/sh /data/local/tmp/installsu.sh"); if (AdbUtility.hasRootPerms()) { log.info("Device rooted. Now cleaning and rebooting. Please wait"); FTShell shell = new FTShell("rebootservicemenu"); shell.runRoot(); shell.clean(); } } else { log.info("Canceled"); } } catch (Exception e) { log.error(e.getMessage()); } } public void doRootRunRootShell() { try { if (pck.length()>0) { doPushRootFiles(pck,false); String device = AdbUtility.run("/system/bin/getprop "+ "ro.product.model"); String buildid = AdbUtility.run("/system/bin/getprop "+ "ro.build.display.id"); String config = device + "_" + buildid; File run_root_shell_enc = new File(OS.getFolderCustom()+File.separator+"root"+File.separator+"run_root_shell"+File.separator+"run_root_shell.enc"); File run_root_shell = new File(OS.getFolderCustom()+File.separator+"root"+File.separator+"run_root_shell"+File.separator+"run_root_shell"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"run_root_shell"+File.separator+"install_root.sh", "/data/local/tmp/"); OS.decrypt(run_root_shell_enc); AdbUtility.push(run_root_shell.getAbsolutePath(), "/data/local/tmp/"); run_root_shell.delete(); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"run_root_shell"+File.separator+"device.db", "/data/local/tmp/"); AdbUtility.run("chmod 755 /data/local/tmp/install_root.sh"); AdbUtility.run("chmod 755 /data/local/tmp/run_root_shell"); log.info("Trying to apply root exploit. It can be very long. Please wait ..."); AdbUtility.run("/data/local/tmp/run_root_shell -c /data/local/tmp/install_root.sh"); if (AdbUtility.hasRootPerms()) { log.info("Device rooted."); AdbUtility.pull("/data/local/tmp/device.db", OS.getFolderCustom()+File.separator+"root"+File.separator+"run_root_shell"+File.separator+"device.db"); } else { log.info("Root failed");; } log.info("Cleaning workdir"); AdbUtility.run("rm /data/local/tmp/su"); AdbUtility.run("rm /data/local/tmp/Superuser.apk"); AdbUtility.run("rm /data/local/tmp/busybox"); AdbUtility.run("rm /data/local/tmp/run_root_shell"); AdbUtility.run("rm /data/local/tmp/install_root.sh"); AdbUtility.run("rm /data/local/tmp/99SuperSUDaemon"); AdbUtility.run("rm /data/local/tmp/chattr"); AdbUtility.run("rm /data/local/tmp/device.db"); AdbUtility.run("rm /data/local/tmp/install-recovery.sh"); } else { log.info("Canceled"); } } catch (Exception e) { log.error(e.getMessage()); } } public void doRootTowelroot() { try { if (pck.length()>0) { doPushRootFiles(pck,false); String tr=OS.getFolderCustom()+File.separator+"root"+File.separator+"towelroot"+File.separator+"tr_mod.apk"; OS.decrypt(new File(tr+".enc")); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"towelroot"+File.separator+"zxz.sh", "/data/local/tmp/"); AdbUtility.run("chmod 755 /data/local/tmp/zxz.sh"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"towelroot"+File.separator+"wp_mod.ko", "/data/local/tmp/"); AdbUtility.run("chmod 644 /data/local/tmp/wp_mod.ko"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"towelroot"+File.separator+"writekmem", "/data/local/tmp/"); AdbUtility.run("chmod 755 /data/local/tmp/writekmem"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"towelroot"+File.separator+"findricaddr", "/data/local/tmp/"); AdbUtility.run("chmod 755 /data/local/tmp/findricaddr"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"towelroot"+File.separator+"modulecrcpatch", "/data/local/tmp/"); AdbUtility.run("chmod 755 /data/local/tmp/modulecrcpatch"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"towelroot"+File.separator+"install_root.sh", "/data/local/tmp/"); AdbUtility.run("chmod 755 /data/local/tmp/install_root.sh"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"towelroot"+File.separator+"install_root.sh", "/data/local/tmp/"); AdbUtility.run("chmod 755 /data/local/tmp/install_root.sh"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"towelroot"+File.separator+"antiric", "/data/local/tmp/"); AdbUtility.run("chmod 755 /data/local/tmp/antiric"); AdbUtility.install(tr); AdbUtility.run("am start -n com.geohot.towelroot/.TowelRoot"); log.info("Click the Make it ra1n button on your phone. Waiting for root"); while (!AdbUtility.hasRootPerms()) { Thread.sleep(1000); } AdbUtility.uninstall("com.geohot.towelroot", false); log.info("Installing latest su binaries"); AdbUtility.push(Devices.getCurrent().getBusybox(false), GlobalConfig.getProperty("deviceworkdir")+"/busybox"); AdbUtility.run("chown shell.shell "+GlobalConfig.getProperty("deviceworkdir")+"/busybox && chmod 755 " + GlobalConfig.getProperty("deviceworkdir")+"/busybox",true); AdbUtility.run("/system/xbin/su -c '/data/local/tmp/install_root.sh'"); log.info("Root done. Cleaning files"); AdbUtility.run("rm /data/local/tmp/99SuperSUDaemon"); AdbUtility.run("rm /data/local/tmp/Superuser.apk"); AdbUtility.run("rm /data/local/tmp/chattr"); AdbUtility.run("rm /data/local/tmp/install-recovery.sh"); AdbUtility.run("rm /data/local/tmp/install_root.sh"); AdbUtility.run("rm /data/local/tmp/kernelmodule_patch.sh"); AdbUtility.run("rm /data/local/tmp/su"); AdbUtility.run("rm /data/local/tmp/sugote-mksh"); AdbUtility.run("rm /data/local/tmp/wp_mod.ko"); AdbUtility.run("rm /data/local/tmp/zxz.sh"); AdbUtility.run("rm /data/local/tmp/writekmem"); AdbUtility.run("rm /data/local/tmp/findricaddr"); AdbUtility.run("rm /data/local/tmp/busybox"); AdbUtility.run("rm /data/local/tmp/ricaddr"); AdbUtility.run("rm /data/local/tmp/zxz_run"); AdbUtility.run("rm /data/local/tmp/antiric"); AdbUtility.run("rm /data/local/tmp/modulecrcpatch"); log.info("Rebooting device"); Devices.getCurrent().reboot(); } else { log.info("Canceled"); } } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage()); } } public void doPushRootFiles(String rootpackage, boolean direct) throws Exception { if (!direct) { AdbUtility.push(Devices.getCurrent().getBusybox(false), GlobalConfig.getProperty("deviceworkdir")+"/busybox"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"subin"+File.separator+rootpackage+File.separator+"su", GlobalConfig.getProperty("deviceworkdir")+"/su"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"subin"+File.separator+rootpackage+File.separator+"Superuser.apk", GlobalConfig.getProperty("deviceworkdir")+"/Superuser.apk"); if (rootpackage.toLowerCase().equals("supersu")) { AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"subin"+File.separator+rootpackage+File.separator+"install-recovery.sh", GlobalConfig.getProperty("deviceworkdir")+"/install-recovery.sh"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"subin"+File.separator+rootpackage+File.separator+"99SuperSUDaemon", GlobalConfig.getProperty("deviceworkdir")+"/99SuperSUDaemon"); } AdbUtility.run("chown shell.shell "+GlobalConfig.getProperty("deviceworkdir")+"/busybox && chmod 755 " + GlobalConfig.getProperty("deviceworkdir")+"/busybox",true); } else { AdbUtility.push(Devices.getCurrent().getBusybox(false), "/system/xbin"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"subin"+File.separator+rootpackage+File.separator+"su", "/system/xbin"); AdbUtility.push(OS.getFolderCustom()+File.separator+"root"+File.separator+"subin"+File.separator+rootpackage+File.separator+"Superuser.apk", "/system/app"); AdbUtility.run("chown root.shell /system/xbin/su"); AdbUtility.run("chmod 06755 /system/xbin/su"); AdbUtility.run("chown root.shell /system/xbin/busybox"); AdbUtility.run("chmod 755 /system/xbin/busybox"); } } public void doInstallRootFiles() throws Exception { AdbUtility.run(GlobalConfig.getProperty("deviceworkdir")+"/busybox mount -o remount,rw /system && /data/local/tmp/busybox mv /data/local/tmp/su /system/xbin/su && /data/local/tmp/busybox mv /data/local/tmp/Superuser.apk /system/app/Superuser.apk && /data/local/tmp/busybox cp /data/local/tmp/busybox /system/xbin/busybox && chown root.root /system/xbin/su && chmod 06755 /system/xbin/su && chmod 655 /system/app/Superuser.apk && chmod 755 /system/xbin/busybox && rm /data/local.prop && reboot"); } public void doInstallRootFilesServiceMenu() throws Exception { AdbUtility.run("/dev/sh /system/bin/mount -o remount,rw -t ext4 /dev/block/platform/msm_sdcc.1/by-name/system /system && /dev/sh /data/local/tmp/busybox mv /data/local/tmp/su /system/xbin/su && /dev/sh /data/local/tmp/busybox mv /data/local/tmp/Superuser.apk /system/app/Superuser.apk && /dev/sh /data/local/tmp/busybox cp /data/local/tmp/busybox /system/xbin/busybox && /dev/sh chown root.root /system/xbin/su && chmod 06755 /system/xbin/su && /dev/sh chmod 655 /system/app/Superuser.apk && /dev/sh chmod 755 /system/xbin/busybox"); } }
21,145
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
XMLFile.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/XMLFile.java
package org.flashtool.gui.tools; import org.jdom2.input.SAXBuilder; import lombok.extern.slf4j.Slf4j; import org.flashtool.gui.TARestore; import org.jdom2.Document; import org.jdom2.JDOMException; import org.jdom2.Element; import java.io.File; import java.io.IOException; import java.util.Enumeration; import java.util.Iterator; import java.util.Vector; @Slf4j public class XMLFile { private Document document; public XMLFile(File xmlsource) throws IOException, JDOMException { SAXBuilder builder = new SAXBuilder(); document = builder.build(xmlsource); } public Enumeration<String> getLanguages() { Vector<String> langs = new Vector<String>(); Iterator<Element> i=document.getRootElement().getChildren().iterator(); while (i.hasNext()) { Element elem = i.next(); langs.add(elem.getAttributeValue("trigger")); } return langs.elements(); } public String getMenuEntry(String entry,String menuitem) { return document.getRootElement().getChild(entry).getChild(menuitem).getAttribute("name").getValue(); } public Enumeration<String> getMenuEntries(String entry) { Vector<String> langs = new Vector<String>(); Iterator<Element> i=document.getRootElement().getChild(entry).getChildren().iterator(); while (i.hasNext()) { Element elem = i.next(); langs.add(elem.getAttributeValue("trigger")); } return langs.elements(); } }
1,434
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
FlashJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/FlashJob.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.widgets.Shell; import org.flashtool.flashsystem.Bundle; import org.flashtool.flashsystem.Flasher; import org.flashtool.flashsystem.FlasherFactory; import org.flashtool.gui.TARestore; import org.flashtool.system.DeviceChangedListener; import lombok.extern.slf4j.Slf4j; @Slf4j public class FlashJob extends Job { Flasher flash = null; Bundle _bundle; boolean canceled = false; Shell _shell; public FlashJob(String name) { super(name); } public void setBundle(Bundle b) { _bundle = b; } public void setShell(Shell shell) { _shell = shell; } public Flasher getFlasher() { return flash; } protected IStatus run(IProgressMonitor monitor) { try { if (_bundle.open()) { log.info("Please connect your device into flashmode."); String result = ""; result = (String)WidgetTask.openWaitDeviceForFlashmode(_shell); if (result.equals("OK")) { flash = FlasherFactory.getFlasher(_bundle, _shell); if (flash.open()) flash.flash(); _bundle.close(); } else { _bundle.close(); log.info("Flash canceled"); } } else { log.info("Cannot open bundle. Flash operation canceled"); } DeviceChangedListener.enableDetection(); return Status.OK_STATUS; } catch (Exception e) { log.error(e.getMessage()); DeviceChangedListener.enableDetection(); return Status.CANCEL_STATUS; } } }
1,696
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
XMLBootConfig.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/XMLBootConfig.java
package org.flashtool.gui.tools; import java.io.File; import java.util.Enumeration; import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.Vector; import org.flashtool.flashsystem.Category; import org.flashtool.gui.TARestore; import org.flashtool.parsers.sin.SinFile; import lombok.extern.slf4j.Slf4j; @Slf4j public class XMLBootConfig { private String _configname = ""; private String _configta = ""; private Vector<String> files = new Vector<String>(); private Properties attributes = new Properties(); private String _folder=""; private Properties matcher = new Properties(); public XMLBootConfig(String name) { _configname = name; } public Vector getFiles() { return files; } public String getMatchingFile(String match) { Vector<String> matched = new Vector<String>(); Iterator<String> file = files.iterator(); while(file.hasNext()) { String name = file.next(); if (SinFile.getShortName(name).equals(SinFile.getShortName(match))) matched.add(name); } if (matched.size()==1) return (_folder.length()>0?_folder+"/":"")+matched.get(0); return null; } public void setFolder(String folder) { _folder = folder+File.separator+"boot"; } public String getAppsBootFile() { Iterator<String> file = files.iterator(); while(file.hasNext()) { String appsboot = file.next(); if (appsboot.toUpperCase().contains("APPSBOOT")) return (_folder.length()>0?_folder+"/":"")+appsboot; } return ""; } public boolean hasAppsBootFile() { return getAppsBootFile().trim().length()>0; } public Vector<String> getOtherFiles() { Vector<String> otherfiles = new Vector<String>(); Iterator<String> file = files.iterator(); while(file.hasNext()) { String curfile = file.next(); if (!curfile.toUpperCase().contains("APPSBOOT")) otherfiles.add((_folder.length()>0?_folder+"/":"")+curfile); } return otherfiles; } public String getName() { return _configname; } public void setTA(String config) { _configta = config; } public String getTA() { return (_folder.length()>0?_folder+"/":"")+_configta; } public void addFile(String file) { files.add(file); } public int getFileCount() { return files.size(); } public void setAttributes(String attribs) { String[] list = attribs.split(";"); for (int i=0;i<list.length;i++) { attributes.setProperty(list[i].split("=")[0], list[i].split("=")[1].replace("\"", "")); } } public String getAttribute(String att) { return attributes.getProperty(att, " "); } public void addMatcher(String attr, String value) { matcher.setProperty(attr, value); } public boolean matches(String otp_lock_status, String otp_data, String idcode, String plfroot) { boolean check_otp_lock_status=true; boolean check_otp_data=true; boolean check_idcode=true; boolean check_plfroot=true; if (attributes.containsKey("OTP_LOCK_STATUS_1")) check_otp_lock_status=otp_lock_status.equals(getAttribute("OTP_LOCK_STATUS_1")); if (attributes.containsKey("OTP_DATA_1")) check_otp_data=otp_data.equals(getAttribute("OTP_DATA_1")); if (attributes.containsKey("IDCODE_1")) check_idcode=idcode.substring(1).equals(getAttribute("IDCODE_1").substring(1)); if (attributes.containsKey("PLF_ROOT_1")) check_plfroot=plfroot.equals(getAttribute("PLF_ROOT_1")); return (check_otp_lock_status && check_otp_data && check_idcode && check_plfroot); } public boolean matchAttributes() { boolean match = true; Enumeration<Object> keys = matcher.keys(); while (keys.hasMoreElements()) { String key=(String)keys.nextElement(); match = attributes.containsKey(key); if (attributes.containsKey(key) && match) match=matcher.getProperty(key).equals(getAttribute(key)); } return match; } public boolean matches(String plf_root_hash) { boolean check_plfroot=false; if (attributes.containsKey("PLF_ROOT_HASH")) check_plfroot=plf_root_hash.equals(getAttribute("PLF_ROOT_HASH")); return check_plfroot; } public int compare(XMLBootConfig c) { if (this.getName().equals(c.getName())) return 0; boolean match = false; Iterator<String> file1 = files.iterator(); while (file1.hasNext()) { String file = file1.next(); Iterator<String> file2 = c.getFiles().iterator(); match = false; while (file2.hasNext()) { String filecompare = file2.next(); if (filecompare.equals(file)) match = true; } if (!match) break; } if (!match) return 2; else return 1; } public boolean isComplete() { if (!new File(getTA()).exists()) { log.error("missing TA "+getTA()); return false; } if (hasAppsBootFile()) { if (!new File(getAppsBootFile()).exists()) { log.error("missing appsboot "+getAppsBootFile()); return false; } } Iterator<String> i = getOtherFiles().iterator(); while (i.hasNext()) { String f = i.next(); if (f.length()>0) { if (!new File(f).exists()) { log.error("missing file "+f); return false; } } } return true; } public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Name : "+_configname+" / TA : "+_configta+" / Attributes : "+attributes+" / Files : "+files); return sb.toString(); } }
5,231
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
BusyboxInstallJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/BusyboxInstallJob.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.gui.TARestore; import org.flashtool.jna.adb.AdbUtility; import org.flashtool.system.Devices; import org.flashtool.system.FTShell; import org.flashtool.system.GlobalConfig; import lombok.extern.slf4j.Slf4j; @Slf4j public class BusyboxInstallJob extends Job { String bbpath; public BusyboxInstallJob(String name) { super(name); } public void setBusybox(String path) { bbpath = path; } protected IStatus run(IProgressMonitor monitor) { try { AdbUtility.push(bbpath, GlobalConfig.getProperty("deviceworkdir")); FTShell shell = new FTShell("busyhelper"); shell.run(false); shell = new FTShell("instbusybox"); shell.setProperty("BUSYBOXINSTALLPATH", Devices.getCurrent().getBusyBoxInstallPath()); shell.runRoot(); log.info("Installed version of busybox : " + Devices.getCurrent().getInstalledBusyboxVersion(true)); log.info("Finished"); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage()); return Status.CANCEL_STATUS; } } }
1,307
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
RestoreTAJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/RestoreTAJob.java
package org.flashtool.gui.tools; import java.util.Vector; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.flashsystem.Flasher; import org.flashtool.gui.TARestore; import org.flashtool.gui.models.TABag; import org.flashtool.gui.models.TADevice; import org.flashtool.logger.LogProgress; import org.flashtool.system.DeviceChangedListener; import lombok.extern.slf4j.Slf4j; @Slf4j public class RestoreTAJob extends Job { Flasher flash = null; TADevice tadev = null; boolean canceled = false; public RestoreTAJob(String name) { super(name); } public void setFlash(Flasher f) { flash=f; } public void setTA(TADevice tad) { this.tadev = tad; } protected IStatus run(IProgressMonitor monitor) { try { flash.open(); if (flash.getCurrentDevice().equals(tadev.getModel()) || tadev.getModel().length()==0) { flash.sendLoader(); flash.setFlashState(true); for (int i=0;i<tadev.getBags().size();i++) { TABag b = tadev.getBags().get(i); if (b.toflash.size()>0) { for (int j=0;j<b.toflash.size();j++) { flash.writeTA(b.partition,b.toflash.get(j)); } } } flash.setFlashState(false); flash.close(); log.info("Restoring TA finished."); LogProgress.initProgress(0); } else { log.info("Those TA units are not for your device"); flash.close(); log.info("Restoring TA finished."); LogProgress.initProgress(0); } DeviceChangedListener.enableDetection(); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); LogProgress.initProgress(0); DeviceChangedListener.enableDetection(); return Status.CANCEL_STATUS; } } }
1,835
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
createFTFJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/createFTFJob.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.flashsystem.Bundle; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class createFTFJob extends Job { Bundle bundle; public createFTFJob(String name) { super(name); } public void setBundle(Bundle b) { bundle=b; } protected IStatus run(IProgressMonitor monitor) { try { bundle.createFTF(); log.info("Bundle creation finished"); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); return Status.CANCEL_STATUS; } } }
769
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
BackupTAJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/BackupTAJob.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.flashsystem.Flasher; import org.flashtool.gui.TARestore; import org.flashtool.logger.LogProgress; import org.flashtool.system.DeviceChangedListener; import lombok.extern.slf4j.Slf4j; @Slf4j public class BackupTAJob extends Job { Flasher flash = null; boolean canceled = false; public BackupTAJob(String name) { super(name); } public void setFlash(Flasher f) { flash=f; } protected IStatus run(IProgressMonitor monitor) { try { flash.open(); flash.sendLoader(); flash.backupTA(); flash.close(); log.info("Dumping TA finished."); LogProgress.initProgress(0); DeviceChangedListener.enableDetection(); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); LogProgress.initProgress(0); DeviceChangedListener.enableDetection(); return Status.CANCEL_STATUS; } } }
1,095
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
CleanJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/CleanJob.java
package org.flashtool.gui.tools; import java.io.File; import java.util.Iterator; import java.util.Vector; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.gui.TARestore; import org.flashtool.jna.adb.AdbUtility; import org.flashtool.logger.LogProgress; import org.flashtool.system.Devices; import org.flashtool.system.FTShell; import org.flashtool.system.GlobalConfig; import org.flashtool.system.OS; import org.flashtool.system.TextFile; import lombok.extern.slf4j.Slf4j; @Slf4j public class CleanJob extends Job { DeviceApps _apps; public CleanJob(String name) { super(name); } public void setDeviceApps(DeviceApps apps) { _apps = apps; } protected IStatus run(IProgressMonitor monitor) { try { new File(Devices.getCurrent().getAppsDir()).mkdirs(); Vector<String> toberemoved = _apps.getToBeRemoved(true); Vector<String> tobeinstalled = _apps.getToBeInstalled(true); LogProgress.initProgress(toberemoved.size()+tobeinstalled.size()); TextFile listtoremove=new TextFile(Devices.getCurrent().getCleanDir()+File.separator+"listappsremove","ISO-8859-15"); TextFile listtoinstall=new TextFile(Devices.getCurrent().getCleanDir()+File.separator+"listappsadd","ISO-8859-15"); if (toberemoved.size()>0) { log.info("Making a backup of removed apps."); listtoremove.open(false); } if (tobeinstalled.size()>0) { listtoinstall.open(false); } Iterator<String> ir = toberemoved.iterator(); while (ir.hasNext()) { String app = _apps.getApkName(ir.next()); listtoremove.writeln(app); LogProgress.updateProgress(); try { AdbUtility.pull("/system/app/"+app, Devices.getCurrent().getAppsDir()); } catch (Exception e) {} } if (toberemoved.size()>0) { log.info("Backup Finished."); listtoremove.close(); AdbUtility.push(listtoremove.getFileName(), GlobalConfig.getProperty("deviceworkdir")+"/"); FTShell s = new FTShell("sysremove"); s.runRoot(); log.info("Apps removed from device."); } if (tobeinstalled.size()>0) { Iterator<String> ii = tobeinstalled.iterator(); while (ii.hasNext()) { String app = _apps.getApkName(ii.next()); listtoinstall.writeln(app); LogProgress.updateProgress(); try { AdbUtility.push(Devices.getCurrent().getAppsDir()+File.separator+app, GlobalConfig.getProperty("deviceworkdir")+"/"); } catch (Exception e) {} } listtoinstall.close(); AdbUtility.push(listtoinstall.getFileName(), GlobalConfig.getProperty("deviceworkdir")+"/"); FTShell s = new FTShell("sysadd"); s.runRoot(); log.info("Installation Finished"); } LogProgress.initProgress(0); listtoinstall.delete(); listtoremove.delete(); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage()); LogProgress.initProgress(0); return Status.CANCEL_STATUS; } } }
3,102
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
DecryptJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/DecryptJob.java
package org.flashtool.gui.tools; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.Vector; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.flashsystem.SeusSinTool; import org.flashtool.gui.TARestore; import org.flashtool.system.OS; import org.flashtool.xmlcombiner.XmlCombiner; import lombok.extern.slf4j.Slf4j; @Slf4j public class DecryptJob extends Job { boolean canceled = false; Vector files; public DecryptJob(String name) { super(name); } public void setFiles(Vector f) { files=f; } protected IStatus run(IProgressMonitor monitor) { try { OS.deleteDirectory(new File(((File)files.get(0)).getParent()+File.separator+"decrypted")); String decryptfolder=""; for (int i=0;i<files.size();i++) { File f = (File)files.get(i); decryptfolder=f.getParentFile().getAbsolutePath()+File.separator+"decrypted"; log.info("Decrypting "+f.getName()); try { SeusSinTool.decryptAndExtract(f.getAbsolutePath()); } catch (Exception e) { log.error(e.getMessage()); } } File update = new File(decryptfolder+File.separator+"update.xml"); File update1 = new File(decryptfolder+File.separator+"update1.xml"); File newupdate = new File(decryptfolder+File.separator+"update2.xml"); if (update.exists() && update1.exists()) { XmlCombiner combiner = new XmlCombiner(); FileInputStream fi1 = new FileInputStream(update); combiner.combine(fi1); FileInputStream fi2 = new FileInputStream(update1); combiner.combine(fi2); FileOutputStream fo = new FileOutputStream(newupdate); combiner.buildDocument(fo); fi1.close(); fi2.close(); fo.close(); update.delete(); update1.delete(); newupdate.renameTo(update); } log.info("Decryption finished"); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); return Status.CANCEL_STATUS; } } }
2,108
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
SearchJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/SearchJob.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.flashsystem.Flasher; import org.flashtool.gui.MainSWT; import org.flashtool.gui.TARestore; import org.flashtool.system.DeviceChangedListener; import org.flashtool.system.DeviceIdent; import org.flashtool.system.Devices; import org.flashtool.system.OS; import lombok.extern.slf4j.Slf4j; @Slf4j public class SearchJob extends Job { boolean canceled = false; boolean obsolete = false; public SearchJob(String name) { super(name); } public void stopSearch() { canceled=true; } protected IStatus run(IProgressMonitor monitor) { while (!canceled) { if (flashmode()) { return Status.OK_STATUS; } } return Status.CANCEL_STATUS; } public boolean flashmode() { boolean found = false; try { Thread.sleep(500); DeviceIdent id = Devices.getConnectedDevice(); found = id.getStatus().equals("flash"); if (found && OS.getName().equals("windows")) { log.info("Using Gordon gate drivers version "+id.getDriverMajor()+"."+id.getDriverMinor()+"."+id.getDriverMili()+"."+id.getDriverMicro()); } if (id.getStatus().equals("flash_obsolete")) { if (!obsolete) { log.error("Device connected in flash mode but driver is too old"); obsolete=true; } } } catch (Exception e) { found = false; } return found; } }
1,558
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
SearchFastbootJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/SearchFastbootJob.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.gui.TARestore; import org.flashtool.jna.adb.FastbootUtility; import lombok.extern.slf4j.Slf4j; @Slf4j public class SearchFastbootJob extends Job { boolean canceled = false; public SearchFastbootJob(String name) { super(name); } public void stopSearch() { canceled=true; } protected IStatus run(IProgressMonitor monitor) { while (!canceled) { try { Thread.sleep(1000); } catch (Exception e) {} if (FastbootUtility.getDevices().hasMoreElements()) { return Status.OK_STATUS; } } return Status.CANCEL_STATUS; } }
809
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
DevicesSyncJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/DevicesSyncJob.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.gui.TARestore; import org.flashtool.system.DevicesGit; import lombok.extern.slf4j.Slf4j; @Slf4j public class DevicesSyncJob extends Job { boolean canceled = false; public DevicesSyncJob(String name) { super(name); } protected IStatus run(IProgressMonitor monitor) { try { log.info("Syncing devices from github"); DevicesGit.gitSync(); log.info("Devices sync finished."); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); log.error("Cannot sync devices : "+e.getMessage()); return Status.CANCEL_STATUS; } } }
811
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
GetULCodeJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/GetULCodeJob.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.flashsystem.Flasher; import org.flashtool.gui.TARestore; import org.flashtool.logger.LogProgress; import org.flashtool.parsers.ta.TAUnit; import org.flashtool.system.ULCodeFile; import org.flashtool.util.HexDump; import lombok.extern.slf4j.Slf4j; @Slf4j public class GetULCodeJob extends Job { Flasher flash = null; boolean canceled = false; String blstatus = ""; String ulcode = ""; String imei = ""; String serial = ""; String phonecert = ""; String platform = ""; boolean alreadyunlocked = false; boolean relockable = false; public String getBLStatus() { return blstatus; } public String getULCode() { return ulcode; } public String getPhoneCert() { return phonecert; } public String getPlatform() { return platform.replace("i", "").replace("a", "").trim(); } public String getSerial() { return serial; } public String getIMEI() { return imei; } public boolean alreadyUnlocked() { return alreadyunlocked; } public GetULCodeJob(String name) { super(name); } public void setFlash(Flasher f) { flash=f; } //907437D662121E6F protected IStatus run(IProgressMonitor monitor) { try { flash.open(); flash.sendLoader(); blstatus = flash.getRootingStatus(); imei = flash.getIMEI(); if (flash.getCurrentDevice().contains("X10") || flash.getCurrentDevice().contains("E10") || flash.getCurrentDevice().contains("E15") || flash.getCurrentDevice().contains("U20")) { if (blstatus.equals("ROOTED")) { flash.close(); LogProgress.initProgress(0); log.info("Phone already unlocked"); log.info("You can safely reboot in normal mode"); } else { LogProgress.initProgress(1); platform = flash.getCurrentDevice(); TAUnit ta=flash.readTA(2,2129); flash.close(); LogProgress.initProgress(0); if (ta!=null) phonecert = HexDump.toHex(ta.getUnitData()); } if (phonecert.length()>874) phonecert = phonecert.substring(489,489+383); } else { TAUnit ta=flash.readTA(2,2226); serial = flash.getSerial(); ULCodeFile uc = new ULCodeFile(serial); ulcode = uc.getULCode(); if (ta!=null) { if (ta.getUnitData().length>2) { ulcode = new String(ta.getUnitData()); uc.setCode(ulcode); } } alreadyunlocked=(ta==null && ulcode.length()>0 && blstatus.equals("ROOTABLE")); relockable=(blstatus.equals("ROOTED") && ta!=null); LogProgress.initProgress(0); //System.out.println("Rootable : " + this.isRootable()); //System.out.println("Relockable : "+ this.isRelockable()); //System.out.println("Already Unlocked : "+ this.alreadyUnlocked()); } return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage()); return Status.CANCEL_STATUS; } } public boolean isRootable() { return (blstatus.equals("ROOTABLE")); } public boolean isRooted() { return (blstatus.equals("ROOTED")); } public boolean isRelockable() { return relockable; } public boolean isRelocked() { return alreadyunlocked && blstatus.equals("ROOTABLE"); } }
3,412
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
FTDExplodeJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/FTDExplodeJob.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.gui.TARestore; import org.flashtool.system.FTDEntry; import lombok.extern.slf4j.Slf4j; @Slf4j public class FTDExplodeJob extends Job { FTDEntry entry = null; boolean canceled = false; public FTDExplodeJob(String name) { super(name); } public void setFTD(FTDEntry f) { entry=f; } protected IStatus run(IProgressMonitor monitor) { try { log.info("Beginning import of "+entry.getName()); if (entry.explode()) log.info(entry.getName()+" imported successfully"); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); return Status.CANCEL_STATUS; } } }
864
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
BackupSystemJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/BackupSystemJob.java
package org.flashtool.gui.tools; import java.io.File; import java.util.Iterator; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.gui.TARestore; import org.flashtool.jna.adb.AdbUtility; import org.flashtool.logger.LogProgress; import org.flashtool.system.Devices; import org.flashtool.system.OS; import lombok.extern.slf4j.Slf4j; @Slf4j public class BackupSystemJob extends Job { public BackupSystemJob(String name) { super(name); } protected IStatus run(IProgressMonitor monitor) { try { new File(OS.getFolderRegisteredDevices()+File.separator+Devices.getCurrent().getSerial()+File.separator+"apps"+File.separator+Devices.getCurrent().getBuildId()).mkdirs(); DeviceApps apps = new DeviceApps(); LogProgress.initProgress(apps.getCurrent().size()); Iterator<String> ic = apps.getCurrent().iterator(); while (ic.hasNext()) { String app = ic.next(); LogProgress.updateProgress(); try { AdbUtility.pull("/system/app/"+app, OS.getFolderRegisteredDevices()+File.separator+Devices.getCurrent().getSerial()+File.separator+"apps"+File.separator+Devices.getCurrent().getBuildId()); } catch (Exception e) {} } log.info("Backup Finished"); LogProgress.initProgress(0); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage()); LogProgress.initProgress(0); return Status.CANCEL_STATUS; } } }
1,575
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
FastBootToolBoxJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/FastBootToolBoxJob.java
package org.flashtool.gui.tools; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.gui.TARestore; import org.flashtool.jna.adb.AdbUtility; import org.flashtool.jna.adb.FastbootUtility; import org.flashtool.system.Devices; import org.flashtool.system.RunOutputs; import lombok.extern.slf4j.Slf4j; @Slf4j public class FastBootToolBoxJob extends Job { boolean canceled = false; String _action = ""; String _image = ""; public FastBootToolBoxJob(String name) { super(name); } public void setAction(String action) { _action = action; } protected IStatus run(IProgressMonitor monitor) { try { if (_action.equals("doRebootFastbootViaAdb")) doRebootFastbootViaAdb(); if (_action.equals("doCheckDeviceStatus")) doCheckDeviceStatus(); if (_action.equals("doGetConnectedDeviceInfo")) doGetConnectedDeviceInfo(); if (_action.equals("doGetFastbootVerInfo")) doGetFastbootVerInfo(); if (_action.equals("doRebootBackIntoFastbootMode")) doRebootBackIntoFastbootMode(); if (_action.equals("doFastbootReboot")) doFastbootReboot(); if (_action.equals("doHotbootKernel")) doHotbootKernel(); if (_action.equals("doFlashKernel")) doFlashKernel(); if (_action.equals("doFlashSystem")) doFlashSystem(); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); return Status.CANCEL_STATUS; } } protected void doRebootFastbootViaAdb() { if (Devices.HasOneAdbConnected()) { if (Devices.getCurrent().canFastboot()) { log.info("Please wait device is rebooting into fastboot mode (via ADB)"); try { FastbootUtility.adbRebootFastboot(); log.info("Device will soon enter fastboot mode"); } catch (Exception e1) { log.error(e1.getMessage()); } } else log.error("This action can be done only if the connected phone has fastboot mode"); } else log.error("This action needs a connected device in ADB mode"); } public void doCheckDeviceStatus() { String deviceStatus="NOT FOUND"; Devices.HasOneFastbootConnected(); if (AdbUtility.isConnected()){ deviceStatus="ADB mode"; } else if (FastbootUtility.getDevices().hasMoreElements()) deviceStatus="FASTBOOT mode"; log.info("Device Status: " + deviceStatus); } public void doGetConnectedDeviceInfo(){ if (!Devices.HasOneFastbootConnected()) { log.error("This action can only be done in fastboot mode"); return; } log.info("Fetching connected device info"); try { RunOutputs outputsRun = FastbootUtility.getDeviceInfo(); log.info("Connected device info: [ " + outputsRun.getStdOut().split("fastboot")[0].trim() + " ]"); } catch (Exception e1) { log.error(e1.getMessage()); } } public void doGetFastbootVerInfo(){ if (!Devices.HasOneFastbootConnected()) { log.error("This action can only be done in fastboot mode"); return; } log.info("Fetching fastboot version info from connected device"); try { RunOutputs outputsRun = FastbootUtility.getFastbootVerInfo(); log.info("FASTBOOT version info: [ " + outputsRun.getStdErr().split("\n")[0].trim() + " ]"); } catch (Exception e1) { log.error(e1.getMessage()); } } public void doRebootBackIntoFastbootMode(){ if (!Devices.HasOneFastbootConnected()) { log.error("This action can only be done in fastboot mode"); return; } log.info("Please wait device is rebooting into fastboot mode (via Fastboot)"); try { FastbootUtility.rebootFastboot(); log.info("Device will soon reboot back into fastboot mode"); } catch (Exception e1) { log.error(e1.getMessage()); } } public void doFastbootReboot(){ if (!Devices.HasOneFastbootConnected()) { log.error("This action can only be done in fastboot mode"); return; } log.info("Device will now exit fastboot mode and start booting into system"); try { FastbootUtility.rebootDevice(); } catch (Exception e1) { log.error(e1.getMessage()); } } public void setImage(String image) { _image = image; } public void doHotbootKernel() { if (!Devices.HasOneFastbootConnected()) { log.error("This action can only be done in fastboot mode"); return; } if (_image.length()==0) { log.error("no kernel (boot.img or kernel.sin) selected!"); } else { log.info("Selected kernel (boot.img or kernel.sin): " + _image); // this wont wait for reply and will move on to next command log.info("HotBooting selected kernel"); try { RunOutputs outputsRun = FastbootUtility.hotBoot(_image); log.info("FASTBOOT Output: \n " + outputsRun.getStdErr().trim() + "\n"); if (!outputsRun.getStdErr().trim().contains("FAILED")) log.info("Device should now start booting with this kernel"); } catch (Exception e1) { log.error(e1.getMessage()); } _image=""; } } public void doFlashKernel() { if (!Devices.HasOneFastbootConnected()) { log.error("This action can only be done in fastboot mode"); return; } if (_image.length()==0) { log.error("no kernel (boot.img or kernel.sin) selected!"); } else { log.info("Selected kernel (boot.img or kernel.sin): " + _image); log.info("Flashing selected kernel"); try { RunOutputs outputsRun = FastbootUtility.flashBoot(_image); log.info("FASTBOOT Output: \n " + outputsRun.getStdErr().trim() + "\n"); log.info("Please check the log before rebooting into system"); } catch (Exception e1) { log.error(e1.getMessage()); } } _image=""; } public void doFlashSystem() { if (!Devices.HasOneFastbootConnected()) { log.error("This action can only be done in fastboot mode"); return; } if (_image.length()==0) { log.error("no kernel (boot.img or kernel.sin) selected!"); } else { log.info("Selected system (system.img or system.sin): " + _image); log.info("Flashing selected system"); try { RunOutputs outputsRun = FastbootUtility.flashSystem(_image); log.info("Please check the log before rebooting into system"); } catch (Exception e1) { log.error(e1.getMessage()); } } _image=""; } }
6,329
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
OldUnlockJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/OldUnlockJob.java
package org.flashtool.gui.tools; import java.io.File; import java.io.FileInputStream; import java.util.Enumeration; import java.util.Properties; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.gui.TARestore; import org.flashtool.jna.adb.AdbUtility; import org.flashtool.system.DeviceEntry; import org.flashtool.system.Devices; import org.flashtool.system.FTShell; import org.flashtool.system.GlobalConfig; import lombok.extern.slf4j.Slf4j; @Slf4j public class OldUnlockJob extends Job { boolean canceled = false; String blstatus = ""; String phonecert = ""; String platform = ""; public void setStatus(String status) { blstatus = status; } public void setPhoneCert(String cert) { phonecert = cert; } public void setPlatform(String pf) { platform = pf; } public String getBLStatus() { return blstatus; } public String getPhoneCert() { return phonecert; } public String getPlatform() { return platform; } public OldUnlockJob(String name) { super(name); } protected IStatus run(IProgressMonitor monitor) { try { DeviceEntry ent = new DeviceEntry(platform); if (!new File(ent.getDeviceDir()+File.separator+"blu"+File.separator+"files"+File.separator+"cert.properties").exists()) throw new Exception("cert.properties is missing"); Properties p = new Properties(); try { p.load(new FileInputStream(new File(ent.getDeviceDir()+File.separator+"blu"+File.separator+"files"+File.separator+"cert.properties"))); } catch (Exception ex) {} String bootwrite = ""; Enumeration<Object> e = p.keys(); while (e.hasMoreElements()) { String key = (String)e.nextElement(); if (p.getProperty(key).equals(phonecert)) { bootwrite = key; break; } } if (bootwrite.length()==0) throw new Exception("Phone certificate not identified"); bootwrite = "bootwrite_"+bootwrite+"SL"; if (!new File(ent.getDeviceDir()+File.separator+"blu"+File.separator+"files"+File.separator+bootwrite).exists()) throw new Exception(bootwrite+" is missing"); if (!new File(ent.getDeviceDir()+File.separator+"blu"+File.separator+"files"+File.separator+"fixPart").exists()) throw new Exception("fixPart is missing"); if (!new File(ent.getDeviceDir()+File.separator+"blu"+File.separator+"files"+File.separator+"mapper_2.6.29.ko").exists()) throw new Exception("mapper_2.6.29.ko is missing"); if (platform.equals("X10")) if (!new File(ent.getDeviceDir()+File.separator+"blu"+File.separator+"files"+File.separator+"mapper_2.6.29-00054-g5f01537.ko").exists()) throw new Exception("mapper_2.6.29-00054-g5f01537.ko is missing"); log.info("Waiting for device to reboot"); Devices.waitForReboot(false); if (!Devices.getCurrent().getKernelVersion().equals("2.6.29-00054-g5f01537") && !Devices.getCurrent().getKernelVersion().equals("2.6.29")) throw new Exception("Kernel does not match a compatible one"); if (!Devices.getCurrent().hasRoot()) throw new Exception("Device must be rooted first"); String mapper = "mapper_"+Devices.getCurrent().getKernelVersion()+".ko"; AdbUtility.push(ent.getDeviceDir()+File.separator+"blu"+File.separator+"files"+File.separator+"fixPart", GlobalConfig.getProperty("deviceworkdir")); FTShell fixpart = new FTShell(new File(ent.getDeviceDir()+File.separator+"blu"+File.separator+"shells"+File.separator+"runfixPart")); String output = fixpart.runRoot(); if (!output.contains("success")) throw new Exception("Error applying fixpart: "+output); log.info("Successfully applied fixPart. Rebooting"); Devices.getCurrent().reboot(); Devices.waitForReboot(false); AdbUtility.push(ent.getDeviceDir()+File.separator+"blu"+File.separator+"files"+File.separator+mapper, GlobalConfig.getProperty("deviceworkdir")); AdbUtility.push(ent.getDeviceDir()+File.separator+"blu"+File.separator+"files"+File.separator+bootwrite, GlobalConfig.getProperty("deviceworkdir")); FTShell runbootwrite = new FTShell(new File(ent.getDeviceDir()+File.separator+"blu"+File.separator+"shells"+File.separator+"runbootwrite")); runbootwrite.setProperty("KVER", Devices.getCurrent().getKernelVersion()); runbootwrite.setProperty("BOOTWRITEBIN", bootwrite); output = runbootwrite.runRoot(); if (!output.contains("success")) throw new Exception("Error applying fixpart: "+output); log.info("Successfully applied bootwrite. Bootloader should be unlocked. Rebooting"); Devices.getCurrent().reboot(); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage()); return Status.CANCEL_STATUS; } } }
4,787
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
FtfFilter.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/FtfFilter.java
package org.flashtool.gui.tools; import java.io.File; import java.io.FileFilter; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class FtfFilter implements FileFilter{ private String ext; public FtfFilter(String endswith) { ext = endswith; if (ext.length()==0) ext="ftf"; } public boolean accept(File file) { if (file.getName().toLowerCase().endsWith(ext.toLowerCase()) && file.isFile()) { return true; } return false; } }
520
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
FirmwareFileFilter.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/FirmwareFileFilter.java
package org.flashtool.gui.tools; import java.io.File; import java.io.FileFilter; import org.flashtool.gui.TARestore; import lombok.extern.slf4j.Slf4j; @Slf4j public class FirmwareFileFilter implements FileFilter { private final String[] okFileExtensions = new String[] {"sin", "ta", "fsc"}; public boolean accept(File file) { for (String extension : okFileExtensions) { if (file.getName().toLowerCase().endsWith(extension) && file.isFile()) { return true; } } return false; } }
535
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
USBParseJob.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/gui/tools/USBParseJob.java
package org.flashtool.gui.tools; import java.util.Vector; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.flashtool.flashsystem.Bundle; import org.flashtool.gui.TARestore; import org.flashtool.parsers.simpleusblogger.Parser; import org.flashtool.parsers.simpleusblogger.S1Packet; import org.flashtool.parsers.simpleusblogger.Session; import lombok.extern.slf4j.Slf4j; @Slf4j public class USBParseJob extends Job { String logfile=""; String sindir=""; Session session; public USBParseJob(String name) { super(name); } public void setFilename(String file) { logfile=file; } public void setSinDir(String dir) { sindir=dir; } protected IStatus run(IProgressMonitor monitor) { try { session = Parser.parse(logfile, sindir); return Status.OK_STATUS; } catch (Exception e) { e.printStackTrace(); return Status.CANCEL_STATUS; } } public Session getSession() { return session; } }
1,102
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
StatusListener.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/system/StatusListener.java
package org.flashtool.system; import java.util.EventListener; public interface StatusListener extends EventListener { public void statusChanged(StatusEvent e); }
167
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
AESInputStream.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/system/AESInputStream.java
package org.flashtool.system; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.Security; import javax.crypto.Cipher; import javax.crypto.CipherInputStream; import javax.crypto.NoSuchPaddingException; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import org.bouncycastle.jce.provider.BouncyCastleProvider; import com.google.common.hash.Hashing; import com.google.common.io.BaseEncoding; import lombok.extern.slf4j.Slf4j; @Slf4j public class AESInputStream extends InputStream { private InputStream in = null; private CipherInputStream localCipherInputStream; public AESInputStream(InputStream in) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, NoSuchProviderException, InvalidAlgorithmParameterException, UnsupportedEncodingException { this.in = in; SecretKeySpec secretKeySpec = new SecretKeySpec(Hashing.sha256().hashBytes(OS.AESKey.getBytes("UTF-8")).asBytes(), "AES"); IvParameterSpec ivParameterSpec = new IvParameterSpec(BaseEncoding.base16().decode(OS.AESIV)); Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding", "BC"); cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec); localCipherInputStream = new CipherInputStream(in, cipher); } @Override public int read() throws IOException { return localCipherInputStream.read(); } @Override public int read(byte[] b) throws IOException { return localCipherInputStream.read(b); } @Override public boolean markSupported() { return localCipherInputStream.markSupported(); } }
1,832
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
TextFile.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/system/TextFile.java
package org.flashtool.system; import java.io.*; import java.util.Collection; import java.util.HashMap; import java.util.Hashtable; import java.util.Map; import java.util.Scanner; import org.apache.commons.io.IOUtils; import lombok.extern.slf4j.Slf4j; @Slf4j public class TextFile { /** Constructor. */ public TextFile(String aFileName, String aEncoding){ fFileName = aFileName; fEncoding = aEncoding; } public void open(boolean append) throws IOException { File f = new File(fFileName); f.getParentFile().mkdirs(); pwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(fFileName), fEncoding)); } public void write(String aText) throws IOException { pwriter.print(aText); } public void writeln(String aText) throws IOException { pwriter.print(aText+"\n"); } public void close() throws IOException { try { pwriter.flush(); pwriter.close(); } catch (NullPointerException npe) {} } public void delete() { try { close(); } catch (Exception e) {} File f = new File(fFileName); f.delete(); } public void readLines() throws IOException { lines = new HashMap<Integer,String>(); Scanner scanner = new Scanner(new FileInputStream(fFileName)); try { int linenumber=1; while (scanner.hasNextLine()){ String aline = scanner.nextLine(); lines.put(linenumber++,aline); } } finally{ scanner.close(); } } public Collection<String> getLines() throws IOException { if (lines==null) readLines(); return lines.values(); } public Map<Integer,String> getMap() throws IOException { if (lines==null) readLines(); return lines; } public static boolean exists(String name) { File f = new File(name); return f.exists(); } public void setProperty(String property, String value) throws Exception { String content = IOUtils.toString(new FileInputStream(fFileName), fEncoding); content = content.replaceAll(property, value); IOUtils.write(content, new FileOutputStream(fFileName), fEncoding); } public String getFileName() { return fFileName; } // PRIVATE protected String fFileName; private final String fEncoding; private PrintWriter pwriter; private HashMap<Integer,String> lines=null; }
2,223
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
RunStack.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/system/RunStack.java
package org.flashtool.system; import java.util.HashSet; import java.util.Iterator; import lombok.extern.slf4j.Slf4j; @Slf4j public class RunStack { static HashSet<ProcessBuilderWrapper> set = new HashSet<ProcessBuilderWrapper>(); public static void addToStack(ProcessBuilderWrapper p) { set.add(p); } public static void removeFromStack(ProcessBuilderWrapper p) { set.remove(p); } public static void killAll() { Iterator<ProcessBuilderWrapper> i = set.iterator(); while (i.hasNext()) i.next().kill(); } }
531
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
DeviceEntry.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/system/DeviceEntry.java
package org.flashtool.system; import java.io.File; import java.io.FilenameFilter; import java.util.HashSet; import java.util.Iterator; import org.eclipse.swt.widgets.Display; import org.flashtool.gui.tools.WidgetTask; import org.flashtool.jna.adb.AdbUtility; import lombok.extern.slf4j.Slf4j; @Slf4j public class DeviceEntry { PropertiesFile _entry; private Boolean hasBusybox=null; private boolean isRecoveryMode=false; private String filter = ""; //private HashSet<DeviceEntryModel> models = new HashSet<DeviceEntryModel>(); public void queryAll() { setVersion(); setKernelVersion(); try { isRecoveryMode=!AdbUtility.isMounted("/data"); } catch (Exception e) { } } public boolean hasRoot() { if (AdbUtility.hasRootNative(false)) return AdbUtility.hasRootNative(false); return AdbUtility.hasRootPerms(); } public boolean isRecovery() { return isRecoveryMode; } public boolean hasSU() { try { return AdbUtility.hasSU(); } catch (Exception e) { return false; } } /*public void rebootSelectedRecovery() throws Exception { RecoveryBootSelectGUI rsel = new RecoveryBootSelectGUI(); rsel.setTitle("Recovery selector"); String current = rsel.getVersion(); if (current.length()>0) { MyLogger.getLogger().info("Rebooting into recovery mode"); Shell shell = new Shell("rebootrecoveryt"); shell.setProperty("RECOV_VERSION", current); shell.runRoot(); MyLogger.getLogger().info("Phone will reboot into recovery mode"); } else { MyLogger.getLogger().info("Canceled"); } }*/ /*public void setDefaultRecovery() throws Exception { RecoveryBootSelectGUI rsel = new RecoveryBootSelectGUI(); String current = rsel.getVersion(); if (current.length()>0) { if (AdbUtility.Sysremountrw()) { MyLogger.getLogger().info("Setting default recovery"); Shell shell = new Shell("setdefaultrecovery"); shell.setProperty("RECOV_VERSION", current); shell.runRoot(); MyLogger.getLogger().info("Done"); } } else { MyLogger.getLogger().info("Canceled"); } }*/ private void setKernelVersion() { _entry.setProperty("kernel.version", AdbUtility.getKernelVersion(isBusyboxInstalled(false))); } public String getKernelVersion() { return _entry.getProperty("kernel.version"); } public DeviceEntry(PropertiesFile entry) { _entry = entry; } public DeviceEntry(String Id) { _entry = new PropertiesFile(); try { String path = OS.getFolderMyDevices()+File.separator+Id+File.separator+Id+".properties"; if (new File(path).exists()) _entry.open("",path); else { path = OS.getFolderDevices()+File.separator+Id+File.separator+Id+".properties"; _entry.open("",path); } } catch (Exception e) { e.printStackTrace(); } } public String getProtocol() { if (_entry.getProperty("flashProtocol")==null) return "S1"; return _entry.getProperty("flashProtocol"); } public String getId() { return _entry.getProperty("internalname"); } public String getName() { return _entry.getProperty("realname"); } public String getDeviceDir() { return OS.getFolderDevices()+File.separator+getId(); } public String getMyDeviceDir() { return OS.getFolderMyDevices()+File.separator+getId(); } public String getFolderRegisteted() { return OS.getFolderRegisteredDevices()+File.separator+this.getSerial(); } public String getCleanDir() { return OS.getFolderRegisteredDevices()+File.separator+getSerial()+File.separator+"clean"+File.separator+getBuildId(); } public String getAppsDir() { return OS.getFolderRegisteredDevices()+File.separator+getSerial()+File.separator+"apps"+File.separator+getBuildId(); } public String getBuildProp() { return _entry.getProperty("buildprop"); } public String getLoaderMD5() { return _entry.getProperty("loader").toUpperCase(); } public String getLoaderUnlockedMD5() { return _entry.getProperty("loader_unlocked").toUpperCase(); } public boolean hasUnlockedLoader() { if (_entry.getProperties().containsKey("loader_unlocked")) { return (_entry.getProperties().getProperty("loader_unlocked").length()>0); } else return false; } public String getBusyBoxInstallPath() { return _entry.getProperty("busyboxinstallpath"); } public String getInstalledBusyboxVersion(boolean force) { if (Devices.getCurrent().isBusyboxInstalled(force)) { return AdbUtility.getBusyboxVersion(getBusyBoxInstallPath()); } else hasBusybox=false; return "N/A"; } public HashSet<String> getRecognitionList() { String[] result = _entry.getProperty("recognition").split(","); HashSet<String> set = new HashSet<String>(); for (int i=0;i<result.length;i++) { set.add(result[i]); } return set; } public HashSet<String> getVariantList() { String[] result = getVariant().split(","); HashSet<String> set = new HashSet<String>(); for (int i=0;i<result.length;i++) { if (result[i].trim().length()>0) set.add(result[i]); } return set; } public String getRecognition() { return _entry.getProperty("recognition"); } public String getVariant() { String variant = _entry.getProperty("variant"); if (variant==null) return getId(); return variant; } public void clearVariants() { _entry.setProperty("variant", ""); _entry.write("ISO-8859-1"); } public void addVariantToList(String model) { String current = _entry.getProperty("variant"); if (current==null) current=""; if (current.length()==0) _entry.setProperty("variant", model); else { current = current + ","+model; _entry.setProperty("variant", current); } _entry.write("ISO-8859-1"); } public void addRecognitionToList(String recog) { String current = _entry.getProperty("recognition"); current = current + ","+recog; _entry.setProperty("recognition", current); _entry.write("ISO-8859-1"); } public String getLoader() { return this.getDeviceDir()+"/loader.sin"; } public String getLoaderUnlocked() { return this.getDeviceDir()+"/loader_unlocked.sin"; } private void setVersion () { _entry.setProperty("android.release",DeviceProperties.getProperty("ro.build.version.release")); _entry.setProperty("android.build",DeviceProperties.getProperty("ro.build.id")); _entry.setProperty("android.arch",DeviceProperties.getProperty("ro.product.cpu.abi").indexOf("arm64")==-1?"32":"64"); } public String getVersion() { return _entry.getProperty("android.release"); } public String getBuildId() { return _entry.getProperty("android.build"); } public String getArch() { return _entry.getProperty("android.arch"); } public boolean canFlash() { return _entry.getProperty("canflash").equals("true"); } public boolean canKernel() { return (_entry.getProperty("cankernel").equals("true")); } public boolean canRecovery() { return (new File(getDeviceDir()+File.separator+"bootkit").exists()); } public boolean canFastboot() { return _entry.getProperty("canfastboot").equals("true"); } public String getBusybox(boolean select) { String version=""; if (!select) version = _entry.getProperty("busyboxhelper"); else { version = WidgetTask.openBusyboxSelector(Display.getCurrent().getActiveShell()); //BusyBoxSelectGUI sel = new BusyBoxSelectGUI(getId()); //version = sel.getVersion(); } if (version.length()==0) return ""; else return OS.getFolderDevices()+File.separator+"busybox"+File.separator+version+File.separator+"busybox"; } public String getOptimize() { return getDeviceDir()+"/optimize.tar"; } public String getBuildMerge() { return getDeviceDir()+"/build.prop"; } public String getCharger() { return getDeviceDir()+"/charger"; } public boolean isBusyboxInstalled(boolean force) { if (hasBusybox==null || force) hasBusybox = (AdbUtility.getBusyboxVersion(getBusyBoxInstallPath()).length()>0); return hasBusybox.booleanValue(); } public void doBusyboxHelper() throws Exception { if (!isBusyboxInstalled(false)) { AdbUtility.push(getBusybox(false), GlobalConfig.getProperty("deviceworkdir")+"/busybox"); FTShell shell = new FTShell("busyhelper"); shell.run(true); } } public void reboot() throws Exception { if (hasRoot()) { FTShell s = new FTShell("reboot"); s.runRoot(false); } else { ProcessBuilderWrapper command = new ProcessBuilderWrapper(new String[] {OS.getPathAdb(),"reboot"},false); } } public String getSerial() { return AdbUtility.getDevices().nextElement(); } /*public boolean canHandleUpdates() { Iterator<DeviceEntryModel> i = getModels().iterator(); while (i.hasNext()) { if (i.next().getTac().length()>0) return true; } return false; } public boolean canShowUpdates() { Iterator<DeviceEntryModel> i = getModels().iterator(); while (i.hasNext()) { if (i.next().getCDA().getProperties().size()>0) return true; } return false; }*/ /*public HashSet<DeviceEntryModel> getModels() { if (models.size()==0) { Iterator<String> ivariants = getVariantList().iterator(); while (ivariants.hasNext()) { models.add(new DeviceEntryModel(this,ivariants.next())); } } return models; }*/ public boolean isFlashScriptMandatory() { if (!_entry.getProperties().containsKey("fscmandatory")) return false; return _entry.getProperty("fscmandatory").equals("true"); } /*public boolean hasFlashScript(String model, String version) { return getFlashScript(model, version).length()>0; }*/ public String getFlashScript(String version,String model) { FilenameFilter fscFilter = new FilenameFilter() { public boolean accept(File dir, String name) { return (name.toLowerCase().equals(filter.toLowerCase())); } }; File mydevices = new File(this.getMyDeviceDir()); File devices = new File(this.getDeviceDir()); File[] fsc; filter = model+"_"+version+".fsc"; if (mydevices.exists()) { fsc = mydevices.listFiles(fscFilter); if (fsc.length>0) return fsc[0].getAbsolutePath(); } fsc = devices.listFiles(fscFilter); if (fsc != null) if (fsc.length>0) return fsc[0].getAbsolutePath(); String[] vnumbers = version.split("\\."); for (int i=vnumbers.length;i>0;i--) { filter=""; for (int j=0; j<i; j++) { filter=filter+(j>0?".":"")+vnumbers[j]; } filter = filter + ".fsc"; if (mydevices.exists()) { fsc = mydevices.listFiles(fscFilter); if (fsc != null) if (fsc.length>0) return fsc[0].getAbsolutePath(); } fsc = devices.listFiles(fscFilter); if (fsc != null) if (fsc.length>0) return fsc[0].getAbsolutePath(); } return ""; } }
10,880
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z
DeviceProperties.java
/FileExtraction/Java_unseen/Androxyde_Flashtool/Flashtool/src/main/java/org/flashtool/system/DeviceProperties.java
package org.flashtool.system; import java.io.File; import java.io.FileInputStream; import java.util.Properties; import org.flashtool.jna.adb.AdbUtility; import lombok.extern.slf4j.Slf4j; @Slf4j public class DeviceProperties { private static Properties devprops = new Properties(); private static String fsep = OS.getFileSeparator(); public static void reload() { devprops.clear(); try { AdbUtility.pull("/system/build.prop", OS.getFolderCustom()+fsep+"root"+fsep+"build.prop",false); File build = new File(OS.getFolderCustom()+fsep+"root"+fsep+"build.prop"); FileInputStream fis = new FileInputStream(build); devprops.load(fis); fis.close(); build.delete(); } catch (Exception e) { try { devprops.setProperty("ro.build.version.release", AdbUtility.run("getprop ro.build.version.release")); devprops.setProperty("ro.build.id", AdbUtility.run("getprop ro.build.id")); devprops.setProperty("ro.product.cpu.abi", AdbUtility.run("getprop ro.product.cpu.abi")); devprops.setProperty("ro.product.device", AdbUtility.run("getprop ro.product.device")); devprops.setProperty("ro.product.model", AdbUtility.run("getprop ro.product.model")); } catch (Exception e1) {} } } public static String getProperty(String key) { String read = devprops.getProperty(key); if (read==null) read = ""; return read; } }
1,365
Java
.java
Androxyde/Flashtool
468
244
165
2014-04-17T19:54:33Z
2024-03-12T15:17:26Z