Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/computer fingerprint #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions android-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down