Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25507] Android. TiResponseCache. Permission

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-02-22T16:21:33.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.1.0
ComponentsAndroid
Labelsandroid, cache, permissions
ReporterSergey Volkov
AssigneeGary Mathews
Created2017-10-13T12:52:01.000+0000
Updated2018-03-02T16:34:42.000+0000

Description

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.

Attachments

FileDateSize
0001-remove-external_storage-permission-requirement-for-c.patch2017-10-13T12:44:56.000+00001687
app.js2017-11-07T10:58:07.000+0000511

Comments

  1. Sharif AbuDarda 2017-10-21

    Hello, What seems to be the issue here? Any particular error you see or application not functioning properly?
  2. Sergey Volkov 2017-10-24

    Hi. Problem is that HTTP responses are not cached on Android API 23+, if "WRITE_EXTERNAL_STORAGE" is not granted. Cache directory ("//Android/data//cache/_tmp/remote-cache") is empty. But fixing this by asking user for "WRITE_EXTERNAL_STORAGE" is wrong, because access to this directory is not restricted by this permission. Take a look at TIMOB-20251 and TIMOB-20470.
  3. Sergey Volkov 2017-11-07

    [^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.
  4. Sharif AbuDarda 2017-11-11

    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.
  5. Sergey Volkov 2017-11-13

    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 ("//Android/data//cache/_tmp/remote-cache"). It should be empty. 5. Run "tcpdump -n -i eth1 host docs.appcelerator.com" in emulator shell. (you may have different device name) 6. Click on the button 6.1. Packets are shown in tcpdump 6.2. Small android icon appear in the window 6.3. Cache directory is still empty 7. Close app; stop/start tcpdump; run app 8. Click on the button 8.1. Packets are shown in tcpdump 8.2. Small android icon appear in the window 8.3. Cache directory is still empty Expected result (SDK with [^0001-remove-external_storage-permission-requirement-for-c.patch]): 6.3. Cache directory is not empty 8.1. No packets in tcpdump 8.3. Cache directory is not empty
  6. Low Bird 2017-11-13

    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?
  7. Sergey Volkov 2017-11-13

    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.
  8. Sergey Volkov 2017-11-14

    https://github.com/appcelerator/titanium_mobile/pull/9596
  9. Hans Knöchel 2017-11-14

    [~jquick] Can you review the community PR for 7.1.0?
  10. Gary Mathews 2018-02-15

    7_1_X: https://github.com/appcelerator/titanium_mobile/pull/9838
  11. Samir Mohammed 2018-02-22

    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
  12. Samir Mohammed 2018-03-02

    Closing ticket; Verified fix in SDK Version: 7.1.0.v20180228160738 and SDK Version: 7.2.0.v20180301101144.

JSON Source