当前位置: 首页>>代码示例>>Java>>正文


Java ITelephony.endCall方法代码示例

本文整理汇总了Java中com.android.internal.telephony.ITelephony.endCall方法的典型用法代码示例。如果您正苦于以下问题:Java ITelephony.endCall方法的具体用法?Java ITelephony.endCall怎么用?Java ITelephony.endCall使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.internal.telephony.ITelephony的用法示例。


在下文中一共展示了ITelephony.endCall方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: endCall

import com.android.internal.telephony.ITelephony; //导入方法依赖的package包/类
/**
 * 挂断电话,需要复制两个AIDL
 */
public void endCall(Context context) {
    try {
        Class clazz = context.getClassLoader()
                .loadClass("android.os.Service.Manager");
        Method method = clazz.getDeclaredMethod("getService",String.class);
        IBinder iBinder = (IBinder) method.invoke(null,Context.TELECOM_SERVICE);
        ITelephony iTelephony = ITelephony.Stub.asInterface(iBinder);
        iTelephony.endCall();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:sh2zqp,项目名称:MobilePhoneSafeProtector,代码行数:16,代码来源:InterceptCallReceiver.java

示例2: breakCall

import com.android.internal.telephony.ITelephony; //导入方法依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
private void breakCall(Context context) {
    if (!Permissions.isGranted(context, Permissions.CALL_PHONE)) {
        return;
    }

    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();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:19,代码来源:CallBroadcastReceiver.java

示例3: blockCall

import com.android.internal.telephony.ITelephony; //导入方法依赖的package包/类
public void blockCall(Context c, Bundle b)
{
    
     TelephonyManager telephony = (TelephonyManager) 
     c.getSystemService(Context.TELEPHONY_SERVICE);  
     try {
      @SuppressWarnings("rawtypes")
Class cls = Class.forName(telephony.getClass().getName());
      @SuppressWarnings("unchecked")
Method m = cls.getDeclaredMethod("getITelephony");
      m.setAccessible(true);
      telephonyService = (ITelephony) m.invoke(telephony);
      //telephonyService.silenceRinger();
      telephonyService.endCall();
     } catch (Exception e) {
      e.printStackTrace();
     }
 
}
 
开发者ID:amitiwary999,项目名称:Call-blocker-app,代码行数:20,代码来源:Blocker.java

示例4: endCall

import com.android.internal.telephony.ITelephony; //导入方法依赖的package包/类
/**
 * 挂断电话
 */
public void endCall() {
	
	//通过反射进行实现
	try {
		//1.通过类加载器加载相应类的class文件
		//Class<?> forName = Class.forName("android.os.ServiceManager");
		Class<?> loadClass = EndCallService.class.getClassLoader().loadClass("android.os.ServiceManager");
		//2.获取类中相应的方法
		//name : 方法名
		//parameterTypes : 参数类型
		Method method = loadClass.getDeclaredMethod("getService", String.class);
		//3.执行方法,获取返回值
		//receiver : 类的实例
		//args : 具体的参数
		IBinder invoke = (IBinder) method.invoke(null, Context.TELEPHONY_SERVICE);
		//aidl
		ITelephony iTelephony = ITelephony.Stub.asInterface(invoke);
		//挂断电话
		iTelephony.endCall();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:liaozhoubei,项目名称:EndCallAndClearCacheDemo,代码行数:28,代码来源:EndCallService.java

示例5: endCall

import com.android.internal.telephony.ITelephony; //导入方法依赖的package包/类
/**
 * 挂断电话,通过反射完成,在低版本中可以直接使用电话服务的endCall()方法完成,高版本的不行了,此方法是隐藏的方法
 * 使用反射和AIDL完成
 */
private void endCall() {

    try {
        //通过类加载器加载ServiceManager
        Class<?> clazz = getClassLoader().loadClass("android.os.ServiceManager");
        //通过反射得到当前的方法
        Method method = clazz.getDeclaredMethod("getService", String.class);

        IBinder iBinder = (IBinder) method.invoke(null, TELEPHONY_SERVICE);

        ITelephony iTelephony = ITelephony.Stub.asInterface(iBinder);

        iTelephony.endCall();

    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
开发者ID:paifeng,项目名称:Mobile-guards,代码行数:24,代码来源:BlacklistService.java

示例6: onReceive

import com.android.internal.telephony.ITelephony; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    GBDeviceEventCallControl.Event callCmd = GBDeviceEventCallControl.Event.values()[intent.getIntExtra("event", 0)];
    switch (callCmd) {
        case END:
        case START:
            try {
                TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
                Class clazz = Class.forName(telephonyManager.getClass().getName());
                Method method = clazz.getDeclaredMethod("getITelephony");
                method.setAccessible(true);
                ITelephony telephonyService = (ITelephony) method.invoke(telephonyManager);
                if (callCmd == GBDeviceEventCallControl.Event.END) {
                    telephonyService.endCall();
                } else {
                    telephonyService.answerRingingCall();
                }
            } catch (Exception e) {
                LOG.warn("could not start or hangup call");
            }
            break;
        default:
    }
}
 
开发者ID:scifiswapnil,项目名称:gadgetbridge_artikcloud,代码行数:25,代码来源:GBCallControlReceiver.java

示例7: onKeyDown

import com.android.internal.telephony.ITelephony; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
	// long press of power button will end the call
	if (KeyEvent.KEYCODE_POWER == event.getKeyCode()) {
		TelephonyManager telephony = (TelephonyManager) getApplicationContext().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();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return true;
	} else if (keyCode == KeyEvent.KEYCODE_BACK) {
		// do nothing
		return true;
	}
	return super.onKeyDown(keyCode, event);
}
 
开发者ID:saurabh2590,项目名称:EasyAccess,代码行数:22,代码来源:CallingScreen.java

示例8: onKeyDown

import com.android.internal.telephony.ITelephony; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
	// long press of power button will end the call
	if (KeyEvent.KEYCODE_POWER == event.getKeyCode()) {
		TelephonyManager telephony = (TelephonyManager) getApplicationContext().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();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return true;
	}
	return super.onKeyDown(keyCode, event);
}
 
开发者ID:saurabh2590,项目名称:EasyAccess,代码行数:19,代码来源:PhoneDialerApp.java

示例9: endCall

import com.android.internal.telephony.ITelephony; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:ittianyu,项目名称:MobileGuard,代码行数:35,代码来源:CallUtils.java

示例10: endCall

import com.android.internal.telephony.ITelephony; //导入方法依赖的package包/类
/**
 * 挂断电话. 调用系统隐藏的api 挂断电话
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
private void endCall() {
	// 1.获取电话服务的代理对象 IBinder
	try {
		Class clazz = getClassLoader().loadClass("android.os.ServiceManager");
		Method method = clazz.getMethod("getService", new Class[] { String.class });
		IBinder iBinder = (IBinder) method.invoke(null, new Object[] { TELEPHONY_SERVICE });
		ITelephony iTelephony = ITelephony.Stub.asInterface(iBinder);
		iTelephony.endCall();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:bingoogolapple,项目名称:Graduation-Design,代码行数:17,代码来源:BlacklistInterceptService.java

示例11: rejectCall

import com.android.internal.telephony.ITelephony; //导入方法依赖的package包/类
private void rejectCall() {
	try {
		TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
		Class clazz = Class.forName(telephonyManager.getClass().getName());
		Method method = clazz.getDeclaredMethod("getITelephony");
		method.setAccessible(true);
		ITelephony telephonyService = (ITelephony) method.invoke(telephonyManager);
		telephonyService.endCall();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:saurabh2590,项目名称:EasyAccess,代码行数:13,代码来源:CallingScreen.java

示例12: disconnectCallAndroid

import com.android.internal.telephony.ITelephony; //导入方法依赖的package包/类
/**
 * This method try to hang up with a hacky method.
 * {@link com.android.internal.telephony.ITelephony} is an internal interface of android.
 * We need to put same interface in our app to use instead
 */
private void disconnectCallAndroid() {
	try {
		TelephonyManager telephonyManager = (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
		Class<?> clazz = Class.forName(telephonyManager.getClass().getName());
		Method method = clazz.getDeclaredMethod("getITelephony");

		method.setAccessible(true);
		ITelephony telephonyService = (ITelephony) method.invoke(telephonyManager);
		telephonyService.endCall();
	} catch (NoSuchMethodException | ClassNotFoundException | InvocationTargetException | IllegalAccessException e) {
		e.printStackTrace();
	}
}
 
开发者ID:kozaxinan,项目名称:OnePlus-One-Screen-Fix,代码行数:19,代码来源:FixServices.java

示例13: hangUp

import com.android.internal.telephony.ITelephony; //导入方法依赖的package包/类
protected void hangUp(Context context, ITelephony telephonyService) throws Exception {
    Log.d("AuthenticatorAutoAnswerIntentService.hangUp", "Waiting for 1000ms");
    try { Thread.sleep(1000); }
    catch(Exception ignored){}
    //end call
    Log.d("AuthenticatorAutoAnswerIntentService.answerToPhonePhactor", "End Call");
    telephonyService.endCall();  //unexpectedly it works :) at least for now
}
 
开发者ID:Mak-Sym,项目名称:android-auth-auto-answer,代码行数:9,代码来源:AuthenticatorAutoAnswerIntentService.java


注:本文中的com.android.internal.telephony.ITelephony.endCall方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。