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


Java ITelephony类代码示例

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


ITelephony类属于com.android.internal.telephony包,在下文中一共展示了ITelephony类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setStateL

import com.android.internal.telephony.ITelephony; //导入依赖的package包/类
@Thunk static boolean setStateL(boolean newState) {
  try {
    ITelephony stub = ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE));
    ReflectionUtil rUtil = new ReflectionUtil(stub);
    if (rUtil.getMethod("setDataEnabled", Boolean.TYPE) != null) {
      rUtil.invokeSetter("setDataEnabled", Boolean.TYPE, newState);
    } else {
      Method altMethod = rUtil.getMethod("setDataEnabled", Integer.TYPE, Boolean.TYPE);
      if (altMethod != null) {
        int subId = ISub.Stub.asInterface(ServiceManager.getService("isub")).getDefaultSubId();
        final Object[] values = new Object[] { subId, newState };
        altMethod.invoke(stub, values);
      } else {
        return false;
      }
    }
    return true;
  } catch (Throwable e) {
    Debug.log(e);
    return false;
  }
}
 
开发者ID:sunnygoyal,项目名称:PowerToggles,代码行数:23,代码来源:GprsStateTracker.java

示例6: 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

示例7: answerPhoneAidl

import com.android.internal.telephony.ITelephony; //导入依赖的package包/类
private void answerPhoneAidl(Context context) throws Exception {
    try {
        TelephonyManager tm = (TelephonyManager) getSystemService("phone");
        Method m = Class.forName(tm.getClass().getName()).getDeclaredMethod("getITelephony", new Class[0]);
        m.setAccessible(true);
        ITelephony telephonyService = (ITelephony) m.invoke(tm, new Object[0]);
        Log.d("AutoAnswer", "Phone answer incoming call now!");
        telephonyService.answerRingingCall();
    } catch (Exception e) {
        Intent intent = new Intent("android.intent.action.MEDIA_BUTTON");
        intent.putExtra("android.intent.extra.KEY_EVENT", new KeyEvent(0, 79));
        context.sendOrderedBroadcast(intent, "android.permission.CALL_PRIVILEGED");
        intent = new Intent("android.intent.action.MEDIA_BUTTON");
        intent.putExtra("android.intent.extra.KEY_EVENT", new KeyEvent(1, 79));
        context.sendOrderedBroadcast(intent, "android.permission.CALL_PRIVILEGED");
    }
}
 
开发者ID:jp1017,项目名称:AutoAnswerCalls,代码行数:18,代码来源:AutoAnswerCallIntentService.java

示例8: 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

示例9: endCall

import com.android.internal.telephony.ITelephony; //导入依赖的package包/类
public void endCall() {
		// TODO Auto-generated method stub
//		IBinder iBinder = ServiceManager.getService(TELEPHONY_SERVICE);
		//反射
		try {
			//加在ServiceManager字节码
			Class clazz = CallSMSSafeService.class.getClassLoader().loadClass("android.os.ServiceManager");
			Method method =  clazz.getDeclaredMethod("getService", String.class);
			IBinder iBinder = (IBinder) method.invoke(null, TELEPHONY_SERVICE);
			ITelephony.Stub.asInterface(iBinder).endCall();
			
			//提示号码为空或已关机,原理为呼叫转移
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
	}
 
开发者ID:qq644531343,项目名称:MobileSafe,代码行数:19,代码来源:CallSMSSafeService.java

示例10: 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

示例11: 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

示例12: getSensorManager

import com.android.internal.telephony.ITelephony; //导入依赖的package包/类
/********************************
 *     SENSOR: ACELEROMETRO     *
 ********************************/
public void getSensorManager() {
	//obtener en la variable global sensorManager una instancia del servicio SENSOR_SERVICE
	sensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);

	//control de volumen
	am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
	volumenNormalVoz = am.getStreamVolume(AudioManager.STREAM_MUSIC);//guardar volumen normal voz del telefono

	//obtener una instancia de ITELEPHONY
	TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
	try {// "cheat" with Java reflection to gain access to TelephonyManager's ITelephony getter
		Class<?> c = Class.forName(tm.getClass().getName());
		Method m = c.getDeclaredMethod("getITelephony");
		m.setAccessible(true);
		telephonyService = (ITelephony) m.invoke(tm);
	} catch (Exception e) {
		e.printStackTrace();
	} 
}
 
开发者ID:juanfegc,项目名称:ShakeMe,代码行数:23,代码来源:ShakeMeService.java

示例13: endCall

import com.android.internal.telephony.ITelephony; //导入依赖的package包/类
/**
	 * 在另外一个进程中执行的远程服务的方法。
	 * 挂断电话。需要相应的权限。由于1.5版本以后,Android对挂断电话进行了修改,原本用来挂断电话的对象被隐藏了。
	 * 要想调用系统挂断电话的方法,需要通过反射来得到拥有此方法的对象ServiceManager。
	 */
	public void endCall() {
		
		try {
			
//			IBinder iBinder = ServiceManager.getService(TELEPHONY_SERVICE);
			
			//得到ServiceManage的字节码
			Class clazz = BlackListService.class.getClassLoader().loadClass("android.os.ServiceManager");
			//得到字节码类中的方法。
			Method method = clazz.getDeclaredMethod("getService", String.class);
			
			//得到了系统正真拥有挂断电话方法的对象。
			IBinder iBinder = (IBinder) method.invoke(null, TELEPHONY_SERVICE);
			
			/*
			 * 调用endCall方法挂断电话。执行这步前,要导入对应的aidl文件。
			 */
			ITelephony.Stub.asInterface(iBinder).endCall();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
 
开发者ID:384401056,项目名称:itheima,代码行数:30,代码来源:BlackListService.java

示例14: execute

import com.android.internal.telephony.ITelephony; //导入依赖的package包/类
@Override
public Message execute(String arguments, Command command, MAXSModuleIntentService service)
		throws Exception {
	if (!PackageManagerUtil.getInstance(service).isSystemApp()) {
		throw new Exception(
				"MAXS Module PhonestateModify needs to be an system app. For information on how to convert it to an system app see projectmaxs.org/systemapp");
	}

	telephonyManager = (TelephonyManager) service.getSystemService(Context.TELEPHONY_SERVICE);
	Class<?> c = Class.forName(telephonyManager.getClass().getName());
	Method m = c.getDeclaredMethod("getITelephony");
	m.setAccessible(true);
	telephonyService = (ITelephony) m.invoke(telephonyManager);

	return null;
}
 
开发者ID:ProjectMAXS,项目名称:maxs,代码行数:17,代码来源:AbstractPhonestateModifyCommand.java

示例15: doStart

import com.android.internal.telephony.ITelephony; //导入依赖的package包/类
private void doStart() {
    IBinder scaBinder = ServiceManager.getService("sca");

    log("scaBinder:" + scaBinder);

    if (scaBinder != null) {
        sent(new Feedback(Response.START_FAILURE_ALREADY_STARTED, "Sca server already started."));
        return;
    }

    ServiceManager.addService(ScaContext.SCA_SERVICE, ScaHookService.get(), true);
    ServiceManager.addService(ScaContext.SCA_TELEPHONY_SERVICE, new TelephonyManagerProxy(), true);
    ServiceManager.addService(ScaContext.SCA_POWER_SERVICE, new PowerManagerProxy().asBinder(), true);

    com.nick.commands.sca.IScaService me =
            com.nick.commands.sca.IScaService.Stub.asInterface(ServiceManager.getService(ScaContext.SCA_SERVICE));
    ITelephony telephony = ITelephony.Stub.asInterface(ServiceManager.getService(ScaContext.SCA_TELEPHONY_SERVICE));
    IPowerManager power = IPowerManager.Stub.asInterface(ServiceManager.getService(ScaContext.SCA_POWER_SERVICE));

    log("Sca service:" + me);
    log("Sca phone service:" + telephony);
    log("Sca power service:" + power);

    if (me == null) {
        sent(new Feedback(Response.START_FAILURE_SYSTEM_ERR, "Sca server startup failure, have you installed?"));
        return;
    }

    sent(new Feedback(Response.START_OK, "Sca server startup success."));
    ServiceKeeper keeper = new ServiceKeeper();
    keeper.keep();
}
 
开发者ID:NickAndroid,项目名称:Scalpel_Android,代码行数:33,代码来源:Sca.java


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