use of android.telephony.TelephonyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SettingsDumpService method dumpDataUsage.
private JSONObject dumpDataUsage() throws JSONException {
JSONObject obj = new JSONObject();
DataUsageController controller = new DataUsageController(this);
ConnectivityManager connectivityManager = getSystemService(ConnectivityManager.class);
SubscriptionManager manager = SubscriptionManager.from(this);
TelephonyManager telephonyManager = TelephonyManager.from(this);
if (connectivityManager.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)) {
JSONArray array = new JSONArray();
for (SubscriptionInfo info : manager.getAllSubscriptionInfoList()) {
NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll(telephonyManager.getSubscriberId(info.getSubscriptionId()));
final JSONObject usage = dumpDataUsage(mobileAll, controller);
usage.put("subId", info.getSubscriptionId());
array.put(usage);
}
obj.put("cell", array);
}
if (connectivityManager.isNetworkSupported(ConnectivityManager.TYPE_WIFI)) {
obj.put("wifi", dumpDataUsage(NetworkTemplate.buildTemplateWifiWildcard(), controller));
}
if (connectivityManager.isNetworkSupported(ConnectivityManager.TYPE_ETHERNET)) {
obj.put("ethernet", dumpDataUsage(NetworkTemplate.buildTemplateEthernet(), controller));
}
return obj;
}
use of android.telephony.TelephonyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class TelephonyUtils method isWorldMode.
private static boolean isWorldMode(Context context) {
boolean worldModeOn = false;
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Resources phoneResources = getPhoneResources(context);
if (phoneResources != null) {
int id = phoneResources.getIdentifier("config_world_mode", "string", "com.android.phone");
if (id > 0) {
final String configString = phoneResources.getString(id);
if (!TextUtils.isEmpty(configString)) {
String[] configArray = configString.split(";");
// and SIM GID value is also set and matches to the current SIM GID.
if (configArray != null && ((configArray.length == 1 && configArray[0].equalsIgnoreCase("true")) || (configArray.length == 2 && !TextUtils.isEmpty(configArray[1]) && tm != null && configArray[1].equalsIgnoreCase(tm.getGroupIdLevel1())))) {
worldModeOn = true;
}
}
} else {
Log.w(TAG, "couldn't find resource of config_world_mode");
}
}
return worldModeOn;
}
use of android.telephony.TelephonyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class TetherSettings method setDefaultValue.
private boolean setDefaultValue(Context ctx, boolean default_ssid, boolean clear_password) {
WifiManager wifiManager = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
if (wifiManager == null) {
return false;
}
WifiConfiguration wifiAPConfig = wifiManager.getWifiApConfiguration();
if (wifiAPConfig == null) {
return false;
}
if (default_ssid) {
TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
String deviceId = tm.getDeviceId();
String lastFourDigits = "";
if ((deviceId != null) && (deviceId.length() > 3)) {
lastFourDigits = deviceId.substring(deviceId.length() - 4);
}
wifiAPConfig.SSID = Build.MODEL;
if ((!TextUtils.isEmpty(lastFourDigits)) && (wifiAPConfig.SSID != null) && (wifiAPConfig.SSID.indexOf(lastFourDigits) < 0)) {
wifiAPConfig.SSID += " " + lastFourDigits;
}
}
if (clear_password) {
wifiAPConfig.preSharedKey = "";
}
wifiManager.setWifiApConfiguration(wifiAPConfig);
return true;
}
use of android.telephony.TelephonyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DefaultPhonePreference method isAvailable.
@Override
public boolean isAvailable(Context context) {
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (!tm.isVoiceCapable()) {
return false;
}
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
final boolean hasUserRestriction = um.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS);
final CharSequence[] entries = getEntries();
return !hasUserRestriction && entries != null && entries.length > 0;
}
use of android.telephony.TelephonyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DefaultSmsPreference method isAvailable.
@Override
public boolean isAvailable(Context context) {
boolean isRestrictedUser = UserManager.get(context).getUserInfo(UserHandle.myUserId()).isRestricted();
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return !isRestrictedUser && tm.isSmsCapable();
}
Aggregations