diff options
author | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2016-02-03 12:26:05 +0100 |
---|---|---|
committer | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2016-02-03 12:26:05 +0100 |
commit | 7fcb81ad1892e123e3b2c67abea966f370112c83 (patch) | |
tree | af3a7eae2c62a82d2a6c7c2f329be343fc335952 /tools/signapk/SignApk.java | |
parent | d1b082df91cb842e314cfb66dda53dc698d4c78c (diff) | |
parent | 705e90f0903eed0fa2ea92e80b8a5f3f09630cb0 (diff) | |
download | build-7fcb81ad1892e123e3b2c67abea966f370112c83.zip build-7fcb81ad1892e123e3b2c67abea966f370112c83.tar.gz build-7fcb81ad1892e123e3b2c67abea966f370112c83.tar.bz2 |
Merge branch 'cm-13.0' of https://github.com/CyanogenMod/android_build into replicant-6.0
Signed-off-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
Diffstat (limited to 'tools/signapk/SignApk.java')
-rw-r--r-- | tools/signapk/SignApk.java | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tools/signapk/SignApk.java b/tools/signapk/SignApk.java index 88f486a..3ddab11 100644 --- a/tools/signapk/SignApk.java +++ b/tools/signapk/SignApk.java @@ -167,18 +167,29 @@ class SignApk { } /** - * Reads the password from console and returns it as a string. + * If a console doesn't exist, reads the password from stdin + * If a console exists, reads the password from console and returns it as a string. * * @param keyFile The file containing the private key. Used to prompt the user. */ private static String readPassword(File keyFile) { Console console; char[] pwd; - if((console = System.console()) != null && - (pwd = console.readPassword("[%s]", "Enter password for " + keyFile)) != null){ - return String.valueOf(pwd); + if ((console = System.console()) == null) { + System.out.print("Enter password for " + keyFile + " (password will not be hidden): "); + System.out.flush(); + BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); + try { + return stdin.readLine(); + } catch (IOException ex) { + return null; + } } else { - return null; + if ((pwd = console.readPassword("[%s]", "Enter password for " + keyFile)) != null) { + return String.valueOf(pwd); + } else { + return null; + } } } |