mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
android: don't use external storage
so that we don't need the extra permission. also because phones these days have enough internal storage for the headers; and maybe it's better even for security reasons to store it there. no upgrade path is provided for the headers stored on external storage, we will litter the filesystem and leave them there. they will be downloaded again into internal storage.
This commit is contained in:
parent
29b697df1a
commit
b21064f16f
2 changed files with 3 additions and 33 deletions
|
@ -52,7 +52,7 @@ fullscreen = False
|
|||
#
|
||||
|
||||
# (list) Permissions
|
||||
android.permissions = INTERNET, WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE, CAMERA
|
||||
android.permissions = INTERNET, CAMERA
|
||||
|
||||
# (int) Android API to use
|
||||
android.api = 28
|
||||
|
|
|
@ -354,41 +354,11 @@ def profiler(func):
|
|||
return lambda *args, **kw_args: do_profile(args, kw_args)
|
||||
|
||||
|
||||
def android_ext_dir():
|
||||
import jnius
|
||||
env = jnius.autoclass('android.os.Environment')
|
||||
return env.getExternalStorageDirectory().getPath()
|
||||
|
||||
def android_data_dir():
|
||||
import jnius
|
||||
PythonActivity = jnius.autoclass('org.kivy.android.PythonActivity')
|
||||
return PythonActivity.mActivity.getFilesDir().getPath() + '/data'
|
||||
|
||||
def android_headers_dir():
|
||||
d = android_ext_dir() + '/org.electrum.electrum'
|
||||
if not os.path.exists(d):
|
||||
try:
|
||||
os.mkdir(d)
|
||||
except FileExistsError:
|
||||
pass # in case of race
|
||||
return d
|
||||
|
||||
def android_check_data_dir():
|
||||
""" if needed, move old directory to sandbox """
|
||||
ext_dir = android_ext_dir()
|
||||
data_dir = android_data_dir()
|
||||
old_electrum_dir = ext_dir + '/electrum'
|
||||
if not os.path.exists(data_dir) and os.path.exists(old_electrum_dir):
|
||||
import shutil
|
||||
new_headers_path = android_headers_dir() + '/blockchain_headers'
|
||||
old_headers_path = old_electrum_dir + '/blockchain_headers'
|
||||
if not os.path.exists(new_headers_path) and os.path.exists(old_headers_path):
|
||||
print_error("Moving headers file to", new_headers_path)
|
||||
shutil.move(old_headers_path, new_headers_path)
|
||||
print_error("Moving data to", data_dir)
|
||||
shutil.move(old_electrum_dir, data_dir)
|
||||
return data_dir
|
||||
|
||||
|
||||
def ensure_sparse_file(filename):
|
||||
# On modern Linux, no need to do anything.
|
||||
|
@ -401,7 +371,7 @@ def ensure_sparse_file(filename):
|
|||
|
||||
|
||||
def get_headers_dir(config):
|
||||
return android_headers_dir() if 'ANDROID_DATA' in os.environ else config.path
|
||||
return config.path
|
||||
|
||||
|
||||
def assert_datadir_available(config_path):
|
||||
|
@ -484,7 +454,7 @@ def bh2u(x: bytes) -> str:
|
|||
|
||||
def user_dir():
|
||||
if 'ANDROID_DATA' in os.environ:
|
||||
return android_check_data_dir()
|
||||
return android_data_dir()
|
||||
elif os.name == 'posix':
|
||||
return os.path.join(os.environ["HOME"], ".electrum")
|
||||
elif "APPDATA" in os.environ:
|
||||
|
|
Loading…
Add table
Reference in a new issue