Android EDLA项目 5G热点打开失败分析

1 篇文章 0 订阅
1 篇文章 0 订阅

Android EDLA项目 5G热点打开失败分析

一、前言

Android 13 外销国外的产品都要过EDLA认证了!
EDLA认证的项目基本都是默认集成GMS Google mainline 和开启KPI;
所以系统会自带了谷歌的很多apk和apex等数据,会造成系统某些代码修改没有作用。

谷歌自动集成的部分的apk目录:

vendor\partner_modules\XXXPrebuilt

部分mainline apk 和Java代码 的关系:

//Google apk
vendor\partner_modules\TetheringPrebuilt\com.google.android.tethering.apks

//Java 代码--Connectivity
package\modules\Connectivity

//Google apk
vendor\partner_modules\WiFiPrebuilt\com.google.android.wifi.apks

//Java 代码-- Wifi
package\modules\Wifi

虽然部分模块的代码无法修改,但是还是要进行分析验证,
谷歌集成的代码和原生代码是差不多的,主要差别就是res的默认属性可能有差别,
所以系统代码逻辑还有要看的,这样才能更准确的定位问题。

本文介绍一下 EDLA 项目5G热点打开失败的一种情况进行分析,对EDLA项目其他一些系统默认配置修改有参考价值,有兴趣的可以看看。

二、EDLA 打开5G热点的分析和实现

1、现象

(1) 已原生Settings设置打开5G热点(关闭拓展性开关)

通过其他手机扫描,连接测试,发现热点是2.4G 热点!

(2)设置band=2,channel=36 的5G热点信息打开热点,无法打开5G热点

查看关键错误如下:

ApConfigUtil : Can not start softAp with band 5G not supported.

2、代码分析

packages\modules\Wifi\service\java\com\android\server\wifi\util\ApConfigUtil.java

    public static boolean isBandSupported(@BandType int apBand, Context context) {
        if (!isBandValid(apBand)) {
            Log.e(TAG, "Invalid SoftAp band " + apBand);
            return false;
        }

        for (int b : SoftApConfiguration.BAND_TYPES) { //BAND_TYPES: 6G,5G,2.4G
            if (containsBand(apBand, b) && !isSoftApBandSupported(context, b)) {
                Log.e(TAG, "Can not start softAp with band " + bandToString(b)
                        + " not supported.");
                return false;
            }
        }

        return true;
    }
    
    
    //containsBand 方法,band = 2,是true 的,
    public static boolean containsBand(@BandType int band, @BandType int testBand) {
        return ((band & testBand) != 0);
    }

    //所以关键是 isSoftApBandSupported,如果为false 就是有问题
    public static boolean isSoftApBandSupported(@NonNull Context context, @BandType int band) {
        switch (band) {
            case SoftApConfiguration.BAND_2GHZ:
                return context.getResources().getBoolean(R.bool.config_wifi24ghzSupport)
                        && context.getResources().getBoolean(
                        R.bool.config_wifiSoftap24ghzSupported);
            case SoftApConfiguration.BAND_5GHZ://5G热点的判断
                return context.getResources().getBoolean(R.bool.config_wifi5ghzSupport)
                        && context.getResources().getBoolean(
                        R.bool.config_wifiSoftap5ghzSupported);
            case SoftApConfiguration.BAND_6GHZ:
                return context.getResources().getBoolean(R.bool.config_wifi6ghzSupport)
                        && context.getResources().getBoolean(
                        R.bool.config_wifiSoftap6ghzSupported);
            default:
                return false;
        }
    }

所以上面系统是否支持5G 是要判断下面两个res属性:

getResources().getBoolean(R.bool.config_wifi5ghzSupport)
getResources().getBoolean(R.bool.config_wifiSoftap5ghzSupported);

其中一个为false都会导致无法打开5G热点。

如果没有overlay的情况,这个res 属性的位置在:

package\modules\Wifi\service\ServiceWifiResources\res\values\config.xml

<bool translatable="false" name ="config_wifi24ghzSupport">true</bool>

//5G wifi,源码这里默认false
<bool translatable="false" name ="config_wifi5ghzSupport">false</bool>

    <!-- Wifi driver supports 5GHz band for softap when chip support 5GHz -->
//5G 热点
<bool translatable="false" name="config_wifiSoftap5ghzSupported">true</bool>

但是实际上很多项目都是在device或者vendor 目录下有overlay属性的情况。

可以命令搜查确认一下:

find . -name "*.xml" | xargs grep "config_wifi5ghzSupport"
find . -name "*.xml" | xargs grep "config_wifiSoftap5ghzSupported"

