一、概述:最近Android P 平台遇到一个打开车机热点,手机连接后不能上网的 问题,下面是正常的log和异常的log
热点正常能上网的log:
热点异常不能上网的log:
通过log发现Tethering: Found upstream interface(s): null 所以出现不能上网的情况,这里也分析一下打开热点,连接上网的过程。
参考博客:
https://blog.youkuaiyun.com/weixin_42093428/article/details/84062557
二、打开热点的流程
调用ConnectivityManager 的 startTethering方法
public void startTethering(int type, boolean showProvisioningUi,
final OnStartTetheringCallback callback, Handler handler) {
Preconditions.checkNotNull(callback, “OnStartTetheringCallback cannot be null.”);
ResultReceiver wrappedCallback = new ResultReceiver(handler) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
if (resultCode == TETHER_ERROR_NO_ERROR) {
callback.onTetheringStarted();
} else {
callback.onTetheringFailed();