diff --git a/pythonforandroid/bootstraps/common/build/build.py b/pythonforandroid/bootstraps/common/build/build.py index 28457c1edd..7d54a6f02b 100644 --- a/pythonforandroid/bootstraps/common/build/build.py +++ b/pythonforandroid/bootstraps/common/build/build.py @@ -470,6 +470,13 @@ def make_package(args): # Folder name for launcher (used by SDL2 bootstrap) url_scheme = 'kivy' + # Copy backup rules file if specified and update the argument + if args.backup_rules: + res_xml_dir = join(res_dir, 'xml') + ensure_dir(res_xml_dir) + shutil.copy(join(args.private, args.backup_rules), res_xml_dir) + args.backup_rules = split(args.backup_rules)[1][:-4] + # Render out android manifest: manifest_path = "src/main/AndroidManifest.xml" render_args = { @@ -758,6 +765,13 @@ def parse_args_and_make_package(args=None): help='Set the launch mode of the main activity in the manifest.') ap.add_argument('--allow-backup', dest='allow_backup', default='true', help="if set to 'false', then android won't backup the application.") + ap.add_argument('--backup-rules', dest='backup_rules', default='', + help=('Backup rules for Android Auto Backup. Argument is a ' + 'filename containing xml. The filename should be ' + 'located relative to the private directory containing your source code ' + 'files (containing your main.py entrypoint). ' + 'See https://developer.android.com/guide/topics/data/' + 'autobackup#IncludingFiles for more information')) ap.add_argument('--no-optimize-python', dest='optimize_python', action='store_false', default=True, help=('Whether to compile to optimised .pyo files, using -OO ' diff --git a/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml b/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml index 8d2557090e..ef65b3a7ff 100644 --- a/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml +++ b/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml @@ -58,6 +58,7 @@ {% if debug %}android:debuggable="true"{% endif %} android:icon="@drawable/icon" android:allowBackup="{{ args.allow_backup }}" + {% if args.backup_rules %}android:fullBackupContent="@xml/{{ args.backup_rules }}"{% endif %} android:theme="{{args.android_apptheme}}{% if not args.window %}.Fullscreen{% endif %}" android:hardwareAccelerated="true" > {% for l in args.android_used_libs %} diff --git a/pythonforandroid/bootstraps/service_only/build/templates/AndroidManifest.tmpl.xml b/pythonforandroid/bootstraps/service_only/build/templates/AndroidManifest.tmpl.xml index 95a5ed1e19..9c48546d85 100644 --- a/pythonforandroid/bootstraps/service_only/build/templates/AndroidManifest.tmpl.xml +++ b/pythonforandroid/bootstraps/service_only/build/templates/AndroidManifest.tmpl.xml @@ -47,7 +47,8 @@ {% for l in args.android_used_libs %} @@ -72,7 +73,7 @@ {% if service %} {% endif %} {% for name in service_names %} diff --git a/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml b/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml index ae28b8b28c..648de9d1d6 100644 --- a/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml +++ b/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml @@ -47,7 +47,8 @@ -->