use of android.telephony.TelephonyManager in project XobotOS by xamarin.
the class DefaultPhoneNotifier method doNotifyDataConnection.
private void doNotifyDataConnection(Phone sender, String reason, String apnType, Phone.DataState state) {
// TODO
// use apnType as the key to which connection we're talking about.
// pass apnType back up to fetch particular for this one.
TelephonyManager telephony = TelephonyManager.getDefault();
LinkProperties linkProperties = null;
LinkCapabilities linkCapabilities = null;
boolean roaming = false;
if (state == Phone.DataState.CONNECTED) {
linkProperties = sender.getLinkProperties(apnType);
linkCapabilities = sender.getLinkCapabilities(apnType);
}
ServiceState ss = sender.getServiceState();
if (ss != null)
roaming = ss.getRoaming();
try {
mRegistry.notifyDataConnection(convertDataState(state), sender.isDataConnectivityPossible(apnType), reason, sender.getActiveApnHost(apnType), apnType, linkProperties, linkCapabilities, ((telephony != null) ? telephony.getNetworkType() : TelephonyManager.NETWORK_TYPE_UNKNOWN), roaming);
} catch (RemoteException ex) {
// system process is dead
}
}
use of android.telephony.TelephonyManager in project android_frameworks_base by ResurrectionRemix.
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;
}
use of android.telephony.TelephonyManager in project android_frameworks_base by ResurrectionRemix.
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);
}
}
use of android.telephony.TelephonyManager in project ride-read-android by Ride-Read.
the class NetworkUtils method getDataEnabled.
/**
* 判断网络是否可用
* <p>需添加权限 {@code <uses-permission android:name="android.permission.INTERNET"/>}</p>
*
* @return {@code true}: 可用<br>{@code false}: 不可用
// */
// public static boolean isAvailableByPing() {
// ShellUtils.CommandResult result = ShellUtils.execCmd("ping -c 1 -w 1 223.5.5.5", false);
// boolean ret = result.result == 0;
// if (result.errorMsg != null) {
// LogUtils.d("isAvailableByPing errorMsg", result.errorMsg);
// }
// if (result.successMsg != null) {
// LogUtils.d("isAvailableByPing successMsg", result.successMsg);
// }
// return ret;
// }
/**
* 判断移动数据是否打开
*
* @return {@code true}: 是<br>{@code false}: 否
*/
public static boolean getDataEnabled() {
try {
TelephonyManager tm = (TelephonyManager) Utils.getAppContext().getSystemService(Context.TELEPHONY_SERVICE);
Method getMobileDataEnabledMethod = tm.getClass().getDeclaredMethod("getDataEnabled");
if (null != getMobileDataEnabledMethod) {
return (boolean) getMobileDataEnabledMethod.invoke(tm);
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
use of android.telephony.TelephonyManager in project ride-read-android by Ride-Read.
the class NetworkUtils method setDataEnabled.
/**
* 打开或关闭移动数据
* <p>需系统应用 需添加权限{@code <uses-permission android:name="android.permission.MODIFY_PHONE_STATE"/>}</p>
*
* @param enabled {@code true}: 打开<br>{@code false}: 关闭
*/
public static void setDataEnabled(boolean enabled) {
try {
TelephonyManager tm = (TelephonyManager) Utils.getAppContext().getSystemService(Context.TELEPHONY_SERVICE);
Method setMobileDataEnabledMethod = tm.getClass().getDeclaredMethod("setDataEnabled", boolean.class);
if (null != setMobileDataEnabledMethod) {
setMobileDataEnabledMethod.invoke(tm, enabled);
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations