GitHub Issue | n/a |
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-02-22T16:21:33.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.1.0 |
Components | Android |
Labels | android, cache, permissions |
Reporter | Sergey Volkov |
Assignee | Gary Mathews |
Created | 2017-10-13T12:52:01.000+0000 |
Updated | 2018-03-02T16:34:42.000+0000 |
HTTP response caching is disabled, if "WRITE_EXTERNAL_STORAGE" is not granted.
After TIMOB-20470 directory for cache is taken by '.getCacheDir()' or '.getExternalCacheDir().
No permissions required to write files in this directories.
Hello, What seems to be the issue here? Any particular error you see or application not functioning properly?
Hi. Problem is that HTTP responses are not cached on Android API 23+, if "WRITE_EXTERNAL_STORAGE" is not granted. Cache directory ("/
[^app.js] How it works now: * First click on button creates request, image is cached in memory, cache directory is empty. No requests are created for later clicks. * After app restart all operate same way (one request for first click). What I expect: * First click on button creates request, image is cached in memory, also image is chaced in storage directory. No requests are created for later clicks. * After app restart no requests are created, image is taken from cache.
Hello, I tried to test your sample code. I click on the button shows a small android icon in the window. for additional click, the new icon is coming up beneath the previous one. Can you explain the testing process? Thanks.
You will need an emulator with Android API 23+ 1. Install app 2. You should not change default permissions in app settings ("Storage" is disabled by default) 3. Run application 4. Check cache directory ("/
I can confirm this: Images loaded via http(s) are not cached in filesystem (tmp dir) for Android by default. They are only cached after the WRITE_EXTERNAL_STORAGE permission is granted. But this permission is not necessary for writing to the tmp dir. I cant explain it any better than s.volkov already did. So the question is: Why is WRITE_EXTERNAL_STORAGE required for TiRepsonseCache to work under android? Is this a bug or is there another dependency we are missing here?
Originally, TiResponseCache wrote to directory on external storage. There was no restrictions to write to external storage. In Android API 23 permissions model was changed, so apps could not write to external storage without permisson. In TIMOB-20251 this problem was solved in wrong way ("No caching if permission is not enabled" [commit](https://github.com/appcelerator/titanium_mobile/commit/1868b11f98a09381a921540c1e660a1872405880)) Since Android API 8, 'Context.getExternalCacheDir()' is available, and in TIMOB-20470 I made appropriate change.
https://github.com/appcelerator/titanium_mobile/pull/9596
[~jquick] Can you review the community PR for 7.1.0?
7_1_X: https://github.com/appcelerator/titanium_mobile/pull/9838
Master and 7_1_x eerged test and other information can be found at: Master: https://github.com/appcelerator/titanium_mobile/pull/9596 7_1_X: https://github.com/appcelerator/titanium_mobile/pull/9838
Closing ticket; Verified fix in SDK Version: 7.1.0.v20180228160738 and SDK Version: 7.2.0.v20180301101144.