Search in sources :

Example 1 with ITelephony

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());
}
Also used : IConnectivityManager(android.net.IConnectivityManager) RemoteException(android.os.RemoteException) ITelephony(com.android.internal.telephony.ITelephony)

Example 2 with ITelephony

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());
}
Also used : RemoteException(android.os.RemoteException) ITelephony(com.android.internal.telephony.ITelephony)

Example 3 with ITelephony

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);
    }
}
Also used : AppOpsManager(android.app.AppOpsManager) RemoteException(android.os.RemoteException) ITelephony(com.android.internal.telephony.ITelephony) SystemApi(android.annotation.SystemApi)

Example 4 with ITelephony

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) {
    }
}
Also used : RemoteException(android.os.RemoteException) ITelephony(com.android.internal.telephony.ITelephony)

Example 5 with ITelephony

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;
    }
}
Also used : Bundle(android.os.Bundle) RemoteException(android.os.RemoteException) ITelephony(com.android.internal.telephony.ITelephony)

Aggregations

ITelephony (com.android.internal.telephony.ITelephony)36 RemoteException (android.os.RemoteException)35 IBluetoothManager (android.bluetooth.IBluetoothManager)5 INfcAdapter (android.nfc.INfcAdapter)5 IBinder (android.os.IBinder)5 SystemApi (android.annotation.SystemApi)4 Bundle (android.os.Bundle)4 Intent (android.content.Intent)3 AppOpsManager (android.app.AppOpsManager)2 ActivityNotFoundException (android.content.ActivityNotFoundException)2 ContentResolver (android.content.ContentResolver)2 Message (android.os.Message)2 IWindowManager (android.view.IWindowManager)2 KeyCharacterMap (android.view.KeyCharacterMap)2 KeyEvent (android.view.KeyEvent)2 WindowManager (android.view.WindowManager)2 IPhoneSubInfo (com.android.internal.telephony.IPhoneSubInfo)2 IActivityManager (android.app.IActivityManager)1 IBluetooth (android.bluetooth.IBluetooth)1 BroadcastReceiver (android.content.BroadcastReceiver)1