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

Android: Change Ti.Filesystem "temp" APIs to use app's cache folder

    Details

      Description

      Summary:
      The following APIs need to use app's scoped storage and avoid external storage.

      • Ti.Filesystem.createTempDirectory()
      • Ti.Filesystem.createTempFile()
      • Ti.Filesystem.tempDirectory

      Note 1:
      We should write temp files according to Google's docs in the link below. They expect us to explicitly set the temp directory to the app's cache directory.
      https://developer.android.com/training/data-storage/app-specific#internal-create-cache

      Note 2:
      Our Ti.Filesystem.tempDirectory property return...

      ./<AppCacheDir>/_tmp
      

      Our Ti.Filesystem.createTempFile() and Ti.Filesystem.createTempDirectory() methods should change their base directory to the below to avoid collision with the above folder.

      ./<AppCacheDir>/.titanium/tmp
      

      Note 3:
      Our TiTempFileHelper.java code (used to acquire a temp directory path) will use getExternalCacheDir() or getCacheDir() depending on if it has access to external storage or not. This may not be a good idea since the temp directory can suddenly change at runtime due to...

      • End-user granting permission, making it dynamically switch to external storage.
      • End-user ejects SD card, which makes temp path switch to internal storage.

      It would be better for the path to be consistent for the app's lifetime. So, it should be hardcoded to internal storage via getCacheDir() like Google's examples.

      Note 4:
      Our HTTP response cache should favor internal storage's cache directory for improved security/privacy. That is what Google suggests in the link below and is what the Chrome browser app does. External storage is best used for large files intended to be shared (like downloaded files).
      https://developer.android.com/reference/android/net/http/HttpResponseCache

      If we do this, then we can remove our startExternalStorageMonitor() related code in TiApplication.java and hard-code our TiResponseCache to always be the default. This means HTTP response caching will alway be enabled, even if you don't have external storage permission.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jquick Joshua Quick
                Reporter:
                jquick Joshua Quick
                Reviewer:
                Gary Mathews
                Tester:
                Satyam Sekhri
              • Watchers:
                6 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