android media文件夹新位置

至android 9之后,开机铃音的文件夹位置已经由/system/media以至/product/media

mount -o remount,rw /product

 

然后将需要的铃音放在/product/media的相应目录下

解决adb无法连接手机的问题

在使用custom kernel情况下,使用adb 手机将不显示允许连接的对话框

 

解决方法:将主机上adbkey.pub(存储位置为~/.android/)复制到手机的/data/misc/adb/并改名为adb_keys

cd ~/.android/
adb push adbkey.pub /data/misc/adb/adb_keys

 

 

参考:https://stackoverflow.com/questions/26213954/how-to-solve-adb-device-unauthorized-in-android-adb-host-device

 

  • Get the public key from the client phone (adb host)

    cat /data/.android/adbkey.pub

  • copy the above public key to the target phone’s /data/misc/adb/adb_keys location. (you may need to stop the adb daemon first with stop adbd)

    cat /data/misc/adb/adb_keys

verify both cat outputs match.

try restarting adb daemon on target start adbd or just reboot them.

If you are having problems reading or writing to ADB KEYS in above steps, try setting environment variable ADB_KEYS_PATH with a temporary path (eg: /data/local/tmp). Refer to that link it goes into more details

    "On the host, the user public/private key pair is automatically generated,
    if it does not exist, when the adb daemon starts and is stored in
    $HOME/.android/adb_key(.pub) or in $ANDROID_SDK_HOME on windows. If needed,
    the ADB_KEYS_PATH env variable may be set to a :-separated (; under
    Windows) list of private keys, e.g. company-wide or vendor keys.

    On the device, vendors public keys are installed at build time in
    /adb_keys. User-installed keys are stored in /data/misc/adb/adb_keys"

K20Pro 刷LineageOS 17[原]

1.解锁 unlock the bootloader;

2.刷twrp (flash twrp)

从这个帖子里下载twrp,感谢mauronofrio(download twrp from this post, thanks for  mauronofrio’s hard work)

TWRP 3.3.1-25 Unofficial by mauronofrio

https://forum.xda-developers.com/k20-pro/development/recovery-unofficial-twrp-xiaomi-redmi-t3944363

用fasterboot刷recovery(flash twrp recovery via fastboot)

fastboot flash recovery  twrp-3.3.1-25-raphael-mauronofrio.img

进入twrp recovery (reboot to twrp recovery)

注意:不能直接重启进入系统,否则twrp将会被替换(IMPORTANT: After flash twrp, DO NOT REBOOT TO MIUI DIRECTLY, OTHERWISE TWRP WILL BE REPLACED BY MIUI RECOVERY)

fastboot boot twrp-3.3.1-25-raphael-mauronofrio.img

在这个帖子里的地址下载K20Pro 的10.0 vendor和LOS17.0 ROM,用MTP上传至手机,感谢abhishek987

 

 

 

anbox安装

1.安装内核模块

1.1从ppa安装

$ sudo add-apt-repository ppa:morphis/anbox-support
$ sudo apt update
$ sudo apt install linux-headers-generic anbox-modules-dkms

1.2加载内核模块

$ sudo modprobe ashmem_linux
$ sudo modprobe binder_linux

1.3 检测内核模块加载情况

$ ls -1 /dev/{ashmem,binder}
/dev/ashmem
/dev/binder

2.安装anbox

2.1 配置snap使用socks5代理

sudo gedit /etc/environment

添加如下内容:

http_proxy="socks5://127.0.0.1:1080"
https_proxy="socks5://127.0.0.1:1080"

2.2刷新snapd服务

sudo systemctl daemon-reload


sudo systemctl restart snapd.service

2.3安装anbox

2.3.1 安装

$ sudo snap install --devmode --beta anbox

2.3.2 更新

$ snap refresh --beta --devmode anbox

 

3.安装amr兼容

Install Google Play Store and enable ARM applications / games support on Anbox (Android in a Box)

Update (February, 2019): The script to install Google Play Store and enable ARM (libhoudini) support for Anbox was updated to automatically download the latest open-gapps, fixing an issue that caused Google Play Store to close immediately after starting in some cases (when the Google Play Store version downloaded by the script was too old).

