UiAutomator自动化测试脚本挂断电话

xiaoxiao2021-02-28  229

在构造函数里实例化context this.targetContext=InstrumentationRegistry.getTargetContext(); public void hangUpCommand() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { TelephonyManager telephonyManager = (TelephonyManager)targetContext.getSystemService(Context.TELEPHONY_SERVICE); Class<TelephonyManager> c = TelephonyManager.class; Method mthEndCall = c.getDeclaredMethod("getITelephony",(Class[])null); mthEndCall.setAccessible(true); final Object obj = mthEndCall.invoke(telephonyManager,(Object[])null); Method mt = obj.getClass().getMethod("endCall"); mt.setAccessible(true); mt.invoke(obj); }
转载请注明原文地址: https://www.6miu.com/read-21860.html

最新回复(0)