def get_possible_input(view_list):    possible_events = []    enabled_view_ids = []    touch_exclude_view_ids = set()    for view_dict in view_list:        if view_dict['enabled'] and \           view_dict['resource_id'] not in \           ['android:id/navigationBarBackground',            'android:id/statusBarBackground']:            enabled_view_ids.append(view_dict['temp_id'])
    for view_id in enabled_view_ids:        if view_list[view_id]['scrollable']:            possible_events.append(ScrollEvent(view=views_list[view_id], direction="UP"))            possible_events.append(ScrollEvent(view=views_list[view_id], direction="DOWN"))            possible_events.append(ScrollEvent(view=views_list[view_id], direction="LEFT"))            possible_events.append(ScrollEvent(view=views_list[view_id], direction="RIGHT"))        elif view_list[view_id]['clickable']:            possible_events.append(TouchEvent(view=views_list[view_id]))            touch_exclude_view_ids.add(view_id)        # elif views_list[view_id]['enabled'] and \        #     views_list[view_id]['focusable']:        #     possible_events.append(TouchEvent(view=views_list[view_id]))    return possible_eventsfor view_id in enabled_view_ids:    if views_list[view_id]['scrollable']:        possible_events.append(ScrollEvent(view=views_list[view_id], direction="UP"))        # possible_events.append(ScrollEvent(view=views_list[view_id], direction="DOWN"))        possible_events.append(ScrollEvent(view=views_list[view_id], direction="LEFT"))        possible_events.append(ScrollEvent(view=views_list[view_id], direction="RIGHT"))
for view_id in enabled_view_ids:    if views_list[view_id]['clickable']:        possible_events.append(TouchEvent(view=views_list[view_id]))        touch_exclude_view_ids.add(view_id)def filter_possible_input(possible_events,origin_dim=[1080, 1920]):    filter_events = []    for event in possible_events:        # 过滤坐标为负的值        bounds = event.view["bounds"]        bounds = [bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1]]        x_min = max(0, bounds[0])        y_min = max(0, bounds[1])        x_max = min(origin_dim[0], bounds[2])        y_max = min(origin_dim[1], bounds[3])        if x_min >= x_max or y_min >= y_max:            continue        # 更新bounds坐标点        event.view["bounds"] = [[x_min,y_min],[x_max,y_max]]
        # 过滤小于5个像素的event        if (y_max-y_min) < 5:            pass        else:            filter_events.append(event)
    return filter_events
评论