use of android.telephony.TelephonyManager in project android_frameworks_base by ResurrectionRemix.
the class DeviceInfoUtils method getFormattedPhoneNumbers.
public static String getFormattedPhoneNumbers(Context context, List<SubscriptionInfo> subscriptionInfo) {
StringBuilder sb = new StringBuilder();
if (subscriptionInfo != null) {
final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(TELEPHONY_SERVICE);
final int count = subscriptionInfo.size();
for (int i = 0; i < count; i++) {
final String rawNumber = telephonyManager.getLine1Number(subscriptionInfo.get(i).getSubscriptionId());
if (!TextUtils.isEmpty(rawNumber)) {
sb.append(PhoneNumberUtils.formatNumber(rawNumber));
if (i < count - 1) {
sb.append("\n");
}
}
}
}
return sb.toString();
}
use of android.telephony.TelephonyManager in project android_frameworks_base by ResurrectionRemix.
the class GnssLocationProvider method subscriptionOrSimChanged.
private void subscriptionOrSimChanged(Context context) {
if (DEBUG)
Log.d(TAG, "received SIM related action: ");
TelephonyManager phone = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
String mccMnc = phone.getSimOperator();
String imsi = phone.getSubscriberId();
String groupId = phone.getGroupIdLevel1();
if (!TextUtils.isEmpty(mccMnc)) {
if (DEBUG)
Log.d(TAG, "SIM MCC/MNC is available: " + mccMnc);
synchronized (mLock) {
if (isVerizon(mccMnc, imsi, groupId)) {
// load current properties for carrier VZW
loadPropertiesFromResource(context, mProperties);
String lpp_profile = mProperties.getProperty("LPP_PROFILE");
// set the persist property LPP_PROFILE for VZW
SystemProperties.set(LPP_PROFILE, lpp_profile);
} else {
// reset the persist property for Non VZW
SystemProperties.set(LPP_PROFILE, "");
}
reloadGpsProperties(context, mProperties);
mNIHandler.setSuplEsEnabled(mSuplEsEnabled);
}
} else {
if (DEBUG)
Log.d(TAG, "SIM MCC/MNC is still not available");
}
}
use of android.telephony.TelephonyManager in project android_frameworks_base by ResurrectionRemix.
the class NetworkPolicyManagerService method ensureActiveMobilePolicyNL.
/**
* Once any {@link #mNetworkPolicy} are loaded from disk, ensure that we
* have at least a default mobile policy defined.
*/
private void ensureActiveMobilePolicyNL() {
if (LOGV)
Slog.v(TAG, "ensureActiveMobilePolicyNL()");
if (mSuppressDefaultPolicy)
return;
final TelephonyManager tele = TelephonyManager.from(mContext);
final SubscriptionManager sub = SubscriptionManager.from(mContext);
final int[] subIds = sub.getActiveSubscriptionIdList();
for (int subId : subIds) {
final String subscriberId = tele.getSubscriberId(subId);
ensureActiveMobilePolicyNL(subscriberId);
}
}
use of android.telephony.TelephonyManager in project android_frameworks_base by ResurrectionRemix.
the class NetworkPolicyManagerService method isTemplateRelevant.
/**
* Test if given {@link NetworkTemplate} is relevant to user based on
* current device state, such as when
* {@link TelephonyManager#getSubscriberId()} matches. This is regardless of
* data connection status.
*/
private boolean isTemplateRelevant(NetworkTemplate template) {
if (template.isMatchRuleMobile()) {
final TelephonyManager tele = TelephonyManager.from(mContext);
final SubscriptionManager sub = SubscriptionManager.from(mContext);
// Mobile template is relevant when any active subscriber matches
final int[] subIds = sub.getActiveSubscriptionIdList();
for (int subId : subIds) {
final String subscriberId = tele.getSubscriberId(subId);
final NetworkIdentity probeIdent = new NetworkIdentity(TYPE_MOBILE, TelephonyManager.NETWORK_TYPE_UNKNOWN, subscriberId, null, false, true);
if (template.matches(probeIdent)) {
return true;
}
}
return false;
} else {
return true;
}
}
use of android.telephony.TelephonyManager in project android_frameworks_base by ResurrectionRemix.
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;
}
Aggregations