-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Support permission properties (maxSdkVersion
and usesPermissionFlags
) + remove WRITE_EXTERNAL_STORAGE
permission, which has been previously declared by default
#2725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… + remove WRITE_EXTERNAL_STORAGE permission, which has been previously required by default
ced6f70
to
c28ae30
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice thanks!
else: | ||
_permissions.append(dict(name=f"android.permission.{permission}")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to add a warning in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean a deprecation warning? I thought the same, but then I decided to go with the slow path instead in order to avoid a large increase in support requests (users may start panicking 😀).
I did not officially deprecated it by purpose, instead, I've changed the docs and added a warning regarding "name-only" permissions.
There's a lot of documentation, posts, videos, etc ... which is referring to "name-only" permissions (And we even need to migrate buildozer
and python-for-android
examples).
What do you think about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes sense 👍
tests/test_bootstrap_build.py
Outdated
try: | ||
parsed_permissions = buildpy.parse_permissions(args.permissions) # noqa: F841 | ||
except ValueError as _e: | ||
assert "Property 'propertyThatFails' is not supported." in str(_e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the exception isn't raised, the test won't catch it.
So we either want to make it fail explicitly after the parse_permissions()
something like self.fail("ValueError not raised")
or use something like the pytest.raises context manager e.g. with pytest.raises(ValueError, match="Property 'propertyThatFails' is not supported."):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for catching this beginner-like error! 😓
Addressed.
…gs`) + remove `WRITE_EXTERNAL_STORAGE` permission, which has been previously declared by default (kivy#2725) * Support permission properties (maxSdkVersion and usesPermissionFlags) + remove WRITE_EXTERNAL_STORAGE permission, which has been previously required by default * Fix test for ValueError
The
--permission
argument historically only accepted something like--permission android.permission.WRITE_EXTERNAL_STORAGE
and--permission VIBRATE
which is not enough in certain use cases.As an example, when dealing with bluetooth permissions and targeting API 31, the legacy
android.permission.BLUETOOTH
andandroid.permission.BLUETOOTH_ADMIN
permissions need the propertyandroid:maxSdkVersion
be set to30
, andthe
"android.permission.BLUETOOTH_SCAN
needs to strongly assert that the app never derives physical location from Bluetooth scan results viaandroid:usesPermissionFlags="neverForLocation"
.Basically, nowadays, android permissions declarations need a lot of fine-tuning, which is not possible at this time via
python-for-android
, unless an extra manifest is used.This PR introduces a new syntax:
--permission (name=android.permission.WRITE_EXTERNAL_STORAGE;maxSdkVersion=18)
that allows the user to set every single (and currently available/supported) property of the<uses-permission>
element.The old syntaxes are migrated before the template gets processed, so users will only notice this change when needed, and when reading the docs.
I also started to add some tests for our
build.py
script. I needed to add a switch to skip some things as ATM are not patchable (at least easily). The whole script needs some refactoring in order to be well-tested.