appium-espresso-driver 10.2.1 → 10.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/lib/commands/server/builder.d.ts +9 -0
  3. package/build/lib/commands/server/builder.d.ts.map +1 -1
  4. package/build/lib/commands/server/builder.js +23 -0
  5. package/build/lib/commands/server/builder.js.map +1 -1
  6. package/build/lib/commands/server/hints.d.ts +28 -0
  7. package/build/lib/commands/server/hints.d.ts.map +1 -0
  8. package/build/lib/commands/server/hints.js +54 -0
  9. package/build/lib/commands/server/hints.js.map +1 -0
  10. package/build/lib/commands/server/runner.d.ts +7 -0
  11. package/build/lib/commands/server/runner.d.ts.map +1 -1
  12. package/build/lib/commands/server/runner.js +43 -4
  13. package/build/lib/commands/server/runner.js.map +1 -1
  14. package/espresso-server/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk +0 -0
  15. package/espresso-server/app/build.gradle.kts +91 -1
  16. package/espresso-server/app/src/androidTestShaded/AndroidManifest.xml +16 -0
  17. package/espresso-server/buildSrc/.gradle/9.7.1/executionHistory/executionHistory.bin +0 -0
  18. package/espresso-server/buildSrc/.gradle/9.7.1/executionHistory/executionHistory.lock +0 -0
  19. package/espresso-server/buildSrc/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  20. package/espresso-server/buildSrc/.gradle/buildOutputCleanup/cache.properties +1 -1
  21. package/espresso-server/buildSrc/build/classes/kotlin/main/META-INF/buildSrc.kotlin_module +0 -0
  22. package/espresso-server/buildSrc/build/classes/kotlin/main/io/appium/espressoserver/gradle/AnnotationSkipper$visitField$1$1.class +0 -0
  23. package/espresso-server/buildSrc/build/classes/kotlin/main/io/appium/espressoserver/gradle/AnnotationSkipper$visitMethod$1$1.class +0 -0
  24. package/espresso-server/buildSrc/build/classes/kotlin/main/io/appium/espressoserver/gradle/AnnotationSkipper.class +0 -0
  25. package/espresso-server/buildSrc/build/classes/kotlin/main/io/appium/espressoserver/gradle/MemberRef.class +0 -0
  26. package/espresso-server/buildSrc/build/classes/kotlin/main/io/appium/espressoserver/gradle/PrefixRemapper.class +0 -0
  27. package/espresso-server/buildSrc/build/classes/kotlin/main/io/appium/espressoserver/gradle/RelocateClassesTask$run$$inlined$groupingBy$1.class +0 -0
  28. package/espresso-server/buildSrc/build/classes/kotlin/main/io/appium/espressoserver/gradle/RelocateClassesTask$run$$inlined$sortedByDescending$1.class +0 -0
  29. package/espresso-server/buildSrc/build/classes/kotlin/main/io/appium/espressoserver/gradle/RelocateClassesTask$run$9$1.class +0 -0
  30. package/espresso-server/buildSrc/build/classes/kotlin/main/io/appium/espressoserver/gradle/RelocateClassesTask$run$remapper$1.class +0 -0
  31. package/espresso-server/buildSrc/build/classes/kotlin/main/io/appium/espressoserver/gradle/RelocateClassesTask.class +0 -0
  32. package/espresso-server/buildSrc/build/classes/kotlin/main/io/appium/espressoserver/gradle/RelocationKt$memberReferences$1$visitMethod$1.class +0 -0
  33. package/espresso-server/buildSrc/build/classes/kotlin/main/io/appium/espressoserver/gradle/RelocationKt$memberReferences$1.class +0 -0
  34. package/espresso-server/buildSrc/build/classes/kotlin/main/io/appium/espressoserver/gradle/RelocationKt$referencedClasses$collector$1.class +0 -0
  35. package/espresso-server/buildSrc/build/classes/kotlin/main/io/appium/espressoserver/gradle/RelocationKt$shareNonPublicDependents$Declared.class +0 -0
  36. package/espresso-server/buildSrc/build/classes/kotlin/main/io/appium/espressoserver/gradle/RelocationKt.class +0 -0
  37. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
  38. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
  39. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
  40. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
  41. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
  42. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
  43. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
  44. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
  45. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
  46. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
  47. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
  48. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
  49. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
  50. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
  51. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
  52. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
  53. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
  54. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
  55. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab +0 -0
  56. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.keystream +0 -0
  57. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.keystream.len +0 -0
  58. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.len +0 -0
  59. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.values.at +0 -0
  60. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab_i +0 -0
  61. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab_i.len +0 -0
  62. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
  63. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
  64. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
  65. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
  66. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
  67. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
  68. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab +0 -0
  69. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.keystream +0 -0
  70. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.keystream.len +0 -0
  71. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.len +0 -0
  72. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.values.at +0 -0
  73. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab_i +0 -0
  74. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
  75. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
  76. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
  77. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
  78. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  79. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
  80. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
  81. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
  82. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
  83. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
  84. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
  85. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
  86. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
  87. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
  88. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
  89. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
  90. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
  91. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
  92. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
  93. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
  94. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
  95. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
  96. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
  97. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
  98. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
  99. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
  100. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/counters.tab +1 -1
  101. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
  102. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
  103. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
  104. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
  105. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
  106. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
  107. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
  108. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
  109. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
  110. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
  111. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
  112. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
  113. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
  114. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
  115. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  116. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
  117. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
  118. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
  119. package/espresso-server/buildSrc/build/kotlin/compileKotlin/cacheable/last-build.bin +0 -0
  120. package/espresso-server/buildSrc/build/kotlin/compileKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
  121. package/espresso-server/buildSrc/build/libs/buildSrc.jar +0 -0
  122. package/espresso-server/buildSrc/build.gradle.kts +6 -0
  123. package/espresso-server/buildSrc/src/main/kotlin/io/appium/espressoserver/gradle/RelocateClassesTask.kt +141 -0
  124. package/espresso-server/buildSrc/src/main/kotlin/io/appium/espressoserver/gradle/Relocation.kt +342 -0
  125. package/espresso-server/buildSrc/src/test/kotlin/io/appium/espressoserver/gradle/RelocationTest.kt +186 -0
  126. package/espresso-server/library/src/main/java/io/appium/espressoserver/lib/handlers/ListIdlingResources.kt +2 -1
  127. package/espresso-server/library/src/main/java/io/appium/espressoserver/lib/helpers/ShadingHelpers.kt +45 -0
  128. package/espresso-server/library/src/main/java/io/appium/espressoserver/lib/helpers/Version.kt +1 -1
  129. package/espresso-server/library/src/main/java/io/appium/espressoserver/lib/http/response/AppiumResponse.kt +3 -2
  130. package/espresso-server/library/src/main/java/io/appium/espressoserver/lib/model/HamcrestMatcher.kt +8 -5
  131. package/espresso-server/library/src/test/java/io/appium/espressoserver/test/helpers/ShadingHelpersTest.kt +37 -0
  132. package/lib/commands/server/builder.ts +29 -0
  133. package/lib/commands/server/hints.ts +69 -0
  134. package/lib/commands/server/runner.ts +53 -5
  135. package/node_modules/appium-adb/CHANGELOG.md +7 -0
  136. package/node_modules/appium-adb/package.json +3 -3
  137. package/node_modules/appium-android-driver/CHANGELOG.md +23 -0
  138. package/node_modules/appium-android-driver/build/lib/commands/bidi/helpers.d.ts +10 -0
  139. package/node_modules/appium-android-driver/build/lib/commands/bidi/helpers.d.ts.map +1 -0
  140. package/node_modules/appium-android-driver/build/lib/commands/bidi/helpers.js +15 -0
  141. package/node_modules/appium-android-driver/build/lib/commands/bidi/helpers.js.map +1 -0
  142. package/node_modules/appium-android-driver/build/lib/commands/bidi/logcat-level.d.ts +9 -0
  143. package/node_modules/appium-android-driver/build/lib/commands/bidi/logcat-level.d.ts.map +1 -0
  144. package/node_modules/appium-android-driver/build/lib/commands/bidi/logcat-level.js +37 -0
  145. package/node_modules/appium-android-driver/build/lib/commands/bidi/logcat-level.js.map +1 -0
  146. package/node_modules/appium-android-driver/build/lib/commands/device/common.d.ts.map +1 -1
  147. package/node_modules/appium-android-driver/build/lib/commands/device/common.js +2 -0
  148. package/node_modules/appium-android-driver/build/lib/commands/device/common.js.map +1 -1
  149. package/node_modules/appium-android-driver/build/lib/commands/log.d.ts.map +1 -1
  150. package/node_modules/appium-android-driver/build/lib/commands/log.js +5 -1
  151. package/node_modules/appium-android-driver/build/lib/commands/log.js.map +1 -1
  152. package/node_modules/appium-android-driver/build/lib/commands/media-stream/exports.d.ts.map +1 -1
  153. package/node_modules/appium-android-driver/build/lib/commands/media-stream/exports.js +2 -4
  154. package/node_modules/appium-android-driver/build/lib/commands/media-stream/exports.js.map +1 -1
  155. package/node_modules/appium-android-driver/lib/commands/bidi/helpers.ts +16 -0
  156. package/node_modules/appium-android-driver/lib/commands/bidi/logcat-level.ts +40 -0
  157. package/node_modules/appium-android-driver/lib/commands/device/common.ts +2 -0
  158. package/node_modules/appium-android-driver/lib/commands/log.ts +5 -1
  159. package/node_modules/appium-android-driver/lib/commands/media-stream/exports.ts +2 -11
  160. package/node_modules/appium-android-driver/package.json +5 -5
  161. package/node_modules/appium-chromedriver/CHANGELOG.md +7 -0
  162. package/node_modules/appium-chromedriver/config/mapping.json +1 -0
  163. package/node_modules/appium-chromedriver/package.json +2 -2
  164. package/node_modules/bare-buffer/CMakeLists.txt +3 -3
  165. package/node_modules/bare-buffer/package.json +1 -1
  166. package/node_modules/bare-buffer/prebuilds/android-arm/bare-buffer.bare +0 -0
  167. package/node_modules/bare-buffer/prebuilds/android-arm64/bare-buffer.bare +0 -0
  168. package/node_modules/bare-buffer/prebuilds/android-ia32/bare-buffer.bare +0 -0
  169. package/node_modules/bare-buffer/prebuilds/android-x64/bare-buffer.bare +0 -0
  170. package/node_modules/bare-buffer/prebuilds/darwin-arm64/bare-buffer.bare +0 -0
  171. package/node_modules/bare-buffer/prebuilds/darwin-x64/bare-buffer.bare +0 -0
  172. package/node_modules/bare-buffer/prebuilds/ios-arm64/bare-buffer.bare +0 -0
  173. package/node_modules/bare-buffer/prebuilds/ios-arm64-simulator/bare-buffer.bare +0 -0
  174. package/node_modules/bare-buffer/prebuilds/ios-x64-simulator/bare-buffer.bare +0 -0
  175. package/node_modules/bare-buffer/prebuilds/linux-arm64/bare-buffer.bare +0 -0
  176. package/node_modules/bare-buffer/prebuilds/linux-x64/bare-buffer.bare +0 -0
  177. package/node_modules/bare-buffer/prebuilds/win32-arm64/bare-buffer.bare +0 -0
  178. package/node_modules/bare-buffer/prebuilds/win32-x64/bare-buffer.bare +0 -0
  179. package/node_modules/bare-url/CMakeLists.txt +5 -5
  180. package/node_modules/bare-url/package.json +1 -1
  181. package/node_modules/bare-url/prebuilds/android-arm/bare-url.bare +0 -0
  182. package/node_modules/bare-url/prebuilds/android-arm64/bare-url.bare +0 -0
  183. package/node_modules/bare-url/prebuilds/android-ia32/bare-url.bare +0 -0
  184. package/node_modules/bare-url/prebuilds/android-x64/bare-url.bare +0 -0
  185. package/node_modules/bare-url/prebuilds/darwin-arm64/bare-url.bare +0 -0
  186. package/node_modules/bare-url/prebuilds/darwin-x64/bare-url.bare +0 -0
  187. package/node_modules/bare-url/prebuilds/ios-arm64/bare-url.bare +0 -0
  188. package/node_modules/bare-url/prebuilds/ios-arm64-simulator/bare-url.bare +0 -0
  189. package/node_modules/bare-url/prebuilds/ios-x64-simulator/bare-url.bare +0 -0
  190. package/node_modules/bare-url/prebuilds/linux-arm64/bare-url.bare +0 -0
  191. package/node_modules/bare-url/prebuilds/linux-x64/bare-url.bare +0 -0
  192. package/node_modules/bare-url/prebuilds/win32-arm64/bare-url.bare +0 -0
  193. package/node_modules/bare-url/prebuilds/win32-x64/bare-url.bare +0 -0
  194. package/node_modules/ini/package.json +5 -5
  195. package/node_modules/io.appium.settings/CHANGELOG.md +7 -0
  196. package/node_modules/io.appium.settings/apks/settings_apk-debug.apk +0 -0
  197. package/node_modules/io.appium.settings/package.json +3 -3
  198. package/package.json +4 -4
  199. package/scripts/check-shaded-packages.mjs +106 -0
