Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-28182

Android: Only add WRITE_EXTERNAL_STORAGE permission when needed

    Details

      Description

      Synopsis:
      The "AndroidManifest.xml" permission WRITE_EXTERNAL_STORAGE is ignored when targeting Android 10+ and running on those Android OS versions. This is because of scoped-storage and Google only allows an app to write to very particular folders on external storage. The app's sandboxed folders on external storage no longer require permission as of Android 4.4.
      https://developer.android.com/training/data-storage/shared/media#request-permissions

      To-Do:
      The Titanium build system should be changed to only inject this permission when needed based on JavaScript APIs used.

      If the Ti.Filesystem.requestStoragePermissions() method is used, then the permission should be added as before like this. This is the only method that requires this permission on Android 10 and above.

      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
      

      If Ti.Media.showCamera() or Ti.Media.saveToPhotoGallery() methods are used, then we should add a maxSdkVersion attribute set to Android 9 since external storage access is not required on Android 10 and higher.

      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
      

      If none of the above JavaScript methods are detected, then we should NOT add this permission.

      Note:
      If the "tiapp.xml" adds the WRITE_EXTERNAL_STORAGE permission, then it should take priority and the above should be ignored.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jquick Joshua Quick
                Reporter:
                jquick Joshua Quick
                Reviewer:
                Gary Mathews
                Tester:
                Lokesh Choudhary
              • Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration