Users can now view the permissions requests themselves.
In the Android section, it was observed that no application for a permission has been applied! The codes I sent are enough to solve this problem.
Users can now view the permissions requests themselves.
In the Android section, it was observed that no application for a permission has been applied! The codes I sent are enough to solve this problem.
Users can now view the permissions requests themselves.
37+@Override
38+public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
39+ switch (requestCode) {
40+ case REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS: {
41+ Map<String, Integer> perms = new HashMap<String, Integer>();
42+ perms.put(Manifest.permission.ACCESS_FINE_LOCATION, PackageManager.PERMISSION_GRANTED);
ACCESS_FINE_LOCATION
?
Ops! This is my mistake, We don’t need to this permission I’ll remove this in the next commit.
Can you tell me all permissions that used in bitcoin core? I’ll set them all in the next level.
Of course I have a plan for iOS version too.
56+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
57 }
58 }
59+
60+@TargetApi(Build.VERSION_CODES.M)
61+private void fuckMarshMallow() {
60+@TargetApi(Build.VERSION_CODES.M)
61+private void fuckMarshMallow() {
62+ List<String> permissionsNeeded = new ArrayList<String>();
63+ final List<String> permissionsList = new ArrayList<String>();
64+ if (!addPermission(permissionsList, Manifest.permission.ACCESS_FINE_LOCATION))
65+ permissionsNeeded.add("Show Location");
485@@ -486,6 +486,14 @@ int GuiMain(int argc, char* argv[])
486 QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
487 QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
488 QApplication::setAttribute(Qt::AA_DontUseNativeDialogs);
489+
490+ // Add new safety native permission dialog for R/W actions.
491+ static const QString write_permission = "android.permission.WRITE_EXTERNAL_STORAGE";
492+ if (QtAndroid::checkPermission(write_permission) == QtAndroid::PermissionResult::Denied)
Java method removed from BitcoinQtActivity.
We use the QtAndroid method instead.
Note: The androidextras module must be added into the project.
This method is enough.
Thank you for cleaning up the Java part @KambizAsadzadeh.
Can you please fix the CI and give us a brief rationale for the PR? What are you able to do with these changes that you weren’t able to do before?
Thank you for cleaning up the Java part @KambizAsadzadeh.
You’re welcome!
Can you please fix the CI and give us a brief rationale for the PR? What are you able to do with these changes that you weren’t able to do before?
Check this please: https://github.com/bitcoin-core/gui/blob/57982f419e36d0023c83af2dd0d683ca3160dc2a/src/qt/android/AndroidManifest.xml#L6
In this section there is a request for permission to write on storage right? Well, In this case a native dialog must be displayed to accept or reject this request and this is important in terms of privacy. This is not possible by default and you must do this manually. :)
Like this one: https://github.com/KambizAsadzadeh/gui/blob/450c5464bfd8ee57d2eb7594b2ba207ee6eca64a/src/qt/bitcoin.cpp#L492
We have two ways to do this, one is to use Java code or JNI inside C++ and the other (I suggest the C++ method) is to use method checkPermission on QtAndroid class. this method checks if the permission was granted or not. This function should be called every time when the application starts for needed permissions, as the users might disable them from Android Settings.
Thank you for clarifying @KambizAsadzadeh. This is something that is needed but if we follow good practices probably doesn’t belong at startup as not all users will opt to use external storage.
According to the docs:
Wait for the user to invoke the task or action in your app that requires access to specific private user data. At that time, your app can request the runtime permission that’s required for accessing that data.
IMO there should be a GUI prompt/explainer and only then should we trigger the OS modal to ask for these permissions. Something to discuss with the design team?
Thank you for clarifying @KambizAsadzadeh. This is something that is needed but if we follow good practices probably doesn’t belong at startup as not all users will opt to use external storage.
According to the docs:
Wait for the user to invoke the task or action in your app that requires access to specific private user data. At that time, your app can request the runtime permission that’s required for accessing that data.
You’re welcome, Thank you for your good comments.
I agree with you regarding UX terms, In my opinion, it’s better to call the QtAndroid::checkPermission
method where this permission is needed instead of startup. Can you show me the part you used for writing external storage?
Rule 4:
Check whether the user has already granted the runtime permission that your app requires. If so, your app can access the private user data. If not, continue to the next step. You must check whether you have that permission every time you perform an operation that requires that permission.
Can you show me the part you used for writing external storage?
I never used external storage, my hardware doesn’t even have such an option.
As it stands right now we use the .bitcoin
folder in app sandbox. I think I enabled WRITE_EXTERNAL_STORAGE
because I believed this would be granted without user intervention. In that case one could change the conf and use the SD.
I realise that external storage is a big use-case (people repurposing old phones) so moving forward I suggest we either:
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
KambizAsadzadeh
hebasto
icota
DrahtBot
Labels
Android