@@ -0,0 +1,342 @@
1
+ package io.appium.espressoserver.gradle
2
+
3
+ import org.objectweb.asm.AnnotationVisitor
4
+ import org.objectweb.asm.ClassReader
5
+ import org.objectweb.asm.ClassVisitor
6
+ import org.objectweb.asm.ClassWriter
7
+ import org.objectweb.asm.FieldVisitor
8
+ import org.objectweb.asm.Handle
9
+ import org.objectweb.asm.Label
10
+ import org.objectweb.asm.MethodVisitor
11
+ import org.objectweb.asm.Opcodes
12
+ import org.objectweb.asm.TypePath
13
+ import org.objectweb.asm.commons.ClassRemapper
14
+ import org.objectweb.asm.commons.Remapper
15
+ import org.objectweb.asm.tree.ClassNode
16
+ import java.io.File
17
+ import java.nio.file.Files
18
+ import java.nio.file.StandardCopyOption
19
+ import java.util.jar.JarEntry
20
+ import java.util.jar.JarFile
21
+ import java.util.jar.JarOutputStream
22
+
23
+ internal const val SERVICES_DIR = "META-INF/services/"
24
+ private val CLASS_NAME = Regex("[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+\\.[A-Z][A-Za-z0-9_$]*")
25
+
26
+ /** Reads every `.class` of the given jars and directories into a map keyed by internal name. First one wins. */
27
+ internal fun readClasses(jars: Collection<File>, dirs: Collection<File>): Map<String, ByteArray> {
28
+ val classes = LinkedHashMap<String, ByteArray>()
29
+ jars.forEach { f ->
30
+ JarFile(f).use { jar ->
31
+ jar.entries().asSequence()
32
+ .filter { it.name.endsWith(".class") && !it.name.startsWith("META-INF/") }
33
+ .forEach { classes.putIfAbsent(it.name.removeSuffix(".class"), jar.getInputStream(it).readBytes()) }
34
+ }
35
+ }
36
+ dirs.forEach { d ->
37
+ d.walkTopDown().filter { it.isFile && it.name.endsWith(".class") }.forEach {
38
+ classes.putIfAbsent(it.relativeTo(d).invariantSeparatorsPath.removeSuffix(".class"), it.readBytes())
39
+ }
40
+ }
41
+ return classes
42
+ }
43
+
44
+ /** `META-INF/services` files of the given jars and directories: interface name to its provider class names. */
45
+ internal fun readServices(jars: Collection<File>, dirs: Collection<File>): Map<String, Set<String>> {
46
+ val services = LinkedHashMap<String, LinkedHashSet<String>>()
47
+ fun add(name: String, content: ByteArray) {
48
+ content.toString(Charsets.UTF_8).lineSequence()
49
+ .map { it.substringBefore('#').trim() }
50
+ .filter { it.isNotEmpty() }
51
+ .toCollection(services.getOrPut(name.removePrefix(SERVICES_DIR)) { LinkedHashSet() })
52
+ }
53
+ jars.forEach { f ->
54
+ JarFile(f).use { jar ->
55
+ jar.entries().asSequence()
56
+ .filter { it.name.startsWith(SERVICES_DIR) && !it.isDirectory }
57
+ .forEach { add(it.name, jar.getInputStream(it).readBytes()) }
58
+ }
59
+ }
60
+ dirs.forEach { d ->
61
+ d.resolve(SERVICES_DIR).takeIf { it.isDirectory }?.listFiles()?.filter { it.isFile }?.forEach {
62
+ add(SERVICES_DIR + it.name, it.readBytes())
63
+ }
64
+ }
65
+ return services
66
+ }
67
+
68
+ /** Bundled classes that extend a platform view (`android.view.*`, `android.widget.*`), directly or indirectly. */
69
+ internal fun viewTypes(classes: Map<String, ByteArray>): List<String> {
70
+ val superNames = classes.mapValues { (_, bytes) -> ClassReader(bytes).superName }
71
+ fun isView(name: String): Boolean {
72
+ var current = superNames[name]
73
+ while (current != null) {
74
+ if (current.startsWith("android/view/") || current.startsWith("android/widget/")) {
75
+ return true
76
+ }
77
+ current = superNames[current]
78
+ }
79
+ return false
80
+ }
81
+ return classes.keys.filter(::isView)
82
+ }
83
+
84
+ /**
85
+ * Internal names of the classes [bytes] links against (signatures, code, constants).
86
+ * Annotations are skipped: a missing annotation class is ignored at runtime, and following them
87
+ * (e.g. `kotlin.Metadata`) would pull a whole library into the shared set.
88
+ */
89
+ internal fun referencedClasses(bytes: ByteArray, onRef: (String) -> Unit) {
90
+ val collector = object : Remapper() {
91
+ override fun map(internalName: String): String {
92
+ onRef(internalName)
93
+ return internalName
94
+ }
95
+ }
96
+ ClassReader(bytes).accept(AnnotationSkipper(ClassRemapper(ClassWriter(0), collector)), 0)
97
+ }
98
+
99
+ private class AnnotationSkipper(cv: ClassVisitor) : ClassVisitor(Opcodes.ASM9, cv) {
100
+ override fun visitAnnotation(descriptor: String?, visible: Boolean): AnnotationVisitor? = null
101
+ override fun visitTypeAnnotation(
102
+ typeRef: Int, typePath: TypePath?, descriptor: String?, visible: Boolean,
103
+ ): AnnotationVisitor? = null
104
+
105
+ override fun visitField(
106
+ access: Int, name: String?, descriptor: String?, signature: String?, value: Any?,
107
+ ): FieldVisitor? = super.visitField(access, name, descriptor, signature, value)?.let { fv ->
108
+ object : FieldVisitor(Opcodes.ASM9, fv) {
109
+ override fun visitAnnotation(descriptor: String?, visible: Boolean): AnnotationVisitor? = null
110
+ override fun visitTypeAnnotation(
111
+ typeRef: Int, typePath: TypePath?, descriptor: String?, visible: Boolean,
112
+ ): AnnotationVisitor? = null
113
+ }
114
+ }
115
+
116
+ override fun visitMethod(
117
+ access: Int, name: String?, descriptor: String?, signature: String?, exceptions: Array<out String>?,
118
+ ): MethodVisitor? = super.visitMethod(access, name, descriptor, signature, exceptions)?.let { mv ->
119
+ object : MethodVisitor(Opcodes.ASM9, mv) {
120
+ override fun visitAnnotation(descriptor: String?, visible: Boolean): AnnotationVisitor? = null
121
+ override fun visitAnnotationDefault(): AnnotationVisitor? = null
122
+ override fun visitParameterAnnotation(
123
+ parameter: Int, descriptor: String?, visible: Boolean,
124
+ ): AnnotationVisitor? = null
125
+
126
+ override fun visitTypeAnnotation(
127
+ typeRef: Int, typePath: TypePath?, descriptor: String?, visible: Boolean,
128
+ ): AnnotationVisitor? = null
129
+
130
+ override fun visitInsnAnnotation(
131
+ typeRef: Int, typePath: TypePath?, descriptor: String?, visible: Boolean,
132
+ ): AnnotationVisitor? = null
133
+
134
+ override fun visitTryCatchAnnotation(
135
+ typeRef: Int, typePath: TypePath?, descriptor: String?, visible: Boolean,
136
+ ): AnnotationVisitor? = null
137
+
138
+ override fun visitLocalVariableAnnotation(
139
+ typeRef: Int, typePath: TypePath?, start: Array<out Label>?, end: Array<out Label>?,
140
+ index: IntArray?, descriptor: String?, visible: Boolean,
141
+ ): AnnotationVisitor? = null
142
+ }
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Grows [closure] with every class reachable from [roots] through references.
148
+ * A shared class shadows the AUT's copy, so whatever it references must stay shared too.
149
+ */
150
+ internal fun growClosure(classes: Map<String, ByteArray>, closure: MutableSet<String>, roots: Collection<String>) {
151
+ val queue = ArrayDeque<String>()
152
+ roots.filter { it in classes && closure.add(it) }.forEach(queue::add)
153
+ while (queue.isNotEmpty()) {
154
+ referencedClasses(classes.getValue(queue.removeFirst())) { ref ->
155
+ if (ref in classes && closure.add(ref)) {
156
+ queue.add(ref)
157
+ }
158
+ }
159
+ }
160
+ }
161
+
162
+ /**
163
+ * A member that code calls or reads. [staticOrSuper] accesses (static members, `super` calls and `super(...)`)
164
+ * are allowed for subclasses from another package; instance accesses are not, unless the receiver is `this`.
165
+ */
166
+ internal data class MemberRef(val owner: String, val name: String, val desc: String, val staticOrSuper: Boolean)
167
+
168
+ /** Members that the code of [bytes] calls or reads, including method handles. */
169
+ internal fun memberReferences(bytes: ByteArray, onRef: (MemberRef) -> Unit) {
170
+ val staticInsns = setOf(Opcodes.INVOKESTATIC, Opcodes.GETSTATIC, Opcodes.PUTSTATIC)
171
+ val staticHandles = setOf(Opcodes.H_INVOKESTATIC, Opcodes.H_GETSTATIC, Opcodes.H_PUTSTATIC, Opcodes.H_INVOKESPECIAL)
172
+ ClassReader(bytes).accept(
173
+ object : ClassVisitor(Opcodes.ASM9) {
174
+ private var superName: String? = null
175
+
176
+ override fun visit(
177
+ version: Int, access: Int, name: String?, signature: String?, superName: String?,
178
+ interfaces: Array<out String>?,
179
+ ) {
180
+ this.superName = superName
181
+ }
182
+
183
+ override fun visitMethod(
184
+ access: Int, name: String?, descriptor: String?, signature: String?, exceptions: Array<out String>?,
185
+ ): MethodVisitor = object : MethodVisitor(Opcodes.ASM9) {
186
+ private val instantiated = HashSet<String>()
187
+ private val isConstructor = name == "<init>"
188
+
189
+ override fun visitTypeInsn(opcode: Int, type: String) {
190
+ if (opcode == Opcodes.NEW) {
191
+ instantiated.add(type)
192
+ }
193
+ }
194
+
195
+ override fun visitMethodInsn(
196
+ opcode: Int, owner: String, name: String, descriptor: String, isInterface: Boolean,
197
+ ) {
198
+ val staticOrSuper = when {
199
+ opcode in staticInsns -> true
200
+ opcode != Opcodes.INVOKESPECIAL -> false
201
+ // `super(...)` is told from `new Base(...)` by the owner and the absence of NEW
202
+ name == "<init>" -> isConstructor && owner == superName && owner !in instantiated
203
+ else -> true
204
+ }
205
+ onRef(MemberRef(owner, name, descriptor, staticOrSuper))
206
+ }
207
+
208
+ override fun visitFieldInsn(opcode: Int, owner: String, name: String, descriptor: String) =
209
+ onRef(MemberRef(owner, name, descriptor, opcode in staticInsns))
210
+
211
+ override fun visitInvokeDynamicInsn(name: String, descriptor: String, handle: Handle, vararg args: Any) {
212
+ (listOf(handle) + args).filterIsInstance<Handle>()
213
+ .forEach { onRef(MemberRef(it.owner, it.name, it.desc, it.tag in staticHandles)) }
214
+ }
215
+ }
216
+ },
217
+ ClassReader.SKIP_DEBUG or ClassReader.SKIP_FRAMES,
218
+ )
219
+ }
220
+
221
+ /**
222
+ * A relocated class lives in another package than the shared ones, so it cannot use a shared class that is
223
+ * not public (e.g. extend a package-private base class), nor its package-private members, nor its protected ones
224
+ * except for static access of a subclass (an instance receiver cannot be proven to be the subclass).
225
+ * Shares such classes, together with what they reference.
226
+ */
227
+ internal fun shareNonPublicDependents(
228
+ classes: Map<String, ByteArray>,
229
+ closure: MutableSet<String>,
230
+ isKept: (String) -> Boolean,
231
+ ) {
232
+ val references = HashMap<String, Set<String>>()
233
+ val members = HashMap<String, Set<MemberRef>>()
234
+ val readers = HashMap<String, ClassReader>()
235
+ fun reader(name: String) = readers.getOrPut(name) { ClassReader(classes.getValue(name)) }
236
+ val isPublic = { name: String -> reader(name).access and Opcodes.ACC_PUBLIC != 0 }
237
+ // Members visible through the class, with the class that declares them and their access flags
238
+ class Declared(val owner: String, val access: Int)
239
+ val declaredMembers = HashMap<String, Map<String, Declared>>()
240
+ fun membersOf(owner: String): Map<String, Declared> = declaredMembers.getOrPut(owner) {
241
+ val result = HashMap<String, Declared>()
242
+ var current: String? = owner
243
+ while (current != null && current in classes) {
244
+ val node = ClassNode().also { reader(current!!).accept(it, ClassReader.SKIP_CODE or ClassReader.SKIP_DEBUG) }
245
+ (node.methods.map { Triple(it.name, it.desc, it.access) } + node.fields.map { Triple(it.name, it.desc, it.access) })
246
+ .forEach { (name, desc, access) -> result.putIfAbsent(name + desc, Declared(current!!, access)) }
247
+ current = node.superName
248
+ }
249
+ result
250
+ }
251
+ fun isSubclass(name: String, owner: String): Boolean {
252
+ var current: String? = name
253
+ while (current != null && current in classes) {
254
+ if (current == owner) {
255
+ return true
256
+ }
257
+ current = reader(current).superName
258
+ }
259
+ return current == owner
260
+ }
261
+ var changed = true
262
+ while (changed) {
263
+ changed = false
264
+ val nonPublic = closure.filterNotTo(HashSet(), isPublic)
265
+ classes.keys.filter { it !in closure && !isKept(it) }.forEach { name ->
266
+ val refs = references.getOrPut(name) {
267
+ HashSet<String>().also { set -> referencedClasses(classes.getValue(name)) { set.add(it) } }
268
+ }
269
+ val memberRefs = members.getOrPut(name) {
270
+ HashSet<MemberRef>().also { set -> memberReferences(classes.getValue(name)) { set.add(it) } }
271
+ }
272
+ // The symbolic owner may be a subclass of the class that declares the member
273
+ val usesRestrictedMember = memberRefs.any { (owner, memberName, desc, staticOrSuper) ->
274
+ val declared = membersOf(owner)[memberName + desc]
275
+ when {
276
+ declared == null || declared.owner !in closure -> false
277
+ declared.access and (Opcodes.ACC_PUBLIC or Opcodes.ACC_PRIVATE) != 0 -> false
278
+ declared.access and Opcodes.ACC_PROTECTED == 0 -> true
279
+ // Protected: a subclass may use it statically or on `this`
280
+ else -> !isSubclass(name, declared.owner) || !(staticOrSuper || isSubclass(owner, name))
281
+ }
282
+ }
283
+ if (usesRestrictedMember || refs.any { it in nonPublic }) {
284
+ growClosure(classes, closure, listOf(name))
285
+ changed = true
286
+ }
287
+ }
288
+ }
289
+ }
290
+
291
+ /** Moves the classes in [moved] under [prefix] (both slash-separated), including names in string constants. */
292
+ internal class PrefixRemapper(
293
+ private val moved: Set<String>,
294
+ private val prefix: String,
295
+ private val bundled: Set<String> = emptySet(),
296
+ private val onSuspicious: (String) -> Unit = {},
297
+ ) : Remapper() {
298
+ private val movedPackages: Set<String> by lazy { moved.map { it.substringBeforeLast('/', "") }.toSet() }
299
+
300
+ override fun map(internalName: String): String = if (internalName in moved) prefix + internalName else internalName
301
+
302
+ override fun mapValue(value: Any?): Any? {
303
+ if (value is String) {
304
+ // Class names in constants: reflection by name, Kotlin metadata (d2), descriptors
305
+ val slashed = value.replace('.', '/')
306
+ if (slashed in moved) {
307
+ return if (value.contains('/')) prefix + value else (prefix + slashed).replace('/', '.')
308
+ }
309
+ if (value.startsWith("L") && value.endsWith(";") && value.substring(1, value.length - 1) in moved) {
310
+ return "L$prefix${value.substring(1)}"
311
+ }
312
+ // Looks like a class of a relocated package that is not bundled: reflection we cannot follow
313
+ if (CLASS_NAME.matches(value) && slashed !in bundled && slashed.substringBeforeLast('/') in movedPackages) {
314
+ onSuspicious(value)
315
+ }
316
+ }
317
+ return super.mapValue(value)
318
+ }
319
+
320
+ /** Relocated name of a class or service interface/provider given in dotted form. */
321
+ fun mapDotted(name: String): String = map(name.replace('.', '/')).replace('/', '.')
322
+ }
323
+
324
+ /** Rewrites [jar] without the entries named in [names]. */
325
+ fun removeJarEntries(jar: File, names: Set<String>) {
326
+ if (names.isEmpty()) {
327
+ return
328
+ }
329
+ val tmp = File(jar.parentFile, "${jar.name}.tmp")
330
+ JarFile(jar).use { src ->
331
+ JarOutputStream(tmp.outputStream().buffered()).use { dst ->
332
+ src.entries().asSequence().filter { it.name !in names }.forEach { e ->
333
+ dst.putNextEntry(JarEntry(e.name).also { it.time = e.time })
334
+ if (!e.isDirectory) {
335
+ src.getInputStream(e).copyTo(dst)
336
+ }
337
+ dst.closeEntry()
338
+ }
339
+ }
340
+ }
341
+ Files.move(tmp.toPath(), jar.toPath(), StandardCopyOption.REPLACE_EXISTING)
342
+ }
@@ -0,0 +1,186 @@
1
+ package io.appium.espressoserver.gradle
2
+
3
+ import org.junit.Assert.assertEquals
4
+ import org.junit.Test
5
+ import org.objectweb.asm.ClassWriter
6
+ import org.objectweb.asm.Opcodes
7
+
8
+ class RelocationTest {
9
+ private fun clazz(
10
+ name: String,
11
+ superName: String = "java/lang/Object",
12
+ access: Int = Opcodes.ACC_PUBLIC,
13
+ members: ClassWriter.() -> Unit = {},
14
+ ): ByteArray = ClassWriter(0).apply {
15
+ visit(Opcodes.V17, access, name, null, superName, null)
16
+ members()
17
+ visitEnd()
18
+ }.toByteArray()
19
+
20
+ private fun ClassWriter.staticMethod(name: String, access: Int, body: org.objectweb.asm.MethodVisitor.() -> Unit = {}) {
21
+ visitMethod(access or Opcodes.ACC_STATIC, name, "()V", null, null).apply {
22
+ visitCode()
23
+ body()
24
+ visitInsn(Opcodes.RETURN)
25
+ visitMaxs(0, 0)
26
+ visitEnd()
27
+ }
28
+ }
29
+
30
+ private fun share(classes: Map<String, ByteArray>, roots: List<String>): Set<String> {
31
+ val closure = HashSet<String>()
32
+ growClosure(classes, closure, roots)
33
+ shareNonPublicDependents(classes, closure) { false }
34
+ return closure
35
+ }
36
+
37
+ @Test
38
+ fun sharesCallersOfPackagePrivateMembersOfPublicSharedClass() {
39
+ val classes = mapOf(
40
+ "sample/Widget" to clazz("sample/Widget", "android/view/View") {
41
+ staticMethod("touch", 0)
42
+ },
43
+ "sample/Peer" to clazz("sample/Peer") {
44
+ staticMethod("call", Opcodes.ACC_PUBLIC) {
45
+ visitMethodInsn(Opcodes.INVOKESTATIC, "sample/Widget", "touch", "()V", false)
46
+ }
47
+ },
48
+ "sample/Other" to clazz("sample/Other") {
49
+ staticMethod("call", Opcodes.ACC_PUBLIC) {
50
+ visitMethodInsn(Opcodes.INVOKESTATIC, "sample/Widget", "publicOne", "()V", false)
51
+ }
52
+ },
53
+ )
54
+ assertEquals(setOf("sample/Widget", "sample/Peer"), share(classes, viewTypes(classes)))
55
+ }
56
+
57
+ @Test
58
+ fun keepsCallersOfPublicMembersRelocated() {
59
+ val classes = mapOf(
60
+ "sample/Widget" to clazz("sample/Widget", "android/view/View") {
61
+ staticMethod("touch", Opcodes.ACC_PUBLIC)
62
+ },
63
+ "sample/Peer" to clazz("sample/Peer") {
64
+ staticMethod("call", Opcodes.ACC_PUBLIC) {
65
+ visitMethodInsn(Opcodes.INVOKESTATIC, "sample/Widget", "touch", "()V", false)
66
+ }
67
+ },
68
+ )
69
+ assertEquals(setOf("sample/Widget"), share(classes, viewTypes(classes)))
70
+ }
71
+
72
+ @Test
73
+ fun allowsSubclassesToUseProtectedMembers() {
74
+ val classes = mapOf(
75
+ "sample/Widget" to clazz("sample/Widget", "android/view/View") {
76
+ staticMethod("touch", Opcodes.ACC_PROTECTED)
77
+ },
78
+ "sample/Sub" to clazz("sample/Sub", "sample/Widget") {
79
+ staticMethod("call", Opcodes.ACC_PUBLIC) {
80
+ visitMethodInsn(Opcodes.INVOKESTATIC, "sample/Widget", "touch", "()V", false)
81
+ }
82
+ },
83
+ "sample/Peer" to clazz("sample/Peer") {
84
+ staticMethod("call", Opcodes.ACC_PUBLIC) {
85
+ visitMethodInsn(Opcodes.INVOKESTATIC, "sample/Widget", "touch", "()V", false)
86
+ }
87
+ },
88
+ )
89
+ assertEquals(setOf("sample/Widget", "sample/Peer"), share(classes, listOf("sample/Widget")))
90
+ }
91
+
92
+ @Test
93
+ fun sharesSubclassesCallingProtectedInstanceMembersOnOtherReceivers() {
94
+ val classes = mapOf(
95
+ "sample/Base" to clazz("sample/Base") {
96
+ visitMethod(Opcodes.ACC_PROTECTED, "touch", "()V", null, null).apply {
97
+ visitCode()
98
+ visitInsn(Opcodes.RETURN)
99
+ visitMaxs(0, 0)
100
+ visitEnd()
101
+ }
102
+ },
103
+ "sample/Sub" to clazz("sample/Sub", "sample/Base") {
104
+ visitMethod(Opcodes.ACC_PUBLIC or Opcodes.ACC_STATIC, "call", "(Lsample/Base;)V", null, null).apply {
105
+ visitCode()
106
+ visitVarInsn(Opcodes.ALOAD, 0)
107
+ visitMethodInsn(Opcodes.INVOKEVIRTUAL, "sample/Base", "touch", "()V", false)
108
+ visitInsn(Opcodes.RETURN)
109
+ visitMaxs(1, 1)
110
+ visitEnd()
111
+ }
112
+ },
113
+ )
114
+ assertEquals(setOf("sample/Base", "sample/Sub"), share(classes, listOf("sample/Base")))
115
+ }
116
+
117
+ private fun ClassWriter.constructor(access: Int, body: org.objectweb.asm.MethodVisitor.() -> Unit) {
118
+ visitMethod(access, "<init>", "()V", null, null).apply {
119
+ visitCode()
120
+ body()
121
+ visitInsn(Opcodes.RETURN)
122
+ visitMaxs(2, 1)
123
+ visitEnd()
124
+ }
125
+ }
126
+
127
+ private fun baseWithProtectedConstructor() = clazz("sample/Base") {
128
+ constructor(Opcodes.ACC_PROTECTED) {
129
+ visitVarInsn(Opcodes.ALOAD, 0)
130
+ visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false)
131
+ }
132
+ }
133
+
134
+ @Test
135
+ fun sharesSubclassesThatConstructSeparateInstancesWithProtectedConstructors() {
136
+ val classes = mapOf(
137
+ "sample/Base" to baseWithProtectedConstructor(),
138
+ "sample/Sub" to clazz("sample/Sub", "sample/Base") {
139
+ staticMethod("run", Opcodes.ACC_PUBLIC) {
140
+ visitTypeInsn(Opcodes.NEW, "sample/Base")
141
+ visitInsn(Opcodes.DUP)
142
+ visitMethodInsn(Opcodes.INVOKESPECIAL, "sample/Base", "<init>", "()V", false)
143
+ visitInsn(Opcodes.POP)
144
+ }
145
+ },
146
+ )
147
+ assertEquals(setOf("sample/Base", "sample/Sub"), share(classes, listOf("sample/Base")))
148
+ }
149
+
150
+ @Test
151
+ fun keepsSubclassesCallingSuperConstructorRelocated() {
152
+ val classes = mapOf(
153
+ "sample/Base" to baseWithProtectedConstructor(),
154
+ "sample/Sub" to clazz("sample/Sub", "sample/Base") {
155
+ constructor(Opcodes.ACC_PUBLIC) {
156
+ visitVarInsn(Opcodes.ALOAD, 0)
157
+ visitMethodInsn(Opcodes.INVOKESPECIAL, "sample/Base", "<init>", "()V", false)
158
+ }
159
+ },
160
+ )
161
+ assertEquals(setOf("sample/Base"), share(classes, listOf("sample/Base")))
162
+ }
163
+
164
+ @Test
165
+ fun resolvesInheritedMembersReferencedThroughSubclass() {
166
+ val classes = mapOf(
167
+ "sample/Base" to clazz("sample/Base") { staticMethod("touch", 0) },
168
+ "sample/Sub" to clazz("sample/Sub", "sample/Base") {
169
+ staticMethod("run", Opcodes.ACC_PUBLIC) {
170
+ visitMethodInsn(Opcodes.INVOKESTATIC, "sample/Sub", "touch", "()V", false)
171
+ }
172
+ },
173
+ )
174
+ assertEquals(setOf("sample/Base", "sample/Sub"), share(classes, listOf("sample/Base")))
175
+ }
176
+
177
+ @Test
178
+ fun sharesDependentsOfNonPublicSharedClasses() {
179
+ val classes = mapOf(
180
+ "sample/Base" to clazz("sample/Base", access = 0),
181
+ "sample/Unrelated" to clazz("sample/Unrelated"),
182
+ "sample/Child" to clazz("sample/Child", "sample/Base"),
183
+ )
184
+ assertEquals(setOf("sample/Base", "sample/Child"), share(classes, listOf("sample/Base")))
185
+ }
186
+ }
@@ -17,13 +17,14 @@
17
17
  package io.appium.espressoserver.lib.handlers
18
18
 
19
19
  import androidx.test.espresso.IdlingRegistry
20
+ import io.appium.espressoserver.lib.helpers.stripShadedPrefix
20
21
  import io.appium.espressoserver.lib.model.*
21
22
 
22
23
  class ListIdlingResources : RequestHandler<AppiumParams, List<String>> {
23
24
 
24
25
  override fun handleInternal(params: AppiumParams): List<String> {
25
26
  return IdlingRegistry.getInstance().resources.map {
26
- it::class.java.canonicalName!!
27
+ it::class.java.canonicalName!!.stripShadedPrefix()
27
28
  }
28
29
  }
29
30
 
@@ -0,0 +1,45 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.helpers
18
+
19
+ // The build relocates the bundled libraries under this package (see RelocateClassesTask)
20
+ const val SHADED_PACKAGE_PREFIX = "io.appium.espressoserver.shaded."
21
+
22
+ /**
23
+ * Loads a class given by a client. Libraries bundled with the server may be relocated,
24
+ * so the relocated name is tried first.
25
+ */
26
+ fun forNameShaded(name: String): Class<*> =
27
+ try {
28
+ Class.forName(SHADED_PACKAGE_PREFIX + name)
29
+ } catch (e: ClassNotFoundException) {
30
+ Class.forName(name)
31
+ }
32
+
33
+ /**
34
+ * Loads a class given by a client that describes the application under test, e.g. a type to match.
35
+ * The application's own class wins over the relocated copy of the server.
36
+ */
37
+ fun forNameApp(name: String): Class<*> =
38
+ try {
39
+ Class.forName(name)
40
+ } catch (e: ClassNotFoundException) {
41
+ Class.forName(SHADED_PACKAGE_PREFIX + name)
42
+ }
43
+
44
+ /** Hides the relocation from the names that are shown to the user. */
45
+ fun String.stripShadedPrefix(): String = replace(SHADED_PACKAGE_PREFIX, "")
@@ -2,6 +2,6 @@ package io.appium.espressoserver.lib.helpers
2
2
 
3
3
  // This value is updated automatically by the NPM versioning script
4
4
  // It should be in sync with the NPM module version from package.json
5
- private const val VERSION = "10.2.1"
5
+ private const val VERSION = "10.3.0"
6
6
 
7
7
  fun getEspressoServerVersion() = VERSION
@@ -21,6 +21,7 @@ import java.util.UUID
21
21
  import fi.iki.elonen.NanoHTTPD.Response.Status
22
22
  import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
23
23
  import io.appium.espressoserver.lib.handlers.exceptions.MESSAGE_UNKNOWN_ERROR
24
+ import io.appium.espressoserver.lib.helpers.stripShadedPrefix
24
25
 
25
26
  class AppiumResponse : BaseResponse {
26
27
  internal var value: Any? = null
@@ -41,8 +42,8 @@ class AppiumResponse : BaseResponse {
41
42
  private fun formatError(e: AppiumException,
42
43
  originalStacktrace: String): Map<String, String> = mapOf(
43
44
  "error" to e.error(),
44
- "message" to (e.message ?: MESSAGE_UNKNOWN_ERROR),
45
- "stacktrace" to originalStacktrace
45
+ "message" to (e.message ?: MESSAGE_UNKNOWN_ERROR).stripShadedPrefix(),
46
+ "stacktrace" to originalStacktrace.stripShadedPrefix()
46
47
  )
47
48
 
48
49
  private fun init(value: Any?, sessionId: String?) {
@@ -24,6 +24,8 @@ import com.google.gson.annotations.JsonAdapter
24
24
  import io.appium.espressoserver.lib.handlers.exceptions.InvalidArgumentException
25
25
  import io.appium.espressoserver.lib.handlers.exceptions.InvalidSelectorException
26
26
  import io.appium.espressoserver.lib.helpers.GsonParserHelpers
27
+ import io.appium.espressoserver.lib.helpers.forNameApp
28
+ import io.appium.espressoserver.lib.helpers.forNameShaded
27
29
  import io.appium.espressoserver.lib.helpers.ReflectionUtils.invokeStaticMethod
28
30
  import org.hamcrest.Matcher
29
31
  import org.hamcrest.Matchers
@@ -57,11 +59,12 @@ data class HamcrestMatcher(
57
59
  className = className.take(className.length - CLASS_SUFFIX.length)
58
60
  }
59
61
 
62
+ // Arguments are types of the app under test, so its classes take precedence
60
63
  try {
61
- Class.forName(className)
64
+ forNameApp(className)
62
65
  } catch (e: ClassNotFoundException) {
63
66
  try {
64
- Class.forName("java.lang.${className}")
67
+ forNameApp("java.lang.${className}")
65
68
  } catch (e: ClassNotFoundException) {
66
69
  it
67
70
  }
@@ -121,13 +124,13 @@ data class HamcrestMatcher(
121
124
  val className = requireValidString("class", it)
122
125
  // Try fully casting class as fully qualified name
123
126
  try {
124
- return@let Class.forName(className).kotlin
127
+ return@let forNameShaded(className).kotlin
125
128
  } catch (cnfe: ClassNotFoundException) { }
126
129
  // If above didn't work, try prepending 'androidx.test.espresso.matcher' package name
127
130
  try {
128
131
  val qualifiedClassName = "androidx.test.espresso.matcher.${className}"
129
- return@let Class.forName(qualifiedClassName).kotlin
130
- } catch (cnfe: ClassCastException) {
132
+ return@let forNameShaded(qualifiedClassName).kotlin
133
+ } catch (cnfe: ClassNotFoundException) {
131
134
  throw JsonParseException("No such class found '${className}'")
132
135
  }
133
136
  }