yashsingh1/xdaforums huggingface dataset:
[Sony Xperia 5 III] Venborg:
Hello kind people of XDA,

Been lurking for a long time and finally decided to (try) to install crDroidAndroid. I have had a few phones with custom ROMS and all but this Sony one seems to have take a lot of consideration before flashing a new ROM somehow.

Firstly, I had to unlock the bootloader. I'm on W10. I've unlocked bootloaders before (although a long time ago). I got the global variant (XQ-BQ52), got the unlock code from Sony etc. I initally had trouble unlocking, then I found out there is a difference between fastbootd and fastboot. I went into proper fastboot, had to manually install Android Bootloader Interface (which I found weird), I checked that I got a response in Terminal with the command

fastboot devices

Then I really went through the instructions on Sony's website and was indeed a bit confused about the command

fastboot oem unlock 0x

The instructions said you needed your code (which I got) but not where to put it. Firstly, I just ran the above command kind of expecting perhaps to put in the code afterwards. Didn't work. Then I just put replaced 0x with my unlock code and then... nothing happened. Terminal just hanged forever.

This is where I perhaps messed up; I abandoned the command with CTRL + C. Now, when trying to reboot or other stuff from Terminal I get

FAILED (Write to device failed (no link)).

Luckily, I still have device response when using

fastboot devices

Right now, I don't dare to do more for now. I am kind of scared and don't know what to do next. I would like to pull the USB cable but I am afraid to potentially mess even more up!

Is there any hope some of you guys can help? Or did I brick it? (Although my intution says that is difficult these days.. but I mean, look where this has taken me).

EDIT: FWIW, I am on a Ryzen CPU if that is of importance. My search led me to this article which I am not sure is important or not.

Sorry for my n00bness. Thanks a billion in advance.
[Sony Xperia 5 III] Omar_ahmed-1:
first of all put the code like this :

fastboot oem unlock 0x( put the code here)

then flash your device's rom
[Sony Xperia 5 III] Omar_ahmed-1:
first of all put the code like this :

fastboot oem unlock0x"code here"

then flash your device's rom
[Sony Xperia 5 III] Venborg:
Hello Omar, thank you for taking time to answer. Now I know how to put in the code.

Unfortunately, right now I am unable to run any command due to

PS C:\Users\user> fastboot oem unlock 0x[my-code-here]
FAILED (Write to device failed (no link))
fastboot: error: Command failed

This is where the issue lies.
[Sony Xperia 5 III] Omar_ahmed-1:
I think there is a problem in the device's drivers

I'm not sure
[Sony Xperia 5 III] Venborg:
You might be right - and I take it you mean my Windows device? I would just assume I could not reach the phone if I got driver issues. Again, I am perfectly able to "ping" my device with fastboot devices.
[Sony Xperia 5 III] Omar_ahmed-1:
The device is Authorized in CMD?

CMD can show the device and write "unauthorized"

And it can be a problem is the USB

check if you have an official ADB binaries too
[Sony Xperia 5 III] Venborg:
Yes, it was authorized.

Very interesting you mentioned CMD specifically, I did use Terminal and thus Powershell. It might have caused some problem.

BUT! Big update:

Left the phone plugged over night in the PC, and naturally computer went to sleep. I just tried to fastboot reboot and BEHOLD: the phone rebooted, showed the "cannot check for corruption [..] screen", wiped the data and booted into the stock ROM. I mean: what?!

Futhermore, it shows unlocked under developer settings and:

C:\Users\user>fastboot getvar unlocked
unlocked: yes
Finished. Total time: 0.001s

Although, this is curious to me:

C:\Users\user>fastboot oem device-info
FAILED (remote: 'unknown command')
fastboot: error: Command failed

Perhaps it is just how Sony phones work?

Nonetheless; I do not know what happened. I think it did succeed in unlocking the bootloader after all. Is there any commands I should run before trying to flash the ROM I would like to install?

Thanks again.
[Sony Xperia 5 III] cactus018:
Phones undergo a factory reset when their bootloader is unlocked to prevent data theft.

Before flashing a custom ROM, it would be wise to disable the AVB (Android Verified Boot). You can do that by flashing a no-verity vbmeta image using "fastboot flash vbmeta <file_name>" command. Aside from that, you should have no trouble installing custom ROMs with an unlocked bootloader.
[Sony Xperia 5 III] Venborg:
Thanks for chiming in, cactus! Much appreciated.

And yes, sorry: I do know they undergo a factory reset after unlocking bootloader - I was just surprised that it (seemingly) worked after all!

