[Settings] Data roaming warning only when turn ON
handlePreferenceTreeClick() goes after setChecked() however configuration may have been altered within setChecked(). Follow same design within MobileDataPreferenceController to fix this issue. A boolean state will be maintained as the condition when warning dialog is required when click. Bug: 148491064 Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=RoamingPreferenceControllerTest Change-Id: I63c4e2149b0e9efa16fd9ee402652c67eb9c5a4d
This commit is contained in:
@@ -22,7 +22,6 @@ import android.provider.Settings;
|
|||||||
import android.telephony.CarrierConfigManager;
|
import android.telephony.CarrierConfigManager;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -110,21 +109,11 @@ public class RoamingPreferenceController extends TelephonyTogglePreferenceContro
|
|||||||
: AVAILABLE_UNSEARCHABLE;
|
: AVAILABLE_UNSEARCHABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
|
||||||
if (TextUtils.equals(preference.getKey(), getPreferenceKey())) {
|
|
||||||
if (isDialogNeeded()) {
|
|
||||||
showDialog();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setChecked(boolean isChecked) {
|
public boolean setChecked(boolean isChecked) {
|
||||||
if (!isDialogNeeded()) {
|
if (isDialogNeeded()) {
|
||||||
|
showDialog();
|
||||||
|
} else {
|
||||||
// Update data directly if we don't need dialog
|
// Update data directly if we don't need dialog
|
||||||
mTelephonyManager.setDataRoamingEnabled(isChecked);
|
mTelephonyManager.setDataRoamingEnabled(isChecked);
|
||||||
return true;
|
return true;
|
||||||
|
@@ -117,10 +117,10 @@ public class RoamingPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void handlePreferenceTreeClick_needDialog_showDialog() {
|
public void setChecked_needDialog_showDialog() {
|
||||||
doReturn(true).when(mController).isDialogNeeded();
|
doReturn(true).when(mController).isDialogNeeded();
|
||||||
|
|
||||||
mController.handlePreferenceTreeClick(mPreference);
|
mController.setChecked(true);
|
||||||
|
|
||||||
verify(mFragmentManager).beginTransaction();
|
verify(mFragmentManager).beginTransaction();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user