UiAutomator???????????????????????
??????????? ???????[ 2016/10/19 11:04:40 ] ?????????????????? UiAutomator
	?????????uiautomator???????????????У????????????????????uiautomator????????longClick()?????????????????????????????д?÷?????
	??????????????£?
	public static boolean longClickWithTime(UiObject obj?? long time) throws Exception {
	Class<?> InteractionControllerClass = null;
	Method findAccessibilityNodeInfoMethod = null;
	Method getInteractionControllerMethod = null;
	Method touchDownMethod = null;
	Method touchUpMethod = null;
	Field WAIT_FOR_SELECTOR_TIMEOUT = null;
	findAccessibilityNodeInfoMethod = UiObject.class.getDeclaredMethod("findAccessibilityNodeInfo"??long.class);
	findAccessibilityNodeInfoMethod.setAccessible(true);
	WAIT_FOR_SELECTOR_TIMEOUT = UiObject.class.getDeclaredField("WAIT_FOR_SELECTOR_TIMEOUT");
	WAIT_FOR_SELECTOR_TIMEOUT.setAccessible(true);
	AccessibilityNodeInfo node = (AccessibilityNodeInfo) findAccessibilityNodeInfoMethod.invoke(obj?? WAIT_FOR_SELECTOR_TIMEOUT.getLong(obj));
	if(node == null) {
	throw new UiObjectNotFoundException(obj.getSelector().toString());
	}
	Rect rect = obj.getVisibleBounds();
	getInteractionControllerMethod = UiObject.class.getDeclaredMethod("getInteractionController");
	getInteractionControllerMethod.setAccessible(true);
	Object interactionController = getInteractionControllerMethod.invoke(obj);
	InteractionControllerClass = Class.forName("com.android.uiautomator.core.InteractionController");
	touchDownMethod = InteractionControllerClass.getDeclaredMethod("touchDown"?? int.class?? int.class);
	touchDownMethod.setAccessible(true);
	touchUpMethod = InteractionControllerClass.getDeclaredMethod("touchUp"?? int.class?? int.class);
	touchUpMethod.setAccessible(true);
	if(Boolean.parseBoolean(touchDownMethod.invoke(interactionController?? rect.centerX()?? rect.centerY()).toString())) {
	SystemClock.sleep(time);
	if(Boolean.parseBoolean(touchUpMethod.invoke(interactionController?? rect.centerX()?? rect.centerY()).toString())) {
	return true;
	}
	}
	return false;
	}
	???????÷????
	?????????uiautomator???????????????longClickWithTime(Object?? time)??????????UiObject???????Ч????????Object??????uiautomator UiObject???????time??????????????λ?????
	???????磺????????????????г???5s??????
	????longClickWithTime(new UiCollection(new UiObject(new UiSelector().text("Clock"))?? 5000)??
??????
					
					???·???
App??С????H5?????????????????Щ??
2024/9/11 15:34:34?????????????????????????
2024/9/10 11:13:49P-One ???????????????????????????????????????
2024/9/10 10:14:12???????????????????????????
2024/9/9 18:04:26??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44
					
			
								
								
								
								
								
								
								
								
								
								
				
sales@spasvo.com