
    ^j                     n    d dl mZmZmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ  G d dee	e      Zy	)
    )DictListUnion)UnknownMethodException)CanExecuteCommands)CanExecuteScripts)CanRememberExtensionPresence)MobileCommandc                   X    e Zd Z	 d	dededeedf   deee      fdZdee   fdZd
dZ	y)PerformanceNpackage_name	data_typedata_read_timeoutreturnc                     d}||d}	 | j                  |      j                  ||      S # t        $ r< |||d<   | j                  |      j	                  t
        j                  |      d   cY S w xY w)a  Returns the information of the system state
        which is supported to read as like cpu, memory, network traffic, and battery.

        Android only.

        Args:
            package_name: The package name of the application
            data_type: The type of system state which wants to read.
                It should be one of the supported performance data types.
                Check :func:`.get_performance_data_types` for supported types
            data_read_timeout: The number of attempts to read

        Usage:
            self.driver.get_performance_data('my.app.package', 'cpuinfo', 5)

        Returns:
            The data along to `data_type`
        zmobile: getPerformanceData)packageNamedataTypedataReadTimeoutvalue)assert_extension_existsexecute_scriptr   mark_extension_absenceexecuteCommandGET_PERFORMANCE_DATA)selfr   r   r   ext_nameargss         c/home/ubuntu/.local/lib/python3.12/site-packages/appium/webdriver/extensions/android/performance.pyget_performance_dataz Performance.get_performance_data   s    * 0;GU^+_	n//9HHSWXX% 	n ,*;&'..x8@@A]A]_cdelmm		ns    * AA/.A/c                     d}	 | j                  |      j                  |      S # t        $ r4 | j                  |      j	                  t
        j                        d   cY S w xY w)a  Returns the information types of the system state
        which is supported to read as like cpu, memory, network traffic, and battery.
        Android only.

        Usage:
            self.driver.get_performance_data_types()

        Returns:
            Available data types
        zmobile: getPerformanceDataTypesr   )r   r   r   r   r   r   GET_PERFORMANCE_DATA_TYPES)r   r   s     r   get_performance_data_typesz&Performance.get_performance_data_types9   sd     5	n//9HHRR% 	n..x8@@AcAcdelmm	ns   $ :A! A!c                     | j                   j                  t        j                  dd       | j                   j                  t        j                  dd       y )NPOSTz-/session/$sessionId/appium/getPerformanceDataz0/session/$sessionId/appium/performanceData/types)command_executoradd_commandr   r   r"   )r   s    r   _add_commandszPerformance._add_commandsK   sJ    ))((;	

 	))..>	
    )N)r   N)
__name__
__module____qualname__strr   intr   r    r#   r(    r)   r   r   r      sW    W[nn,/nDI#t)DTn	d3in>nDI n$

r)   r   N)typingr   r   r   selenium.common.exceptionsr   /appium.protocols.webdriver.can_execute_commandsr   .appium.protocols.webdriver.can_execute_scriptsr   :appium.protocols.webdriver.can_remember_extension_presencer	   appium.webdriver.mobilecommandr
   r   r   r/   r)   r   <module>r6      s/    % $ = N L c C<
$&79U <
r)   