Search in sources :

Example 86 with TelephonyManager

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;
}
Also used : NetworkTemplate(android.net.NetworkTemplate) JSONObject(org.json.JSONObject) TelephonyManager(android.telephony.TelephonyManager) ConnectivityManager(android.net.ConnectivityManager) DataUsageController(com.android.settingslib.net.DataUsageController) JSONArray(org.json.JSONArray) SubscriptionInfo(android.telephony.SubscriptionInfo) SubscriptionManager(android.telephony.SubscriptionManager)

Example 87 with TelephonyManager

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;
}
Also used : TelephonyManager(android.telephony.TelephonyManager) Resources(android.content.res.Resources)

Example 88 with TelephonyManager

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;
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiConfiguration(android.net.wifi.WifiConfiguration) TelephonyManager(android.telephony.TelephonyManager)

Example 89 with TelephonyManager

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;
}
Also used : TelephonyManager(android.telephony.TelephonyManager) UserManager(android.os.UserManager)

Example 90 with TelephonyManager

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();
}
Also used : TelephonyManager(android.telephony.TelephonyManager)

Aggregations

TelephonyManager (android.telephony.TelephonyManager)294 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)20 SubscriptionManager (android.telephony.SubscriptionManager)20 Test (org.junit.Test)15 ConnectivityManager (android.net.ConnectivityManager)14 Context (android.content.Context)11 Intent (android.content.Intent)11 NetworkIdentity (android.net.NetworkIdentity)11 Method (java.lang.reflect.Method)11 GsmCellLocation (android.telephony.gsm.GsmCellLocation)10 PackageManager (android.content.pm.PackageManager)9 SubscriptionInfo (android.telephony.SubscriptionInfo)9 IntentFilter (android.content.IntentFilter)8 IOException (java.io.IOException)8 PackageInfo (android.content.pm.PackageInfo)7 ServiceState (android.telephony.ServiceState)7 NetworkPolicy (android.net.NetworkPolicy)6 WifiManager (android.net.wifi.WifiManager)6 DevicePolicyManagerInternal (android.app.admin.DevicePolicyManagerInternal)5 SharedPreferences (android.content.SharedPreferences)5