Skip to content

Commit 12ce9c3

Browse files
committed
Show USB driver warning
1 parent 32f4200 commit 12ce9c3

File tree

2 files changed

+47
-14
lines changed

2 files changed

+47
-14
lines changed

src/processing/mode/android/AndroidEditor.java

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -482,21 +482,44 @@ public void run() {
482482
* Build the sketch and run it on a device with the debugger connected.
483483
*/
484484
public void handleRunDevice() {
485-
new Thread() {
486-
public void run() {
487-
toolbar.activate(AndroidToolbar.RUN);
488-
startIndeterminate();
489-
prepareRun();
490-
try {
491-
androidMode.handleRunDevice(sketch, AndroidEditor.this);
492-
} catch (SketchException e) {
493-
statusError(e);
494-
} catch (IOException e) {
495-
statusError(e);
496-
}
497-
stopIndeterminate();
485+
if(Base.isWindows() && !Preferences.getBoolean("usbDriverWarningShown")) {
486+
Preferences.setBoolean("usbDriverWarningShown", true);
487+
488+
String message = "";
489+
File usbDriverFile = new File(((AndroidMode) sketch.getMode()).getSDK().getSdkFolder(), "extras/google/usb_driver");
490+
if (usbDriverFile.exists()) {
491+
message = "<html><body>" +
492+
"You might need to install Google USB Driver to run the sketch on your device.<br>" +
493+
"Please follow the guide at <a href='http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver'>http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver</a> to install the driver.<br>" +
494+
"For your reference, the driver is located in: " + usbDriverFile.getAbsolutePath();
495+
} else {
496+
message = "<html><body>" +
497+
"You might need to install Google USB Driver to run the sketch on your device.<br>" +
498+
"Please follow the guide at <a href='http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver'>http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver</a> to install the driver.<br>" +
499+
"You will also need to download the driver from <a href='http://developer.android.com/sdk/win-usb.html'>http://developer.android.com/sdk/win-usb.html</a>";
498500
}
499-
}.start();
501+
502+
Base.showWarning(
503+
"USB Driver warning",
504+
message
505+
);
506+
} else {
507+
new Thread() {
508+
public void run() {
509+
toolbar.activate(AndroidToolbar.RUN);
510+
startIndeterminate();
511+
prepareRun();
512+
try {
513+
androidMode.handleRunDevice(sketch, AndroidEditor.this);
514+
} catch (SketchException e) {
515+
statusError(e);
516+
} catch (IOException e) {
517+
statusError(e);
518+
}
519+
stopIndeterminate();
520+
}
521+
}.start();
522+
}
500523
}
501524

502525

src/processing/mode/android/SDKDownloader.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class SDKDownloader extends JFrame implements PropertyChangeListener {
3232

3333
private static final String URL_REPOSITORY = "https://dl-ssl.google.com/android/repository/repository-10.xml";
3434
private static final String URL_REPOSITORY_FOLDER = "http://dl-ssl.google.com/android/repository/";
35+
private static final String URL_USB_DRIVER = "https://dl-ssl.google.com//android/repository/latest_usb_driver_windows.zip";
3536

3637
private static final String PLATFORM_API_LEVEL = "10";
3738

@@ -69,6 +70,8 @@ protected Object doInBackground() throws Exception {
6970
if (!platformsFolder.exists()) platformsFolder.mkdir();
7071
File buildToolsFolder = new File(sdkFolder, "build-tools");
7172
if (!buildToolsFolder.exists()) buildToolsFolder.mkdir();
73+
File extrasFolder = new File(sdkFolder, "extras");
74+
if(!extrasFolder.exists()) extrasFolder.mkdir();
7275

7376
// creating temp folder for downloaded zip packages
7477
File tempFolder = new File(modeFolder, "temp");
@@ -95,6 +98,13 @@ protected Object doInBackground() throws Exception {
9598
File downloadedPlatform = new File(tempFolder, downloadUrls.platformFilename);
9699
downloadAndUnpack(downloadUrls.platformUrl, downloadedPlatform, platformsFolder);
97100

101+
// usb driver
102+
if(Base.isWindows()) {
103+
File usbDriverFolder = new File(extrasFolder, "google");
104+
File downloadedFolder = new File(tempFolder, "latest_usb_driver_windows.zip");
105+
downloadAndUnpack(URL_USB_DRIVER, downloadedFolder, usbDriverFolder);
106+
}
107+
98108
if (Base.isLinux() || Base.isMacOS()) {
99109
Runtime.getRuntime().exec("chmod -R 755 " + sdkFolder.getAbsolutePath());
100110
}

0 commit comments

Comments
 (0)