Outils pour utilisateurs

Outils du site


informatique:adb

Adb

Un toot sur Mastodon a attiré mon attention sur adb qui permet apparemment de supprimer les applications qu'on ne sait pas supprimer depuis l'interface d'android (mais uniquement désactiver) comme Facebook, les Google Apps, etc..

Mettre son smartphone en "mode debug"

Frandroid nous indique comment activer le “mode développeur”.

Il faut aller dans les Paramètres, puis dans À propos du téléphone et toucher 7 fois la case Numéro de build. Le menu Options pour les développeurs apparaît alors dans les paramètres systèmes. (Ça donne l'impression d'être une mauvaise astuce pour un jeux vidéo, mais ça marche…)

Dans le menu pour les développeurs, on trouve une option “Débogage USB” qu'on peut activer.

Installer adb

$ sudo apt install adb

J'ai eu des erreurs de permissions dans certains cas :

$ adb devices
List of devices attached
ZY909667	no permissions (user in plugdev group; are your udev rules wrong?); see [http://developer.android.com/tools/device.html]

J'ai trouvé la solution là : https://www.janosgyerik.com/adding-udev-rules-for-usb-debugging-android-devices/

Jouer avec adb

Liste des appareils branchés

J'ai du lancer plusieurs fois la commande :

$ adb devices
List of devices attached
* daemon not running. starting it now on port 5037 *
free(): invalid next size (fast)
ADB server didn't ACK
* failed to start daemon *
error: cannot connect to daemon
 
$ adb devices
List of devices attached
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
BJ030262	unauthorized

Un pop-up apparait sur le téléphone pour demander si on autorise l'accès à cet ordinateur. Une fois qu'on a validé, on peut relancer la commande :

$ adb devices
List of devices attached
BJ030262	device

Voir les logs du téléphone

La commande “logcat” permet de voir les logs du téléphone mais ça spamme vraiment beaucoup…

$ adb logcat 

Se connecter sur le téléphone

$ adb shell
1|bardock:/ $

Liste des programmes installés sur le téléphone :

$ a
acpi           am             app_process    app_process64  appops         atrace         autoload
alias          antradio_app   app_process32  applypatch     appwidget      audioflacapp
 
$ b                                                                                          
base64       bcc          bg           blockdev     brctl        bu           bugreportz   bzcat
basename     bdt          bind         bmgr         break        bugreport    builtin
 
$ c                                                                                          
cal                  chcon                chroot               comm                 cpio
case                 chdir                cksum                command              cplay
cat                  chgrp                clear                content              curl
cd                   chmod                cmd                  continue             cut
chamomile_provision  chown                cmp                  cp
 
$ d                                                                                          
dalvikvm                  dex2oat                   dirname                   dpm
dalvikvm32                dexdump                   dmesg                     du
dalvikvm64                dexlist                   do                        dumpsys
date                      df                        done
dd                        diag_callback_sample      dos2unix
 
$ e                                                                                          
e_loop    echo      elif      env       eval      exit      export
ebtables  egrep     else      esac      exec      expand    expr
 
$ f                                                                                          
fallocate            fgrep                fm_qsoc_patches      for
false                fi                   fmconfig             free
fc                   find                 fmfactorytest        function
fg                   flock                fmfactorytestserver  functions
 
$ g                                                                                          
getenforce   getopts      global       grep         gzip
getevent     getprop      gptest       groups
 
$ h                                                                                          
hash             hci_qcomm_init   head             history          hostname         hwclock
 
$ i                                                                                          
id                   ime                  insmod               iorenice             ip6tables-save
if                   in                   integer              ip                   iptables
ifconfig             inotifyd             ioctl                ip6tables            iptables-restore
iftop                input                ionice               ip6tables-restore    iptables-save
 
$ j
jobs                                                                                       
 
$ k                                                                                          
kill     killall
 
$ l                                                                                          
ld.mc        linker       load_policy  logcat       logwrapper   lsmod
let          linker64     local        login        losetup      lsof
let]         ln           log          logname      ls           lsusb
 
$ m                                                                                          
make_ext4fs          mknod                mm-qjpeg-enc-test    mmi_agent32          monkey
make_f2fs            mkswap               mm-qomx-idec-test    mmi_agent64          more
md5sum               mktemp               mm-qomx-ienc-test    mmi_debug            mount
media                mm-qcamera-app       mm-vidc-omx-test     mmi_diag             mountpoint
mkdir                mm-qjpeg-dec-test    mmc_utils_extended   modinfo              mv
 
$ n                                                                                          
nameref      nandread     netstat      newfs_msdos  nice         nl           nl_listener  nohup
 
$ o                                                                                          
oatdump  od
 
$ p                                                                                          
paste     patchoat  pidof     ping6     pm        print     printf    ps
patch     pgrep     ping      pkill     pmap      printenv  prlimit   pwd
 
$ q                                                                                          
qjpeg-dma-test            qmi-framework-tests/      qmi_simple_ril_test
 
$ r                                                                                          
r            readlink     realpath     renice       return       rmmod        run-as
radish       readonly     reboot       requestsync  rm           rmnetcli     runcon
read         readwritenv  rename       restorecon   rmdir        route
 
$ s                                                                                          
schedtest      sendevent      setenforce     sha1sum        source         suspend
screencap      sensors_test   setprop        shift          split          svc
screenrecord   sensorservice  setsid         sleep          start          swapoff
secdiscard     seq            settings       sm             stat           swapon
sed            service        setup_fs       sort           stop           sync
select         set            sh             soter_client   strings        sysctl
 
$ t                                                                                          
tac                  telecom              times                top                  truncate
tail                 test                 tinycap              touch                tty
tar                  test_module_pproc    tinymix              toybox               type
taskset              then                 tinypcminfo          tr                   typeset
tc                   time                 tinyplay             trap
tee                  timeout              toolbox              true
 
$ u                                                                                          
uiautomator  umask        unalias      uniq         unset        uptime
ulimit       umount       uname        unix2dos     until        usleep
 
$ v                                                                                          
vendor_cmd_tool  vmstat
 
$ w                                                                                          
wait       wc         wdsdaemon  whence     which      while      whoami     wm
 
$ x                                                                                          
xargs  xxd
 
$ y 
(rien)
 
$ z
(rien)                                                                                          

Récupérer la liste des applications installées

1|bardock:/ $ pm list packages                                                                           
package:com.bq.wizardbq.insurance
(...)
package:com.google.android.inputmethod.latin

On peut bien évidemment filtrer cette liste avec grep :

bardock:/ $ pm list packages | grep google                                                               
package:com.google.android.youtube
package:com.google.android.ext.services
package:com.google.android.googlequicksearchbox
package:com.google.android.onetimeinitializer
package:com.google.android.ext.shared
package:com.google.android.apps.messaging
package:com.google.android.configupdater
package:com.google.android.marvin.talkback
package:com.google.android.deskclock
package:com.google.android.gm
package:com.google.android.apps.tachyon
package:com.google.android.instantapps.supervisor
package:com.google.zxing.client.android
package:com.google.android.setupwizard
package:com.google.android.music
package:com.google.android.dialer
package:com.google.android.apps.docs
package:com.google.android.apps.maps
package:com.google.android.webview
package:com.google.android.syncadapters.contacts
package:com.google.android.calculator
package:com.google.android.packageinstaller
package:com.google.android.gms
package:com.google.android.gsf
package:com.google.android.ims
package:com.google.android.tts
package:com.google.android.partnersetup
package:com.google.android.videos
package:com.google.android.feedback
package:com.google.android.printservice.recommendation
package:com.google.android.apps.photos
package:com.google.android.calendar
package:com.google.android.gsf.login
package:com.google.android.backuptransport
package:com.google.android.talk
package:com.google.android.inputmethod.latin

