Search in sources :

Example 26 with ITelephony

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

Example 27 with ITelephony

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

Example 28 with ITelephony

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

Example 29 with ITelephony

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

Example 30 with ITelephony

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;
    }
}
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