Protect static global access with a global flag.

  - The global objects are protected by a global flag, during
    application teardown.
  - The following APIs, which could potentially be called during
    application teardown, will be NO-OP if global objects are no
    longer alive.
        rsContextCreate
        rsContextCreateGL
        rsContextDestroy
   - Added a test of the problematic use-cases.

   Detailed discussion:
   https://goto.google.com/rs-static-destructor

Bug: 62027113

Test: mm
Test: Before the change to rsApiStubs.cpp, the test hangs during
termination.
Test: After the change to rsApiStubs.cpp, the test passes without any
problems.
Change-Id: I7a43a61d9ccf848c17a88e047e97d087132addda

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