Gordon icon indicating copy to clipboard operation
Gordon copied to clipboard

Add '-g' to install flags

Open vladcudoidem opened this issue 2 years ago • 5 comments

The Google Bundletool version 1.15.0+ provides the functionality to also set the -g install flag, in addition to -d, -r and -t, which are already set as of now. Some tests require extra permissions, which is not a problem if all requested permissions are automatically granted at runtime (which is what -g does).

As the diff shows, I've only updated the bundletool dependency and added the flag in the Device.installApk() and Device.installApkSet() extension functions.

vladcudoidem avatar Nov 22 '23 17:11 vladcudoidem

Please tell me if I missed something.

vladcudoidem avatar Nov 22 '23 17:11 vladcudoidem

I'm not sure this is the best idea. At the very least we'd want to make this configurable, and let devs opt in to this behavior. I'm not so sure it's needed at all though - is there a problem with just using GrantPermissionRule in your tests?

joshschriever avatar Nov 29 '23 16:11 joshschriever

Good point. I was not aware of the GrantPermissionRule. I'll check that out. By the way, are you aware of any Rule that does the opposite (revokes permissions)?

vladcudoidem avatar Dec 02 '23 11:12 vladcudoidem

No, I don't know of a rule that revokes permissions. But if I understand GrantPermissionRule correctly, it grants permissions only for the current instrumentation. So the way Gordon works, I think it should grant permissions only for the tests the rule is applied to, and not others.

joshschriever avatar Dec 04 '23 16:12 joshschriever

Alright, thanks! Only one thing to add here: GrantPermissionRule might not solve the problem if the requested permission is an install-time permission. I say 'might', because I have not tested it yet (and I unfortunately cannot test it right now) and because the docs say that the rule only grants runtime permissions.

If it does grant those permissions as well, then the change that I proposed in this PR is of no use. But if it does not, then I do not think that there is any other way to grant install-time permissions for tests. (Or maybe I am missing some obvious solution?)

Update: Just now I noticed that a Rule that grants install-time permissions makes little to no sense, as a Rule only gets the chance to do anything long after installation.

vladcudoidem avatar Dec 04 '23 17:12 vladcudoidem