由于android系统开机向导界面比较特殊,会通过Settings.Global.DEVICE_PROVISIONED 属性来控制,刷完机第一次启启动此值会默认为0 ,开机向导结束后会设置为1,系统很多地方会根据此值来控制
opt/telephony/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
opt/telephony/src/java/com/android/internal/telephony/dataconnection/DataEnabledSettings.java
DataEnabledSettings.java 中:
public boolean isProvisioning() {
return Settings.Global.getInt(mResolver, Settings.Global.DEVICE_PROVISIONED, 0) == 0;
}
/**
* In provisioning, we might want to have enable mobile data during provisioning. It depends
* on value of Settings.Global.DEVICE_PROVISIONING_MOBILE_DATA_ENABLED which is set by
* setupwizard. It only matters if it's in provisioning stage.
* @return whether we are enabling userData during provisioning stage.
*/
public boolean isProvisioningDataEnabled() {
final String prov_property = SystemProperties.get("ro.com.android.prov_mobiledata",
"false");
boolean retVal = "true".equalsIgnoreCase(prov_property);
final int prov_mobile_data = Settings.Global.getInt(mResolver,
Settings.Global.DEVICE_PROVISIONING_MOBILE_DATA_ENABLED,
retVal ? 1 : 0);
retVal = prov_mobile_data != 0;
log("getDataEnabled during provisioning retVal=" + retVal + " - (" + prov_property
+ ", " + prov_mobile_data + ")");
return retVal;
}
所以问题就比较简单了系统给开了个后门:直接在开机向导里第一个页面初始化Settings.Global.DEVICE_PROVISIONING_MOBILE_DATA_ENABLED 值为 1
如:
/**
* 开机向导能界面能开启数据
*/
private void startData() {
Settings.Global.putInt(getContentResolver(), "device_provisioning_mobile_data", 1);
}
快速验证通过adb 命令:adb shell settings put global device_provisioning_mobile_data 1 直接设置到数据库中!!!