summaryrefslogtreecommitdiff
path: root/system/blueberry/utils/ui_pages/utils.py
blob: f73d198520c34334ee5fe2faa8f5cd826f05119a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Utilities used by ui_pages module."""
from typing import Any, Callable, Dict


def dr_wakeup_before_op(op: Callable[..., Any]) -> Callable[..., Any]:
  """Sends keycode 'KEYCODE_WAKEUP' before conducting UI function.

  Args:
    op: UI function (click, swipe etc.)

  Returns:
    Wrapped UI function.
  """
  def _wrapper(*args: Any, **kargs: Dict[str, Any]) -> Callable[..., Any]:
    """Wrapper of UI function.

    Args:
      *args: Argument list passed into UI function.
      **kargs: key/value argument passed into UI function.

    Returns:
      The returned result by calling the wrapped UI operation method.
    """

    ui_page_self = args[0]
    ui_page_self.ctx.ad.adb.shell(
        'input keyevent KEYCODE_WAKEUP')
    return op(*args, **kargs)

  return _wrapper