Loading src/java/com/android/internal/telephony/GsmCdmaPhone.java +1 −1 Original line number Diff line number Diff line Loading @@ -1866,7 +1866,7 @@ public class GsmCdmaPhone extends Phone { @Override public void setDataRoamingEnabled(boolean enable) { mDcTracker.setDataRoamingEnabled(enable); mDcTracker.setDataRoamingEnabledByUser(enable); } @Override Loading src/java/com/android/internal/telephony/Phone.java +3 −0 Original line number Diff line number Diff line Loading @@ -140,6 +140,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { // Key used to read/write "disable data connection on boot" pref (used for testing) public static final String DATA_DISABLED_ON_BOOT_KEY = "disabled_on_boot_key"; // Key used to read/write data_roaming_is_user_setting pref public static final String DATA_ROAMING_IS_USER_SETTING_KEY = "data_roaming_is_user_setting_key"; /* Event Constants */ protected static final int EVENT_RADIO_AVAILABLE = 1; /** Supplementary Service Notification received. */ Loading src/java/com/android/internal/telephony/dataconnection/DcTracker.java +74 −13 Original line number Diff line number Diff line Loading @@ -264,12 +264,8 @@ public class DcTracker extends Handler { + " mIsWifiConnected=" + mIsWifiConnected); } } else if (action.equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) { CarrierConfigManager configMgr = (CarrierConfigManager) mPhone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE); if (configMgr != null) { PersistableBundle cfg = configMgr.getConfigForSubId(mPhone.getSubId()); if (cfg != null) mAllowUserEditTetherApn = cfg.getBoolean(CarrierConfigManager.KEY_EDITABLE_TETHER_APN_BOOL); if (mIccRecords.get() != null && mIccRecords.get().getRecordsLoaded()) { setDefaultDataRoamingEnabled(); } } else { if (DBG) log("onReceive: Unknown action=" + action); Loading Loading @@ -2642,9 +2638,9 @@ public class DcTracker extends Handler { } /** * Modify {@link android.provider.Settings.Global#DATA_ROAMING} value. * Modify {@link android.provider.Settings.Global#DATA_ROAMING} value for user modification only */ public void setDataRoamingEnabled(boolean enabled) { public void setDataRoamingEnabledByUser(boolean enabled) { final int phoneSubId = mPhone.getSubId(); if (getDataRoamingEnabled() != enabled) { int roaming = enabled ? 1 : 0; Loading @@ -2652,6 +2648,7 @@ public class DcTracker extends Handler { // For single SIM phones, this is a per phone property. if (TelephonyManager.getDefault().getSimCount() == 1) { Settings.Global.putInt(mResolver, Settings.Global.DATA_ROAMING, roaming); setDataRoamingFromUserAction(true); } else { Settings.Global.putInt(mResolver, Settings.Global.DATA_ROAMING + phoneSubId, roaming); Loading @@ -2660,12 +2657,12 @@ public class DcTracker extends Handler { mSubscriptionManager.setDataRoaming(roaming, phoneSubId); // will trigger handleDataOnRoamingChange() through observer if (DBG) { log("setDataRoamingEnabled: set phoneSubId=" + phoneSubId log("setDataRoamingEnabledByUser: set phoneSubId=" + phoneSubId + " isRoaming=" + enabled); } } else { if (DBG) { log("setDataRoamingEnabled: unchanged phoneSubId=" + phoneSubId log("setDataRoamingEnabledByUser: unchanged phoneSubId=" + phoneSubId + " isRoaming=" + enabled); } } Loading @@ -2675,21 +2672,21 @@ public class DcTracker extends Handler { * Return current {@link android.provider.Settings.Global#DATA_ROAMING} value. */ public boolean getDataRoamingEnabled() { boolean isDataRoamingEnabled = "true".equalsIgnoreCase(SystemProperties.get( "ro.com.android.dataroaming", "false")); boolean isDataRoamingEnabled; final int phoneSubId = mPhone.getSubId(); try { // For single SIM phones, this is a per phone property. if (TelephonyManager.getDefault().getSimCount() == 1) { isDataRoamingEnabled = Settings.Global.getInt(mResolver, Settings.Global.DATA_ROAMING, isDataRoamingEnabled ? 1 : 0) != 0; Settings.Global.DATA_ROAMING, getDefaultDataRoamingEnabled() ? 1 : 0) != 0; } else { isDataRoamingEnabled = TelephonyManager.getIntWithSubId(mResolver, Settings.Global.DATA_ROAMING, phoneSubId) != 0; } } catch (SettingNotFoundException snfe) { if (DBG) log("getDataRoamingEnabled: SettingNofFoundException snfe=" + snfe); isDataRoamingEnabled = getDefaultDataRoamingEnabled(); } if (VDBG) { log("getDataRoamingEnabled: phoneSubId=" + phoneSubId Loading @@ -2698,6 +2695,70 @@ public class DcTracker extends Handler { return isDataRoamingEnabled; } /** * get default values for {@link Settings.Global#DATA_ROAMING} * return {@code true} if either * {@link CarrierConfigManager#KEY_CARRIER_DEFAULT_DATA_ROAMING_ENABLED_BOOL} or * system property ro.com.android.dataroaming is set to true. otherwise return {@code false} */ private boolean getDefaultDataRoamingEnabled() { final CarrierConfigManager configMgr = (CarrierConfigManager) mPhone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE); boolean isDataRoamingEnabled = "true".equalsIgnoreCase(SystemProperties.get( "ro.com.android.dataroaming", "false")); isDataRoamingEnabled |= configMgr.getConfigForSubId(mPhone.getSubId()).getBoolean( CarrierConfigManager.KEY_CARRIER_DEFAULT_DATA_ROAMING_ENABLED_BOOL); return isDataRoamingEnabled; } /** * Set default value for {@link android.provider.Settings.Global#DATA_ROAMING} * if the setting is not from user actions. default value is based on carrier config and system * properties. */ private void setDefaultDataRoamingEnabled() { // For single SIM phones, this is a per phone property. String setting = Settings.Global.DATA_ROAMING; boolean useCarrierSpecificDefault = false; if (TelephonyManager.getDefault().getSimCount() != 1) { setting = setting + mPhone.getSubId(); try { Settings.Global.getInt(mResolver, setting); } catch (SettingNotFoundException ex) { // For msim, update to carrier default if uninitialized. useCarrierSpecificDefault = true; } } else if (!isDataRoamingFromUserAction()) { // for single sim device, update to carrier default if user action is not set useCarrierSpecificDefault = true; } if (useCarrierSpecificDefault) { boolean defaultVal = getDefaultDataRoamingEnabled(); log("setDefaultDataRoamingEnabled: " + setting + "default value: " + defaultVal); Settings.Global.putInt(mResolver, setting, defaultVal ? 1 : 0); mSubscriptionManager.setDataRoaming(defaultVal ? 1 : 0, mPhone.getSubId()); } } private boolean isDataRoamingFromUserAction() { final SharedPreferences sp = PreferenceManager .getDefaultSharedPreferences(mPhone.getContext()); // since we don't want to unset user preference from system update, pass true as the default // value if shared pref does not exist and set shared pref to false explicitly from factory // reset. if (!sp.contains(Phone.DATA_ROAMING_IS_USER_SETTING_KEY) && Settings.Global.getInt(mResolver, Settings.Global.DEVICE_PROVISIONED, 0) == 0) { sp.edit().putBoolean(Phone.DATA_ROAMING_IS_USER_SETTING_KEY, false).commit(); } return sp.getBoolean(Phone.DATA_ROAMING_IS_USER_SETTING_KEY, true); } private void setDataRoamingFromUserAction(boolean isUserAction) { final SharedPreferences.Editor sp = PreferenceManager .getDefaultSharedPreferences(mPhone.getContext()).edit(); sp.putBoolean(Phone.DATA_ROAMING_IS_USER_SETTING_KEY, isUserAction).commit(); } // When the data roaming status changes from roaming to non-roaming. private void onDataRoamingOff() { if (DBG) log("onDataRoamingOff"); Loading tests/telephonytests/src/com/android/internal/telephony/dataconnection/DcTrackerTest.java +8 −3 Original line number Diff line number Diff line Loading @@ -663,7 +663,7 @@ public class DcTrackerTest extends TelephonyTest { //user is in roaming doReturn(true).when(mServiceState).getDataRoaming(); logd("Sending DISABLE_ROAMING_CMD"); mDct.setDataRoamingEnabled(false); mDct.setDataRoamingEnabledByUser(false); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_ROAMING_ON)); waitForMs(200); Loading @@ -675,7 +675,7 @@ public class DcTrackerTest extends TelephonyTest { assertEquals(DctConstants.State.CONNECTED, mDct.getState(PhoneConstants.APN_TYPE_IMS)); // reset roaming settings / data enabled settings at end of this test mDct.setDataRoamingEnabled(roamingEnabled); mDct.setDataRoamingEnabledByUser(roamingEnabled); mDct.setDataEnabled(dataEnabled); waitForMs(200); } Loading @@ -701,7 +701,7 @@ public class DcTrackerTest extends TelephonyTest { mDct.setDataEnabled(true); logd("Sending DISABLE_ROAMING_CMD"); mDct.setDataRoamingEnabled(false); mDct.setDataRoamingEnabledByUser(false); logd("Sending EVENT_RECORDS_LOADED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_RECORDS_LOADED, null)); Loading @@ -724,6 +724,11 @@ public class DcTrackerTest extends TelephonyTest { assertEquals(DctConstants.State.CONNECTED, mDct.getOverallState()); assertEquals(DctConstants.State.IDLE, mDct.getState(PhoneConstants.APN_TYPE_DEFAULT)); assertEquals(DctConstants.State.CONNECTED, mDct.getState(PhoneConstants.APN_TYPE_IMS)); // reset roaming settings / data enabled settings at end of this test mDct.setDataRoamingEnabledByUser(roamingEnabled); mDct.setDataEnabled(dataEnabled); waitForMs(200); } // Test the default data switch scenario. Loading tests/telephonytests/src/com/android/internal/telephony/mocks/DcTrackerMock.java +1 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ public class DcTrackerMock extends DcTracker { throw new RuntimeException("Not Implemented"); } @Override public void setDataRoamingEnabled(boolean enabled) { public void setDataRoamingEnabledByUser(boolean enabled) { throw new RuntimeException("Not Implemented"); } @Override Loading Loading
src/java/com/android/internal/telephony/GsmCdmaPhone.java +1 −1 Original line number Diff line number Diff line Loading @@ -1866,7 +1866,7 @@ public class GsmCdmaPhone extends Phone { @Override public void setDataRoamingEnabled(boolean enable) { mDcTracker.setDataRoamingEnabled(enable); mDcTracker.setDataRoamingEnabledByUser(enable); } @Override Loading
src/java/com/android/internal/telephony/Phone.java +3 −0 Original line number Diff line number Diff line Loading @@ -140,6 +140,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface { // Key used to read/write "disable data connection on boot" pref (used for testing) public static final String DATA_DISABLED_ON_BOOT_KEY = "disabled_on_boot_key"; // Key used to read/write data_roaming_is_user_setting pref public static final String DATA_ROAMING_IS_USER_SETTING_KEY = "data_roaming_is_user_setting_key"; /* Event Constants */ protected static final int EVENT_RADIO_AVAILABLE = 1; /** Supplementary Service Notification received. */ Loading
src/java/com/android/internal/telephony/dataconnection/DcTracker.java +74 −13 Original line number Diff line number Diff line Loading @@ -264,12 +264,8 @@ public class DcTracker extends Handler { + " mIsWifiConnected=" + mIsWifiConnected); } } else if (action.equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) { CarrierConfigManager configMgr = (CarrierConfigManager) mPhone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE); if (configMgr != null) { PersistableBundle cfg = configMgr.getConfigForSubId(mPhone.getSubId()); if (cfg != null) mAllowUserEditTetherApn = cfg.getBoolean(CarrierConfigManager.KEY_EDITABLE_TETHER_APN_BOOL); if (mIccRecords.get() != null && mIccRecords.get().getRecordsLoaded()) { setDefaultDataRoamingEnabled(); } } else { if (DBG) log("onReceive: Unknown action=" + action); Loading Loading @@ -2642,9 +2638,9 @@ public class DcTracker extends Handler { } /** * Modify {@link android.provider.Settings.Global#DATA_ROAMING} value. * Modify {@link android.provider.Settings.Global#DATA_ROAMING} value for user modification only */ public void setDataRoamingEnabled(boolean enabled) { public void setDataRoamingEnabledByUser(boolean enabled) { final int phoneSubId = mPhone.getSubId(); if (getDataRoamingEnabled() != enabled) { int roaming = enabled ? 1 : 0; Loading @@ -2652,6 +2648,7 @@ public class DcTracker extends Handler { // For single SIM phones, this is a per phone property. if (TelephonyManager.getDefault().getSimCount() == 1) { Settings.Global.putInt(mResolver, Settings.Global.DATA_ROAMING, roaming); setDataRoamingFromUserAction(true); } else { Settings.Global.putInt(mResolver, Settings.Global.DATA_ROAMING + phoneSubId, roaming); Loading @@ -2660,12 +2657,12 @@ public class DcTracker extends Handler { mSubscriptionManager.setDataRoaming(roaming, phoneSubId); // will trigger handleDataOnRoamingChange() through observer if (DBG) { log("setDataRoamingEnabled: set phoneSubId=" + phoneSubId log("setDataRoamingEnabledByUser: set phoneSubId=" + phoneSubId + " isRoaming=" + enabled); } } else { if (DBG) { log("setDataRoamingEnabled: unchanged phoneSubId=" + phoneSubId log("setDataRoamingEnabledByUser: unchanged phoneSubId=" + phoneSubId + " isRoaming=" + enabled); } } Loading @@ -2675,21 +2672,21 @@ public class DcTracker extends Handler { * Return current {@link android.provider.Settings.Global#DATA_ROAMING} value. */ public boolean getDataRoamingEnabled() { boolean isDataRoamingEnabled = "true".equalsIgnoreCase(SystemProperties.get( "ro.com.android.dataroaming", "false")); boolean isDataRoamingEnabled; final int phoneSubId = mPhone.getSubId(); try { // For single SIM phones, this is a per phone property. if (TelephonyManager.getDefault().getSimCount() == 1) { isDataRoamingEnabled = Settings.Global.getInt(mResolver, Settings.Global.DATA_ROAMING, isDataRoamingEnabled ? 1 : 0) != 0; Settings.Global.DATA_ROAMING, getDefaultDataRoamingEnabled() ? 1 : 0) != 0; } else { isDataRoamingEnabled = TelephonyManager.getIntWithSubId(mResolver, Settings.Global.DATA_ROAMING, phoneSubId) != 0; } } catch (SettingNotFoundException snfe) { if (DBG) log("getDataRoamingEnabled: SettingNofFoundException snfe=" + snfe); isDataRoamingEnabled = getDefaultDataRoamingEnabled(); } if (VDBG) { log("getDataRoamingEnabled: phoneSubId=" + phoneSubId Loading @@ -2698,6 +2695,70 @@ public class DcTracker extends Handler { return isDataRoamingEnabled; } /** * get default values for {@link Settings.Global#DATA_ROAMING} * return {@code true} if either * {@link CarrierConfigManager#KEY_CARRIER_DEFAULT_DATA_ROAMING_ENABLED_BOOL} or * system property ro.com.android.dataroaming is set to true. otherwise return {@code false} */ private boolean getDefaultDataRoamingEnabled() { final CarrierConfigManager configMgr = (CarrierConfigManager) mPhone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE); boolean isDataRoamingEnabled = "true".equalsIgnoreCase(SystemProperties.get( "ro.com.android.dataroaming", "false")); isDataRoamingEnabled |= configMgr.getConfigForSubId(mPhone.getSubId()).getBoolean( CarrierConfigManager.KEY_CARRIER_DEFAULT_DATA_ROAMING_ENABLED_BOOL); return isDataRoamingEnabled; } /** * Set default value for {@link android.provider.Settings.Global#DATA_ROAMING} * if the setting is not from user actions. default value is based on carrier config and system * properties. */ private void setDefaultDataRoamingEnabled() { // For single SIM phones, this is a per phone property. String setting = Settings.Global.DATA_ROAMING; boolean useCarrierSpecificDefault = false; if (TelephonyManager.getDefault().getSimCount() != 1) { setting = setting + mPhone.getSubId(); try { Settings.Global.getInt(mResolver, setting); } catch (SettingNotFoundException ex) { // For msim, update to carrier default if uninitialized. useCarrierSpecificDefault = true; } } else if (!isDataRoamingFromUserAction()) { // for single sim device, update to carrier default if user action is not set useCarrierSpecificDefault = true; } if (useCarrierSpecificDefault) { boolean defaultVal = getDefaultDataRoamingEnabled(); log("setDefaultDataRoamingEnabled: " + setting + "default value: " + defaultVal); Settings.Global.putInt(mResolver, setting, defaultVal ? 1 : 0); mSubscriptionManager.setDataRoaming(defaultVal ? 1 : 0, mPhone.getSubId()); } } private boolean isDataRoamingFromUserAction() { final SharedPreferences sp = PreferenceManager .getDefaultSharedPreferences(mPhone.getContext()); // since we don't want to unset user preference from system update, pass true as the default // value if shared pref does not exist and set shared pref to false explicitly from factory // reset. if (!sp.contains(Phone.DATA_ROAMING_IS_USER_SETTING_KEY) && Settings.Global.getInt(mResolver, Settings.Global.DEVICE_PROVISIONED, 0) == 0) { sp.edit().putBoolean(Phone.DATA_ROAMING_IS_USER_SETTING_KEY, false).commit(); } return sp.getBoolean(Phone.DATA_ROAMING_IS_USER_SETTING_KEY, true); } private void setDataRoamingFromUserAction(boolean isUserAction) { final SharedPreferences.Editor sp = PreferenceManager .getDefaultSharedPreferences(mPhone.getContext()).edit(); sp.putBoolean(Phone.DATA_ROAMING_IS_USER_SETTING_KEY, isUserAction).commit(); } // When the data roaming status changes from roaming to non-roaming. private void onDataRoamingOff() { if (DBG) log("onDataRoamingOff"); Loading
tests/telephonytests/src/com/android/internal/telephony/dataconnection/DcTrackerTest.java +8 −3 Original line number Diff line number Diff line Loading @@ -663,7 +663,7 @@ public class DcTrackerTest extends TelephonyTest { //user is in roaming doReturn(true).when(mServiceState).getDataRoaming(); logd("Sending DISABLE_ROAMING_CMD"); mDct.setDataRoamingEnabled(false); mDct.setDataRoamingEnabledByUser(false); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_ROAMING_ON)); waitForMs(200); Loading @@ -675,7 +675,7 @@ public class DcTrackerTest extends TelephonyTest { assertEquals(DctConstants.State.CONNECTED, mDct.getState(PhoneConstants.APN_TYPE_IMS)); // reset roaming settings / data enabled settings at end of this test mDct.setDataRoamingEnabled(roamingEnabled); mDct.setDataRoamingEnabledByUser(roamingEnabled); mDct.setDataEnabled(dataEnabled); waitForMs(200); } Loading @@ -701,7 +701,7 @@ public class DcTrackerTest extends TelephonyTest { mDct.setDataEnabled(true); logd("Sending DISABLE_ROAMING_CMD"); mDct.setDataRoamingEnabled(false); mDct.setDataRoamingEnabledByUser(false); logd("Sending EVENT_RECORDS_LOADED"); mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_RECORDS_LOADED, null)); Loading @@ -724,6 +724,11 @@ public class DcTrackerTest extends TelephonyTest { assertEquals(DctConstants.State.CONNECTED, mDct.getOverallState()); assertEquals(DctConstants.State.IDLE, mDct.getState(PhoneConstants.APN_TYPE_DEFAULT)); assertEquals(DctConstants.State.CONNECTED, mDct.getState(PhoneConstants.APN_TYPE_IMS)); // reset roaming settings / data enabled settings at end of this test mDct.setDataRoamingEnabledByUser(roamingEnabled); mDct.setDataEnabled(dataEnabled); waitForMs(200); } // Test the default data switch scenario. Loading
tests/telephonytests/src/com/android/internal/telephony/mocks/DcTrackerMock.java +1 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ public class DcTrackerMock extends DcTracker { throw new RuntimeException("Not Implemented"); } @Override public void setDataRoamingEnabled(boolean enabled) { public void setDataRoamingEnabledByUser(boolean enabled) { throw new RuntimeException("Not Implemented"); } @Override Loading