Details
-
Type:
Improvement
-
Status: Closed
-
Priority:
High
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: Release 9.3.0
-
Component/s: Android
-
Labels:
-
Story Points:8
-
Epic Link:
-
Sprint:2020 Sprint 21
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
- is blocked by
-
TIMOB-28059 Android: Modify Ti.Media APIs to use scoped storage
-
- Closed
-
- relates to
-
TIMOB-28176 Android: createTempDirectory() does not create a directory
-
- Closed
-
-
TIMOB-28177 Android: createTempFile() should create file under Ti.Filesystem.tempDirectory
-
- Closed
-