These instructions will obviously not work if Anbox is not already installed on your Linux desktop. If you haven’t already, install Anbox by following the installation instructions found here. Also, make sure you run anbox.appmgr at least once after installing Anbox and before using this script, to avoid running into issues. Also, make sure Anbox is not running when executing the script below (I suspect this is what causes this issue mentioned in the comments).

1. Install the required dependencies (wgetlzipunzip and squashfs-tools).

In Debian, Ubuntu or Linux Mint, use this command to install the required dependencies:

sudo apt install wget curl lzip tar unzip squashfs-tools

2. Download and run the script that automatically downloads and installs Google Play Store (and Google Play Services) and libhoudini (for ARM apps / games support) on your Android in a Box installation.

Warning: never run a script you didn’t write without knowing what it does. Before running this script, check out its code

To download the script and make it executable, use these commands in a terminal:

wget https://raw.githubusercontent.com/geeks-r-us/anbox-playstore-installer/master/install-playstore.sh
chmod +x install-playstore.sh


Now you can run the script:

./install-playstore.sh

Initially the script needed to run with superuser privileges, but that’s no longer the case. After it’s done installing Google Play Store and libhoudini, you can clean the leftovers – remove the anbox-work folder created by the script.

4. To get Google Play Store to work in Anbox, you need to enable all the permissions for both Google Play Store and Google Play Services

To do this, run Anbox:

anbox.appmgr

Then go to Settings > Apps > Google Play Services > Permissions and enable all available permissions. Do the same for Google Play Store!

You should now be able to login using a Google account into Google Play Store.

Without enabling all permissions for Google Play Store and Google Play Services, you may encounter an issue when trying to login to your Google account, with the following error message: “Couldn’t sign in. There was a problem communicating with Google servers. Try again later“, as you can see in this screenshot:

After logging in, you can disable some of the Google Play Store / Google Play Services permissions.

If you’re encountering some connectivity issues when logging in to your Google account on Anbox, make sure the anbox-bride.sh is running:

  • to start it:
sudo /snap/anbox/current/bin/anbox-bridge.sh start

 

  • to restart it:
sudo /snap/anbox/current/bin/anbox-bridge.sh restart

You may also need to install the dnsmasq package if you continue to have connectivity issues with Anbox, according to this user. But this wasn’t required on my Ubuntu 18.04 desktop.

 

 

android-x86 设置

1.兼容性问题

Android x86 默认不带houdini,运行纯ARM版会提示:

很抱歉,”xxxx”已停止运行

设置->应用兼容性->打开

终端模拟器

$ su
# enable_nativebridge

 

脚本会自动下载houdini.tgz并解压到相应位置

 

2.网络设置

网络设置为桥架模式

adb connect 192.168.56.101:5555
adb devices
adb -s 192.168.56.101:5555 root
adb -s 192.168.56.101:5555 shell

 

3.ADB安装app

adb install ***.apk

lg v20 刷twrp

1. re-boot into fastboot mode
2. flash twrp use fastboot command.
3. power-off the phone
4. power-on with power and volume down button holding
5. while lg log appears, release power button immediately for 1 second and then hold again
6. when recovery selection screen appears, select ‘yes’ both two times.
now phone boot to twrp recovery.

REMEMBER: WHEN YOU BOOT INTO LG’S SYSTEM AGAIN, YOU WILL LOST TWRP. IF U WANT TO USE TWRP AGAIN, U MUST RE-FLASH TWRP AND REPEAT THE STEPS ABOVE.

THIS WILL LOST ALL DATA(PHONE WILL GET FACTORY RECOVERED)!!

 

Quote:

Originally Posted by mking007cn 

here is a new problem, each time i start a normal boot, i will lost twrp again. anyone can tell me how to solve this, thank you
You need to delete the file recovery-from-boot.p in /system

Each time you boot, that file gets executed and restores the stock recovery from recoverybak. Alternatively, you can flash TWRP to both recovery and recoverybak.

-- Brian

How to Fix PIN Errors After Restoring from TWRP Android Backups

ref:https://www.howtogeek.com/240657/how-to-fix-pin-errors-after-restoring-from-twrp-android-backups/

Making TWRP backups is a must if you’re going to be rooting and tweaking Android. But if your phone is encrypted, you may have some issues with your PIN or password lock after restoring from a backup. Here’s what’s going on.

If the backup you’re restoring uses the same PIN as your current system, everything should go swimmingly. However, if the system you’re restoring to uses a different PIN than the system you’re restoring from, you may run into some quirks. When you reboot your phone, it’ll ask you for a PIN, saying “PIN required when you restart device”. In some cases, you’ll have to enter your latest PIN when you boot, and your old PIN to get into your phone. In other cases, you may not be able to unlock your phone at all. But don’t panic: in both cases, this is easily fixable.

If Your Device Is Stuck Using Two PINs or Passwords

After restoring from backup, you may find that your device accepts two PINs: your most recent PIN at boot, and your old PIN (from the backup you restored) for unlocking the device. This isn’t a huge problem, but can be confusing since you need to remember both PINs. Thankfully, the solution is simple: Just reset your PIN in Android’s settings.

Head to Android’s Settings app and go to Security > Screen Lock. From there, tap on PIN or Password to choose a new PIN or password to lock your phone.

After doing so, that is the PIN or password you will use for everything–at boot and at the lock screen.

If Your Device Won’t Unlock At All

Here’s where things get really dicey. In some rarer cases, your most recent PIN will work at boot, but no PIN will work to unlock the screen–meaning you can’t access anything on your phone. Thankfully, this is fixable too–it just takes a few more steps.

First, boot back into TWRP’s recovery environment. It’ll likely ask you for a password–enter your most recent working PIN (the one you were using before you restored from backup). If you didn’t have a PIN, type in default_password. You’ll be greeted with the main TWRP window.

Then, head to Advanced > File Manager, and go to the /data/system folder. Scroll down and find the two files with  the .key extension. Delete both of them (by tapping on the file and then tapping the “Delete” button). Then, delete all the files containing the word locksettings.

So on my Nexus 5X, for example, I deleted the following files:

  • password.key
  • pattern.key
  • locksettings.db
  • locksettings.db-shm
  • locksettings.db-wal

Once you’ve deleted all the key and locksettings files, reboot your system. If it asks you to install SuperSU, choose “Do Not Install”.

You may be prompted for a PIN before your phone finishes booting. Once again, it should work with your most recent PIN–the one you were using before you restored from backup.

Once Android starts, your lock screen should appear, with no PIN or password prompt. Unlock your phone (yay!) and head to Android’s Settings. Scroll down and go to Security > Screen Lock. From there, you can choose a new PIN or password to lock your phone.

After doing so, that is the PIN or password you will use for everything from here on out.

goldendict

Android上好用的词典-GoldenDict

ref:http://www.jianshu.com/p/3bbdd2fd98c4

 

简介

GoldenDict是一款功能强大的开源词典应用,使用WebKit作为渲染核心,支持多种词典格式和基于MediaWiki引擎的网站,目前最新版本是1.0.1。GoldenDict 发布于 GNU GPLv3+ 许可之下,可运行于 Linux、Windows、Android平台上,更多关于它的详情可以查看官网,和Github地址。本文主要介绍GoldenDict在Android上的安装和使用方法。

下载安装

在Google Play中搜索GoldenDict,会看到有两个GoldenDict版本,其中FREE版本有限制最大可导入的词典为5本,其它的与收费版本差不多。当然因为GoldenDict是开源项目,所以如果大家资金充裕,可以选择够买收费版本,支持一下GoldenDict团队。

Google Play搜索

安装成功后,打开应用,我会看到如下提示,因为目前我们手机上还没有任何词典,下面我们就来导入自己喜欢的词典。

提示

导入词典

在SD卡的根目录上创建GoldenDict目录,如果手机没有SD卡,也可以在手机的内存根目录上创建GoldenDict目录。

然后前往资源网站上下载自己需要的词典。因为GoldenDict可以支持很多种格式的词典,大家也可以自己去寻找自己喜欢的字典资源导入。这里我们下载一个:《牛津英汉双解》。

下载资源

下载完成后,解压词典文件夹到刚刚创建的GoldenDict目录下,你可以使用电脑连接手机的方式,或者直接使用手机上的文件管理器完成以上步骤。

此时再打开GoldenDict应用,就会发现它识别出了刚刚我们拷贝的词典。

识别词典

点击Proceed就完成了这本词典的导入了。你可以选择自己任意喜欢的词典再加入,但free版本最大限制是5本。

使用简介

查询

goldendict下优质词典简介及安装

ref:https://blog.yuanbin.me/posts/2013/01/goldendictxia-san-da-you-zhi-ci-ku-shi-yong-xiao-ji.html

使用Arch Linux一年以来,如果要问自己最为中意的词典程序是? 当然是Goldendict啦!想详细了解这款瑞士军刀的请猛戳这里.

以前在Win下都是用的lingoes, 感觉还不错,词典库很全,中英双解的词典很多,其它诸如取词, 整句翻译的功能都还能凑合着用(其实是用的第三方引擎),总之这个对于天朝大众还是很不错的啦!一年前转到Arch Linux下就一直在找Linux下比较好用的词典程序和词典,综合来看,Goldendict确实是上上之选(可以认为是stardict的升级版么?),支持的词典格式比较典型的有dsl bgl stardict...,总之是够用了啦!不过话说回来,选择过多有时候却等于没有选择,星际译王的词典确实很多,但试用了一些,大多质量不是很高,幸好使用Google找到了这么一个帖子-Goldendict及其词典详述, RT,楼主实在是很用心,几乎把每个细节都讲到了,对于刚使用goldendict筒子们无疑是帮了一个大大的忙,不过帖子中提供的词典链接基本都已经坏掉了,而且个人觉得对于词典使用者来说,那些步骤也确实太麻烦了,下边我就一些优质的词典安装使用做简要的说明,跟着我这个来下载完后基本就能用了,Troubleshoot部分就一些细节再做一丁点补充。「前人种树,后人乘凉」呼呼~~

goldendict安装

只要你使用的发行版不是过于小众,应该都可以在软件源找到goldendict这款软件。

  • Debian/Ubuntu sudo apt-get install goldendict
  • Arch sudo pacman -S goldendict

Oops…如果实在是没有,解决方案有两个,一是果断换发行版!!二是前往github自行编译。 自从爪机换成Android后自己用的主力词典软件也是goldendict, 将下边带词库文件复制到指定目录下即可使用,非常棒。

词典下载及使用方法简介

  1. Oxford Advanced Learner’s Dictionary 8th edition(En-En)-牛津高阶词典(英英)第8版,含图片及英式发音和美式发音
  2. Merriam-Webster’s Collegiate 11th edition(En-En)-韦氏大学词典(英英)第11版,含图片及发音
  3. Longman DOCE5-Longman Dictinary of Contemporary English 5th edition(En-En)-朗文当代第五版英英词典,含发音和图片,大部分例句也带有朗读,很强悍!!!
  4. Longman Pronunciation Dictionary 3rd edition(En-En)-朗文发声辞典第三版,词典中有英音、美音,并对于“多音”的词,配有preference poll图表,即不同的发音在不同地区、不同年龄层里所占的比例。不得不说,这个碉堡了!!!
  5. Longman DOCE5 Extras(En-En)-不包含单词发音和图片,但是包含了该词汇的各种搭配,和牛津搭配词典类似
  6. 牛津高阶英汉双解 第四版(En-zh_CN)-英汉双解,我想这个对于国人是必不可少的吧?bgl的格式,排版很美观,无发音
  7. en_US_1.0.zip-词形匹配,查词时会自动将复数或者其他形式转换为标准形式

以上6部词典应该是完全够用了,前3部英英词典任选一部即可。以上的文件放在我的百度云网盘中,需要的请移步这里,将词典下载至你想要放的任何位置(直接使用网页打包下载可能会不稳定而下载失败,极其不推荐这种方式下载,做好心理准备…),再到goldendict下设置词典目录即可,重新扫描->大功告成!
之前用Dropbox分享过,最近Dropbox老是提示我流量过多而禁用分享,所以转向了不限流量的百度云,同时也方便国内用户下载。最近发现有其他人保存了我发布过的Dropbox分享,下载时选择「复制到我的Dropbox」就不会给分享人造成流量过多而禁用分享的问题了,而且通过同步下载的方式也稳定的多。

