diff --git a/android-mode.el b/android-mode.el index 9ed16eb..639ae21 100644 --- a/android-mode.el +++ b/android-mode.el @@ -64,6 +64,10 @@ available." :type 'string :group 'android-mode) +(defcustom android-public-key-file "~/.android/adbkey.pub" + :type 'string + :group 'android-mode) + (defcustom android-mode-sdk-tool-subdirs '("tools" "platform-tools") "List of subdirectors in the SDK containing commandline tools." :type '(repeat string) @@ -590,6 +594,33 @@ logs" ('gradle 'android-gradle-uninstallDebug) ('maven 'android-maven-android-undeploy)))) +(defun extract-ssh-public-key (list) + "Extract SSH public key. The base64 body must be at least 700 characters wide (the Android's default length on February 16, 2016). See https://www.ietf.org/rfc/rfc4716.txt for more info about the format" + (let ((minimum-body-length 700)) + (if (< (length (car list)) minimum-body-length) + (extract-ssh-public-key (cdr list)) + (car list) + ) + ) + ) + +(defun android-adb-public-key () + "Extract adb's public key." + (with-temp-buffer + (insert-file-contents public-key-file) + (extract-ssh-public-key (split-string (buffer-string))) + ) + ) + +(defun android-adb-fingerprint () + "Compute the adb's public key fingerprint. To match the fingerprint shown in the debugging device the first time it receives a connection from a PC." + (interactive) + (let ((public-key (android-adb-public-key))) + (message (upcase + (md5 (base64-decode-string public-key))) + )) + ) + (defconst android-mode-keys '(("d" . android-start-ddms) ("e" . android-start-emulator)