[Libreoffice-commits] core.git: android/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Nov 2 00:32:27 UTC 2018


 android/source/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java |    3 ---
 android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java                      |   10 +++++-----
 2 files changed, 5 insertions(+), 8 deletions(-)

New commits:
commit 187a3db08ecc0e42787aa57d8b4ed67aa9c37e74
Author:     Mert Tumer <merttumer at outlook.com>
AuthorDate: Wed Oct 24 11:41:25 2018 +0300
Commit:     Gülşah Köse <gulsah.1004 at gmail.com>
CommitDate: Fri Nov 2 01:31:59 2018 +0100

    Fix permission settings on Android Viewer
    
    We ask READ_EXTERNAL_STORAGE permission on first start
    then check WRITE_EXTERNAL_STORAGE permission on switching
    between document providers. This causes problems on Android 8+
    Signed-off-by: Mert Tumer <merttumer at outlook.com>
    
    Change-Id: Ia7290e33b2a55f5a2197374ca39c60998edfff72
    Reviewed-on: https://gerrit.libreoffice.org/62269
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
    Tested-by: Jenkins

diff --git a/android/source/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java b/android/source/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java
index c2e03dfc7bdd..15522e93a45e 100644
--- a/android/source/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java
+++ b/android/source/src/java/org/libreoffice/storage/local/LocalDocumentsDirectoryProvider.java
@@ -48,9 +48,6 @@ public class LocalDocumentsDirectoryProvider extends LocalDocumentsProvider {
     public IFile getRootDirectory(Context context) {
         File documentsDirectory = getDocumentsDir();
         if (!documentsDirectory.exists()) {
-            // might be a little counter-intuitive: if we were granted READ permission already, we're also granted the write-permission
-            // when we ask for it, since they are both in the same storage group (for 5.1 and lower it is granted at install-time already)
-            // see https://developer.android.com/guide/topics/permissions/requesting.html#perm-groups
             if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
                 if(!documentsDirectory.mkdirs()) {
                     // fallback to the toplevel dir - might be due to the dir not mounted/used as USB-Mass-Storage or similar
diff --git a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
index d6501f08bd85..3fb715e46778 100644
--- a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -99,7 +99,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
     private String displayLanguage;
 
     // dynamic permissions IDs
-    private static final int PERMISSION_READ_EXTERNAL_STORAGE = 0;
+    private static final int PERMISSION_WRITE_EXTERNAL_STORAGE = 0;
 
     FileFilter fileFilter;
     FilenameFilter filenameFilter;
@@ -949,11 +949,11 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
     @Override
     protected void onStart() {
         super.onStart();
-        if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
+        if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
             Log.i(LOGTAG, "no permission to read external storage - asking for permission");
             ActivityCompat.requestPermissions(this,
-                    new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
-                    PERMISSION_READ_EXTERNAL_STORAGE);
+                    new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
+                    PERMISSION_WRITE_EXTERNAL_STORAGE);
         } else {
             switchToDocumentProvider(documentProviderFactory.getDefaultProvider());
             setEditFABVisibility(View.VISIBLE);
@@ -1207,7 +1207,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings
     @Override
     public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
         switch(requestCode){
-            case PERMISSION_READ_EXTERNAL_STORAGE:
+            case PERMISSION_WRITE_EXTERNAL_STORAGE:
                 if(permissions.length>0 && grantResults[0] == PackageManager.PERMISSION_GRANTED){
                     switchToDocumentProvider(documentProviderFactory.getDefaultProvider());
                     setEditFABVisibility(View.VISIBLE);


More information about the Libreoffice-commits mailing list