Search in sources :

Example 11 with ITelephony

use of com.android.internal.telephony.ITelephony in project android_frameworks_base by DirtyUnicorns.

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 12 with ITelephony

use of com.android.internal.telephony.ITelephony in project android_frameworks_base by AOSPA.

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 13 with ITelephony

use of com.android.internal.telephony.ITelephony in project platform_frameworks_base by android.

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

Example 14 with ITelephony

use of com.android.internal.telephony.ITelephony in project platform_frameworks_base by android.

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 15 with ITelephony

use of com.android.internal.telephony.ITelephony in project platform_frameworks_base by android.

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() {
    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) PersistableBundle(android.os.PersistableBundle) 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