use of com.android.internal.telephony.ITelephony in project android_frameworks_base by ParanoidAndroid.
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;
} else if ("prefer".equals(args[1])) {
IConnectivityManager connMgr = IConnectivityManager.Stub.asInterface(ServiceManager.getService(Context.CONNECTIVITY_SERVICE));
try {
connMgr.setNetworkPreference(ConnectivityManager.TYPE_MOBILE);
} catch (RemoteException e) {
System.err.println("Failed to set preferred network: " + e);
}
return;
}
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 ResurrectionRemix.
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 ResurrectionRemix.
the class TelephonyManager method setDataEnabled.
/** @hide */
@SystemApi
public void setDataEnabled(int subId, boolean enable) {
try {
Log.d(TAG, "setDataEnabled: enabled=" + enable);
AppOpsManager appOps = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE);
if (enable) {
if (appOps.noteOp(AppOpsManager.OP_DATA_CONNECT_CHANGE) != AppOpsManager.MODE_ALLOWED) {
Log.w(TAG, "Permission denied by user.");
return;
}
}
ITelephony telephony = getITelephony();
if (telephony != null)
telephony.setDataEnabled(subId, enable);
} catch (RemoteException e) {
Log.e(TAG, "Error calling setDataEnabled", e);
}
}
use of com.android.internal.telephony.ITelephony in project android_frameworks_base by ResurrectionRemix.
the class TelephonyManager method factoryReset.
/**
* Resets telephony manager settings back to factory defaults.
*
* @hide
*/
public void factoryReset(int subId) {
try {
Log.d(TAG, "factoryReset: subId=" + subId);
ITelephony telephony = getITelephony();
if (telephony != null)
telephony.factoryReset(subId);
} catch (RemoteException e) {
}
}
use of com.android.internal.telephony.ITelephony in project android_frameworks_base by ResurrectionRemix.
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