adb shell get text from clipboard


Question

enter image description here



After I copy text in emulator I want to get this text in adb shell



I found a reference:



// API < 11
static final int TRANSACTION_getClipboardText 1
static final int TRANSACTION_hasClipboardText 3
static final int TRANSACTION_setClipboardText 2
// API >= 11
static final int TRANSACTION_setPrimaryClip = 1
static final int TRANSACTION_getPrimaryClip = 2
static final int TRANSACTION_getPrimaryClipDescription = 3
static final int TRANSACTION_hasPrimaryClip = 4
static final int TRANSACTION_addPrimaryClipChangedListener = 5
static final int TRANSACTION_removePrimaryClipChangedListener = 6
static final int TRANSACTION_hasClipboardText = 7


And I did service call clipboard 1



root@iX101T1:/ # service call clipboard 1
service call clipboard 1
Result: Parcel(
0x00000000: fffffffc 00000069 00740041 00650074 '....i...A.t.t.e.'
0x00000010: 0070006d 00200074 006f0074 00690020 'm.p.t. .t.o. .i.'
0x00000020: 0076006e 006b006f 00200065 00690076 'n.v.o.k.e. .v.i.'
0x00000030: 00740072 00610075 0020006c 0065006d 'r.t.u.a.l. .m.e.'
0x00000040: 00680074 0064006f 00270020 006e0069 't.h.o.d. .'.i.n.'
0x00000050: 00200074 006e0061 00720064 0069006f 't. .a.n.d.r.o.i.'
0x00000060: 002e0064 006f0063 0074006e 006e0065 'd...c.o.n.t.e.n.'
0x00000070: 002e0074 006c0043 00700069 00610044 't...C.l.i.p.D.a.'
0x00000080: 00610074 0067002e 00740065 00740049 't.a...g.e.t.I.t.'
0x00000090: 006d0065 006f0043 006e0075 00280074 'e.m.C.o.u.n.t.(.'
0x000000a0: 00270029 006f0020 0020006e 00200061 ').'. .o.n. .a. .'
0x000000b0: 0075006e 006c006c 006f0020 006a0062 'n.u.l.l. .o.b.j.'
0x000000c0: 00630065 00200074 00650072 00650066 'e.c.t. .r.e.f.e.'
0x000000d0: 00650072 0063006e 00000065 'r.e.n.c.e... ')


I tried other indexes from 1-7 the clipboard not changed. I read this question from StackIverflow
but installing additional .apk is not a solution for me


Answer

This answer from StackOverflow should be hepful. It requires to use of the input command and keyevent.



adb shell input keyevent 279

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes