Etc udev rules d 51 android rules

Android Debug Bridge

The Android Debug Bridge (ADB) is a command-line tool that can be used to install, uninstall and debug apps, transfer files and access the device’s shell.

Contents

Installation

ADB is part of the Platform-Tools SDK package and the android-tools package.

Usage

Connect device

To connect to a real device or phone via ADB under Arch, you must:

  1. You might want to install android-udev if you wish to connect the device to the proper /dev/ entries.
  2. plug in your android device via USB.
  3. Enable USB Debugging on your phone or device:
    • Jelly Bean (4.2) and newer: Go to Settings > About Phone tap Build Number 7 times until you get a popup that you have become a developer. Build number may be under a menu called Software info on newer Android OS versions. Then go to Settings > Developer > USB debugging and enable it. The device will ask to allow the computer with its fingerprint to connect. Allowing it permanently will copy

/.android/adbkey.pub onto the devices /data/misc/adb/adb_keys folder.

  • Older versions: This is usually done from Settings > Applications > Development > USB debugging. Reboot the phone after checking this option to make sure USB debugging is enabled.
  • If ADB recognizes your device ( adb devices shows it as «device» and not as «unauthorized» , or it is visible and accessible in IDE), you are done. Otherwise see the instructions below.

    Figure out device IDs

    Each Android device has a USB vendor/product ID. An example for HTC Evo is:

    Plug in your device and execute:

    It should come up something like this:

    Adding udev rules

    Use the rules from android-udev (or android-udev-git AUR ), install them manually from Android developer, or use the following template for your udev rules, just replace [VENDOR ID] and [PRODUCT ID] with yours. Copy these rules into /etc/udev/rules.d/51-android.rules :

    Then, to reload your new udev rules, execute:

    Make sure you are member of adbusers user group to access adb devices.

    Detect the device

    After you have setup the udev rules, unplug your device and replug it.

    you should see something like:

    If adb still does not detect the device after plugging your device back in, kill and restart the adb server as root and check devices again:

    If adb devices still shows «unauthorized» next to your device, make sure that that device has debugging permission allowed on the device itself. A ‘Allow USB Debugging?’ dialog should be presented when you physically connect the device. Select ‘Always Allow. «, then tap «OK». If the dialog was never presented, try Settings > Developer Options > Revoke USB Debugging Authorizations (then «OK»), and repeat the steps in this section. If you still do not see the ‘Allow USB Debugging?’ dialog, and the device is listed as unauthorized, then enter the Developer Options on the device and first uncheck «USB Debugging» and then check it again.

    Transferring files

    You can now use adb to transfer files between the device and your computer. To transfer files to the device, use

    To transfer files from the device, use

    Backup and restore

    You can also backup and restore your device with adb. Moreover, no root is required to follow the process. The commands below led to backup your device to a single file which can also be successively restored.

    The command to create a backup is

    The command parameters list is

    Then confirm the process on your device’s display and provide a password whether a backup password has been set before.

    The command to restore a previous backup is

    Tips and tricks

    Bash completion

    In order to enable Bash completion, install one of the following:

    • android-completionAUR – Bash completion for adb and fastboot , taken from AOSP.
    • android-bash-completionAUR – Bash completion for android , adb , emulator , fastboot , and repo , developed independently.

    Tools building on ADB

    • adbfs-rootless-gitAUR – a FUSE filesystem over ADB.
    • adb-sync (available as adb-sync-gitAUR ) – a tool to synchronize files between a PC and an Android device using the ADB protocol.
    • AndroidScreencast (available as androidscreencast-binAUR ) – view and control your Android device from a PC (via ADB).
    • logcat-colorAUR – a colorful and highly configurable alternative to the standard adb logcat command.
    • scrcpy (available as scrcpy ) – display and control your Android device.
    • qtscrcpy (available as qtscrcpy-gitAUR ) – Android real-time display control software.

    Troubleshooting

    Empty device list

    A possible cause for your device not showing up is not having enabled USB debugging on your device. You can do that by going to Settings > Applications > Development and enabling USB debugging. Since Android 4.2 (Jelly Bean), the development menu is hidden; to enable it go to Settings > About phone and tap Build number 7 times.

    No permissions error

    If the device shows up with a «no permissions» label, it probably has a different vendor/product ID with respect to the ones collected by android-udev .

    This can happen for instance when the device uses a custom ROM, or when it is switched from MTP to USB tethering mode, sideload and/or fastboot mode. Verify the actual device’s ID with lsusb and add the appropriate udev rules as described above.

    Источник

    Etc udev rules d 51 android rules

    Небольшой мануал для тех, кто хочет подготовить свою linux-машину для работы с ADB. Почему небольшой? Потому что настройка будет намного более простой, чем в Windows. Не нужно скачивать дополнительные драйвера, все что Вам потребуется это компьютер и устройство, подключенное по USB к компьютеру. Подробности под катом.

    Для начала необходимо активировать отладку по USB в режиме разработчика на Вашем android-устройстве. Делается это через настройки. Как правило пункт меню находится в разделе System, если его нет – значит он скрыт.

    Смотрите как активировать его для вашего устройства, но как правило необходимо несколько раз тапнуть по названию прошивки устройства в свойствах, пока режим разработчика не станет доступен.

    После чего заходим в него и активируем отладку по USB. На этом настройка устройства закончилась.

    Открываем терминал, заходим из под root. Далее необходимо установить ADB на компьютер. Делается это следующими командами:

    ADB установлен в систему. Теперь необходимо разрешить пользователю системы работать с устройством. Для этого необходимо настроить udev. Разделение устройств происходит по параметру VID (Vendor ID). Они имеются у каждого устройства, подключенного по USB. Чтобы их узнать, запустите в терминале lsusb, затем подключите устройство к компьютеру и запустите lsusb снова.

    Найдите отличия между выводом – это и будет ваше android-устройство. Значение ID x:y где x – VID. Параметры указаны в шестнадцатеричной системе счисления. Запоминаем это значение. По нему и будет даваться доступ к устройству для пользователя. Запускаем текстовый редактор из консоли с созданием нового файла:

    Вместо gedit подставьте свой текстовый редактор. Добавляем строчку:

    Вместо vid подставляем свое значение, вместо username – имя текущего пользователя (под которым создана сессия). Сохраняем файл, закрываем редактор. Перезапускаем сервис udev

    При подключенном устройстве запускаем команду adb devices. Если настройка правильная, Вы увидите список доступных устройств:

    Если в списке устройств ничего нет, проверьте внимательно каждый шаг настройки. Возможно откючена отладка по USB на устройстве (при подключении ADB к устройству необходимо на самом устройстве разрешить подключения для этого компьютера).

    Источник

    51-android.rules to autorun Android’s adb server

    This webpage helps you set up your 51-android.rules file so that you can automatically start Android’s adb server program.

    This file is of interest to you if you use the Android SDK toolkit or Eclipse on Linux while trying to develop or test a program on your Android Cell Phone or Tablet. The contents on this webpage are based on information found on Android’s SDK Dev Guide, the Vendor and Product list found on the USB ID Repository and information gathered from various other websites and pages (as of October 11, 2011).

    This webpage was written due to what seemed to be some confusion and a lack of information needed to get other Linux Distros such as Fedora, Mageia, Mandriva, RedHat, and other distros with subtle differences to work.

    WHY ARE YOU INTERESTED IN THIS FILE?

    Three reasons come to mind, but you may think of other reasons why too.

    • If you have used the Android Debug Bridge (adb server) or the Eclipse Debugger on Linux and you cannot find or connect to your Cell Phone or Tablet.
    • If you are interested in how this rules file works for the purposes of tethering or connecting other hardware you may have in mind.
    • If you are interested in how this works for the purposes of connecting hardware-software automatically to your computer.

    The problem that is happening is that the SDK tries to connect to the Android cell Phone or Tablet as a regular user program, but Linux is blocking and firewalling as a default condition. Linux needs to know that you are allowed access, and therefore needs to setup for those conditions.

    These conditions can be solved manually, or automatically. To do this automatically, the solution is to describe what needs to be done when the hardware is plugged into the USB port on your computer, and the way to do that «here» is using a udev rules file. For the Android SDK, this file is referred to, as 51-android.rules.

    First, you can download 51-android.rules, or you can copy and paste the file shown below into a text editor.

    You need to modify this file before you can use it.

    GET YOUR PHONE OR TABLET ID DETAILS FIRST

    Before you can make use of the file above, you need to see what are the and numbers so that you can edit the file with the correct information before using it.

    When you plug your Android phone or tablet into the USB on your computer, it identifies itself differently based on which mode your cell phone is set to, for example, the HTC Magic cell phone identifies itself as «0bb4:0c01» in normal mode, but as «0bb4:0c02» when it is in debug mode.

    If you have a development cell phone or tablet, go to it’s settings and find the setting you need to turn it into «debug» mode. After you switch your Android phone or tablet into «debug» mode, then plug it into the USB slot on your computer. Next go to the command line, and use the lsusb command to find the cell phone or tablet identity. You can follow the steps shown below.

      su — The lsusb command needs to be done in Root Super User mode, so, first you will need to do su.

    lsusb — This command shows all the devices currently plugged into your computer’s USB ports. You should see your cell phone device appear amongst the list.

    This example above shows the results of «0bb4:0c02«.

    ADD OR EDIT THE FILE WITH YOUR PHONE OR TABLET ID DETAILS

    The udev program that uses the ID information is case sensitive and expects the information as lower-case hexidecimal values. You need to edit, or add a line to your 51-android.rules file with the information you found if it isn’t already included in the list. It should look something like this:
    The first line beginning with «#» is an optional comment. The second line is the important line which checks for the ID and then sets the value «yes» which is needed further down in the file.

    If your Android cell phone or table does not have a separate code for «debug» mode, or you want to make the udev rules a bit more general, then you can substitute ? (question marks), such as ATTR=»0c0?», or you can leave-out the statement like this:
    . however, you need to be careful that you do not use other items from the same manufacturer at the same time you use this rule file, otherwise they may also be incorrectly seen as another similar device (for example, a Motorola Modem would mistakenly also be seen as a Motorola Cell Phone).

    If your device does not have a separate ID for debug mode, or if you decide to do the more general method, you should comment-out the instructions at the bottom because you may not want to run the Android adb server every time you plug-in your Development Phone or Tablet.

    If you want to simplify this file, you can remove all the other lines referring to other Cell Phones that you do not have or use.

    USB OR PLUGDEV GROUP?

    Good question. This is one of those subtle differences between various Linux distributions. For example: RedHat, Fedora, Mageia, Mandriva, etc. have a user group named «usb» while other distributions such as Debian, Ubuntu, etc. have a user group named «plugdev«.

    If you want to follow the example shown on Android’s Using Hardware Devices and you are using a Linux distribution which makes use of «plugdev«, then you will want to edit this line near the bottom of the file:

    MODE=»0664″ OR MODE=»0666″?

    If you want only users belonging to group «usb» to be able to write to your Cell Phone or Tablet, then keep MODE=»0664″, but you need to add yourself to the «usb» or «plugdev» group. If you want to keep it simple and give eveyone access, then you will need to change the command to MODE=»0666″.

    YOU NEED TO EDIT THE RUN+ INSTRUCTION

    When you downloaded Android’s SDK toolkit, you saved it somewhere, like your home directory, or another directory. Inside the toolkit is a subdirectory «android-sdk-linux_x86/platform-tools/» which has the adb server which is needed when you connect to your hardware to debug a program. You will need to edit the «RUN+» instruction to point to the location where your adb is located.

    If you run the adb server as a normal user, you can run into the problem that Linux blocks access to your hardware.

      adb devices — You probably have seen this before. You need your 51-android.rules file set up first.

    If you get these udev 51-android.rules set up, and you run the adb server as a root user, then you can access your hardware device. Once the adb server is running as a root user, you can then access your hardware as a normal user too.

      adb devices — You should get a list of the devices connected to your computer after you get these udev 51-android.rules set up.

    If you want to run Android’s adb server under another user other than «root«, then modify the «RUN+» statement like this (substitute a user for «you«):
    Note: Make sure the user you choose has user or group access to the USB port.

    Here is an example output if you did it this way:

      adb devices — You should get a list of the devices connected to your computer after you get these udev 51-android.rules set up.

    ps -A -f | grep «adb» — Check to see who is adb running under.

    WHAT DOES SYMLINK+ DO?

    This is not important for Android’s adb server since it does not use this, but it might be useful to you if you need a consistent location to find your hardware for other purposes.

    Some computers have USB devices appear in directory «/dev/usb/«, other computers may have devices appear in directory «/dev/bus/usb/«. You may have noticed that when you plug in a device into a USB port, it appears on one port when you look inside directory «/dev«, then if you unplug the device and plug it back in, it appears on another location. Do it again, it appears somewhere else in directory «/dev«. Not very consistent. What the «SYMLINK+» instruction does, is create a link to your device in a consistent location, so regardless of where it appears in directory «/dev/«, you can always find a link at «/dev/android_adb/» when you plug your device into a USB port on your computer.

    A few webpages referred to «android_adb«, so it seemed a good choice just to be consistent.

    This shows you what it could look like for you after you setup your udev rules file.

      ls -l /dev/an* — This would display the symlink that is created when you plug-in your Android Cell Phone or Tablet (after you set up your 51-android.rules).

    ls -l /dev/bsg/ — For this example, the symlink pointed to a directory named «bsg«, so if you look in directory «bsg«, you would then see the device is already connected.

    INSERT YOUR FILE IN UDEV RULES.D DIRECTORY

    Once you have added or edited your particular Cell Phone or Tablet to the rules file, and added the location of where you keep your adb server, it is now time to save the 51-android.rules file in directory «/etc/udev/rules.d/«. We assume you saved your edited file in your «

    su — The next few commands need to be done in Root Super User mode.

    /51-android.rules /etc/udev/rules.d/ — Copy the file to the udev rules directory.

    chown root:root /etc/udev/rules.d/51-android.rules — Use the chown command to make it a file that belongs to Root.

    chmod 644 /etc/udev/rules.d/51-android.rules — Use the chmod command to make it known as a read-only type file for all other users.

    exit — You no longer need to be in Root Super User mode.

    exit — Exit the command-line terminal. You are done.

    NOTES: According to some websites, some people indicate they have had trouble with this file if it is named 51-android.rules. This can happen if another rule after this changes some settings, such as user or group ownership of the USB ports get reverted back to «root:root«. To solve this problem, you will need to save your file with a number that makes this rule happen later in the udev rules process, for example 61-android.rules or 71-android.rules (the 51, 61, 71 indicates when the rule applies).

    TEST TO SEE IF THE ADB SERVER WORKS

    After saving the rules file above, check if it all works. Reboot your computer. Change your Cell Phone or Tablet to «Debug» mode, and also enable «unknown sources«, then plug it into your computer’s USB port. Then go to the command line and check:

      adb devices — The adb server should already be running by now, so you should see a list of the devices already connected when you try this command.
      NOTE: Some devices may still have problems, so you might need to run android update adb for some devices, or you may need to append a vendor ID value at the end of file

    /.android/adb_usb.ini (for example 0x2080 for the Nook, or 0x0e79 for the Archos). Please read more about your specific device as there may be some extra steps required.

    ls -l /dev/an* — This should display a symlink to your Android Cell Phone or Tablet (and it will disappear if you unplug your Phone).

    ls -l /dev/bsg/ — For this example, the symlink points to a directory named «bsg«, so if you look in directory «bsg«, you should see your device with the correct group. and mode of 0664. If the group and permissions are wrong, you likely need to make the rule file run later, like maybe 6N or 7N or maybe 8N. Take a look inside directory «/etc/udev/rules.d» and look at the files after 51 towards 99 for possible conflicts.

    adb shell — If the adb server is running, you can now create a shell into your cell phone.

    ls -l — List the directories inside your cell phone.

    exit — Exit the shell out from your phone.

    exit — Exit the command-line terminal. You are done.

    COMMENTS, ERRORS OR FEEDBACK

    It is great if you find this 51-android.rules file useful. If you have any comments, suggestions, or fixes, please send them using the comment section here, thanks!

    If you want to know more about udev, you can read this very detailed guide writing udev rules.

    Источник

    Читайте также:  Как почистить андроид чтобы быстрее работал
    Оцените статью