Si je regarde un peu les applications qui sont désactivées dans mon téléphones, je trouve :

  • L'agenda de base (J'utilise Etar)
  • L'appareil photo de base (J'utilise OpenCamera)
  • Chrome (J'utilise IceCatMobile)
  • Clavier Google (J'utilise MessagEase)
  • Contacts (J'utilise Simple Contacts)
  • Drive (J'utilise Nextcloud)
  • Duo
  • Gmail
  • Google Play Musique
  • Google Play Films et séries
  • Google
  • Hangouts
  • Magnétophone
  • Maps
  • Messages (J'utilise Silence)
  • Photos (J'utilise Simple Galery)
  • YouTube (J'utilise NewPipe)

Avoir plus d'informations sur une applications

bardock:/ $ dumpsys | grep -A 50 "Package .*youtube"                                                     
Can't find service: android.service.gatekeeper.IGateKeeperService
Can't find service: netd
  Package [com.google.android.youtube] (8fe1a80):
    userId=10090
    pkg=Package{ac2e252 com.google.android.youtube}
    codePath=/system/app/YouTube
    resourcePath=/system/app/YouTube
    legacyNativeLibraryDir=/system/app/YouTube/lib
    primaryCpuAbi=arm64-v8a
    secondaryCpuAbi=null
    versionCode=1307553400 minSdk=21 targetSdk=26
    versionName=13.07.55
    splits=[base]
    apkSigningVersion=1
    applicationInfo=ApplicationInfo{15f5ad5 com.google.android.youtube}
    flags=[ SYSTEM HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP KILL_AFTER_RESTORE RESTORE_ANY_VERSION LARGE_HEAP ]
    privateFlags=[ HAS_DOMAIN_URLS RESIZEABLE_ACTIVITIES ]
    dataDir=/data/user/0/com.google.android.youtube
    supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity]
    timeStamp=2009-01-01 00:00:00
    firstInstallTime=2009-01-01 00:00:00
    lastUpdateTime=2009-01-01 00:00:00
    signatures=PackageSignatures{35b8923 [7d3bce25]}
    installPermissionsFixed=false installStatus=1
    pkgFlags=[ SYSTEM HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP KILL_AFTER_RESTORE RESTORE_ANY_VERSION LARGE_HEAP ]
    declared permissions:
      com.google.android.youtube.permission.C2D_MESSAGE: prot=signature, INSTALLED
    install permissions:
      com.google.android.c2dm.permission.RECEIVE: granted=true
      android.permission.USE_CREDENTIALS: granted=true
      com.google.android.providers.gsf.permission.READ_GSERVICES: granted=true
      com.google.android.youtube.permission.C2D_MESSAGE: granted=true
      android.permission.MANAGE_ACCOUNTS: granted=true
      android.permission.SYSTEM_ALERT_WINDOW: granted=true
      android.permission.NFC: granted=true
      android.permission.RECEIVE_BOOT_COMPLETED: granted=true
      com.google.android.gms.permission.AD_ID_NOTIFICATION: granted=true
      android.permission.INTERNET: granted=true
      android.permission.GET_PACKAGE_SIZE: granted=true
      android.permission.ACCESS_NETWORK_STATE: granted=true
      android.permission.VIBRATE: granted=true
      android.permission.ACCESS_WIFI_STATE: granted=true
      android.permission.WAKE_LOCK: granted=true
    User 0: ceDataInode=1139683 installed=true hidden=false suspended=false stopped=false notLaunched=false enabled=3
      lastDisabledCaller: com.android.settings
      gids=[3003]

Supprimer une application

Commençons par supprimer chrome :

bardock:/ $ pm list packages | grep chrome                                                               
package:com.android.chrome

On va utiliser la commande pm :

127|bardock:/ $ pm --help
Error: unknown command '--help'
usage: pm path [--user USER_ID] PACKAGE
       pm dump PACKAGE
       pm install [-lrtsfd] [-i PACKAGE] [--user USER_ID] [PATH]
       pm install-create [-lrtsfdp] [-i PACKAGE] [-S BYTES]
               [--install-location 0/1/2]
               [--force-uuid internal|UUID]
       pm install-write [-S BYTES] SESSION_ID SPLIT_NAME [PATH]
       pm install-commit SESSION_ID
       pm install-abandon SESSION_ID
       pm uninstall [-k] [--user USER_ID] PACKAGE
       pm set-installer PACKAGE INSTALLER
       pm move-package PACKAGE [internal|UUID]
       pm move-primary-storage [internal|UUID]
       pm clear [--user USER_ID] PACKAGE
       pm enable [--user USER_ID] PACKAGE_OR_COMPONENT
       pm disable [--user USER_ID] PACKAGE_OR_COMPONENT
       pm disable-user [--user USER_ID] PACKAGE_OR_COMPONENT
       pm disable-until-used [--user USER_ID] PACKAGE_OR_COMPONENT
       pm default-state [--user USER_ID] PACKAGE_OR_COMPONENT
       pm hide [--user USER_ID] PACKAGE_OR_COMPONENT
       pm unhide [--user USER_ID] PACKAGE_OR_COMPONENT
       pm grant [--user USER_ID] PACKAGE PERMISSION
       pm revoke [--user USER_ID] PACKAGE PERMISSION
       pm reset-permissions
       pm set-app-link [--user USER_ID] PACKAGE {always|ask|never|undefined}
       pm get-app-link [--user USER_ID] PACKAGE
       pm set-install-location [0/auto] [1/internal] [2/external]
       pm get-install-location
       pm set-permission-enforced PERMISSION [true|false]
       pm trim-caches DESIRED_FREE_SPACE [internal|UUID]
       pm create-user [--profileOf USER_ID] [--managed] [--restricted] [--ephemeral] [--guest] USER_NAME
       pm remove-user USER_ID
       pm get-max-users
 
NOTE: 'pm list' commands have moved! Run 'adb shell cmd package'
  to display the new commands.
 
pm path: print the path to the .apk of the given PACKAGE.
 
pm dump: print system state associated with the given PACKAGE.
 
pm install: install a single legacy package
pm install-create: create an install session
    -l: forward lock application
    -r: replace existing application
    -t: allow test packages
    -i: specify the installer package name
    -s: install application on sdcard
    -f: install application on internal flash
    -d: allow version code downgrade (debuggable packages only)
    -p: partial application install
    -g: grant all runtime permissions
    -S: size in bytes of entire session
 
pm install-write: write a package into existing session; path may
  be '-' to read from stdin
    -S: size in bytes of package, required for stdin
 
pm install-commit: perform install of fully staged session
pm install-abandon: abandon session
 
pm set-installer: set installer package name
 
pm uninstall: removes a package from the system. Options:
    -k: keep the data and cache directories around after package removal.
 
pm clear: deletes all data associated with a package.
 
pm enable, disable, disable-user, disable-until-used, default-state:
  these commands change the enabled state of a given package or
  component (written as "package/class").
 
pm grant, revoke: these commands either grant or revoke permissions
    to apps. The permissions must be declared as used in the app's
    manifest, be runtime permissions (protection level dangerous),
    and the app targeting SDK greater than Lollipop MR1.
 
pm reset-permissions: revert all runtime permissions to their default state.
 
pm get-install-location: returns the current install location.
    0 [auto]: Let system decide the best location
    1 [internal]: Install on internal device storage
    2 [external]: Install on external media
 
pm set-install-location: changes the default install location.
  NOTE: this is only intended for debugging; using this can cause
  applications to break and other undersireable behavior.
    0 [auto]: Let system decide the best location
    1 [internal]: Install on internal device storage
    2 [external]: Install on external media
 
pm trim-caches: trim cache files to reach the given free space.
 
pm create-user: create a new user with the given USER_NAME,
  printing the new user identifier of the user.
 
pm remove-user: remove the user with the given USER_IDENTIFIER,
  deleting all data associated with that user

L'option “–user 0” semble indispensable. Il y a également l'option “-k” qui permet de garder les données et caches du programme.

bardock:/ $ pm uninstall com.android.chrome
Failure [DELETE_FAILED_INTERNAL_ERROR]
bardock:/ $ pm uninstall --user 0 com.android.chrome                                                     
Success

Après avoir désinstallé Chrome, j'étais à 8,78 Go utilisé par les applications. On continue! Hop, on vire “Google Musique” :

bardock:/ $ pm uninstall --user 0 com.google.android.music                                               
Success

Le plus compliqué reste de trouver le nom du package à supprimer. On peut chercher avec dumpsys, comme par exemple pour Google Vidéos :

$ dumpsys | grep -A 50 "Package .*videos" 
(...)
versionName=4.1.6.13

On peut alors comparer dans le menu et vérifier que la version correspond.

  • L'agenda de base : com.android.providers.calendar
  • L'appareil photo de base : ?
  • Chrome : com.android.chrome
  • Clavier Google :
  • Contacts :
  • Drive :
  • Duo :
  • Gmail : com.google.android.gm
  • Google Play Musique : com.google.android.music
  • Google Play Films et séries : com.google.android.videos
  • Google (le widget) : com.google.android.googlequicksearchbox
  • Hangouts : com.google.android.talk
  • Magnétophone : ?
  • Maps : com.google.android.apps.maps
  • Messages : com.google.android.apps.messaging
  • Photos : com.google.android.apps.photos
  • YouTube : com.google.android.youtube
bardock:/ $ pm uninstall --user 0 com.google.android.apps.maps
Success
bardock:/ $ pm uninstall --user 0 com.google.android.apps.photos                                         
Success
bardock:/ $ pm uninstall --user 0 com.google.android.music 
Success
bardock:/ $ pm uninstall --user 0 com.android.providers.calendar                                         
Success
bardock:/ $ pm uninstall --user 0 com.google.android.googlequicksearchbox                                
Success
bardock:/ $ pm uninstall --user 0 com.google.android.talk                                                
Success
bardock:/ $ pm uninstall --user 0 com.google.android.apps.messaging                                      
Success
bardock:/ $ pm uninstall --user 0 com.google.android.videos                                              
Success
bardock:/ $ pm uninstall --user 0 com.google.android.youtube                                             
Success
bardock:/ $ pm uninstall --user 0 com.google.android.gm                                                  
Success
bardock:/ $ pm uninstall --user 0 com.google.android.calendar                                            
Success

Upgrade LineageOS

Mettre à jour LineageOS : https://wiki.lineageos.org/devices/bardock/upgrade

$ adb root
$ adb reboot sideload
$ adb sideload lineage-17.1-20210316-nightly-bardock-signed.zip 
serving: 'lineage-17.1-20210316-nightly-bardock-signed.zip'  (~47%)    adb: failed to read command: Success

La dernière fois, je n'ai pas réussis à lancer la commande “adb sideload …”, j'ai du copier le fichier sur le téléphone et lancer l'installation directement depuis TWRP.

$ adb push lineage-18.1-20220705-nightly-bardock-signed.zip /storage/self/primary/lineage-18.1-20220705-nightly-bardock-signed.zip
informatique/adb.txt · Dernière modification : 2022/07/09 09:59 de simon