com.android.internal.telephony.ITelephony Java Examples

The following examples show how to use com.android.internal.telephony.ITelephony. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConnectivityManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * @hide
 * @deprecated Talk to TelephonyManager directly
 */
@Deprecated
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.isUserDataEnabled(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;
}
 
Example #2
Source File: CallBroadcastReceiver.java    From BlackList with Apache License 2.0 6 votes vote down vote up
private void breakCallNougatAndLower(Context context) {
    Log.d(TAG, "Trying to break call for Nougat and lower with TelephonyManager.");
    TelephonyManager telephony = (TelephonyManager)
            context.getSystemService(Context.TELEPHONY_SERVICE);
    try {
        Class c = Class.forName(telephony.getClass().getName());
        Method m = c.getDeclaredMethod("getITelephony");
        m.setAccessible(true);
        ITelephony telephonyService = (ITelephony) m.invoke(telephony);
        telephonyService.endCall();
        Log.d(TAG, "Invoked 'endCall' on TelephonyService.");
    } catch (Exception e) {
        Log.e(TAG, "Could not end call. Check stdout for more info.");
        e.printStackTrace();
    }
}
 
Example #3
Source File: DialtactsActivity.java    From coursera-android with MIT License 6 votes vote down vote up
/**
 * Returns true if the intent is due to hitting the green send key (hardware call button:
 * KEYCODE_CALL) while in a call.
 *
 * @param intent the intent that launched this activity
 * @param recentCallsRequest true if the intent is requesting to view recent calls
 * @return true if the intent is due to hitting the green send key while in a call
 */
private boolean isSendKeyWhileInCall(final Intent intent,
        final boolean recentCallsRequest) {
    // If there is a call in progress go to the call screen
    if (recentCallsRequest) {
        final boolean callKey = intent.getBooleanExtra("call_key", false);

        try {
            ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
            if (callKey && phone != null && phone.showCallScreen()) {
                return true;
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to handle send while in call", e);
        }
    }

    return false;
}
 
Example #4
Source File: CallUtils.java    From MobileGuard with MIT License 5 votes vote down vote up
/**
 * End call or go to the Home screen
 * use reflex to call endCall in ITelephony
 * @return whether it hung up
 */
public static boolean endCall() {
    // the src code is like this
    /*
    private ITelephony getITelephony() {
        return ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE));
    }
    public boolean endCall() {
        try {
            ITelephony telephony = getITelephony();
            if (telephony != null)
                return telephony.endCall();
        } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelephony#endCall", e);
        }
        return false;
    }
    */

    try {
        Class serviceManager = Class.forName("android.os.ServiceManager");
        Method getService = serviceManager.getDeclaredMethod("getService", String.class);
        ITelephony telephony = ITelephony.Stub.asInterface((IBinder) getService.invoke(null, Context.TELEPHONY_SERVICE));
        return telephony.endCall();

    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
Example #5
Source File: CmdMobileData.java    From PhoneProfilesPlus with Apache License 2.0 5 votes vote down vote up
private static boolean run(int subId, boolean enable) {
    try {
        ITelephony adapter = ITelephony.Stub.asInterface(ServiceManager.getService("phone")); // service list | grep ITelephony
        adapter.setUserDataEnabled(subId, enable); // hm... support for dual sim
        return true;
    } catch (Throwable e) {
        return false;
    }
}