词典下载链接

  • 百度云, 『保存到网盘』,尽量不要使用网页下载 ,下载不稳定并且容易损坏原文件。
  • Dropbox(流量太大长期被Dropbox关闭分享请使用以下分流链接), then click the Add to my Dropbox, 中文的话点击『复制到我的Dropbox』,尽量不要使用网页下载,一来下载不稳定并且容易损坏原文件,二来会增加Dropbox的流量而被暂时禁掉掉分享链接!!我用了几年前注册过的Dropbox帐号对以上词典进行分流,下载方式同上,建议通过『复制到我的Dropbox』方式下载。如果你还没有Dropbox帐号的话不妨猛击我的Dropbox推广链接
  1. En-En_Longman_DOCE5 and Longman DOCE5 Extras(En-En)
  2. En-En_Longman_Pronunciation3
  3. En-En_Merriam_Webster11
  4. En-En_OALD8
  5. En-zh_CN_OALD4
  6. en_US_1.0.zip

词形匹配

很多人抱怨 Goldendict 取词 “books” 居然查不到,它不会自己转换成 “book”,那不过是你没有正确设置而已,事实上这一点 Goldendict 利用构词法规则库可以做得极其强大。编辑-》词典-》词典来源-》构词法规则库可以设置其所在目录。英语构词法规则库到这里下载,注意需要解压缩,英文版软件则通过Edit->Dictionaries->Morphology设置构词法规则库所在文件夹。

http://forum.ubuntu.org.cn/viewtopic.php?f=95&t=265588 功能篇

各词典使用截图

文件目录树

.dictionary
├── [4.0K] En-En_Longman_DOCE5
│ ├── [2.2K] En-En-Longman_DOCE5.ann
│ ├── [1.4K] En-En-Longman_DOCE5.bmp
│ ├── [ 17M] En-En-Longman_DOCE5.dsl.dz
│ ├── [1.3G] En-En-Longman_DOCE5.dsl.files.zip
│ ├── [ 854] En-En-Longman_DOCE5_Extras.ann
│ ├── [1.4K] En-En-Longman_DOCE5_Extras.bmp
│ └── [ 53M] En-En-Longman_DOCE5_Extras.dsl.dz
├── [4.0K] En-En_Longman-Pronunciation
│ ├── [ 277] En-En-Longman_Pronunciation_abrv.dsl.dz
│ ├── [ 848] En-En-Longman_Pronunciation.ann
│ ├── [1.4K] En-En-Longman_Pronunciation.bmp
│ ├── [3.3M] En-En-Longman_Pronunciation.dsl.dz
│ └── [566M] En-En-Longman_Pronunciation.dsl.dz.files.zip
├── [4.0K] En-En_MW11
│ ├── [ 850] En-En-MWCollegiate11.ann
│ ├── [ 980] En-En-MWCollegiate11.bmp
│ ├── [ 13M] En-En-MWCollegiate11.dsl.dz
│ └── [570M] En-En-MWCollegiate11.dsl.dz.files.zip
├── [4.0K] En-En_OALD8
│ ├── [ 290] En-En_Oxford Advanced Learners Dictionary_abrv.dsl.dz
│ ├── [3.8K] En-En_Oxford Advanced Learners Dictionary.ann
│ ├── [ 978] En-En_Oxford Advanced Learners Dictionary.bmp
│ ├── [ 23M] En-En_Oxford Advanced Learners Dictionary.dsl.dz
│ └── [562M] En-En_Oxford Advanced Learners Dictionary.dsl.dz.files.zip
└── [4.0K] En-zh_CN_OALD4
│ └── [ 11M] Oxford_Advanced_Learner_English-Chinese_Dictionary-4th.bgl

5 directories, 22 files

Troubleshoot-故障排除

网上大多给出的是dsl及音频图片的原始格式,我这里已经对dsl进行了压缩处理(使用dictzip进行压缩,Arch Linux下安装dictd即可使用dictzip命令),音频和图片的zip文档是从115上下下来的,如果对音频图片不在乎的话就不用下…dsl.dz.files.zip这些庞然大物了。我最开始下的都是dsl和音频图片的源格式,可折腾死我了, 几十万个音频用zip压缩起来估计得要个一个星期左右, 压缩刚开始的时候速度还可以,到后头就变成了蜗牛,实在是受不了,放在/tmp下也没见得好很多,其它诸如提升进程优先级的方法也试过,除了使CPU的风扇呼呼地吹之外也没见有什么加速的效果,最后果断放弃之,皇天不负有心人,在Google 搜索框内En-En site:115.com总算发现了我要的这些文档。不过下下来后比较了一下,发现网络上的那些zip文档中包含的音频文件总比我下的原始文件数少了那么几个,10多万个少那么一两个问题也不大啦!凑合着用吧!

