Skip to content

Instantly share code, notes, and snippets.

@tonyseek
Last active April 2, 2024 02:49
Show Gist options
  • Star 38 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save tonyseek/bc5b72197ddb15418c61406061720186 to your computer and use it in GitHub Desktop.
Save tonyseek/bc5b72197ddb15418c61406061720186 to your computer and use it in GitHub Desktop.
Overrides the captive portal settings of Android in the People's Republic China mainland
#!/usr/bin/env sh
## I don't have any devices running Android OS now. These settings may have been outdated but I cannot verify it.
adb shell settings put global captive_portal_fallback_url http://g.cn/generate_204
adb shell settings put global captive_portal_http_url http://www.google.cn/generate_204
adb shell settings put global captive_portal_https_url https://www.google.cn/generate_204
adb shell settings put global captive_portal_other_fallback_urls http://www.qualcomm.cn/generate_204
@edwardw
Copy link

edwardw commented Jul 29, 2019

Figured it out, changing the https check url works:

adb shell settings put global captive_portal_https_url https://www.qualcomm.cn/generate_204

@vip008008
Copy link

How to install this setting in android 8.1 version please let me know

@escape0707
Copy link

escape0707 commented Mar 13, 2021

@vip008008 I suppose you still didn't figure it out. If you did, why not edit your post and share the way?

So, basically you look up how to use adb to connect to your device, then run commands in the original gist.

Finally, some people mentioned that only captive_portal_http_url captive_portal_https_url is implemented and used. So basically you have to rely on setting these two correctly.

Although if I recall correctly, in Android 12 there will be a new way to work with captive portal things, etc.


Figured it out, changing the https check url works:
adb shell settings put global captive_portal_https_url https://www.qualcomm.cn/generate_204

Make sure to use http url with http setting, and https url with https setting.

@jacoblyw
Copy link

jacoblyw commented Oct 29, 2021

Not in China, but I had the "no internet" WiFi icon when the tablet came back from having the screen repaired. Internet worked, but automatic connections to WIFi didn't.

And then [recently] I started getting "open captive portal" messages

connect with adb shell:
adb shell

use superuser:
su

Check what setting is set (just out of curiosity):
settings get global captive_portal_server
status.eqoe.cn

I didn't bother with any of the fallback or http/https settings, I just did the following setting:
settings put global captive_portal_server "connectivitycheck.gstatic.com"

and it worked! That's a relief!

Thanks to everyone for pointing me in the right direction. (I also got some hints on the URL to use on android.Stackexchange.com, but I don't have enough reputation to post there.)

@escape0707
Copy link

@jacoblyw That seems to be a quite scammy website. I highly suggest you to flash your whole system, including recovery and boot loader if you could.

@adelneo
Copy link

adelneo commented Nov 15, 2023

I get the prompt

'run the following command in adb : pm grant io.github.muntashirakon.captiveportalcontroller android.permission.WRITE_SECURE_SETTINGS'

but when i do I'm getting err: adb.exe: unknown command pm

@jacoblyw
Copy link

@jacoblyw That seems to be a quite scammy website. I highly suggest you to flash your whole system, including recovery and boot loader if you could.

I agree that the .cn site seemed up to no good. I really have to wonder about the repair place and what they're passing on to clients.

The tablet broke again, so it doesn't matter much.

@escape0707
Copy link

@jacoblyw I just gave another search of whois of that hostname, it turns out to be an Alibaba Cloud hostname. I think it might be that you are using a device sold in China? Anyway, I hope you got some new device that fits your requirement now!

@yanfeng42
Copy link

Thanks , Bro. From 2023/12/15, With pixel 7 & Android 14, my config:

adb shell
lynx:/ $ settings put global captive_portal_http_url http://connect.rom.miui.com/generate_204
lynx:/ $ settings put global captive_portal_https_url http://connect.rom.miui.com/generate_204

@jacoblyw
Copy link

jacoblyw commented Jan 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment