Ë
    Ñ—Äj6(  ã                  ó  — U d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZ  G d	„ d
e«      Zdd„Z e
d¬«      dd„«       Z ej$                  dej&                  «      Zded<   dd„Zdd„Ze	dd„«       Zd
gZy)zAndroid.é    )ÚannotationsN)Úsuppress)ÚcacheÚ	lru_cache)ÚFinalé   )ÚPlatformDirsABCc                  óö  — e Zd ZdZedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Z	edd„«       Z
edd„«       Zedd	„«       Zedd
„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zy)ÚAndroidaî  Platform directories for Android.

    Follows the guidance `from here <https://android.stackexchange.com/a/216132>`_. Directories are typically located
    under the app's private storage (``/data/user/<userid>/<packagename>/``).

    Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`, `version
    <platformdirs.api.PlatformDirsABC.version>`, `opinion <platformdirs.api.PlatformDirsABC.opinion>`, `ensure_exists
    <platformdirs.api.PlatformDirsABC.ensure_exists>`.

    c                ó:   — | j                  t        «       dd¬«      S )z\Data directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/files/<AppName>``.ÚfilesT©Úprivate©Ú_append_app_name_and_versionÚ_require_android_folder©Úselfs    úYC:\Users\pivot\Documents\cueki\casual-preloader\Lib\site-packages\platformdirs/android.pyÚuser_data_dirzAndroid.user_data_dir   ó!   € ð ×0Ñ0Ô1HÓ1JÈGÐ]aÐ0ÓbÐbó    c                ó   — | j                   S )z8Data directory shared by users, same as `user_data_dir`.©r   r   s    r   Úsite_data_dirzAndroid.site_data_dir    ó   € ð ×!Ñ!Ð!r   c                ó:   — | j                  t        «       dd¬«      S )zeConfig directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/shared_prefs/<AppName>``.Úshared_prefsTr   r   r   s    r   Úuser_config_dirzAndroid.user_config_dir%   s!   € ð ×0Ñ0Ô1HÓ1JÈNÐdhÐ0ÓiÐir   c                ó   — | j                   S )z<Config directory shared by users, same as `user_config_dir`.©r   r   s    r   Úsite_config_dirzAndroid.site_config_dir*   ó   € ð ×#Ñ#Ð#r   c                ó:   — | j                  t        «       dd¬«      S )z]Cache directory tied to the user, e.g.,``/data/user/<userid>/<packagename>/cache/<AppName>``.r   Tr   r   r   s    r   Úuser_cache_dirzAndroid.user_cache_dir/   r   r   c                ó   — | j                   S )z:Cache directory shared by users, same as `user_cache_dir`.)r%   r   s    r   Úsite_cache_dirzAndroid.site_cache_dir4   ó   € ð ×"Ñ"Ð"r   c                ó   — | j                   S )z:State directory tied to the user, same as `user_data_dir`.r   r   s    r   Úuser_state_dirzAndroid.user_state_dir9   r   r   c                ó   — | j                   S )z:State directory shared by users, same as `user_state_dir`.)r*   r   s    r   Úsite_state_dirzAndroid.site_state_dir>   r(   r   c                óœ   — | j                   }| j                  r3t        j                  j	                  |d«      }| j                  |d¬«       |S )zŸLog directory tied to the user, same as `user_cache_dir` if not opinionated else ``log`` in it, e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>/log``.ÚlogTr   ©r%   ÚopinionÚosÚpathÚjoinÚ_optionally_create_directory©r   r2   s     r   Úuser_log_dirzAndroid.user_log_dirC   óB   € ð ×"Ñ"ˆØ�<Š<Ü—7‘7—<‘<  eÓ,ˆDØ×-Ñ-¨d¸DÐ-ÔAØˆr   c                ó   — | j                   S )z6Log directory shared by users, same as `user_log_dir`.)r6   r   s    r   Úsite_log_dirzAndroid.site_log_dirL   ó   € ð × Ñ Ð r   c                ó   — t        d«      S )zLDocuments directory tied to the user e.g. ``/storage/emulated/0/Documents``.Ú	Documents©Ú_android_public_folderr   s    r   Úuser_documents_dirzAndroid.user_documents_dirQ   s   € ô & kÓ2Ð2r   c                ó   — t        d«      S )zKDownloads directory tied to the user e.g. ``/storage/emulated/0/Download``.ÚDownloadr=   r   s    r   Úuser_downloads_dirzAndroid.user_downloads_dirV   ó   € ô & jÓ1Ð1r   c                ó   — t        d«      S )zJPictures directory tied to the user e.g. ``/storage/emulated/0/Pictures``.ÚPicturesr=   r   s    r   Úuser_pictures_dirzAndroid.user_pictures_dir[   rC   r   c                ó   — t        d«      S )zFVideos directory tied to the user e.g. ``/storage/emulated/0/Movies``.ÚMoviesr=   r   s    r   Úuser_videos_dirzAndroid.user_videos_dir`   s   € ô & hÓ/Ð/r   c                ó   — t        d«      S )zDMusic directory tied to the user e.g. ``/storage/emulated/0/Music``.ÚMusicr=   r   s    r   Úuser_music_dirzAndroid.user_music_dire   s   € ô & gÓ.Ð.r   c                ó   — t        «       › d�S )zRDesktop directory tied to the user e.g. ``/storage/emulated/0/Documents/Desktop``.z/Documents/Desktop©Ú_shared_storager   s    r   Úuser_desktop_dirzAndroid.user_desktop_dirk   s   € ô "Ó#Ð$Ð$6Ð7Ð7r   c                ó   — t        «       › d�S )zTProjects directory tied to the user e.g. ``/storage/emulated/0/Documents/Projects``.z/Documents/ProjectsrN   r   s    r   Úuser_projects_dirzAndroid.user_projects_dirp   s   € ô "Ó#Ð$Ð$7Ð8Ð8r   c                ó   — t        «       › d�S )zVPublic share directory tied to the user e.g. ``/storage/emulated/0/Documents/Public``.z/Documents/PublicrN   r   s    r   Úuser_publicshare_dirzAndroid.user_publicshare_diru   s   € ô "Ó#Ð$Ð$5Ð6Ð6r   c                ó   — t        «       › d�S )zVTemplates directory tied to the user e.g. ``/storage/emulated/0/Documents/Templates``.z/Documents/TemplatesrN   r   s    r   Úuser_templates_dirzAndroid.user_templates_dirz   s   € ô "Ó#Ð$Ð$8Ð9Ð9r   c                ó   — t        «       › d�S )zNFonts directory tied to the user e.g. ``/storage/emulated/0/Documents/fonts``.z/Documents/fontsrN   r   s    r   Úuser_fonts_dirzAndroid.user_fonts_dir   s   € ô "Ó#Ð$Ð$4Ð5Ð5r   c                ó   — | j                   S )zCPreference directory tied to the user, same as ``user_config_dir``.r!   r   s    r   Úuser_preference_dirzAndroid.user_preference_dir„   r#   r   c                óT   — t         j                  j                  t        «       dd«      S )zUBin directory tied to the user, e.g. ``/data/user/<userid>/<packagename>/files/bin``.r   Úbin)r1   r2   r3   r   r   s    r   Úuser_bin_dirzAndroid.user_bin_dir‰   s   € ô �w‰w�|‰|Ô3Ó5°wÀÓFÐFr   c                ó   — | j                   S )z6Bin directory shared by users, same as `user_bin_dir`.)r]   r   s    r   Úsite_bin_dirzAndroid.site_bin_dirŽ   r:   r   c                ó   — | j                   S )zAApplications directory tied to the user, same as `user_data_dir`.r   r   s    r   Úuser_applications_dirzAndroid.user_applications_dir“   r   r   c                ó   — | j                   S )zHApplications directory shared by users, same as `user_applications_dir`.)ra   r   s    r   Úsite_applications_dirzAndroid.site_applications_dir˜   s   € ð ×)Ñ)Ð)r   c                óœ   — | j                   }| j                  r3t        j                  j	                  |d«      }| j                  |d¬«       |S )z£Runtime directory tied to the user, same as `user_cache_dir` if not opinionated else ``tmp`` in it, e.g. ``/data/user/<userid>/<packagename>/cache/<AppName>/tmp``.ÚtmpTr   r/   r5   s     r   Úuser_runtime_dirzAndroid.user_runtime_dir�   r7   r   c                ó   — | j                   S )z>Runtime directory shared by users, same as `user_runtime_dir`.)rf   r   s    r   Úsite_runtime_dirzAndroid.site_runtime_dir¦   s   € ð ×$Ñ$Ð$r   N©ÚreturnÚstr) Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   r   r   r"   r%   r'   r*   r,   r6   r9   r?   rB   rF   rI   rL   rP   rR   rT   rV   rX   rZ   r]   r_   ra   rc   rf   rh   © r   r   r   r      s+  „ ñ	ð òcó ðcð ò"ó ð"ð òjó ðjð ò$ó ð$ð òcó ðcð ò#ó ð#ð ò"ó ð"ð ò#ó ð#ð òó ðð ò!ó ð!ð ò3ó ð3ð ò2ó ð2ð ò2ó ð2ð ò0ó ð0ð ò/ó ð/ð
 ò8ó ð8ð ò9ó ð9ð ò7ó ð7ð ò:ó ð:ð ò6ó ð6ð ò$ó ð$ð òGó ðGð ò!ó ð!ð ò"ó ð"ð ò*ó ð*ð òó ðð ò%ó ñ%r   r   c                 ó8   — t        «       x} €d}t        |«      ‚| S )Nzfcannot find the Android app folder: python4android and pyjnius failed and no app folder is on sys.path)Ú_android_folderÚRuntimeError)ÚfolderÚmsgs     r   r   r   ¬   s%   € Ü!Ó#Ð#ˆÐ,ØvˆÜ˜3ÓÐØ€Mr   )Úmaxsizec                 óx  — t        «       } | €Ut        j                  dt        j                  «      }t        j
                  D ]  }|j                  |«      x}sŒ|d   }  n d} | €Vt        j                  dt        j                  «      }t        j
                  D ]  }|j                  |«      x}sŒ|d   }  | S  d} | S )zF:returns: base folder for the Android OS or None if it cannot be foundNa3  
            (?P<folder>
                /data/(?:data|user/\d+)  # internal storage of the primary user or of user N
                /[^/]+                   # package name, one path segment
            )
            /files                       # the files directory the interpreter runs from
            ru   aˆ  
            (?P<folder>
                /mnt/expand/[a-fA-F0-9-]{36}  # adopted storage volume, named by its UUID
                /(?:data|user/\d+)             # the primary user or user N
                /[^/]+                         # package name, one path segment
            )
            /files                             # the files directory the interpreter runs from
            )Ú_python_for_android_folderÚreÚcompileÚVERBOSEÚsysr2   Úmatch)ÚresultÚpatternr2   r~   s       r   rs   rs   ³   sÌ   € ô (Ó)€FØ€~ô —*‘*ðô �J‰Jó	
ˆô —H”HˆDØŸ™ dÓ+Ð+ˆuÑ+Ø˜x™�Ùð ð
 ˆFØ€~ô —*‘*ðô �J‰Jó

ˆô —H”HˆDØŸ™ dÓ+Ð+ˆuÑ+Ø˜x™�Øð €Mð ð
 ˆFØ€Mr   z¼
    /user/         # the per-user data root, under /data or an adopted /mnt/expand volume
    (?P<user>\d+)  # the Android user id
    /              # followed by the package folder
    r   Ú_USER_IDc                 ó`   — t         j                  t        «       xs d«      x} r| d   nd}d|› �S )NÚ ÚuserÚ0z/storage/emulated/)r�   Úsearchrs   )r~   r„   s     r   rO   rO   ë   s6   € ä&.§o¡o´oÓ6GÒ6MÈ2Ó&NÐN˜UÐNˆ5�Š=ÐUX€DØ ˜vÐ&Ð&r   c                 ój  — t        t        «      5  ddlm} m} t        | «      5   |d«      j
                  x}€ |d«      j                  }|�>|j                  «       j                  «       j                  «       cd d d «       cd d d «       S 	 d d d «       d d d «       y # 1 sw Y   ŒxY w# 1 sw Y   y xY w)Nr   ©ÚJavaExceptionÚ	autoclasszorg.kivy.android.PythonActivityzorg.kivy.android.PythonService)
r   ÚImportErrorÚjniusr‰   rŠ   Ú	mActivityÚmServiceÚgetFilesDirÚgetParentFileÚgetAbsolutePath)r‰   rŠ   Úcontexts      r   ry   ry   ñ   s™   € Ü	”+Õ	ß2ä�mÕ$á$Ð%FÓG×QÑQÐQ�ÐZÙ#Ð$DÓE×NÑN�ØÐ"Ø×*Ñ*Ó,×:Ñ:Ó<×LÑLÓN÷ %Ð$÷ 
Ñ	ð #÷	 %÷ 
ð ÷ %Ð$ú÷ 
ð ús)   �B)¤ABÁ8	B)ÂB)ÂB&	Â"B)Â)B2c                ó  — t        t        «      5  ddlm}m} t        |«      5   |d«      j                  | «      j                  «       cd d d «       cd d d «       S # 1 sw Y   nxY w	 d d d «       n# 1 sw Y   nxY wt        «       › d| › �S )Nr   rˆ   zandroid.os.EnvironmentÚ/)r   r‹   rŒ   r‰   rŠ   Ú!getExternalStoragePublicDirectoryr‘   rO   )Únamer‰   rŠ   s      r   r>   r>   þ   sr   € ä	”+Õ	ß2ä�mÕ$ÙÐ5Ó6×XÑXÐY]Ó^×nÑnÓp÷ %Ð$÷ 
Ñ	÷ %Ð$úÐ$÷ 
×	Ñ	úô
 ÓÐ   $ Ð(Ð(s"   �A2¤%AÁ		A2ÁA%	Á!A2Á2A;ri   )rj   z
str | None)r–   rk   rj   rk   )ro   Ú
__future__r   r1   rz   r}   Ú
contextlibr   Ú	functoolsr   r   Útypingr   Úapir	   r   r   rs   r{   r|   r�   Ú__annotations__rO   ry   r>   Ú__all__rq   r   r   Ú<module>rž      sŸ   ðÚ å "ã 	Û 	Û 
Ý ß &Ý å  ôZ%ˆoô Z%ózñ �1Ôò*ó ð*ðZ �"—*‘*ðð
 ‡J�Jó€ˆ%ó ó'ó
ð ò)ó ð)ð ð�r   