Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome Beta support? #2

Closed
devnll opened this issue May 22, 2022 · 2 comments
Closed

Chrome Beta support? #2

devnll opened this issue May 22, 2022 · 2 comments

Comments

@devnll
Copy link
Contributor

devnll commented May 22, 2022

Thanks for sharing this!

I have both Chrome and Chrome Beta running on my phone. Is it possible to get the tabs from Chrome Beta instead of regular Chrome?

@machinateur
Copy link
Owner

machinateur commented May 23, 2022

Ok, this is an interesting question...

I've done some quick research on the underlying workings of the forwarding ability of adb. So, according to the docs it uses unix sockets.

This is related to the forwarding done by copy-tabs internally using adb forward.

https://github.com/machinateur/android-chrome-tab-transfer/blob/933bc81512f778ee6df68f7e7baf84132ac84752/src/Command/CopyTabsCommand.php#L92-L97

The socket part is localabstract:chrome_devtools_remote, which is the one exposed by the "normal" chrome version on android.

It appears the chrome beta on the device does expose such a socket too. I think you can safely follow this blog post to find out what socket you are looking for. It should look just like the "normal" one, but with a number appended to its name. The relevant excerpt:

Finding the unix domain socket

/proc/net/unix contains the list of unix domain sockets. Chrome creates sockets with _devtools_remote somewhere in the name of the socket (see devtools_adb_bridge.cc).

You can view it by using the following command on the host:

adb shell cat /proc/shell/unix | grep _devtools_remote

The output should be something like this:

00000000: 00000002 00000000 00010000 0001 01 107909 @chrome_devtools_remote_8985
00000000: 00000002 00000000 00010000 0001 01 87977 @chrome_devtools_remote

There are two sockets listed because I have Chrome Beta and Chrome running at the same time. The ‘@’ in front of the socket name implies an abstract socket.

Sadly (my bad actually) the socket name cannot be changed from the cli when calling the copy-tabs command in the current version. So for now you'll have to edit the hardcoded value and exchange it for the one yielded by the above adb shell call. PRs always welcome.

Also, there is always chrome://inspect/#devices to the rescue and for checking what's going on.

@devnll
Copy link
Contributor Author

devnll commented May 23, 2022

Awesome, thank you!

I did have to make one small modification - it seems that /proc/shell/unix doesn't exist on my phone so instead I had to do:

adb shell cat /proc/net/unix | strings | grep -a _devtools_remote

This gave the desired output:

0000000000000000: 00000002 00000000 00010000 0001 01 332286 @chrome_devtools_remote
0000000000000000: 00000002 00000000 00010000 0001 01 332568 @chrome_devtools_remote_6408

So I was able to set up the forward using:

adb -d forward tcp:9223 localabstract:chrome_devtools_remote_6408

and then got the json from http://localhost:9223/json/list

I'll submit a PR that adds the socket name as a cli argument to copy-tabs in case anyone else might find this useful :)

devnll added a commit to devnll/android-chrome-tab-transfer that referenced this issue May 23, 2022
e.g. to get tabs from Chrome Beta instead of regular Chrome (see machinateur#2)
devnll added a commit to devnll/android-chrome-tab-transfer that referenced this issue May 24, 2022
e.g. to get tabs from Chrome Beta instead of regular Chrome (see machinateur#2)
@machinateur machinateur pinned this issue May 27, 2022
@machinateur machinateur self-assigned this May 31, 2022
@machinateur machinateur removed their assignment Oct 22, 2022
@machinateur machinateur unpinned this issue Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants