Fix issue #881: Add android.allow_backup parameter to buildozer.spec (#1206)

* Add android.allow_backup parameter to buildozer.spec
* Rework patch to only use --allow-backup when it is set to false
* Added testcase for android.allow_backup
* Added default value for android.allow_backup to spec
This commit is contained in:
Jorilx 2020-08-14 15:35:13 +02:00 committed by GitHub
parent 4a18fb321e
commit 7bf9f39709
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 0 deletions

View file

@ -228,6 +228,9 @@ android.arch = armeabi-v7a
# this is not the same as app version and should only be edited if you know what you're doing
# android.numeric_version = 1
# (bool) enables Android auto backup feature (Android API >=23)
android.allow_backup = True
#
# Python for android (p4a) specific
#

View file

@ -1158,6 +1158,11 @@ class TargetAndroid(Target):
if numeric_version:
build_cmd += [("--numeric-version", numeric_version)]
# android.allow_backup
allow_backup = config.getbooldefault('app', 'android.allow_backup', True)
if not allow_backup:
build_cmd += [('--allow-backup', 'false')]
# build only in debug right now.
if self.build_mode == 'debug':
build_cmd += [("debug", )]

View file

@ -298,3 +298,29 @@ class TestTargetAndroid:
]
)
]
def test_allow_backup(self):
"""The `android.allow_backup` config should be passed to `build_package()`."""
target_android = init_target(self.temp_dir, {
"android.allow_backup": "false"
})
buildozer = target_android.buildozer
m_execute_build_package = call_build_package(target_android)
assert m_execute_build_package.call_args_list == [
mock.call(
[
("--name", "'My Application'"),
("--version", "0.1"),
("--package", "org.test.myapp"),
("--minsdk", "21"),
("--ndk-api", "21"),
("--private", "{buildozer_dir}/android/app".format(buildozer_dir=buildozer.buildozer_dir)),
("--android-entrypoint", "org.kivy.android.PythonActivity"),
("--android-apptheme", "@android:style/Theme.NoTitleBar"),
("--orientation", "portrait"),
("--window",),
("--allow-backup", "false"),
("debug",),
]
)
]