4

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

0

2 Answers 2

2

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

adb shell input keyevent 279
0
1

For older Android versions until 9, you can read the clipboard with the command line using an app like https://github.com/PRosenb/AdbClipboard.

You don't need to use the Python script, you can directly install Adb Clipboard from Google Play at https://play.google.com/store/apps/details?id=ch.pete.adbclipboard.

Then you can use this command to read the clipboard with or without adb (command taken from the Python script):

am broadcast -n ch.pete.adbclipboard/.ReadReceiver

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .