├── .gitignore ├── .idea ├── ant.xml ├── artifacts │ └── JavaFXApp.xml ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── description.html ├── encodings.xml ├── gradle.xml ├── libraries │ └── gson_2_2_4.xml ├── misc.xml ├── modules.xml ├── uiDesigner.xml ├── vcs.xml └── workspace.xml ├── ADBUITool.iml ├── README.md ├── adbuitool.properties ├── adbuitool.xml ├── libs └── gson-2.2.4.jar ├── module_adbuitool.xml └── src ├── application ├── ADBHelper.java ├── AdbUtils.java ├── DateUtil.java ├── DialogUtil.java ├── FXMLMain.fxml ├── FXMLMainController.java ├── FileUtils.java ├── FolderUtil.java ├── Main.java ├── ProcessUtils.java ├── apks │ ├── APKsTab.fxml │ └── APKsTabController.java ├── application.css ├── applications │ ├── ApplicationsTab.fxml │ └── ApplicationsTabController.java ├── batchcommands │ ├── BatchCommandEditController.java │ ├── BatchCommandEditLayout.fxml │ ├── BatchCommandTab.fxml │ ├── BatchCommandTabController.java │ ├── BatchCommandViewUtil.java │ ├── BatchCommandsListView.java │ ├── CommandWizardController.java │ └── CommandWizardLayout.fxml ├── devices │ ├── DevicesController.java │ └── DevicesLayout.fxml ├── intentbroadcasts │ ├── IntentBroadcast.java │ ├── IntentBroadcastsController.java │ └── IntentsBroadcastsLayout.fxml ├── log │ └── Logger.java ├── logexceptions │ ├── ExceptionLog.java │ ├── Log.java │ ├── LogExceptionsController.java │ └── LogExceptionsLayout.fxml ├── model │ ├── Application.java │ ├── Command.java │ ├── CommandBatch.java │ ├── Device.java │ ├── Model.java │ ├── ModelListener.java │ └── PackageProcess.java ├── preferences │ ├── PreferenceController.java │ ├── PreferenceLayout.fxml │ └── Preferences.java ├── screencapture │ ├── ScreenCaptureController.java │ └── ScreenCaptureLayout.fxml ├── services │ ├── ApplicationsMonitorService.java │ └── DeviceMonitorService.java ├── startupcheck │ ├── StartupCheckController.java │ └── StartupCheckLayout.fxml ├── terminal │ ├── TerminalController.java │ └── TerminalLayout.fxml └── view │ ├── DateTimePicker.fxml │ └── DateTimePickerController.java └── res └── icon.png /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yapplications/ADB-GUI/9aeee11d24ff0fa290ac91d39ccca7852bd3f849/.gitignore -------------------------------------------------------------------------------- /.idea/ant.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/artifacts/JavaFXApp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/JavaFXApp 4 | 5 | 6 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/description.html: -------------------------------------------------------------------------------- 1 | Simple JavaFX 2.0 application that includes simple .fxml file with attached controller and Main class to quick start. Artifact to build JavaFX application is provided. 2 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/libraries/gson_2_2_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ADBUITool.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ADB-GUI - [GitHub Page](https://yapplications.github.io/ADB-GUI/) 2 | UI wrapper around ADB to make life easier for Android Developer and QA 3 | 4 | [Medium post about ADB-GUI-Tool (27.01.2017)](https://medium.com/@evgenishafran/keep-your-sanity-while-doing-android-development-1d9964929199#.k7s9ztavo) 5 | 6 | ![alt tag](https://github.com/yapplications/ADB-GUI/blob/gh-pages/images/example-auto-login.gif) 7 | 8 | [Install](https://github.com/yapplications/ADB-GUI/blob/master/README.md#install)
9 | [Submit an issue](https://github.com/yapplications/ADB-GUI/blob/master/README.md#submit-an-issue)
10 | [Use Cases](https://github.com/yapplications/ADB-GUI/blob/master/README.md#use-cases)
11 | [Abilities](https://github.com/yapplications/ADB-GUI/blob/master/README.md#abilities)
12 | [Share 'command batch' / 'intent' with your team](https://github.com/yapplications/ADB-GUI/blob/master/README.md#share-command-batch--intent-with-your-team)
13 | [Known Isseus](https://github.com/yapplications/ADB-GUI/blob/master/README.md#known-issues)
14 | 15 | ## Install: 16 | 17 | * You should have Java and adb (comes with android studio) installed. 18 | 19 | 1. Dowload: [ADB-GUI-Tool 0.1.9v](https://github.com/yapplications/ADB-GUI/releases/download/0.1.9v/ADB-GUI-Tool-0.1.9.zip) 20 | 21 | 2. Unzip to a path **without spaces** 22 | 23 | 3. MAC: give running permission to: ADB-GUI-Tool.jar 24 | 25 | 4. Run: ADB-GUI-Tool.jar (Double press from finder / explorer or run: `java -jar ADB-GUI-Tool.jar` from terminal) 26 | 27 | 5. On first run: change 'adb path' in preference screen to point to your local adb 28 | 29 | ## Submit an issue 30 | If you encountered a problem, something is not working, please open an issue.
31 | But before you do so please go to the app path, open 'preference' file,
32 | Change: "debug":false -> "debug":true
33 | Try to recreate your error and send me the last logs (both the error and regular one) created at: 'app-logs' directory under you app directory. 34 | 35 | ## Use Cases: 36 | 37 | 1. Automate login forms via Batch Commands 38 | 2. Automate device readiness for QA (install multiple APKs and copy files) via Batch Commands 39 | 3. Take snapshots easily 40 | 4. Install APKs 41 | 5. Test deep linking via Inten / Broadcasts 42 | 6. Get APKs from device 43 | 7. Run monkey runner with a simple click 44 | 45 | And much more... 46 | 47 | ## Abilities: 48 | 49 | The app devided into Device Panel 7 Tabs and status line 50 | 51 | #### Status line: 52 | 53 | Appears at the bottom, most of the commands will update it. 54 | 55 | * Black color text: command is running 56 | * Green color text: command executed succesfully 57 | * Red color text: command failed 58 | 59 | Some commands will appear green result even if the command failed 60 | 61 | #### Device Panel: 62 | 63 | 1. Device selection: all device commands that you will execute will be executed on the device you select here 64 | 65 | 2. Connect device via WiFi: click in order to start working via WiFi 66 | * Device should be on the same network as the pc 67 | * After pressed there should be an extra device in the list and you can disconnect it from usb. 68 | * Connection will be lost if adb / device restarts 69 | 70 | 3. Take snapshot: opens an 'device view' screen 71 | * Screen will be updated by itself 72 | * Press 'Save' to save a snapshot 73 | * You can save as many snapshots as you like in one session 74 | 75 | 4. Send quick text to device: enter the text you want to send and press enter 76 | 77 | 5. Change emulator date: opens a dilog for changing emulator time 78 | * Works only on emulators 79 | * Will also disable the auto date / time zone update 80 | * If you move to the clock extensively it can jump back 81 | 82 | 6. Open developer settings on the device 83 | 84 | 7. Open app directory: open the directory where all the files stored on your pc 85 | 86 | #### Tabs 87 | 88 | 1. Batch command 89 | * Create and execute batch adb commands 90 | * You don't need to know the adb command behind it, just use the command wizard tool 91 | 92 | 2. Applications 93 | * Clear app data 94 | * Uninstall app 95 | * Kill all apps process, only on debugble apps, to emulate android memory clean 96 | * Get installed APK from device 97 | * Run monkey runner on any app 98 | 99 | 3. APKs 100 | * Install APK for pc (can configure to show several folders) 101 | * Run de-obfuscation tool (need to be downloaded separately) 102 | 103 | 4. Intent / Broadcasts 104 | * Send broadcast / intents to device 105 | * Save you popular ones for future use 106 | 107 | 5. Log / Exceptions 108 | * See logcat 109 | * Browse through exceptions 110 | * Save exception / log to file 111 | 112 | 6. Terminal 113 | * Expirement with adb commands 114 | 115 | 7. Preference 116 | * Edit app preference 117 | 118 | ## Share 'command batch' / 'intent' with your team 119 | You can easily send you team an 'command batch' or 'intent' they both saved in a JSON file.
120 | Just find the right file under your app directory and send it to your team mate.
121 | Ask him to put it into the right directory and that it, he got it! 122 | 123 | ## Known Issues 124 | 125 | Was developed and tested on MAC, windows and linux support is limited some features may not work (It should but was partialy tested). 126 | Was tested on variety of devices mainly on NEXUS 5x and emulators 127 | 128 | 1. Unothorized device: some times the adb devices command will retrive one of the devices as unothorized in this case you should: 129 | * Press "Kill ADB" 130 | * Open terminal / command line and write "adb devices" (Running this command from the App not working for some reason) 131 | * Press "Start monitoring" to get the device list back 132 | 133 | 2. Some of the functions will not work if the app is placed in path with spaces 134 | -------------------------------------------------------------------------------- /adbuitool.properties: -------------------------------------------------------------------------------- 1 | path.variable.kotlin_bundled=/Applications/IntelliJ IDEA CE.app/Contents/plugins/Kotlin/kotlinc 2 | path.variable.maven_repository=/Users/evgeni.shafran/.m2/repository 3 | jdk.home.1.8=/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home 4 | idea.home=/Applications/IntelliJ IDEA CE.app/Contents 5 | javac2.instrumentation.includeJavaRuntime=false -------------------------------------------------------------------------------- /adbuitool.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /libs/gson-2.2.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yapplications/ADB-GUI/9aeee11d24ff0fa290ac91d39ccca7852bd3f849/libs/gson-2.2.4.jar -------------------------------------------------------------------------------- /module_adbuitool.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /src/application/ADBHelper.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import application.intentbroadcasts.IntentBroadcast; 4 | import application.log.Logger; 5 | 6 | import java.text.SimpleDateFormat; 7 | import java.util.Calendar; 8 | import java.util.HashSet; 9 | import java.util.Set; 10 | 11 | public class ADBHelper { 12 | public static boolean pull(String from, String to) { 13 | 14 | //to = to.replaceAll(" ", "_"); 15 | //to = to.replaceAll(" ", "\\\\ "); 16 | /*byte ptext[] = new byte[0]; 17 | try { 18 | ptext = to.getBytes("UTF-8"); 19 | 20 | to = new String(ptext, "CP1252"); 21 | } catch (UnsupportedEncodingException e) { 22 | e.printStackTrace(); 23 | }*/ 24 | 25 | String run ="pull " + from + " " + to + ""; 26 | String result = AdbUtils.run(run); 27 | 28 | if (!result.trim().contains("100%")) { 29 | Logger.e(result + "\nto: " + to); 30 | return false; 31 | } 32 | 33 | return true; 34 | } 35 | 36 | public static String rm(String fileToDelete) { 37 | return AdbUtils.run("shell rm \"" + fileToDelete + "\""); 38 | } 39 | 40 | public static String killServer() { 41 | return AdbUtils.run("kill-server"); 42 | } 43 | 44 | public static String openApp(String packageString) { 45 | String result = AdbUtils.run("shell monkey -p " + packageString + " 1"); 46 | 47 | if (!result.contains("No activities found to run")) { 48 | result = null; 49 | } 50 | 51 | return result; 52 | } 53 | 54 | public static String runMonkey(String applicationName, int numberOfSteps, int throttle) { 55 | String result = AdbUtils.run("shell monkey -p " + applicationName + " -v --throttle " + throttle + " " + numberOfSteps); 56 | 57 | if (!result.contains("No activities found to run")) { 58 | result = null; 59 | } 60 | 61 | return result; 62 | } 63 | 64 | public static String kill(String packageName, String pid) { 65 | String result = AdbUtils.run("shell run-as " + packageName + " kill " + pid); 66 | 67 | if (!result.contains("not debuggable")) { 68 | result = null; 69 | } 70 | 71 | 72 | return result; 73 | } 74 | 75 | public static String clearData(String getSelectedAppPackage) { 76 | 77 | String result = AdbUtils.run("shell pm clear " + getSelectedAppPackage); 78 | 79 | if (result.contains("Success")) { 80 | result = null; 81 | } 82 | 83 | return result; 84 | } 85 | 86 | public static String install(String selectedApk) { 87 | 88 | String result = AdbUtils.run("install -r " + selectedApk + ""); 89 | String[] split = result.split("\n"); 90 | 91 | if (split.length > 0) { 92 | if (split[split.length - 1].contains("Failure") || split[split.length - 1].contains("Missing")) { 93 | return split[split.length - 1]; 94 | } else { 95 | return null; 96 | } 97 | } 98 | 99 | return "Wired Error"; 100 | } 101 | 102 | public static void sendInputText(String text) { 103 | String result = AdbUtils.run("shell input text \"" + text + "\""); 104 | Logger.d("shell input text " + text + " -> " + result); 105 | 106 | } 107 | 108 | public static String sendIntent(IntentBroadcast intentBroadcast) { 109 | String command = "shell am " + intentBroadcast.activityManagerCommand + 110 | (!intentBroadcast.action.equals("") ? " -a " + intentBroadcast.action : "") + 111 | (!intentBroadcast.data.equals("") ? " -d " + intentBroadcast.data : "") + 112 | (!intentBroadcast.mimeType.equals("") ? " -t " + intentBroadcast.mimeType : "") + 113 | (!intentBroadcast.category.equals("") ? " -c " + intentBroadcast.category : "") + 114 | (!intentBroadcast.component.equals("") ? " -n " + intentBroadcast.component : "") + 115 | ""; 116 | 117 | Logger.d(command); 118 | 119 | String result = AdbUtils.run(command); 120 | 121 | if (!result.contains("Error:")) { 122 | result = null; 123 | } 124 | 125 | return result; 126 | } 127 | 128 | public static String connectDeviceToWifi() { 129 | String result = null; 130 | 131 | result = AdbUtils.run("shell ip -f inet addr show wlan0"); 132 | Logger.d("shell ip " + result); 133 | 134 | String[] split = result.split("\n"); 135 | String ip = null; 136 | for (String line : split) { 137 | if (line.contains("inet")) { 138 | 139 | String[] splitSpaces = line.split("\\s+"); 140 | int i = 0; 141 | for (String word : splitSpaces) { 142 | if (word.contains("inet")) { 143 | break; 144 | } 145 | i++; 146 | } 147 | 148 | if (splitSpaces.length > i + 1) { 149 | ip = splitSpaces[i + 1].split("/")[0]; 150 | } 151 | 152 | Logger.d("connectDeviceToWifi: ip: " + ip); 153 | 154 | break; 155 | } 156 | } 157 | 158 | if (ip != null) { 159 | result = AdbUtils.run("tcpip 5555"); 160 | Logger.d("tcpip " + result); 161 | if (result.contains("restarting")) { 162 | 163 | result = AdbUtils.run("connect " + ip + ":5555"); 164 | Logger.d("connect " + result); 165 | 166 | if (result.contains("connected")) { 167 | result = null; 168 | } 169 | 170 | } 171 | } 172 | return result; 173 | } 174 | 175 | public static String setDateTime(Calendar calendar) { 176 | String result = null; 177 | result = AdbUtils.run("shell settings put global auto_time 0"); 178 | Logger.d(result); 179 | 180 | result = AdbUtils.run("shell settings put global auto_time_zone 0"); 181 | Logger.d(result); 182 | 183 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMddhhmmyyyy.ss"); 184 | 185 | String dateString = simpleDateFormat.format(calendar.getTime()); 186 | 187 | result = AdbUtils.run("root"); 188 | 189 | result = AdbUtils.run("shell date " + dateString); 190 | Logger.d("shell date " + dateString + " ---> " + result); 191 | 192 | if (!result.contains("bad date") && !result.contains("not permitted")){ 193 | result = null; 194 | } 195 | 196 | return result; 197 | } 198 | 199 | public static Set getPackages() { 200 | String result = AdbUtils.run("shell pm list packages"); 201 | 202 | String[] split = result.split("\n"); 203 | 204 | Set packages = new HashSet(); 205 | 206 | for (int i = 1; i < split.length; i++) { 207 | String packageName = split[i].replace("package:", "").trim(); 208 | if (packageName.equals("android")) { 209 | continue; 210 | } 211 | 212 | packages.add(packageName); 213 | } 214 | 215 | return packages; 216 | } 217 | 218 | public static boolean isADBFound() { 219 | String result = AdbUtils.run("version"); 220 | 221 | return result.startsWith("Android Debug Bridge"); 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /src/application/AdbUtils.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.InputStreamReader; 5 | import java.util.concurrent.*; 6 | 7 | import application.preferences.Preferences; 8 | import javafx.application.Platform; 9 | import application.log.Logger; 10 | import application.model.Command; 11 | import application.model.CommandBatch; 12 | import application.model.Device; 13 | import application.model.Model; 14 | 15 | public class AdbUtils { 16 | //public static ExecutorService executor = Executors.newSingleThreadExecutor(); 17 | public static ExecutorService executor = Executors.newScheduledThreadPool(2); 18 | public static ExecutorService executorTimeout = Executors.newScheduledThreadPool(2); 19 | 20 | public interface TimeCallListener{ 21 | void timeout(); 22 | void error(Exception e); 23 | } 24 | 25 | public static T timedCall(Callable c, long timeout, TimeUnit timeUnit, final TimeCallListener timeCallListener) { 26 | FutureTask task = new FutureTask(c); 27 | executor.execute(task); 28 | executorTimeout.execute(new Runnable() { 29 | @Override 30 | public void run() { 31 | try { 32 | task.get(timeout, timeUnit); 33 | } catch (InterruptedException e) { 34 | timeCallListener.error(e); 35 | } catch (ExecutionException e) { 36 | timeCallListener.error(e); 37 | } catch (TimeoutException e) { 38 | timeCallListener.timeout(); 39 | } 40 | } 41 | }); 42 | return null; 43 | } 44 | 45 | 46 | public static String run(CommandBatch batch) { 47 | String result = ""; 48 | 49 | for (Command command : batch.commands) { 50 | result += executeADBCommand(command.command) + "\n"; 51 | } 52 | 53 | return result; 54 | } 55 | 56 | private static String executeADBCommand(String command) { 57 | return executeCommand(getAdbCommand(command)); 58 | } 59 | 60 | public static String getAdbCommand(String command) { 61 | if (command.startsWith("adb")){ 62 | command = command.replaceFirst("adb", ""); 63 | } 64 | 65 | Device selectedDevice = Model.instance.getSelectedDevice(); 66 | return Preferences.getInstance().getAdbInstallLocatoin() + "adb " 67 | + (selectedDevice != null ? "-s " + selectedDevice.getId() + " " : "") + command; 68 | // return "adb " + command; 69 | } 70 | 71 | public interface ADBRunListener { 72 | void onFinish(String resporse); 73 | } 74 | 75 | public static void runAsync(String string, ADBRunListener listener) { 76 | executor.execute(new Runnable() { 77 | 78 | @Override 79 | public void run() { 80 | String resporse = executeADBCommand(string); 81 | 82 | if (listener != null) { 83 | Platform.runLater(new Runnable() { 84 | @Override 85 | public void run() { 86 | listener.onFinish(resporse); 87 | } 88 | }); 89 | } 90 | } 91 | }); 92 | } 93 | 94 | public static String run(Command command) { 95 | 96 | return executeADBCommand(command.command); 97 | } 98 | 99 | public static String run(String string) { 100 | 101 | return executeADBCommand(string); 102 | } 103 | 104 | public static String executeCommand(String [] command) { 105 | return executeCommand(null, command); 106 | } 107 | 108 | public static String executeCommand(String command) { 109 | return executeCommand(command, null); 110 | } 111 | public static String executeCommand(String command , String [] commands) { 112 | // System.out.println("Run: " + command); 113 | 114 | StringBuffer output = new StringBuffer(); 115 | 116 | Process p; 117 | try { 118 | 119 | String[] envp = {}; 120 | if (commands == null) { 121 | p = Runtime.getRuntime().exec(command, envp); 122 | } else { 123 | p = Runtime.getRuntime().exec(commands, envp); 124 | } 125 | 126 | p.waitFor(10, TimeUnit.SECONDS); 127 | BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); 128 | 129 | boolean firstLine = true; 130 | String line = ""; 131 | while ((line = reader.readLine()) != null) { 132 | if (!firstLine) { 133 | output.append("\n"); 134 | } 135 | firstLine = false; 136 | output.append(line); 137 | // System.out.println(line); 138 | } 139 | 140 | reader = new BufferedReader(new InputStreamReader(p.getErrorStream())); 141 | 142 | while ((line = reader.readLine()) != null) { 143 | if (!firstLine) { 144 | output.append("\n"); 145 | } 146 | firstLine = false; 147 | output.append(line + "\n"); 148 | // System.out.println(line); 149 | } 150 | 151 | } catch (Exception e) { 152 | e.printStackTrace(); 153 | output.append(e.getMessage()); 154 | } 155 | 156 | String result = output.toString(); 157 | 158 | if (false){ 159 | Logger.d("Run: " + command + "\n" + result); 160 | } 161 | 162 | return result; 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /src/application/DateUtil.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | /** 7 | * Created by evgeni.shafran on 10/13/16. 8 | */ 9 | public class DateUtil { 10 | 11 | public static String getCurrentTimeStamp() { 12 | return new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss_SSS").format(new Date()); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/application/DialogUtil.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import javafx.scene.control.Alert; 4 | import javafx.scene.control.Alert.AlertType; 5 | 6 | public class DialogUtil { 7 | public static void showErrorDialog(String headerText){ 8 | Alert alert = new Alert(AlertType.ERROR); 9 | alert.setTitle("Error"); 10 | alert.setHeaderText(headerText); 11 | //alert.setContentText("Ooops, there was an error!"); 12 | 13 | alert.showAndWait(); 14 | } 15 | 16 | public static void showInfoDialog(String headerText) { 17 | Alert alert = new Alert(AlertType.INFORMATION); 18 | alert.setTitle("Info"); 19 | alert.setHeaderText(headerText); 20 | //alert.setContentText("Ooops, there was an error!"); 21 | 22 | alert.showAndWait(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/application/FXMLMain.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 |
59 | 60 | 61 | 62 | 63 | 64 |