Make Settings robotest work with tot Robolectric
Bug: 116278591 Test: make -j RunSettingsRoboTests Change-Id: I32cb2fcf6094675f79d2fc24702ef6298a9691e4
This commit is contained in:
@@ -37,6 +37,7 @@ public class CarrierPreferenceController extends BasePreferenceController {
|
||||
|
||||
public CarrierPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
mCarrierConfigManager = new CarrierConfigManager(context);
|
||||
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
}
|
||||
|
@@ -59,6 +59,7 @@ public class MobileDataPreferenceController extends TogglePreferenceController
|
||||
|
||||
public MobileDataPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
|
||||
mDataContentObserver = new DataContentObserver(new Handler(Looper.getMainLooper()));
|
||||
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
|
@@ -82,7 +82,7 @@ public class MobileNetworkUtils {
|
||||
* Returns true if Wifi calling is enabled for at least one phone.
|
||||
*/
|
||||
public static boolean isWifiCallingEnabled(Context context) {
|
||||
int phoneCount = TelephonyManager.from(context).getPhoneCount();
|
||||
int phoneCount = context.getSystemService(TelephonyManager.class).getPhoneCount();
|
||||
for (int i = 0; i < phoneCount; i++) {
|
||||
if (isWifiCallingEnabled(context, i)) {
|
||||
return true;
|
||||
@@ -218,7 +218,7 @@ public class MobileNetworkUtils {
|
||||
*/
|
||||
public static void setMobileDataEnabled(Context context, int subId, boolean enabled,
|
||||
boolean disableOtherSubscriptions) {
|
||||
final TelephonyManager telephonyManager = TelephonyManager.from(context)
|
||||
final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class)
|
||||
.createForSubscriptionId(subId);
|
||||
final SubscriptionManager subscriptionManager = context.getSystemService(
|
||||
SubscriptionManager.class);
|
||||
@@ -230,7 +230,7 @@ public class MobileNetworkUtils {
|
||||
if (subInfoList != null) {
|
||||
for (SubscriptionInfo subInfo : subInfoList) {
|
||||
if (subInfo.getSubscriptionId() != subId) {
|
||||
TelephonyManager.from(context).createForSubscriptionId(
|
||||
context.getSystemService(TelephonyManager.class).createForSubscriptionId(
|
||||
subInfo.getSubscriptionId()).setDataEnabled(false);
|
||||
}
|
||||
}
|
||||
@@ -245,7 +245,7 @@ public class MobileNetworkUtils {
|
||||
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
|
||||
return false;
|
||||
}
|
||||
final TelephonyManager telephonyManager = TelephonyManager.from(context)
|
||||
final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class)
|
||||
.createForSubscriptionId(subId);
|
||||
final PersistableBundle carrierConfig = context.getSystemService(
|
||||
CarrierConfigManager.class).getConfigForSubId(subId);
|
||||
@@ -307,7 +307,7 @@ public class MobileNetworkUtils {
|
||||
}
|
||||
|
||||
private static boolean isGsmBasicOptions(Context context, int subId) {
|
||||
final TelephonyManager telephonyManager = TelephonyManager.from(context)
|
||||
final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class)
|
||||
.createForSubscriptionId(subId);
|
||||
final PersistableBundle carrierConfig = context.getSystemService(
|
||||
CarrierConfigManager.class).getConfigForSubId(subId);
|
||||
@@ -329,7 +329,7 @@ public class MobileNetworkUtils {
|
||||
* settings
|
||||
*/
|
||||
public static boolean isWorldMode(Context context, int subId) {
|
||||
final TelephonyManager telephonyManager = TelephonyManager.from(context)
|
||||
final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class)
|
||||
.createForSubscriptionId(subId);
|
||||
boolean worldModeOn = false;
|
||||
final String configString = context.getString(R.string.config_world_mode);
|
||||
@@ -392,7 +392,7 @@ public class MobileNetworkUtils {
|
||||
Context con = context.createPackageContext("com.android.systemui", 0);
|
||||
int id = con.getResources().getIdentifier("config_show4GForLTE",
|
||||
"bool", "com.android.systemui");
|
||||
return con.getResources().getBoolean(id);
|
||||
return con.getResources().getBoolean(id);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "NameNotFoundException for show4GFotLTE");
|
||||
return false;
|
||||
@@ -404,7 +404,7 @@ public class MobileNetworkUtils {
|
||||
*/
|
||||
public static boolean isTdscdmaSupported(Context context, int subId) {
|
||||
return isTdscdmaSupported(context,
|
||||
TelephonyManager.from(context).createForSubscriptionId(subId));
|
||||
context.getSystemService(TelephonyManager.class).createForSubscriptionId(subId));
|
||||
}
|
||||
|
||||
//TODO(b/117651939): move it to telephony
|
||||
|
@@ -59,6 +59,7 @@ public class RoamingPreferenceController extends TogglePreferenceController impl
|
||||
|
||||
public RoamingPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
|
||||
mDataContentObserver = new DataContentObserver(new Handler(Looper.getMainLooper()));
|
||||
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
|
@@ -22,6 +22,7 @@ import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
@@ -48,6 +49,7 @@ public abstract class CdmaBasePreferenceController extends BasePreferenceControl
|
||||
|
||||
public CdmaBasePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
mDataContentObserver = new DataContentObserver(new Handler(Looper.getMainLooper()));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user