zip …提示「参数列表过多」或者是压缩速度过慢
若你不小心下载到了.rar的音频和图片文件,结果解压缩后却发现文件夹下有100,000+个音频文件等着你… 如果你真有耐心,那就按下边的步骤来做吧。
压缩过程不要在图形界面下做!!!100000+个文件会把你的CPU和内存拖垮的!!!

  • 压缩速度过慢.

将压缩得到的文件置于/tmp文件夹下,Arch Linux下此文件夹利用ram和swap作为介质,对硬盘的损伤会小很多,速度也会快很多。
将图片音频解压到/tmp下某一文件夹下(这一步可以在图形界面下做),解压后得到的文件像下边的这个样子:
.
├── 12ste01v.wav
├── 9keesh01.wav
├── 9keros01.wav
├── 9ketog01.wav
├── 9khalk01.wav
├── 9khalk02.wav

  • 参数列表过多.

进入音频或图片所在文件夹.
find . -name "*" -print | zip -9 /tmp/En-En-your dictionary.dsl.dz.files.zip [email protected]
另外一种方法就是
for d in ./\*. ; do zip -9 En-En-your-dictionary.dsl.files.zip "$d" ; done

不知为何,我用第二种方法的时候压缩速度实在是太慢,用第一种方法则很快,网友们可自行测试一下。

  • 找不到dictzip这个命令.

看网上说Ubuntu下安装这个软件包即可,Arch Linux下则安装dictd这个包,其它发行版搜索下应该也能找到

  • 使用goldendict是总是显示加载中.

有可能是你下的词典不行,我当时下的一个牛津高阶英汉双解bgl格式的可把我坑死了,最后终于找到了上文中那个相对比较完美的版本(除了音标不完整)。

  • goldendict使用维基百科不显示图片-not display pictures while using Wikipedia

自行到github编译goldendict最新版-go to https://github.com/goldendict/goldendict. The readme file will tell you how to compile from the source. Arch Linux下只需使用AUR中的git版本即可,大爱Arch!^_^

  • 版权问题

以上词典均由网络收集…

音标问题

1.音标可用文件:

https://www.douban.com/note/308047059/

GoldenDict支持CSS,文件名为article-style.css,用记事本编辑如下:
article-style.css:
body {
font-family: “Lucida Sans Unicode”,Tahoma, Verdana, sans-serif;
}

在Linux下,放在~/.goldendict
在Windows下,放在%APPDATA%\GoldenDict
如果是便携版的,放在portable

=====

哪些字体包含国际音标呢?
在微软的Windows与Office的2000或以上版本中分别带有Lucida Sans Unicode和Arial Unicode MS两种字体(以下分别简称LSU和AUM),它们包含了1993年的《国际音标表》上所有音标和附加符号(逾两百个)。

 

2.音标乱码

