use of com.android.internal.telephony.ITelephony in project android_frameworks_base by DirtyUnicorns.
the class ConnectivityManager method getMobileDataEnabled.
/**
* @hide
* @deprecated Talk to TelephonyManager directly
*/
public boolean getMobileDataEnabled() {
IBinder b = ServiceManager.getService(Context.TELEPHONY_SERVICE);
if (b != null) {
try {
ITelephony it = ITelephony.Stub.asInterface(b);
int subId = SubscriptionManager.getDefaultDataSubscriptionId();
Log.d("ConnectivityManager", "getMobileDataEnabled()+ subId=" + subId);
boolean retVal = it.getDataEnabled(subId);
Log.d("ConnectivityManager", "getMobileDataEnabled()- subId=" + subId + " retVal=" + retVal);
return retVal;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
Log.d("ConnectivityManager", "getMobileDataEnabled()- remote exception retVal=false");
return false;
}
use of com.android.internal.telephony.ITelephony in project android_frameworks_base by AOSPA.
the class ConnectivityManager method getMobileDataEnabled.
/**
* @hide
* @deprecated Talk to TelephonyManager directly
*/
public boolean getMobileDataEnabled() {
IBinder b = ServiceManager.getService(Context.TELEPHONY_SERVICE);
if (b != null) {
try {
ITelephony it = ITelephony.Stub.asInterface(b);
int subId = SubscriptionManager.getDefaultDataSubscriptionId();
Log.d("ConnectivityManager", "getMobileDataEnabled()+ subId=" + subId);
boolean retVal = it.getDataEnabled(subId);
Log.d("ConnectivityManager", "getMobileDataEnabled()- subId=" + subId + " retVal=" + retVal);
return retVal;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
Log.d("ConnectivityManager", "getMobileDataEnabled()- remote exception retVal=false");
return false;
}
use of com.android.internal.telephony.ITelephony in project android_frameworks_base by ResurrectionRemix.
the class TelephonyManager method getLine1Number.
/**
* Returns the phone number string for line 1, for example, the MSISDN
* for a GSM phone for a particular subscription. Return null if it is unavailable.
* <p>
* Requires Permission:
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
* OR
* {@link android.Manifest.permission#READ_SMS}
* <p>
* The default SMS app can also use this.
*
* @param subId whose phone number for line 1 is returned
* @hide
*/
public String getLine1Number(int subId) {
android.util.SeempLog.record_str(9, "" + subId);
String number = null;
try {
ITelephony telephony = getITelephony();
if (telephony != null)
number = telephony.getLine1NumberForDisplay(subId, mContext.getOpPackageName());
} catch (RemoteException ex) {
} catch (NullPointerException ex) {
}
if (number != null) {
return number;
}
try {
IPhoneSubInfo info = getSubscriberInfo();
if (info == null)
return null;
return info.getLine1NumberForSubscriber(subId, mContext.getOpPackageName());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
// This could happen before phone restarts due to crashing
return null;
}
}
use of com.android.internal.telephony.ITelephony in project android_frameworks_base by crdroidandroid.
the class DataCommand method run.
public void run(String[] args) {
boolean validCommand = false;
if (args.length >= 2) {
boolean flag = false;
if ("enable".equals(args[1])) {
flag = true;
validCommand = true;
} else if ("disable".equals(args[1])) {
flag = false;
validCommand = true;
}
if (validCommand) {
ITelephony phoneMgr = ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE));
try {
if (flag) {
phoneMgr.enableDataConnectivity();
} else
phoneMgr.disableDataConnectivity();
} catch (RemoteException e) {
System.err.println("Mobile data operation failed: " + e);
}
return;
}
}
System.err.println(longHelp());
}
use of com.android.internal.telephony.ITelephony in project android_frameworks_base by crdroidandroid.
the class TelephonyManager method getCellLocation.
/**
* Returns the current location of the device.
*<p>
* If there is only one radio in the device and that radio has an LTE connection,
* this method will return null. The implementation must not to try add LTE
* identifiers into the existing cdma/gsm classes.
*<p>
* In the future this call will be deprecated.
*<p>
* @return Current location of the device or null if not available.
*
* <p>Requires Permission:
* {@link android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_COARSE_LOCATION} or
* {@link android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_FINE_LOCATION}.
*/
public CellLocation getCellLocation() {
android.util.SeempLog.record(49);
try {
ITelephony telephony = getITelephony();
if (telephony == null) {
Rlog.d(TAG, "getCellLocation returning null because telephony is null");
return null;
}
Bundle bundle = telephony.getCellLocation(mContext.getOpPackageName());
if (bundle.isEmpty()) {
Rlog.d(TAG, "getCellLocation returning null because bundle is empty");
return null;
}
CellLocation cl = CellLocation.newFromBundle(bundle);
if (cl.isEmpty()) {
Rlog.d(TAG, "getCellLocation returning null because CellLocation is empty");
return null;
}
return cl;
} catch (RemoteException ex) {
Rlog.d(TAG, "getCellLocation returning null due to RemoteException " + ex);
return null;
} catch (NullPointerException ex) {
Rlog.d(TAG, "getCellLocation returning null due to NullPointerException " + ex);
return null;
}
}
Aggregations