aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager/libs/sdkuilib/src
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2012-02-09 12:57:23 -0800
committerRaphael <raphael@google.com>2012-02-09 13:12:31 -0800
commit56a6d5e290d78888d3640a555385d123abb0d503 (patch)
tree07a50029f345831fb3815b28c9f1b3af0de69dfa /sdkmanager/libs/sdkuilib/src
parent8c578aff7c5d84bc38d5a6d391986aece3cd2e19 (diff)
downloadsdk-56a6d5e290d78888d3640a555385d123abb0d503.zip
sdk-56a6d5e290d78888d3640a555385d123abb0d503.tar.gz
sdk-56a6d5e290d78888d3640a555385d123abb0d503.tar.bz2
SDK Manager: use find_lock.exe when install dir is locked.
For the SDK Manager on Windows, this uses find_lock.exe to try to find the processes that are locking an existing SDK folder that cannot be moved out of the way. The result is displayed in a simple yes/no dialog or on the command-line if invoked without UI. Change-Id: I39fa7529e207e870376a30c8311440f9c240d4b3
Diffstat (limited to 'sdkmanager/libs/sdkuilib/src')
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SdkUpdaterNoWindow.java40
1 files changed, 37 insertions, 3 deletions
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SdkUpdaterNoWindow.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SdkUpdaterNoWindow.java
index 7b94c94..89f084c 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SdkUpdaterNoWindow.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SdkUpdaterNoWindow.java
@@ -347,11 +347,37 @@ public class SdkUpdaterNoWindow {
@Override
public boolean displayPrompt(final String title, final String message) {
// TODO Make it interactive if mForce==false
- mSdkLog.printf("\n%s\n%s\n[y/n] => %s\n",
+ mSdkLog.printf("\n%1$s\n%2$s\n%3$s", //$NON-NLS-1$
title,
message,
- mForce ? "yes" : "no (use --force to override)");
- return mForce;
+ mForce ? "--force used, will reply yes\n" :
+ "Note: you can use --force to override to yes.\n");
+ if (mForce) {
+ return true;
+ }
+
+ while (true) {
+ mSdkLog.printf("%1$s", "[y/n] =>"); //$NON-NLS-1$
+ try {
+ byte[] readBuffer = new byte[2048];
+ String reply = readLine(readBuffer).trim();
+ mSdkLog.printf("\n"); //$NON-NLS-1$
+ if (reply.length() > 0 && reply.length() <= 3) {
+ char c = reply.charAt(0);
+ if (c == 'y' || c == 'Y') {
+ return true;
+ } else if (c == 'n' || c == 'N') {
+ return false;
+ }
+ }
+ mSdkLog.printf("Unknown reply '%s'. Please use y[es]/n[o].\n"); //$NON-NLS-1$
+
+ } catch (IOException e) {
+ // Exception. Be conservative and say no.
+ mSdkLog.printf("\n"); //$NON-NLS-1$
+ return false;
+ }
+ }
}
/**
@@ -417,6 +443,14 @@ public class SdkUpdaterNoWindow {
return new UserCredentials(login, password, workstation, domain);
}
+ /**
+ * Reads current console input in the given buffer.
+ *
+ * @param buffer Buffer to hold the user input. Must be larger than the largest
+ * expected input. Cannot be null.
+ * @return A new string. May be empty but not null.
+ * @throws IOException in case the buffer isn't long enough.
+ */
private String readLine(byte[] buffer) throws IOException {
int count = System.in.read(buffer);