Android 8.1 预置WIFI

本文介绍了如何在Android8.1设备上预置WIFI网络,包括创建和编辑WifiConfigStore.xml文件,以及涉及的相关系统设置和代码片段,确保首次启动时WIFI配置被自动加载。
摘要由CSDN通过智能技术生成

Android 8.1 预置WIFI

最近收到客户需求,想要预置指定WIFI,预置WIFI账号密码以uID、uPassword为例说明,具体修改参照如下:

创建WIFI配置文件 WifiConfigStore.xml:

/prebuilts/data/misc/WifiConfigStore.xml

<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<WifiConfigStoreData>
<int name="Version" value="1" />
<NetworkList>
<Network>
<WifiConfiguration>
<string name="ConfigKey">&quot;uID&quot;WPA_PSK</string>
<string name="SSID">&quot;uID&quot;</string>
<null name="BSSID" />
<string name="PreSharedKey">&quot;uPassword&quot;</string>
<null name="WEPKeys" />
<int name="WEPTxKeyIndex" value="0" />
<boolean name="HiddenSSID" value="false" />
<boolean name="RequirePMF" value="false" />
<byte-array name="AllowedKeyMgmt" num="1">02</byte-array>
<byte-array name="AllowedProtocols" num="1">03</byte-array>
<byte-array name="AllowedAuthAlgos" num="1">01</byte-array>
<byte-array name="AllowedGroupCiphers" num="1">0f</byte-array>
<byte-array name="AllowedPairwiseCiphers" num="1">06</byte-array>
<boolean name="Shared" value="true" />
<null name="SimSlot" />
<null name="Aliases" />
<int name="Priority" value="0" />
<int name="Status" value="2" />
<null name="FQDN" />
<null name="ProviderFriendlyName" />
<null name="LinkedNetworksList" />
<null name="DefaultGwMacAddress" />
<boolean name="ValidatedInternetAccess" value="false" />
<boolean name="NoInternetAccessExpected" value="false" />
<int name="UserApproved" value="0" />
<boolean name="MeteredHint" value="false" />
<int name="MeteredOverride" value="0" />
<boolean name="UseExternalScores" value="false" />
<int name="NumAssociation" value="0" />
<int name="CreatorUid" value="1000" />
<string name="CreatorName">android.uid.system:1000</string>
<string name="CreationTime">time=12-27 13:42:19.561</string>
<int name="LastUpdateUid" value="1000" />
<string name="LastUpdateName">android.uid.system:1000</string>
<int name="LastConnectUid" value="0" />
<boolean name="IsLegacyPasspointConfig" value="false" />
<long-array name="RoamingConsortiumOIs" num="0" />
</WifiConfiguration>
<NetworkStatus>
<string name="SelectionStatus">NETWORK_SELECTION_ENABLED</string>
<string name="DisableReason">NETWORK_SELECTION_ENABLE</string>
<null name="ConnectChoice" />
<long name="ConnectChoiceTimeStamp" value="-1" />
<boolean name="HasEverConnected" value="false" />
</NetworkStatus>
<IpConfiguration>
<string name="IpAssignment">DHCP</string>
<string name="ProxySettings">NONE</string>
</IpConfiguration>
</Network>
</NetworkList>
<PasspointConfigData>
<long name="ProviderIndex" value="0" />
</PasspointConfigData>
</WifiConfigStoreData>

/device/droi/pj/device.mk:
 

+PRODUCT_COPY_FILES += upjpath/prebuilts/data/misc/WifiConfigStore.xml:system/etc/WifiConfigStore.xml

/system/core/rootdir/init.rc:

+on property:persist.sys.pj.firstboot=1
+    copy /system/etc/WifiConfigStore.xml /data/misc/wifi/WifiConfigStore.xml
+    chown system system /data/misc/wifi/WifiConfigStore.xml
+    chmod 0600 /data/misc/wifi/WifiConfigStore.xml

/frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java

    public void systemReady() {
        enforceSystemOrRoot("Only the system can claim the system is ready");

+        String ufirstboot = SystemProperties.get("persist.sys.pj.firstboot","0");
+        if ("0".equals(ufirstboot)) {
+            SystemProperties.set("persist.sys.pj.firstboot","1");
+            SystemProperties.set("persist.sys.pj.firstboot","2");
+        }

重新编译验证,修改生效,已成功预置WIFI

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Jeffries_C

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

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

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

打赏作者

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

抵扣说明:

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

余额充值