Thanks for the suggestion regarding AVB, I will need to research upon that. If I am able to flash a no-verity vbmeta image, I take it that I do indeed have an unlocked bootloader.

But I mean; thanks to @Omar_ahmed-1, I am sure I messed up the `fastboot oem unlock` command. I did not get a proper response in the terminal and killed the process. That is why I am kind of uncertain whether I actually managed to unlock the bootloader or not - or somehow "damaged" something? How likely is that, if you know?

It might be a stupid question, but will anything happens if I re-run `fastboot oem unlock` with the same unlock code?
[Sony Xperia 5 III] Omar_ahmed-1:
If you killed the process before putting the code I think it is safe

But

Don't try to re-unlock the bootloader until you know it is safe or not

It may have some risks (sorry for my bad English at all)
[Sony Xperia 5 III] Venborg:
@cactus018, if you don't mind me asking: regarding disabling AVB, should I be able just to follow this guide and use the vbmeta.img file directly from Google?
[Sony Xperia 5 III] Venborg:
I ran fastboot oem unlock "my-unlock-code" in PowerShell without 0x in front of my unlock code. And then I got no response for some time, and then I abandonded the process with CTRL + C. After that, I kept getting "failed: no link" with every command I tried. Then I tried again this morning (after PC had been in hibernation), ran fastboot reboot again which all of a sudden worked.
[Sony Xperia 5 III] cactus018:
I wouldn't suggest you this. Usually, custom ROM producers (such as LineageOS, Pixel Experience etc.) provide you all the img files you need to flash, including the VBMETA file (which is obviously with no-verity). Just flash the vbmeta.img file provided in the list of custom ROM img files. Also, not all vbmeta partitions (on all devices) have the same sizes. Some are 4 KB large, some are 8 KB... There's no generic vbmeta file for all devices. So my suggestion is to use the VBMETA file bundled with your desired custom ROM.
[Sony Xperia 5 III] cactus018:
I also had this issue today while helping a friend of mine. That's actually a weird issue that happens due to USB 3.0 ports (or maybe drivers?). If you have this error in the future, just connect your phone into a USB 2.0 port, keep rebooting into bootloader and keep trying to run the command. Depending on your luck, it will eventually work and execute the command with no errors (in the case of my friend, it worked immediately after a restart and swapping to a USB 2.0 port)
[Sony Xperia 5 III] Venborg:
Ah, like so. Makes sense. For this device, it seems there is very limited choice, but I intend to install crDroidAndroid as first custom ROM. However, I don't see an img-file with the exact name "vbmeta.img", but I take it one of these will be the VBMETA file?
[Sony Xperia 5 III] Venborg:
That is interesting indeed - and a good tip, thanks!

However, I still don't understand how I successfully managed to unlock the bootloader (and still not quite sure if I did, lol) while using the wrong command. I did afterwards put in correct command in same session, but as mentioned I got "failed: no link" and thus I don't belive the command was excecuted. Or perhaps it was but Powershell didn't show?
[Sony Xperia 5 III] cactus018:
Maybe it doesn't have a vbmeta file because the boot partition is patched by them so the phone skips the AVB. 🤷
[Sony Xperia 5 III] cactus018:
You unlocked the bootloader - no worries.

Yes, I'm talking about "failed: no link". About this specific error. I believe it's simply a glitch and not a real error, since just by restarting a few times and keeping spamming your desired command it will eventually work. That's the same for "remote error: unknown command". Errors displayed out of blue with no reason.
[Sony Xperia 5 III] Venborg:
Thanks a tonne! So, you think I'm safe in trying to proceed and (finally, lol) flash the custom ROM, right? (And following the instructions, of course)

Once again, I really appreciate your replies - thanks!
[Sony Xperia 5 III] cactus018:
Just do it, what bad could happen? As long as what you're installing doesn't mess up the bootloader, you can always return to fastboot mode to fix whatever mistake you did. So go on.
[Sony Xperia 5 III] Venborg:
I did it and all went smoothly! Except for flashing the "camera addons" .zip-file.

I am not sure why this time was scary and different from previous times, but it indeed worked out fine in the end. I highly appreciate your help, thank you very much.

Have a lovely day!
[Redmi K20 Pro / Xiaomi Mi 9T Pro Questions & Answe] Sak0ya:
Yesterday my device worked with adb and I was using scrcpy screen mirror fine with it, today when I tried it couldn't recognize, I thought it was my computer but I tried my other phone it was working fine and detecting the adb serial and was working fine with scrcpy. What I have tried so far is deleting the adbkey and adbkey.pub in .android but not luck. It's not prompting the pair thing or authorize the device anymore. Earlier I did revoke usb debug auth I thought that would reset it no luck too. what works is adb in recovery mode I have orange fox, also my device is already rooted with evo x rom. I was thinking of dirty flashing it over if that would work but I might break some stuff so if you guys have any other ideas before I do that.
[Samsung Galaxy Watch 4] harvey186:
on my GW4 with OneUI 5.0 adb over wifi does not work. when I try connection with adb connect IP port it needs some seconds and then I'm getting the error: connection failed.

If I try adb pair IP port I get ask for pin, but after entering the PIN I'm getting the error: unknown host service

Any tips how to solve this issue / getting access via adb ?

View attachment 6094093
[Samsung Galaxy Watch 4] wyt18:
You need to pair your device first. Click pair new device on the wireless debugging settings
[Samsung Galaxy Watch 4] harvey186:
AS I habe written:

If I try adb pair IP port I get ask for pin, but after entering the PIN I'm getting the error: unknown host service
[Samsung Galaxy Watch 4] wyt18:
it probably means your device is not accessible via the network. try rebooting or resetting wifi
[Samsung Galaxy Watch 4] harvey186:
I have 3 different mm networks at home and I have tried them all. I have rebooted watch several times and also the desktop. Always the same.

I have updated platform tools to latest version. But still get no access.

I have tried it with my phone/PC. No problem, connection works fine. I fear that Samsung has disabled it with OneUi 5 ??
[Samsung Galaxy Watch 4] harvey186:
Is there a way to find device number for changing listen port. Port 5555 works much better, but therefore I need to change it on watch with adb -s device-number 5555
[Samsung Galaxy Watch 4] wyt18:
No, it isn't disabled and works fine for most. Try using a static IP address instead of randomized Mac?
[Samsung Galaxy Watch 4] harvey186:
mhm, I never have written or used a randomized Mac. When I was talking about device number I was meaning the number which is normally shown by 'adb devices' -- but I have found it. it's written under 'Model'
[Samsung Galaxy Watch 4] harvey186:
OK, now I was able to pair

ich@pop-os:~$ adb pair 192.168.1.102:41599
Enter pairing code: 261986
Successfully paired to 192.168.1.102:41599 [guid=adb-RFAT216QRSM-1P2MSX]
ich@pop-os:~$ adb shell
adb: no devices/emulators found
ich@pop-os:~$

But as you can see, adb shell is not working. And under 'IP address and port' is now written 'Unavailable'

and device is shown as 'offline'

ich@pop-os:~$ adb devices
List of devices attached
192.168.1.102:41599 offline

ich@pop-os:~$ adb connect 192.168.1.102:41599
already connected to 192.168.1.102:41599
ich@pop-os:~$ adb shell
adb: device offline
ich@pop-os:~$
[Samsung Galaxy Watch 4] devaponnadsm:
Is your ADB version on Mac the latest? If not, update
[Samsung Galaxy Watch 4] harvey186:
I'm not on MAC, I'm on Linux
[Samsung Galaxy Watch 4] bdr127:
What version of platform tools are you using? What is the output of the command adb version ?

If it's not 35.0.1, then update platform tools and try again.
[Samsung Galaxy Watch 4] bdr127:
Should have asked the obvious first, since it wasn't explicitly stated in your posts.... I assume developer mode is unlocked on your watch?

What version of WearOS? (Phones/tablets require Android 11+ to use wireless adb... but WearOS requires Android 13+.)
[Samsung Galaxy Watch 4] devaponnadsm:
Whatever, check if you have latest ADB installed?

Latest version is available here: https://developer.android.com/tools/releases/platform-tools
[Samsung Galaxy Watch 4] devaponnadsm:
Also, the connection port and pairing port is different. Make sure you are entering so.
[Samsung Galaxy Watch 4] harvey186:
If you have followed my posts, you will know, that pairing is work. But no adb over WiFi and no way to use adb shell.

And also you will know, that I'm using latest platform tools from google.
[Samsung Galaxy Watch 4] devaponnadsm:
I saw the same ports for pair & connect command, usually different
[Samsung Galaxy Watch 4] bdr127:
Are you just ignoring my posts above? There are several questions and commands I asked about.
[Samsung Galaxy Watch 4] harvey186:
Oh, sorry, I haven't seen your post.

- adb:

ich@pop-os:~$ adb --version
Android Debug Bridge version 1.0.41
Version 35.0.1-11580240
Installed as /usr/lib/android-sdk/platform-tools/adb
Running on Linux 6.8.0-76060800daily20240311-generic (x86_6

- developer mode:

yes, it's activated (otherwise I wouldn't be able to use adb over wifi'

- WearOS:

4.0 / Android 13

- mobile device OS

- several, but all Android 13 and 14
[Samsung Galaxy Watch 4] harvey186:
it's stupid:

After first run:

ich@pop-os:~$ adb connect 192.168.1.101:46051
failed to connect to 192.168.1.101:46051

after second run:

ich@pop-os:~$ adb connect 192.168.1.101:46051
already connected to 192.168.1.101:46051

but adb shell don't work:

ich@pop-os:~$ adb shell
adb: device offline

EDIT: It's getting more stupid. I have reset all and use different network. Now I'm getting this error after release the port in PoPOS firewall:

failed to connect to '10.10.10.124:37343': No route to host

View attachment 6104087
[Samsung Galaxy Watch 4] harvey186:
lol. The watch does not have an USB port. If it would have, I would see no reason to use adb over wifi
[OnePlus 12R / OnePlus Ace 3] Mrid0401:
Does the phone support frame interpolation if not any method to enable it?
[OnePlus 12R / OnePlus Ace 3] PriPhaze:
As far as i know only Ace3 Supports it but you have to be in ColorOS, idk if a 12r with ColorOS can also use it.
[General Questions and Answers] elight1:
I managed to install dnsmasq using termux by running this:

pkg i root-repo && pkg up && pkg i dnsmasq

This installs it in this path: /data/data/com.termux/files/usr/bin/dnsmasq

I followed the instructions in this post to configure dnsmasq:

[TUT] Adblock using DNSMASQ [root]

After much struggling with high cpu loads using Androids own dnsmasq I finally came up with the solution to use dnsmasq for ad domain blocking. [Q] Need root? Yep. [Q] Why dnsmasq? Dnsmasq can use wildcards in domain names, no more lenghty...

xdaforums.com

I can adb shell into my phone, and run dnsmasq successfully like this:

/system/bin/dnsmasq --pid-file --conf-file=/etc/dnsmasq.conf <&-

I can look at the logs and see that dnsmasq is running:

logcat | grep dnsmasq

My problem is that it seems like the phone is still using its default DNS servers and avoiding dnsmasq, as I can't see the logs being updated whenever I visit a website. I believe I need to prevent the phone from using default DNS servers and force it look them up through dnsmasq. On the linux I simply remove the file /etc/resolv.conf but it doens not exist on Lineage. How can I solve this problem?
[General Questions and Answers] Ultramanoid:
I believe you need root on Termux in the device itself to run it. As I understand it you can't make it work from an external computer.

Edit : I just realized dnsmasq is actually included in Android ( who knew ), in my system it is at /system/bin as shown in the screenshot. I normally put my binaries in a system directory as well to be run as root only, because as a normal user or even root from Termux' data directories in many cases won't work well.

... But this one also needs root to be used from there anyway. This would be a better option than using it with Termux, I suppose.
[General Questions and Answers] Ultramanoid:
I've tried Android's /system/bin/dnsmasq as root and apparently you want to put your pid file at :

/var/run/dnsmasq.pid

Hope that helps !
[General Questions and Answers] elight1:
Thanks. It isn't included in LineageOS.

Passing the flag --pid-file alone without a path avoids the need to have this file.

I can run it fine as well. But my question was: How do you force phone traffic through dnsmasq? Normally it uses a standard DNS address, how is it possible to change this address to dnsmasq (127.0.0.1)?
[General Questions and Answers] xXx yYy:
IIRC, directly forcing phone traffic through dnsmasq on LineageOS (or most Android phones) isn't really possible, this because Android prioritizes pre-configured DNS: By default, Android uses the DNS servers provided by your router (often public servers like 8.8.8.8). It might bypass locally configured options like dnsmasq.

IMO a workaround would be Using the "hosts" file: LineaOS allows modifying the "/etc/hosts" file, which can be used to map specific domain names to local IP addresses. This is useful for a few internal resources but won't handle all DNS lookups.

NOTE: Editing this file requires root access on your phone.
[General Questions and Answers] elight1:
Thanks.

Here is an open source project (personaldnsfilter) https://www.zenz-solutions.de/personaldnsfilter-wp/ which does exactly that. When enabled, it behaves as the default DNS server (replaces 8.8.8.8), and it filters all DNS queries. It isn't a firewall, but it can be used as one. There are many firewalls that use exactly the same technique, for example: https://play.google.com/store/apps/details?id=com.everaccountable.bulldog

Modifying the hosts file isn't really a solution as once it passes a certain size it starts depleting the battery and slowing down domain lookup. Using personaldnsfilter is much better than modifying /etc/hosts as it can take 10s of millions of domains and look them up much more efficiently.

After years of building up a hosts file, I found that it was an impossible task, there will always be countless gaps and bad domains being created everyday. Therefore a walled-garden solution is the best solution. I can already do this on my linux pc (dnsmasq + e2guardian + iptables). I just need to figure out how to do it on Android (dnsmasq alone is sufficient, no need for man-in-the-middle/e2guardian filtering).
[General Questions and Answers] espionage724:
What about using a compressed HOSTS?

On Linux I use StevenBlack's as-is, but on Windows I use Compressed from ScriptTiger. On Android I used StevenBlack's minimized years ago seemingly without issue.
[General Questions and Answers] elight1:
I see.

Take the following 2 hosts projects: https://github.com/ShadowWhisperer/BlockLists/blob/master/Lists/Adult and https://github.com/bon-appetit/porn-domains

There are new pornographic domains being discovered and added on an hourly basis. They render any hosts based firewall useless. Again: I already have the best possible hosts blocking solution: https://github.com/elyahw/filter-Android (a list of almost 15m bad domains)

But as I clarified above, there are gaps being created on a daily basis. Hence the need for the opposite solution: walled-garden i.e. allow a limited whitelist of domains, instead of blocking tens of thousands of unwanted domains.
[General Questions and Answers] xXx yYy:
@elight1

you complained about loss of speed and battery drain when making excessive use of Android's hosts file.

Here my 2 cents:

Preface:

The Android hosts file is consulted during each network request. This means whenever an app tries to access the internet, the Android system checks the hosts file first.

Estimating Speed loss:

The exact number of CPU cycles required to read a hosts file with say 20,00 entries - as mine has - depends on several factors:

Hardware: The processing speed (clock rate) of the CPU will significantly impact the number of cycles needed. A faster CPU will complete the task in fewer cycles. The clock rate advertised for modern Android phones typically falls in the range of 1.8 GHz to 2.2 GHz for the fastest processors.

File size:The size of the hosts file itself plays a role. Larger files due to additional characters will require more cycles to read. Here's a simplified approach to estimate cycles:

Instruction types: We can assume basic instructions like loading a character might take 2 cycles, and adding might take 1 cycle.

Line reading instructions: For a 128 character line, we'd need 128 load instructions (one per character) and potentially an add instruction for the null terminator.

Total cycles: By multiplying the number of instructions by their estimated cycles, we get an initial estimate.

Storage device: The speed of the storage device (eMMC vs UFS) can influence the read time and consequently the CPU cycles. Faster storage delivers data quicker, reducing CPU usage.

My resume:

A 1.8 GHz SoC can theoretically perform 1,800,000,000 cycles per second. Hence reading a hosts file, even a massive one, only takes milliseconds which is absolutely negligible.

Battery Drain Estimation:

While CPU cycles are directly linked to power consumption, accurately calculating the battery drain from reading a hosts file is difficult. Reason: Reading a file, even with 20,000 entries, is a very quick operation.

My resume:

The CPU usage spike would be minimal and likely undetectable in overall battery consumption.
[General Questions and Answers] elight1:
Have you heard about web proxy? Take croxyproxy.com, there are thousands of others, hundreds spring up everyday.

They render your solution useless. This is why I am seeking to enable dnsmasq walled-garden.

My question goes unanswered: How do I force all DNS traffic through dnsmasq on LineageOS?
[General Questions and Answers] xXx yYy:
That's NOT true: you were told to make use of Android's /etc/hosts file.

AFAIK dnsmasq is a lightweight program that combines two important networking functions: DNS server and DHCP server. If I correctly understood you want to run dnsmasq as DNS server. By default, dnsmasq on most Android devices (if available) should automatically read and utilize the /etc/hosts file, means read your device's hosts file ( This allows you to define custom domain name translations for local devices on your network that aren't part of the global DNS ). But this requires the /etc/hosts file needs to be readable by dnsmasq.

Here's how to enable dnsmasq to read /etc/hosts file - requires root access:

Run shell commands

su -c "chmod 644 /system/etc/hosts"
su -c "chown username:<dnsmasq> /system/etc/hosts"

Note: Replace <dnsmasq> with the group dnsmasq belongs to, if applicable

Android 9 introduced a "Private DNS" feature. Hence allows specifying a custom DNS provider like dnsmasq.

Here's how to enable dnsmasq as Private DNS:

Go to Settings > Network & internet (or Wi-Fi)

Tap on the WiFi network you're connected to.

Look for an option called "Private DNS" or "DNS over TLS (DoT)"

Choose "Private DNS provider"

Enter the hostname or IP address of your dnsmasq server

These were my last 2 cents here:

View attachment 6096502