Set the default cachedir during context create.

 - Use JNI reflection to access RenderScriptCacheDir.mCacheDir, and set
 it immediately after the context is created.
 - Java or C++ APIs could still call ContextSetCacheDir to override it.
 - The JNI query is guarded by std::unique_lock to make sure that the
 current thread is the only one attached to JNI.
 - This change ensures that vendors could always get a valid code cache
 dir even with support lib path, as RenderScriptCacheDir.mCacheDir is
 set by ActivityThread.java when launching the application, regardless
 of using RenderScript or not.

Bug: 34396220
Test: mm, CTS tests pass, tested with RSTest_CompatLib to make sure that
support lib path is covered.

Change-Id: I542ed2fe03e34b72e85398271b748c0053a35ae3
3 files changed
tree: d5e95935e191d70fde7a566fe00f10ee8c724bb1
  1. cpp/
  2. cpu_ref/
  3. driver/
  4. rsov/
  5. script_api/
  6. support/
  7. tests/
  8. Android.bp
  9. Android.mk
  10. build_rs.py
  11. CleanSpec.mk
  12. libRS.map
  13. rs.h
  14. rs.spec
  15. rs_compat.spec
  16. rs_hal.h
  17. rsAllocation.cpp
  18. rsAllocation.h
  19. rsAnimation.cpp
  20. rsAnimation.h
  21. rsApiAllocation.cpp
  22. rsApiContext.cpp
  23. rsApiDevice.cpp
  24. rsApiElement.cpp
  25. rsApiFileA3D.cpp
  26. rsApiMesh.cpp
  27. rsApiStubs.cpp
  28. rsApiStubs.h
  29. rsApiType.cpp
  30. rsClosure.cpp
  31. rsClosure.h
  32. rsCompatibilityLib.h
  33. rsComponent.cpp
  34. rsComponent.h
  35. rsContext.cpp
  36. rsContext.h
  37. rsCppUtils.cpp
  38. rsCppUtils.h
  39. rsDebugHelper.h
  40. rsDefines.h
  41. rsDevice.cpp
  42. rsDevice.h
  43. rsDriverLoader.cpp
  44. rsElement.cpp
  45. rsElement.h
  46. rsEnv.h
  47. rsFallbackAdaptation.cpp
  48. rsFallbackAdaptation.h
  49. rsFBOCache.cpp
  50. rsFBOCache.h
  51. rsFifo.h
  52. rsFifoSocket.cpp
  53. rsFifoSocket.h
  54. rsFileA3D.cpp
  55. rsFileA3D.h
  56. rsFont.cpp
  57. rsFont.h
  58. rsg.spec
  59. rsg_generator.c
  60. rsgApi.cpp.rsg
  61. rsgApiFuncDecl.h.rsg
  62. rsgApiReplay.cpp.rsg
  63. rsgApiStructs.h.rsg
  64. rsGrallocConsumer.cpp
  65. rsGrallocConsumer.h
  66. rsHidlAdaptation.cpp
  67. rsHidlAdaptation.h
  68. rsInternalDefines.h
  69. rsList.h
  70. rsMap.h
  71. rsMatrix2x2.cpp
  72. rsMatrix2x2.h
  73. rsMatrix3x3.cpp
  74. rsMatrix3x3.h
  75. rsMatrix4x4.cpp
  76. rsMatrix4x4.h
  77. rsMesh.cpp
  78. rsMesh.h
  79. rsMutex.cpp
  80. rsMutex.h
  81. rsObjectBase.cpp
  82. rsObjectBase.h
  83. rsProgram.cpp
  84. rsProgram.h
  85. rsProgramBase.h
  86. rsProgramFragment.cpp
  87. rsProgramFragment.h
  88. rsProgramRaster.cpp
  89. rsProgramRaster.h
  90. rsProgramStore.cpp
  91. rsProgramStore.h
  92. rsProgramVertex.cpp
  93. rsProgramVertex.h
  94. rsRuntime.h
  95. rsSampler.cpp
  96. rsSampler.h
  97. rsScript.cpp
  98. rsScript.h
  99. rsScriptC.cpp
  100. rsScriptC.h
  101. rsScriptC_Lib.cpp
  102. rsScriptC_LibGL.cpp
  103. rsScriptGroup.cpp
  104. rsScriptGroup.h
  105. rsScriptGroup2.cpp
  106. rsScriptGroup2.h
  107. rsScriptGroupBase.h
  108. rsScriptIntrinsic.cpp
  109. rsScriptIntrinsic.h
  110. rsSignal.cpp
  111. rsSignal.h
  112. rsStream.cpp
  113. rsStream.h
  114. rsThreadIO.cpp
  115. rsThreadIO.h
  116. rsType.cpp
  117. rsType.h
  118. rsUtils.h
  119. run_rs_cts.sh
  120. spec.h
  121. spec.l
  122. update-prebuilts.py
  123. update_rs_prebuilts.sh