简单记录下,首先找到 Settings 数据库,
路径:frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
可以看到默认是打开的,于是在工程目录下修改为 false ,
PRODUCT_PROPERTY_OVERRIDES += \
ro.com.android.mobiledata=false \
persist.sys.callforwarding = 2
但是开关显示仍然异常,因为这个是基于单卡项目修改的双卡,第二张卡开关显示打开,但状态栏是关闭的,于是认为是默认值有问题。首先想到的是 ConnectivityService ,
发现还是有问题,于是 grep 检索下 Settings.Global.MOBILE_DATA ,将设置为默认值的方法全部修改为通过读取配置的参数,这样就能保持默认值的一致性。
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
index 957dfe6..e3ae6f9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
@@ -2076,7 +2076,7 @@ class QuickSettingsModel implements BluetoothStateChangeCallback,
public void registerReceiver(){
mContext.getContentResolver().registerContentObserver(
Settings.Global.getUriFor(Settings.Global.MOBILE_DATA),
- true, mMobileDataObserver);
+ "true".equalsIgnoreCase(SystemProperties.get("ro.com.android.mobiledata","true")), mMobileDataObserver);
IntentFilter filter = new IntentFilter();
filter.addAction(TelephonyIntents.ACTION_DEFAULT_PHONE_CHANGE);
filter.addAction(Intent.ACTION_DATA_CONNECTION_DETTACH);
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 0071cf2..17468ab 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -1977,7 +1977,7 @@ private OutputStream connectToDrmSocket() {
/* @} */
boolean retVal = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.MOBILE_DATA, 1) == 1;
+ Settings.Global.MOBILE_DATA, "true".equalsIgnoreCase(SystemProperties.get("ro.com.android.mobiledata","true")) ? 1 : 0) == 1;
if (VDBG) log("getMobileDataEnabled returning " + retVal);
return retVal;
}
@@ -5837,7 +5837,7 @@ private OutputStream connectToDrmSocket() {
public boolean getMobileDataEnabledByPhoneId(int phoneId) {
enforceAccessPermission();
boolean retVal = Settings.Global.getIntAtIndex(mContext.getContentResolver(),
- Settings.Global.MOBILE_DATA, phoneId, 1) == 1;
+ Settings.Global.MOBILE_DATA, phoneId, "true".equalsIgnoreCase(SystemProperties.get("ro.com.android.mobiledata","true")) ? 1 : 0) == 1;
if (DBG) Slog.d(TAG, "getMobileDataEnabled[" + phoneId + "] returning " + retVal);
return retVal;
}
diff --git a/services/java/com/android/server/location/GpsLocationProvider.java b/services/java/com/android/server/location/GpsLocationProvider.java
index bec84e8..861490d 100644
--- a/services/java/com/android/server/location/GpsLocationProvider.java
+++ b/services/java/com/android/server/location/GpsLocationProvider.java
++ Settings.Global.MOBILE_DATA, phoneId, 0) == 1;
+ if (DBG) Slog.d(TAG, "getMobileDataEnabled[" + phoneId + "] returning " + retVal);
+ return retVal;
+ }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
index 957dfe6..e3ae6f9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
@@ -2076,7 +2076,7 @@ class QuickSettingsModel implements BluetoothStateChangeCallback,
public void registerReceiver(){
mContext.getContentResolver().registerContentObserver(
Settings.Global.getUriFor(Settings.Global.MOBILE_DATA),
- true, mMobileDataObserver);
+ "true".equalsIgnoreCase(SystemProperties.get("ro.com.android.mobiledata","true")), mMobileDataObserver);
IntentFilter filter = new IntentFilter();
filter.addAction(TelephonyIntents.ACTION_DEFAULT_PHONE_CHANGE);
filter.addAction(Intent.ACTION_DATA_CONNECTION_DETTACH);
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 0071cf2..17468ab 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -1977,7 +1977,7 @@ private OutputStream connectToDrmSocket() {
/* @} */
boolean retVal = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.MOBILE_DATA, 1) == 1;
+ Settings.Global.MOBILE_DATA, "true".equalsIgnoreCase(SystemProperties.get("ro.com.android.mobiledata","true")) ? 1 : 0) == 1;
if (VDBG) log("getMobileDataEnabled returning " + retVal);
return retVal;
}
@@ -5837,7 +5837,7 @@ private OutputStream connectToDrmSocket() {
public boolean getMobileDataEnabledByPhoneId(int phoneId) {
enforceAccessPermission();
boolean retVal = Settings.Global.getIntAtIndex(mContext.getContentResolver(),
- Settings.Global.MOBILE_DATA, phoneId, 1) == 1;
+ Settings.Global.MOBILE_DATA, phoneId, "true".equalsIgnoreCase(SystemProperties.get("ro.com.android.mobiledata","true")) ? 1 : 0) == 1;
if (DBG) Slog.d(TAG, "getMobileDataEnabled[" + phoneId + "] returning " + retVal);
return retVal;
}