Differences

This shows you the differences between two versions of the page.


Previous revision
Next revision
fuss:android [2020/07/01 23:43] – [Delivering Input Events via ADB] office
Line 1: Line 1:
 +====== Enable Developer Options ======
 +
 +There are several ways to do this depending on the device, but usually the procedure is to open the Android settings application and find something along the lines of ''About'' or ''About phone''. Enter the menu selection and you should get various information on your device. Scroll all the way down and find the item ''Build number'' and tap it ''10'' times - after ''5'' taps the device will tell you that you are ''5'' taps away from becoming a developer.
 +
 +====== Access Android via The Command Line ======
 +
 +First, developer mode has to be enabled and ''Settings->Developer options->USB Debugging'' has to be enabled. Instead of installing an SSH server to be able to log-in to a rooted Android device, the ''adb'' tool can be used instead.
 +
 +On OSX, adb can be installed via Homebrew:
 +<code bash>
 +brew install caskroom/cask/android-platform-tools
 +</code>
 +
 +Once the device is connected via USB, issue:
 +<code bash>
 +adb shell
 +</code>
 +
 +You may get the error message:
 +<code>
 +error: device unauthorized.
 +This adb server's $ADB_VENDOR_KEYS is not set
 +Try 'adb kill-server' if that seems wrong.
 +</code>
 +
 +in which case, issue ''adb shell'' again but pay attention to the Android device screen because Android will prompt for authorization.
 +
 +
 +====== Write to Root Filesystem ======
 +
 +In order to be able to write to the root filesystem, issue:
 +<code bash>
 +mount -o remount,rw /
 +</code>
 +
 +Some folders in the root are symlinked into the ''/system/'' filesystem, which can also be (re)mounted with read-write permissions instead of read only:
 +<code bash>
 +mount -o remount,rw /system
 +</code>
 +
 +====== Generating Keys and Signing Packages ======
 +
 +Keys can be generated by issuing:
 +<code bash>
 +openssl genrsa -out key.pem 1024
 +openssl req -new -key key.pem -out request.pem
 +openssl x509 -req -days 9999 -in request.pem -signkey key.pem -out certificate.pem
 +openssl pkcs8 -topk8 -outform DER -in key.pem -inform PEM -out key.pk8 -nocrypt
 +</code>
 +
 +and then can be signed using {{fuss:aospsign.jar|aospsign.jar}} (also available from [[https://android.googlesource.com/platform/build|Google]]):
 +<code>
 +java -jar SignApk.jar certificate.pem key.pk8 Application.apk Application_signed.apk
 +</code>
 +where:
 +  * ''Application.apk'' is the application to sign,
 +  * ''Application_signed.apk'' is the resulting file
 +
 +A package can be opened with a simple zip program and you do not need to use ''apktool'' if you are looking to reverse-engineering Android packages.
 +
 +====== Disable Hardware Keys ======
 +
 +To disable hardware keys, root is needed and then a hardware key map file must be edited. Using a root explorer, navigate to ''/system/usr/keylayout'' and locate the keylayout file - ''Generic.kl'' should work for most devices, ''mtk-kpd.kl'' works for MediaTek devices (AllView).
 +
 +Edit the file and place a hash sign (''#'') in front of the button mapping, for instance:
 +<code>
 +key 115 VOLUME_UP
 +</code>
 +
 +will turn into:
 +<code>
 +#key 115 VOLUME_UP
 +</code>
 +
 +Finally, restart the device for the changes to take effect. Note that this is a good and reliable way to disable the power button.
 +
 +====== Completely Disable Calls ======
 +
 +An easy trick to disable calls (such as the emergency call button from the lock screen), is to go to the phone settings, manage applications and disable the ''Dialer'' or ''Phone'' application.
 +
 +====== Android x86 on LibVirt ======
 +
 +In case Android x86 under qemu/kvm boots to a command prompt (or just displays a blank screen with a curor) and does not go any further then most likely the problem is that ''-vga std'' has to be passed to the qemu/kvm command line.
 +
 +After installing Android under libvirt, the domain name has to be edited, for instance:
 +<code bash>
 +virsh -c qemu:///system
 +</code>
 +
 +followed by:
 +<code>
 +edit android.domain
 +</code>
 +
 +The ''video'' tag has to be deleted and replaced by:
 +<code>
 +    <video>
 +      <model type='vga'/>
 +    </video>
 +</code>
 +
 +to allow Android to boot the window manager.
 +
 +Even better:
 +<code>
 +    <video>
 +      <model type='virtio'/>
 +    </video>
 +</code>
 +
 +can be used for 3D acceleration.
 +
 +====== Delivering Input Events via ADB ======
 +
 +Input events can be sent to a device connected to a computer with the Android Platform Tools installed via the ''adb'' command.
 +
 +Here is a list of useful commands:
 +<code bash>
 +adb shell input tap 500 600
 +</code>
 +
 +will tap the screen at $(x,y)=(500,600)$.
 +
 +<code bash>
 +adb shell input text 'Hello Android'
 +</code>
 +
 +will type in the text 'Hello Android'.
 +
 +Even raw key events can be sent:
 +<code bash>
 +adb shell input keyevent 66
 +</code>
 +
 +will press the enter key.
 +
 +Similarly, D-PAD events can be triggered:
 +
 +^ Direction ^ KeyCode ^
 +| Up        | ''19''  |
 +| Down      | ''20''  |
 +| Left      | ''21''  |
 +| Right     | ''22''  |
 +
 +For instance:
 +<code bash>
 +adb shell input keyevent 19
 +</code>
 +
 +will press D-PAD up.
 +
 +====== Fixing MicroG/UnifiedNLP Permissions ======
 +
 +Issue the following commands via ADB to fix permissions for most packages involved with UnifiedNLP:
 +<code bash>
 +pm grant com.google.android.gms android.permission.ACCESS_COARSE_LOCATION
 +pm grant com.google.android.gms android.permission.ACCESS_FINE_LOCATION
 +pm grant com.google.android.gms android.permission.GET_ACCOUNTS
 +pm grant com.google.android.gms android.permission.READ_EXTERNAL_STORAGE
 +pm grant com.google.android.gms android.permission.READ_PHONE_STATE
 +pm grant com.google.android.gms android.permission.WRITE_EXTERNAL_STORAGE
 +
 +pm grant com.android.vending android.permission.ACCESS_COARSE_LOCATION
 +pm grant com.android.vending android.permission.ACCESS_FINE_LOCATION
 +pm grant com.android.vending android.permission.GET_ACCOUNTS
 +pm grant com.android.vending android.permission.READ_EXTERNAL_STORAGE
 +pm grant com.android.vending android.permission.READ_PHONE_STATE
 +pm grant com.android.vending android.permission.WRITE_EXTERNAL_STORAGE
 +
 +pm grant org.microg.nlp.backend.ichnaea android.permission.ACCESS_COARSE_LOCATION
 +pm grant org.microg.nlp.backend.ichnaea android.permission.ACCESS_FINE_LOCATION
 +pm grant org.microg.nlp.backend.ichnaea android.permission.READ_PHONE_STATE
 +
 +pm grant org.fitchfamily.android.dejavu android.permission.ACCESS_COARSE_LOCATION
 +pm grant org.fitchfamily.android.dejavu android.permission.ACCESS_FINE_LOCATION
 +
 +pm grant com.google.android.gms android.permission.ACCESS_COARSE_LOCATION
 +pm grant com.google.android.gms android.permission.ACCESS_FINE_LOCATION
 +pm grant com.google.android.gms android.permission.GET_ACCOUNTS
 +pm grant com.google.android.gms android.permission.READ_EXTERNAL_STORAGE
 +pm grant com.google.android.gms android.permission.READ_PHONE_STATE
 +pm grant com.google.android.gms android.permission.WRITE_EXTERNAL_STORAGE
 +
 +pm grant com.android.vending android.permission.ACCESS_COARSE_LOCATION
 +pm grant com.android.vending android.permission.ACCESS_FINE_LOCATION
 +pm grant com.android.vending android.permission.GET_ACCOUNTS
 +pm grant com.android.vending android.permission.READ_EXTERNAL_STORAGE
 +pm grant com.android.vending android.permission.READ_PHONE_STATE
 +pm grant com.android.vending android.permission.WRITE_EXTERNAL_STORAGE
 +
 +pm grant org.microg.nlp.backend.ichnaea android.permission.ACCESS_COARSE_LOCATION
 +pm grant org.microg.nlp.backend.ichnaea android.permission.ACCESS_FINE_LOCATION
 +pm grant org.microg.nlp.backend.ichnaea android.permission.READ_PHONE_STATE
 +
 +pm grant org.fitchfamily.android.dejavu android.permission.ACCESS_COARSE_LOCATION
 +pm grant org.fitchfamily.android.dejavu android.permission.ACCESS_FINE_LOCATION
 +
 +</code>
 +
 +
  

fuss/android.txt · Last modified: 2024/01/11 01:39 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.