到这里,你以为就完了吗,其实正文还没开始!

如果是普通项目,查找所有可能的overlay 修改一下就OK了;
但是EDLA 项目不同,你要overlay的应用是 Google的应用,并不是源码的应用。

3、EDLA 中Google apk 的overlay

如果是EDLA 项目,应该是有应用被overlay的示例代码的。可以借鉴参考。

如果你不确定是 Google 的哪个apk 对应哪个模块代码,可以直接grep -nr “关键代码” 这样也能找出对应的apk。

比如 wifi modules下的代码关键字和查找命令:

grep -nr "Can not start softAp"

这里仅供参考,如果有比较多的重复的,可以使用其他关键代码。

查找结果:

release/vendor/partner_modules$ grep -nr "Can not start softAp"
匹配到二进制文件 WiFiPrebuilt/com.google.android.wifi.apks
匹配到二进制文件 WiFiPrebuilt/go/com.google.android.go.wifi.apks
release/vendor/partner_modules$ 

所以 package\modules\Wifi 的源码就是对应的 com.google.android.wifi.apks

release\vendor\mediatek\tv\packages\overlay\WifiRROOverlay\AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.wifi.resources.rro" //这个包名是无所谓的
    android:versionCode="1"
    android:versionName="1.0">
    <application android:hasCode="false" />
     //targetPackage包名是关键
    <overlay
      android:targetPackage="com.android.wifi.resources"
      android:targetName="WifiCustomization"
      android:isStatic="true"
      android:priority="0"/>
</manifest>

上面代码如果 targetPackage 如果不是google 的apk,那样也只替换了原生的而已,
如果要替换Google apk的资源,就要修改一下:

android:targetPackage="com.google.android.wifi.resources"

找到res里面的config 看看 5G属性是否支持,如果没有支持就设置支持:

release\vendor\mediatek\tv\packages\overlay\WifiRROOverlay\res\values\config.xml


    <!-- Boolean indicating whether the wifi chipset has 5GHz frequency band support -->
    <bool translatable="false" name="config_wifi5ghzSupport">true</bool>

上面是Android14 上 mtk EDLA 的源码目录,仅供参考。

如果你的方案没有 WifiRROOverlay 文件夹就要自己创建,进行overlay属性覆盖。

其实res voerlay 的代码,就三个文件

1、Android.bp 普通加载apk,只编译res就行
2、AndroidManifest.xml 写明需要覆盖的具体apk包名
3、config.xml 需要覆盖的属性

其中,第一点和第三点都不简单易懂的,
只有第二点要确定overlay 的apk包名,需要研究一下。

比如要覆盖的是:wifi 模块
但是实际要写 com.android.wifi.resources

要覆盖的是:热点和Connectivity模块
但是实际要写 com.android.networkstack.tethering

从目录看大概种类就十个,常用的估计就三五个。这里不继续进行分析了。

三、其他

本文分析的主要是针对 EDLA 项目,并且内核驱动正常加载的情况,
如果底层驱动不支持5G,那又是另外的情况了,
这种情况,看wifi关键字,是可以看出大致异常信息的,这里不展开分析。

1、EDLA项目因为配置属性导致 5G 热点开启失败分析解决思路

(1)查看日志确定问题

查看是否存在ApConfigUtil文件打印的如下日志:

Can not start softAp with band 5G not supported

如果不是这种情况,那么另外分析。

(2)查看是否有overlay属性

一种思路是查看是否有overlay wifi apk 的情况,

//查看overlay 原生wifi应用
find . -name "AndroidManifest.xml" | xargs grep "com.android.wifi.resources"

//查看overlay 谷歌wifi应用
find . -name "AndroidManifest.xml" | xargs grep "com.google.android.wifi.resources"

如果只是overlay了原生wifi应用,那么谷歌应用是未覆盖的。
要么要需要覆盖的应用修改为谷歌应用,要么重新创建一个应用,覆盖google应用的属性。

还有种思路是查看是否有 overlay wifi res属性的情况。

find . -name "*.xml" | xargs grep "config_wifi5ghzSupport"
find . -name "*.xml" | xargs grep "config_wifiSoftap5ghzSupported"

看看是哪个应该有overlay属性。并查看相关信息,进行适配修改。

2、Android13 热点默认5G频道配置修改

https://blog.csdn.net/wenzhi20102321/article/details/140531300

3、Android13 设置固定热点ip地址192.168.43.1

https://blog.csdn.net/wenzhi20102321/article/details/136290974

4、Android11 热点开启流程

https://blog.csdn.net/wenzhi20102321/article/details/128473734

  • 29
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

峥嵘life

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值