Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd4ba9f34a | ||
|
|
5513cabf3e | ||
|
|
cc541e78de | ||
|
|
2d31e5199f | ||
|
|
c5fa538b42 | ||
|
|
32d0f1cde8 | ||
|
|
83fc93c670 | ||
|
|
0925798199 |
@@ -5,10 +5,6 @@ This is a re-implementation of the [15 seconds ADB Installer](https://forum.xda-
|
||||
|
||||
This installer requires an internet connection.
|
||||
|
||||
The main component is [the PowerShell script](https://github.com/josephsmendoza/ADB-Installer/blob/master/install.ps1) which downloads [the latest android platform tools for windows](https://dl.google.com/android/repository/platform-tools-latest-windows.zip) and installs them to either `C:\adb`, an auto-detected previous install location, or a path you can specify via `-installPath`.
|
||||
|
||||
For conveinence, this is wrapped in an `.exe` file which runs the script with `ExecutionPolicy` set to `Bypass`. This file is fully automated.
|
||||
|
||||
Icon is from [Google via icon-icons.com](https://icon-icons.com/icon/adb/90476)
|
||||
|
||||
Built with [7z SFX Builder](https://sourceforge.net/projects/s-zipsfxbuilder)
|
||||
Packaged with [7z SFX Builder](https://sourceforge.net/projects/s-zipsfxbuilder)
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
Param( [Parameter(Position=0)] [String[]] $installPath )
|
||||
Set-PSDebug -Trace 2
|
||||
$ErrorActionPreference = 'Inquire'
|
||||
$shell = New-Object -ComObject Wscript.Shell
|
||||
$adb=Get-Command "adb" -ErrorAction SilentlyContinue
|
||||
$fastboot=Get-Command "fastboot" -ErrorAction SilentlyContinue
|
||||
|
||||
if($installPath.Length.Equals(0)){
|
||||
if(!$adb -and $fastboot){
|
||||
$installPath=fastboot --version | Select-String -Pattern "(?<=installed as )(.+)(?=\\.*\.exe)" | % { $_.Matches } | % { $_.Value }
|
||||
}
|
||||
if($adb){
|
||||
$installPath=adb --version | Select-String -Pattern "(?<=installed as )(.+)(?=\\.*\.exe)" | % { $_.Matches } | % { $_.Value }
|
||||
Invoke-Command -ScriptBlock {
|
||||
$ErrorActionPreference = 'Ignore'
|
||||
adb kill-server
|
||||
}
|
||||
}
|
||||
if($installPath.Length.Equals(0)){
|
||||
$installPath="$env:APPDATA\SideQuest\platform-tools"
|
||||
}
|
||||
}
|
||||
|
||||
if ( (cmd /c sc query Windefend) -like "*RUNNING*" ){
|
||||
Add-MpPreference -ExclusionPath $installPath
|
||||
Add-MpPreference -ExclusionProcess "adb.exe"
|
||||
} else {
|
||||
$shell.Popup("Windows Defender is not running!
|
||||
If you have antivirus, exclude $installPath")
|
||||
}
|
||||
|
||||
if(!$adb -and !$fastboot){
|
||||
$oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path
|
||||
$newpath = "$oldpath;$installPath"
|
||||
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath
|
||||
}
|
||||
|
||||
Import-Module BitsTransfer
|
||||
Start-BitsTransfer -Source "https://dl.google.com/android/repository/platform-tools-latest-windows.zip" -Destination "$env:temp\platform-tools-latest-windows.zip"
|
||||
Set-PSDebug -Off
|
||||
Expand-Archive -Path "$env:temp\platform-tools-latest-windows.zip" -DestinationPath "$env:temp" -Force
|
||||
Set-PSDebug -Trace 2
|
||||
if(-Not (Test-Path $installPath)){
|
||||
mkdir $installPath
|
||||
}
|
||||
Copy-Item -Path "$env:temp\platform-tools\*" -Destination "$installPath\" -Force
|
||||
|
||||
$PSScriptRootLegacy=split-path -parent $MyInvocation.MyCommand.Definition
|
||||
Start-Process $PSScriptRootLegacy/android_winusb.inf -Verb Install
|
||||
|
||||
$shell.Popup("Done!")
|
||||
@@ -0,0 +1,34 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id "org.beryx.runtime" version "1.2.1" //https://plugins.gradle.org/plugin/org.beryx.runtime
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src'
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'net.java.dev.jna:jna:5.3.1'
|
||||
compile 'net.java.dev.jna:jna-platform:5.3.1'
|
||||
}
|
||||
|
||||
jar {
|
||||
from {
|
||||
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
}
|
||||
|
||||
application {
|
||||
mainClassName = 'josephsmendoza.android.sdk.platformTools.installer.Common'
|
||||
}
|
||||
|
||||
runtime {
|
||||
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
|
||||
modules = ['java.desktop','java.logging','java.datatransfer','jdk.crypto.ec']
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
Param( [Parameter(Position=0)] [String[]] $installPath )
|
||||
Set-PSDebug -Trace 2
|
||||
$ErrorActionPreference = 'Inquire'
|
||||
$shell = New-Object -ComObject Wscript.Shell
|
||||
$adb=Get-Command "adb" -ErrorAction SilentlyContinue
|
||||
$fastboot=Get-Command "fastboot" -ErrorAction SilentlyContinue
|
||||
|
||||
if($installPath.Length.Equals(0)){
|
||||
if(!$adb -and $fastboot){
|
||||
$installPath=fastboot --version | Select-String -Pattern "(?<=installed as )(.+)(?=\\.*\.exe)" | % { $_.Matches } | % { $_.Value }
|
||||
}
|
||||
if($adb){
|
||||
$installPath=adb --version | Select-String -Pattern "(?<=installed as )(.+)(?=\\.*\.exe)" | % { $_.Matches } | % { $_.Value }
|
||||
Invoke-Command -ScriptBlock {
|
||||
$ErrorActionPreference = 'Ignore'
|
||||
adb kill-server
|
||||
}
|
||||
}
|
||||
if($installPath.Length.Equals(0)){
|
||||
$installPath="C:\android-platform-tools"
|
||||
}
|
||||
}
|
||||
|
||||
if ( (cmd /c sc query Windefend) -like "*RUNNING*" ){
|
||||
Add-MpPreference -ExclusionPath $installPath
|
||||
Add-MpPreference -ExclusionProcess "adb.exe"
|
||||
} else {
|
||||
$shell.Popup("Windows Defender is not running!
|
||||
If you have antivirus, exclude $installPath")
|
||||
}
|
||||
|
||||
if(!$adb -and !$fastboot){
|
||||
$oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path
|
||||
$newpath = "$oldpath;$installPath"
|
||||
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath
|
||||
}
|
||||
|
||||
Import-Module BitsTransfer
|
||||
Start-BitsTransfer -Source "https://dl.google.com/android/repository/platform-tools-latest-windows.zip" -Destination "$env:temp\platform-tools-latest-windows.zip"
|
||||
Set-PSDebug -Off
|
||||
Expand-Archive -Path "$env:temp\platform-tools-latest-windows.zip" -DestinationPath "$env:temp" -Force
|
||||
Set-PSDebug -Trace 2
|
||||
if(-Not (Test-Path $installPath)){
|
||||
mkdir $installPath
|
||||
}
|
||||
Copy-Item -Path "$env:temp\platform-tools\*" -Destination "$installPath\" -Force
|
||||
|
||||
$shell.Popup("Done!")
|
||||
@@ -1,8 +1,11 @@
|
||||
;!@Install@!UTF-8!
|
||||
RunProgram="powershell -executionpolicy bypass -file %%T\install.ps1"
|
||||
GUIMode="1"
|
||||
MiscFlags="4"
|
||||
OverwriteMode="2"
|
||||
RunProgram="%%T/bin/ADB-Installer.bat"
|
||||
;Config file generated by 7z SFX Builder v2.1. (http://sourceforge.net/projects/s-zipsfxbuilder/)
|
||||
;!@InstallEnd@!
|
||||
7zSFXBuilder_7zArchive=C:\Users\Josef\Documents\ADB-Installer\install.7z
|
||||
7zSFXBuilder_SFXIcon=C:\Users\Josef\Documents\ADB-Installer\adb.ico
|
||||
7zSFXBuilder_UseDefMod=7zsd_All_x64
|
||||
7zSFXBuilder_7zArchive=C:\Users\Josef\Documents\ADB-Installer\image.7z
|
||||
7zSFXBuilder_SFXIcon=C:\Users\Josef\Documents\ADB-Installer\-adb_90476.ico
|
||||
7zSFXBuilder_UseDefMod=7zsd_All
|
||||
7zSFXBuilder_UPXCommands=--best --all-methods
|
||||
@@ -0,0 +1,57 @@
|
||||
package josephsmendoza.android.sdk.platformTools.installer;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
public class AVFixInstall implements Runnable {
|
||||
|
||||
private String installPath;
|
||||
private String command;
|
||||
private String running;
|
||||
private String excludePath;
|
||||
private String excludeProcess;
|
||||
|
||||
public AVFixInstall(String path) {
|
||||
installPath=path;
|
||||
command="sc query WinDefend";
|
||||
running="RUNNING";
|
||||
excludePath="powershell Add-MpPreference -ExclusionPath";
|
||||
excludeProcess="powershell Add-MpPreference -ExclusionProcess";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Runtime cmd=Runtime.getRuntime();
|
||||
String av=new String(cmd.exec(command).getInputStream().readAllBytes());
|
||||
if(av.contains(running)) {
|
||||
cmd.exec(excludePath+installPath);
|
||||
cmd.exec(excludeProcess+Common.adb);
|
||||
cmd.exec(excludeProcess+Common.fastboot);
|
||||
} else {
|
||||
JDialog frame=new JDialog();
|
||||
frame.setLayout(new BoxLayout(frame.getContentPane(),BoxLayout.Y_AXIS));
|
||||
frame.setIconImage(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB_PRE));
|
||||
frame.add(new JLabel("Windows Defender is not running!"));
|
||||
frame.add(new JLabel("Make exceptions in your antivirus for:"));
|
||||
frame.add(new JLabel("adb.exe"));
|
||||
frame.add(new JLabel("fastboot.exe"));
|
||||
frame.add(new JLabel(installPath));
|
||||
frame.add(new JLabel("The install path has been copied to your clipboard"));
|
||||
frame.setModal(true);
|
||||
frame.pack();
|
||||
frame.setLocationRelativeTo(null);
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(installPath), null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package josephsmendoza.android.sdk.platformTools.installer;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class Common {
|
||||
|
||||
private static ExecutorService executorService;
|
||||
public static final Set<String> installPaths = Collections.synchronizedSet(new HashSet<String>());
|
||||
public static volatile boolean FileSearchComplete=false;
|
||||
public static volatile boolean PathSearchComplete=false;
|
||||
public static volatile boolean FileInstallComplete=false;
|
||||
public static volatile boolean PathInstallComplete=false;
|
||||
public static volatile boolean SettingsInstallComplete=false;
|
||||
public static final String OS = System.getProperty("os.name").toUpperCase().substring(0, 3);
|
||||
public static final String adb=" adb";
|
||||
public static final String fastboot=" fastboot";
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
GUI gui = new GUI();
|
||||
initInstallPaths();
|
||||
executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
|
||||
executorService.execute(gui);
|
||||
executorService.execute(new FileSearch());
|
||||
executorService.execute(new PathSearch());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void initInstallPaths() {
|
||||
final String append = Paths.get("Android", "SDK", "platform-tools").toString();
|
||||
switch (OS) {
|
||||
case "WIN":
|
||||
installPaths.add(Paths.get(System.getenv("LocalAppData"), append).toString());
|
||||
installPaths.add(Paths.get(System.getenv("ProgramFiles"), append).toString());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void install(String path) {
|
||||
executorService.execute(new FileInstall(path));
|
||||
executorService.execute(new PathInstall(path));
|
||||
executorService.execute(new AVFixInstall(path));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package josephsmendoza.android.sdk.platformTools.installer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.net.URL;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
public class FileInstall implements Runnable {
|
||||
|
||||
private String installPath;
|
||||
|
||||
public FileInstall(String path) {
|
||||
installPath=path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
ZipInputStream ziStream=new ZipInputStream(new URL(getURL()).openStream());
|
||||
ZipEntry zEntry;
|
||||
while((zEntry=ziStream.getNextEntry())!=null) {
|
||||
File f=new File(installPath+zEntry.getName().replaceAll("platform-tools", ""));
|
||||
int size=(int) zEntry.getSize();
|
||||
if(size==0) {
|
||||
f.mkdirs();
|
||||
continue;
|
||||
}
|
||||
if(!f.exists()) {
|
||||
f.createNewFile();
|
||||
}
|
||||
FileOutputStream foStream=new FileOutputStream(f);
|
||||
foStream.write(ziStream.readNBytes(size));
|
||||
foStream.flush();
|
||||
foStream.close();
|
||||
}
|
||||
|
||||
Common.FileInstallComplete=true;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getURL() {
|
||||
switch(Common.OS) {
|
||||
case "WIN":
|
||||
return "https://dl.google.com/android/repository/platform-tools-latest-windows.zip";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package josephsmendoza.android.sdk.platformTools.installer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.FileVisitor;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
public class FileSearch implements FileVisitor<Path>, Runnable {
|
||||
|
||||
private String matchRegex = ".*adb.exe|.*fastboot.exe";
|
||||
private String skipRegex = ".*Recycle\\.Bin|.*Temp.*";
|
||||
private Path startPath = getRoot();
|
||||
|
||||
private Path getRoot() {
|
||||
if (Common.OS == "WIN") {
|
||||
return Paths.get("C:\\");
|
||||
}
|
||||
return Paths.get("/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
|
||||
if (dir.toAbsolutePath().toString().matches(skipRegex)) {
|
||||
return FileVisitResult.SKIP_SUBTREE;
|
||||
} else {
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
Path absolutePath = file.toAbsolutePath();
|
||||
if (absolutePath.toString().matches(matchRegex) && file.toFile().canExecute())
|
||||
Common.installPaths.add((absolutePath.getParent().toString()));
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Files.walkFileTree(startPath, this);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Common.FileSearchComplete = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package josephsmendoza.android.sdk.platformTools.installer;
|
||||
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
|
||||
|
||||
public class GUI implements Runnable {
|
||||
|
||||
JFrame frame;
|
||||
JPanel statusPanel;
|
||||
JLabel searchingLabel;
|
||||
JPanel selectionPanel;
|
||||
|
||||
public GUI() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
|
||||
frame=new JFrame("ADB Installer");
|
||||
frame.setLayout(new BoxLayout(frame.getContentPane(),BoxLayout.Y_AXIS));
|
||||
frame.setIconImage(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB_PRE));
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
|
||||
statusPanel=new JPanel();
|
||||
statusPanel.setLayout(new GridLayout(0,1));
|
||||
frame.add(statusPanel);
|
||||
|
||||
JLabel selectLabel=new JLabel("Select an install location");
|
||||
selectLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
statusPanel.add(selectLabel);
|
||||
|
||||
searchingLabel=new JLabel("Searching for pre-existing files...");
|
||||
searchingLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
statusPanel.add(searchingLabel);
|
||||
|
||||
selectionPanel=new JPanel();
|
||||
selectionPanel.setLayout(new GridLayout(0,1));
|
||||
frame.add(selectionPanel);
|
||||
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int lastSize=0;
|
||||
while (!Common.FileSearchComplete) {
|
||||
if(lastSize<Common.installPaths.size()) {
|
||||
update();
|
||||
lastSize=Common.installPaths.size();
|
||||
}
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
statusPanel.remove(searchingLabel);
|
||||
frame.pack();
|
||||
while(!Common.FileInstallComplete || !Common.PathInstallComplete) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
JLabel done=new JLabel("Done");
|
||||
done.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
frame.setContentPane(done);
|
||||
frame.pack();
|
||||
}
|
||||
|
||||
private void update() {
|
||||
selectionPanel.removeAll();
|
||||
for(String path:Common.installPaths) {
|
||||
JButton selectionButton=new JButton(path);
|
||||
selectionButton.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
selectionButton.addActionListener(l -> install(path));
|
||||
selectionPanel.add(selectionButton);
|
||||
}
|
||||
frame.pack();
|
||||
}
|
||||
|
||||
private void install(String path) {
|
||||
JLabel installing=new JLabel("Installing...");
|
||||
installing.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
frame.setContentPane(installing);
|
||||
frame.pack();
|
||||
Common.install(path);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package josephsmendoza.android.sdk.platformTools.installer;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.sun.jna.platform.win32.Advapi32Util;
|
||||
import com.sun.jna.platform.win32.WinReg;
|
||||
|
||||
public class PathInstall implements Runnable {
|
||||
|
||||
private String dir;
|
||||
private String sysKey;
|
||||
private String userKey;
|
||||
private String value;
|
||||
//private Advapi32Util winReg;
|
||||
|
||||
public PathInstall(String installPath) {
|
||||
dir = installPath;
|
||||
sysKey = "System\\CurrentControlSet\\Control\\Session Manager\\Environment";
|
||||
userKey = "Environment";
|
||||
value = "PATH";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (dir.contains(System.getProperty("user.home"))) {
|
||||
install(userKey);
|
||||
} else {
|
||||
install(sysKey);
|
||||
}
|
||||
}
|
||||
|
||||
private void install(String key){
|
||||
try {
|
||||
final String PATH = Advapi32Util.registryGetStringValue(WinReg.HKEY_LOCAL_MACHINE, sysKey, value);
|
||||
if (!PATH.contains(dir)) {
|
||||
Advapi32Util.registrySetStringValue(WinReg.HKEY_LOCAL_MACHINE, key, value,
|
||||
PATH + File.pathSeparatorChar + dir);
|
||||
}
|
||||
Common.PathInstallComplete = true;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package josephsmendoza.android.sdk.platformTools.installer;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class PathSearch implements Runnable{
|
||||
|
||||
public PathSearch() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
File adb=new File(new String(Runtime.getRuntime().exec(adbGetCommand()).getInputStream().readAllBytes()));
|
||||
if(adb.canExecute()) {
|
||||
Common.installPaths.add(adb.getParentFile().getAbsolutePath());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Not found
|
||||
}
|
||||
try {
|
||||
File fastboot=new File(new String(Runtime.getRuntime().exec(fastbootGetCommand()).getInputStream().readAllBytes()));
|
||||
if(fastboot.canExecute()) {
|
||||
Common.installPaths.add(fastboot.getParentFile().getAbsolutePath());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Not found
|
||||
}
|
||||
}
|
||||
|
||||
private String fastbootGetCommand() {
|
||||
return getCommand()+Common.fastboot;
|
||||
}
|
||||
|
||||
private String adbGetCommand() {
|
||||
return getCommand()+Common.adb;
|
||||
}
|
||||
|
||||
private String getCommand() {
|
||||
if(Common.OS=="WIN") {
|
||||
return "where";
|
||||
} else {
|
||||
return "which";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user