六、AOSP-wifi无法连接互联网提示+同步时间

一、wifi无法连接互联网提示

这个是AOSP源码的通病,实际是可以联网的

1、源码路径

frameworks/base/services/core/java/com/android/server/connectivity/NetworkMonitor.java

2、源码

    mIsCaptivePortalCheckEnabled = Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.CAPTIVE_PORTAL_MODE, Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT)
                != Settings.Global.CAPTIVE_PORTAL_MODE_IGNORE;

3、修改

	//zjp update
	mIsCaptivePortalCheckEnabled = false;
        /*mIsCaptivePortalCheckEnabled = Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.CAPTIVE_PORTAL_MODE, Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT)
                != Settings.Global.CAPTIVE_PORTAL_MODE_IGNORE;*/

二、wifi同步时间

1、源码路径

/frameworks/base/core/java/android/util/NtpTrustedTime.java

2、源码

    @Override
    public boolean forceRefresh() {
        if (TextUtils.isEmpty(mServer)) {
            // missing server, so no trusted time available
            return false;
        }

        // We can't do this at initialization time: ConnectivityService might not be running yet.
        synchronized (this) {
            if (mCM == null) {
                mCM = (ConnectivityManager) sContext.getSystemService(Context.CONNECTIVITY_SERVICE);
            }
        }

        final NetworkInfo ni = mCM == null ? null : mCM.getActiveNetworkInfo();
        if (ni == null || !ni.isConnected()) {
            if (LOGD) Log.d(TAG, "forceRefresh: no connectivity");
            return false;
        }


        if (LOGD) Log.d(TAG, "forceRefresh() from cache miss");
        final SntpClient client = new SntpClient();
        if (client.requestTime(mServer, (int) mTimeout)) {
            mHasCache = true;
            mCachedNtpTime = client.getNtpTime();
            mCachedNtpElapsedRealtime = client.getNtpTimeReference();
            mCachedNtpCertainty = client.getRoundTripTime() / 2;
            return true;
        } else {
            return false;
        }
    }

3、修改

主要就是添加一个同步的服务器 -> “ntp1.aliyun.com”
再添加一个else if判断来同步时间

    @Override
    public boolean forceRefresh() {
        if (TextUtils.isEmpty(mServer)) {
            // missing server, so no trusted time available
            return false;
        }

        // We can't do this at initialization time: ConnectivityService might not be running yet.
        synchronized (this) {
            if (mCM == null) {
                mCM = (ConnectivityManager) sContext.getSystemService(Context.CONNECTIVITY_SERVICE);
            }
        }

        final NetworkInfo ni = mCM == null ? null : mCM.getActiveNetworkInfo();
        if (ni == null || !ni.isConnected()) {
            if (LOGD) Log.d(TAG, "forceRefresh: no connectivity");
            return false;
        }


        if (LOGD) Log.d(TAG, "forceRefresh() from cache miss");
        final SntpClient client = new SntpClient();
        //zjp update
        final String backServer = "ntp1.aliyun.com";
        if (client.requestTime(mServer, (int) mTimeout)) {
            mHasCache = true;
            mCachedNtpTime = client.getNtpTime();
            mCachedNtpElapsedRealtime = client.getNtpTimeReference();
            mCachedNtpCertainty = client.getRoundTripTime() / 2;
            return true;
        }else if(client.requestTime(backServer, (int) mTimeout)){
            Log.d("Andrew", "request backServer success...");
            mHasCache = true;
            mCachedNtpTime = client.getNtpTime();
            mCachedNtpElapsedRealtime = client.getNtpTimeReference();
            mCachedNtpCertainty = client.getRoundTripTime() / 2;
            return true;
        } else {
            return false;
        }
    }
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在AOSP中使用i2c-gpio的步骤与在Linux中使用的步骤类似,只是在AOSP中需要将i2c-gpio驱动程序编译进Android系统中。 以下是在AOSP中使用i2c-gpio的基本步骤: 1. 确认设备树中使用i2c-gpio。在设备树中需要指定SDA和SCL引脚的GPIO编号,并将i2c-gpio驱动程序与设备绑定。例如,下面是在设备树中使用i2c-gpio的示例: ``` i2c-gpio { #address-cells = <1>; #size-cells = <0>; compatible = "i2c-gpio"; gpios = <&gpio0 1 GPIO_ACTIVE_LOW>, <&gpio0 2 GPIO_ACTIVE_LOW>; i2c-gpio,delay-us = <2>; i2c-gpio,sda-inverted; i2c-gpio,scl-inverted; i2c-gpio,sda-open-drain; i2c-gpio,scl-open-drain; status = "okay"; }; ``` 2. 在Android的kernel配置中需要启用i2c-gpio模块。可以使用以下命令进行配置: ``` $ make menuconfig ``` 然后找到Device Drivers -> I2C support -> I2C GPIO expanders和Device Drivers -> GPIO Support -> GPIO bit-banging interfaces,选择i2c-gpio模块并将其编译进内核或编译为模块。 3. 编译Android系统。可以使用以下命令进行编译: ``` $ make ``` 4. 在Android中使用i2c-gpio。可以像在Linux中一样,使用modprobe命令加载i2c-gpio模块,并配置GPIO引脚。例如,使用以下命令加载模块: ``` $ modprobe i2c-gpio ``` 然后,使用类似以下的命令将SDA和SCL引脚的GPIO编号配置为相应的值: ``` $ echo "gpio_sda=<SDA_GPIO_NUM>" > /sys/module/i2c_gpio/parameters/options $ echo "gpio_scl=<SCL_GPIO_NUM>" > /sys/module/i2c_gpio/parameters/options ``` 5. 现在可以在Android系统中使用i2c-gpio进行I2C通信。可以使用i2c-tools等工具进行测试。 以上是在AOSP中使用i2c-gpio的基本步骤。注意要根据具体的硬件环境和需求进行相应的配置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

无休止符

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

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

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

打赏作者

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

抵扣说明:

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

余额充值