File: mergeall-android11-updates-media/MORE--logs-and-code/Permissions-Termux-POST-REINSTALL.txt
#######################################################################################
# Demo Android 11 permissions in the Termux "legacy" app, on a Galaxy Note20 Ultra:
#
# - /sdcard in shared storage, /data is app-private storage (both are internal)
# - /storage/{6C2A-1618 and 8145-191C} are attached MSD and USB drives, respectively
# - /.../Android/data/com.termux/ is app-specific storage, and mostly private in 11
#
# This is the "before" picture - when Termux's permissions are working as they should,
# after running temux-setup-storage to grant access to shared storage and make folders.
#######################################################################################
$ python
Python 3.9.1 (default, Dec 9 2020, 13:22:01)
[Clang 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 98c855489 on linux
Type "help", "copyright", "credits" or "license" for more information.
# APP PRIVATE
>>> open('/data/data/com.termux/xxx.txt', 'w').write('1234')
4
>>> open('/data/data/com.termux/xxx.txt', 'r').read()
'1234'
# SHARED INTERNAL ("LEGACY")
>>> open('/sdcard/xxx.txt', 'w').write('1234')
4
>>> open('/sdcard/xxx.txt', 'r').read()
'1234'
# ONBOARD MSD CARD ROOT
>>> open('/storage/6C2A-1618/xxx.txt', 'w').write('1234')
4
>>> open('/storage/6C2A-1618/xxx.txt', 'r').read()
'1234'
# ATTACHED USB DRIVE: *FAILS*
>>> open('/storage/8145-191C/xxx.txt', 'w').write('1234')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/storage/8145-191C/xxx.txt'
>>>
>>> open('/storage/8145-191C/xxx.txt', 'r').read()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/storage/8145-191C/xxx.txt'
# APP-SPECIFIC (MSD)
>>> open('/storage/6C2A-1618/Android/data/com.termux/xxx.txt', 'w').write('1234')
4
>>> open('/storage/6C2A-1618/Android/data/com.termux/xxx.txt', 'r').read()
'1234'
# APP-SPECIFIC (INTERNAL)
>>> open('/sdcard/Android/data/com.termux/xxx.txt', 'w').write('1234')
4
>>> open('/sdcard/Android/data/com.termux/xxx.txt', 'r').read()
'1234'
# SHARED INTERNAL; MSD; USB (NOT); APP MSD; APP INTERNAL
>>> import os
>>> os.listdir('/sdcard')[:5]
['Samsung', 'Android', 'Music', 'Podcasts', 'Ringtones']
>>>
>>> os.listdir('/storage/6C2A-1618')[:5]
['.com.apple.timemachine.donotpresent', '._.NO-.nomedia', 'MY-STUFF', '.DS_Store', '._.DS_Store']
>>>
>>> os.listdir('/storage/8145-191C')[:5]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/storage/8145-191C'
>>>
>>> os.listdir('/storage/6C2A-1618/Android/data/com.termux')[:5]
['files', 'xxx.txt']
>>>
>>> os.listdir('/sdcard/Android/data/com.termux')[:5]
['files', 'test', 'xxx.txt']