今天朋友问我如何使用安卓版的Goldendict加载 Oxford Advanced Learner’s English-Chinese Dictionary.bgl 并使其音标部分显示正常。( P( u9 b& t7 `* a8 I1 K% [7 u( }
正常情况下,桌面版安装了 金山音标字体 后就可以了,然而安卓版需要DIY!只需要稍微自定义一下GD全局的CSS文件即可。

 
(一)首先需要知道词典文件里固定的字体名称:
使用桌面版GD,加载这个.BGL词典,查询任意词条,【右键】→【审查元素】→点击到字体部分所在的HTML代码→得知字体名称是:Kingsoft Phonetic Plain

(二)自定义安卓版GD的CSS,添加字体信息:
 kingsoft_phonetic_ue.ttf 复制到 sdcard/GoldenDict/.config/ 目录夹下,! M! L2 H  E; b1 A. _
在同样目录下,新建 article-style.css,编辑,粘贴以下我们这儿需要的自定义字体的代码:

@font-face{font-family:"Kingsoft Phonetic Plain";font-weight:normal;font-style:normal;src: url('file:///sdcard/GoldenDict/.config/kingsoft_phonetic_ue.ttf');}

(三)重新打开GD,音标部分显示正常了!

kingsoft_phonetic_ue.ttf字体下载

https://github.com/liuyug/myfont/tree/master/.fonts

https://github.com/sbw983/myfont9

 

Android 5/6/7/7.1.x 去除网络感叹号方法

貌似自从Android 5.0 Lollipop开始,Google就增加了一个Portal Server门户服务器的连通性测试,大意是为了在连接到需要验证的Public Wi-Fi时,能根据连通测试的情况自动弹出Wi-Fi登陆提示页面,但是默认的地址是 [国内不存在的] gstatic.com 的,鉴于国内的奇葩环境,不管Wi-Fi是不是好的,都会被认为网络是不通的显示一个感叹号提示(Android 7.0 Nougat改成了小叉叉)……

注意:本文提到的方法都无需root,但是需要adb工具并开启开发者选项。

Android 5.0 Lollipop & Android 6.0 Marshmallow的解决方法

在Android 5.0 Lollipop & Android 6.0 Marshmallow时,根据小狐狸分析,可以用以下两个方法解决

    • 方法一:直接禁用Portal Server的连通性测试

在开启了开发者选项的情况下,连接电脑,安装最新版的adb工具,然后执行以下命令:

然后飞行模式一下,就没有了,但是有个弊端,就是如果你连接公共Wifi需要验证的时候,会发现不会自动弹出验证网页,需要自己打开浏览器访问任意网页才行。

    • 方法二:更改默认的Portal Server地址

网上有一些热心人士提供了在国内可正常连接的Portal Server,包括小狐狸v2exg.cn等,我个人比较喜欢g.cn的,同样在adb下输入以下命令可以达到修改Portal Server的目的:

方法二我一直都在用,但是直到Android 7 Nougat这个办法就失效了……如果你用了方法一,应该不用往下看,以下都是基于方法二的调整。

Android 7.0 Nougat的解决方法

这个时候,之前的方法失效了,于是遍寻网上,后来有人发现是验证方法改成HTTPS了,而之前是HTTP的,于是热心人士的服务器纷纷失效了,因此v2ex还升级了之前提供的服务,开出了一个子域名专门做Portal Server,并同时提供HTTP和HTTPS两种连接方式。同样可用的热心人士服务器有Google.cn …… 如果你之前用的就是v2ex的,那么在v2升级后,你就检测就会恢复了,不需要再修改设置。

在Android 7 Nougat仍然可以通过禁用检测的方式来解决这个问题,但我更喜欢无损解决,所以,把上面方法二的服务器换一下就行:

Android 7.1.x Nougat的解决方法

ref:http://bbs.gfan.com/android-8892832-1-1.html

在android 7.1.2中,以前所用的感叹号处理方法不再有效,看了看代码,有两种方式可以消除感叹号

1.直接禁用网络验证检测,使用命令:
adb shell settings put global captive_portal_mode 0

2.修改网络验证的HTTPS URL(推荐):
adb shell settings put global captive_portal_https_url https://connectivitycheck.gstatic.com/generate_204

PS: connectivitycheck.gstatic.com 解析得到的IP在国内,不用哪个啥,android O应该也可以用这两种处理(没测试)

 

以下无效:

请执行以下命令

 

1
2
3
4
5
adb shell “settings put global captive_portal_https_url https://www.google.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://captive.v2ex.co/generate_204”
adb shell “settings put global captive_portal_http_url http://captive.v2ex.co/generate_204”

目前来看,我刚升级到7.1.1的Nexus 5x是解决了这个问题了,不知道下次版本升级又会发生什么…… 以上的操作,如果要恢复出厂原始设置,可以执行以下命令:

 

1
2
3
4
adb shell “settings delete global captive_portal_server”
adb shell “settings delete global captive_portal_https_url”
adb shell “settings delete global captive_portal_http_url”
adb shell “settings put global captive_portal_detection_enabled 1”

P.S:个人极力推荐有各种科学上网需求的童鞋,完全可以买一个Google Project Fi的SIM卡来日常用,天然科学上网,自带米国手机号,无障碍平滑激活Google Now/Location等服务,等有空写写Fi的使用体会。

-EOF-

——————–
引用参考:

  1. 狐狸的小小窝:关于 android 5.0 网络图标上的感叹号及其解决办法
  2. V2EX:关于 V2EX 提供的 Android Captive Portal Server 地址的更新
  3. V2EX:关于 Android 7.0 的 global captive_server_use_https 设置的默认值
  4. V2EX:可否加入 generate_204 ,方便 Android L 消除叹号。
  5. 私家折腾笔记:Android 7.1.1 去除网络叉号