Search in sources :

Example 31 with TelephonyManager

use of android.telephony.TelephonyManager in project android_frameworks_base by DirtyUnicorns.

the class UsageStatsService method fetchCarrierPrivilegedAppsLocked.

private void fetchCarrierPrivilegedAppsLocked() {
    TelephonyManager telephonyManager = getContext().getSystemService(TelephonyManager.class);
    mCarrierPrivilegedApps = telephonyManager.getPackagesWithCarrierPrivileges();
    mHaveCarrierPrivilegedApps = true;
    if (DEBUG) {
        Slog.d(TAG, "apps with carrier privilege " + mCarrierPrivilegedApps);
    }
}
Also used : TelephonyManager(android.telephony.TelephonyManager)

Example 32 with TelephonyManager

use of android.telephony.TelephonyManager in project android_frameworks_base by DirtyUnicorns.

the class KeyguardUpdateMonitor method refreshSimState.

/**
     * @return true if and only if the state has changed for the specified {@code slotId}
     */
private boolean refreshSimState(int subId, int slotId) {
    // This is awful. It exists because there are two APIs for getting the SIM status
    // that don't return the complete set of values and have different types. In Keyguard we
    // need IccCardConstants, but TelephonyManager would only give us
    // TelephonyManager.SIM_STATE*, so we retrieve it manually.
    final TelephonyManager tele = TelephonyManager.from(mContext);
    int simState = tele.getSimState(slotId);
    State state;
    try {
        state = State.intToState(simState);
    } catch (IllegalArgumentException ex) {
        Log.w(TAG, "Unknown sim state: " + simState);
        state = State.UNKNOWN;
    }
    SimData data = mSimDatas.get(subId);
    final boolean changed;
    if (data == null) {
        data = new SimData(state, slotId, subId);
        mSimDatas.put(subId, data);
        // no data yet; force update
        changed = true;
    } else {
        changed = data.simState != state;
        data.simState = state;
    }
    return changed;
}
Also used : TelephonyManager(android.telephony.TelephonyManager) State(com.android.internal.telephony.IccCardConstants.State) ServiceState(android.telephony.ServiceState)

Example 33 with TelephonyManager

use of android.telephony.TelephonyManager in project android_frameworks_base by DirtyUnicorns.

the class NetworkPolicyManagerService method normalizePoliciesNL.

private void normalizePoliciesNL(NetworkPolicy[] policies) {
    final TelephonyManager tele = TelephonyManager.from(mContext);
    final String[] merged = tele.getMergedSubscriberIds();
    mNetworkPolicy.clear();
    for (NetworkPolicy policy : policies) {
        // When two normalized templates conflict, prefer the most
        // restrictive policy
        policy.template = NetworkTemplate.normalize(policy.template, merged);
        final NetworkPolicy existing = mNetworkPolicy.get(policy.template);
        if (existing == null || existing.compareTo(policy) > 0) {
            if (existing != null) {
                Slog.d(TAG, "Normalization replaced " + existing + " with " + policy);
            }
            mNetworkPolicy.put(policy.template, policy);
        }
    }
}
Also used : TelephonyManager(android.telephony.TelephonyManager) NetworkPolicy(android.net.NetworkPolicy) NetworkPolicyManager.uidRulesToString(android.net.NetworkPolicyManager.uidRulesToString)

Example 34 with TelephonyManager

use of android.telephony.TelephonyManager in project android_frameworks_base by DirtyUnicorns.

the class NetworkStatsAccess method checkAccessLevel.

/** Returns the {@link NetworkStatsAccess.Level} for the given caller. */
@NetworkStatsAccess.Level
public static int checkAccessLevel(Context context, int callingUid, String callingPackage) {
    final DevicePolicyManagerInternal dpmi = LocalServices.getService(DevicePolicyManagerInternal.class);
    final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    boolean hasCarrierPrivileges = tm != null && tm.checkCarrierPrivilegesForPackage(callingPackage) == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
    boolean isDeviceOwner = dpmi != null && dpmi.isActiveAdminWithPolicy(callingUid, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
    if (hasCarrierPrivileges || isDeviceOwner || UserHandle.getAppId(callingUid) == android.os.Process.SYSTEM_UID) {
        // all apps on the device.
        return NetworkStatsAccess.Level.DEVICE;
    }
    boolean hasAppOpsPermission = hasAppOpsPermission(context, callingUid, callingPackage);
    if (hasAppOpsPermission || context.checkCallingOrSelfPermission(READ_NETWORK_USAGE_HISTORY) == PackageManager.PERMISSION_GRANTED) {
        return NetworkStatsAccess.Level.DEVICESUMMARY;
    }
    boolean isProfileOwner = dpmi != null && dpmi.isActiveAdminWithPolicy(callingUid, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
    if (isProfileOwner) {
        // permission can access data usage for all apps in this user/profile.
        return NetworkStatsAccess.Level.USER;
    }
    // Everyone else gets default access (only to their own UID).
    return NetworkStatsAccess.Level.DEFAULT;
}
Also used : DevicePolicyManagerInternal(android.app.admin.DevicePolicyManagerInternal) TelephonyManager(android.telephony.TelephonyManager)

Example 35 with TelephonyManager

use of android.telephony.TelephonyManager in project android_frameworks_base by DirtyUnicorns.

the class NetworkPolicyManagerService method setNetworkTemplateEnabled.

/**
     * Proactively disable networks that match the given
     * {@link NetworkTemplate}.
     */
private void setNetworkTemplateEnabled(NetworkTemplate template, boolean enabled) {
    if (template.getMatchRule() == MATCH_MOBILE_ALL) {
        // If mobile data usage hits the limit or if the user resumes the data, we need to
        // notify telephony.
        final SubscriptionManager sm = SubscriptionManager.from(mContext);
        final TelephonyManager tm = TelephonyManager.from(mContext);
        final int[] subIds = sm.getActiveSubscriptionIdList();
        for (int subId : subIds) {
            final String subscriberId = tm.getSubscriberId(subId);
            final NetworkIdentity probeIdent = new NetworkIdentity(TYPE_MOBILE, TelephonyManager.NETWORK_TYPE_UNKNOWN, subscriberId, null, false, true);
            // Template is matched when subscriber id matches.
            if (template.matches(probeIdent)) {
                tm.setPolicyDataEnabled(enabled, subId);
            }
        }
    }
}
Also used : NetworkIdentity(android.net.NetworkIdentity) TelephonyManager(android.telephony.TelephonyManager) SubscriptionManager(android.telephony.SubscriptionManager) NetworkPolicyManager.uidRulesToString(android.net.NetworkPolicyManager.uidRulesToString)

Aggregations

TelephonyManager (android.telephony.TelephonyManager)679 SubscriptionInfo (android.telephony.SubscriptionInfo)64 ConnectivityManager (android.net.ConnectivityManager)59 SubscriptionManager (android.telephony.SubscriptionManager)53 Context (android.content.Context)42 Method (java.lang.reflect.Method)40 Intent (android.content.Intent)34 IOException (java.io.IOException)30 SuppressLint (android.annotation.SuppressLint)29 ArrayList (java.util.ArrayList)26 PhoneAccountHandle (android.telecom.PhoneAccountHandle)24 NetworkTemplate (android.net.NetworkTemplate)22 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)20 PhoneAccount (android.telecom.PhoneAccount)19 Test (org.junit.Test)18 Preference (android.support.v7.preference.Preference)17 TelecomManager (android.telecom.TelecomManager)17 View (android.view.View)17 DialogInterface (android.content.DialogInterface)16 Resources (android.content.res.Resources)16