shakebug-react-native 1.0.14

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 (296) hide show
  1. package/DeviceInfo/index.js.flow +177 -0
  2. package/DeviceInfo/index.ts +1034 -0
  3. package/DeviceInfo/internal/asyncHookWrappers.ts +59 -0
  4. package/DeviceInfo/internal/devicesWithDynamicIsland.ts +30 -0
  5. package/DeviceInfo/internal/devicesWithNotch.ts +374 -0
  6. package/DeviceInfo/internal/nativeInterface.ts +28 -0
  7. package/DeviceInfo/internal/privateTypes.ts +231 -0
  8. package/DeviceInfo/internal/supported-platform-info.ts +97 -0
  9. package/DeviceInfo/internal/types.ts +19 -0
  10. package/DeviceInfo/web/index.js +223 -0
  11. package/GetLocals/src/NativeRNLocalize.ts +18 -0
  12. package/GetLocals/src/constants.ts +269 -0
  13. package/GetLocals/src/index.ts +56 -0
  14. package/GetLocals/src/module.ts +51 -0
  15. package/GetLocals/src/module.web.ts +148 -0
  16. package/GetLocals/src/types.ts +31 -0
  17. package/GetLocation/LocationError.ts +20 -0
  18. package/GetLocation/index.ts +46 -0
  19. package/GetLocation/utils.ts +89 -0
  20. package/ImageOrVedioPicker/src/index.ts +28 -0
  21. package/ImageOrVedioPicker/src/platforms/NativeImagePicker.ts +10 -0
  22. package/ImageOrVedioPicker/src/platforms/native.ts +61 -0
  23. package/ImageOrVedioPicker/src/platforms/web.ts +159 -0
  24. package/ImageOrVedioPicker/src/types.ts +74 -0
  25. package/NetInfo/src/__tests__/eventListenerCallbacks.spec.ts +332 -0
  26. package/NetInfo/src/__tests__/fetch.spec.ts +479 -0
  27. package/NetInfo/src/index.ts +186 -0
  28. package/NetInfo/src/internal/__mocks__/nativeModule.ts +13 -0
  29. package/NetInfo/src/internal/defaultConfiguration.ts +17 -0
  30. package/NetInfo/src/internal/defaultConfiguration.web.ts +17 -0
  31. package/NetInfo/src/internal/internetReachability.ts +180 -0
  32. package/NetInfo/src/internal/nativeInterface.ts +43 -0
  33. package/NetInfo/src/internal/nativeInterface.web.ts +27 -0
  34. package/NetInfo/src/internal/nativeModule.ts +15 -0
  35. package/NetInfo/src/internal/nativeModule.web.ts +306 -0
  36. package/NetInfo/src/internal/privateTypes.ts +41 -0
  37. package/NetInfo/src/internal/state.ts +137 -0
  38. package/NetInfo/src/internal/types.ts +128 -0
  39. package/README.md +246 -0
  40. package/RecordScreen/src/index.tsx +75 -0
  41. package/ScreenShot/src/RNViewShot.js +3 -0
  42. package/ScreenShot/src/RNViewShot.web.js +42 -0
  43. package/ScreenShot/src/index.js +308 -0
  44. package/Sensor/src/index.js +14 -0
  45. package/Sensor/src/rnsensors.js +57 -0
  46. package/Sensor/src/sensors.js +97 -0
  47. package/VideoPlayer/PlayVideo.tsx +51 -0
  48. package/VideoPlayer/index.js +69 -0
  49. package/android/README.md +14 -0
  50. package/android/build/generated/source/buildConfig/debug/com/shakebug/BuildConfig.java +10 -0
  51. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +42 -0
  52. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +18 -0
  53. package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +6 -0
  54. package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +1 -0
  55. package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
  56. package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
  57. package/android/build/intermediates/compile_symbol_list/debug/R.txt +47 -0
  58. package/android/build/intermediates/compiled_local_resources/debug/out/xml_imagepicker_provider_paths.xml.flat +0 -0
  59. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +12 -0
  60. package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +2 -0
  61. package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +2 -0
  62. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
  63. package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +2 -0
  64. package/android/build/intermediates/javac/debug/classes/com/shakebug/BuildConfig.class +0 -0
  65. package/android/build/intermediates/javac/debug/classes/com/shakebug/CustomMediaMetadataRetriever.class +0 -0
  66. package/android/build/intermediates/javac/debug/classes/com/shakebug/ImageMetadata.class +0 -0
  67. package/android/build/intermediates/javac/debug/classes/com/shakebug/ImagePickerProvider.class +0 -0
  68. package/android/build/intermediates/javac/debug/classes/com/shakebug/Metadata.class +0 -0
  69. package/android/build/intermediates/javac/debug/classes/com/shakebug/Options.class +0 -0
  70. package/android/build/intermediates/javac/debug/classes/com/shakebug/RecordScreenModule$1.class +0 -0
  71. package/android/build/intermediates/javac/debug/classes/com/shakebug/RecordScreenModule.class +0 -0
  72. package/android/build/intermediates/javac/debug/classes/com/shakebug/Shakebug.class +0 -0
  73. package/android/build/intermediates/javac/debug/classes/com/shakebug/ShakebugPackage.class +0 -0
  74. package/android/build/intermediates/javac/debug/classes/com/shakebug/Utility.class +0 -0
  75. package/android/build/intermediates/javac/debug/classes/com/shakebug/Utils.class +0 -0
  76. package/android/build/intermediates/javac/debug/classes/com/shakebug/VideoMetadata.class +0 -0
  77. package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$1.class +0 -0
  78. package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$2.class +0 -0
  79. package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$Formats.class +0 -0
  80. package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$Results.class +0 -0
  81. package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$ReusableByteArrayOutputStream.class +0 -0
  82. package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot.class +0 -0
  83. package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +49 -0
  84. package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +82 -0
  85. package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +42 -0
  86. package/android/build/intermediates/navigation_json/debug/navigation.json +1 -0
  87. package/android/build/intermediates/packaged_res/debug/values/values.xml +25 -0
  88. package/android/build/intermediates/packaged_res/debug/xml/imagepicker_provider_paths.xml +4 -0
  89. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/BuildConfig.class +0 -0
  90. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/CustomMediaMetadataRetriever.class +0 -0
  91. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ImageMetadata.class +0 -0
  92. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ImagePickerProvider.class +0 -0
  93. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Metadata.class +0 -0
  94. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Options.class +0 -0
  95. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/RecordScreenModule$1.class +0 -0
  96. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/RecordScreenModule.class +0 -0
  97. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Shakebug.class +0 -0
  98. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ShakebugPackage.class +0 -0
  99. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Utility.class +0 -0
  100. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Utils.class +0 -0
  101. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/VideoMetadata.class +0 -0
  102. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$1.class +0 -0
  103. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$2.class +0 -0
  104. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$Formats.class +0 -0
  105. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$Results.class +0 -0
  106. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$ReusableByteArrayOutputStream.class +0 -0
  107. package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot.class +0 -0
  108. package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +48 -0
  109. package/android/build/outputs/logs/manifest-merger-debug-report.txt +97 -0
  110. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  111. package/android/build.gradle +235 -0
  112. package/android/src/main/AndroidManifest.xml +40 -0
  113. package/android/src/main/java/com/shakebug/AmazonFireDeviceConnectivityPoller.java +170 -0
  114. package/android/src/main/java/com/shakebug/BaseUtils.java +33 -0
  115. package/android/src/main/java/com/shakebug/BroadcastReceiverConnectivityReceiver.java +131 -0
  116. package/android/src/main/java/com/shakebug/ConnectivityReceiver.java +318 -0
  117. package/android/src/main/java/com/shakebug/CrashLoggerModule.java +48 -0
  118. package/android/src/main/java/com/shakebug/DateUtil.java +64 -0
  119. package/android/src/main/java/com/shakebug/DeviceType.java +18 -0
  120. package/android/src/main/java/com/shakebug/DeviceUtil.java +46 -0
  121. package/android/src/main/java/com/shakebug/DrawingView.java +90 -0
  122. package/android/src/main/java/com/shakebug/DrawingViewManager.java +38 -0
  123. package/android/src/main/java/com/shakebug/GetLocation.java +147 -0
  124. package/android/src/main/java/com/shakebug/ImageMetadata.java +42 -0
  125. package/android/src/main/java/com/shakebug/ImagePickerProvider.java +8 -0
  126. package/android/src/main/java/com/shakebug/Metadata.java +46 -0
  127. package/android/src/main/java/com/shakebug/NetInfoModule.java +79 -0
  128. package/android/src/main/java/com/shakebug/NetInfoUtils.java +50 -0
  129. package/android/src/main/java/com/shakebug/NetworkCallbackConnectivityReceiver.java +209 -0
  130. package/android/src/main/java/com/shakebug/Options.java +42 -0
  131. package/android/src/main/java/com/shakebug/RNDeviceModule.java +1036 -0
  132. package/android/src/main/java/com/shakebug/RNInstallReferrerClient.java +124 -0
  133. package/android/src/main/java/com/shakebug/RNLocalizeModule.java +79 -0
  134. package/android/src/main/java/com/shakebug/RNLocalizeModuleImpl.java +258 -0
  135. package/android/src/main/java/com/shakebug/ReactNativeGetLocationModule.java +95 -0
  136. package/android/src/main/java/com/shakebug/RecordScreenModule.java +202 -0
  137. package/android/src/main/java/com/shakebug/ScreenshotDetectorModule.java +63 -0
  138. package/android/src/main/java/com/shakebug/SettingsUtil.java +44 -0
  139. package/android/src/main/java/com/shakebug/Shakebug.java +181 -0
  140. package/android/src/main/java/com/shakebug/ShakebugPackage.java +75 -0
  141. package/android/src/main/java/com/shakebug/ShakebugSDKImagePickerModule.java +56 -0
  142. package/android/src/main/java/com/shakebug/ShakebugSDKImagePickerModuleImpl.java +230 -0
  143. package/android/src/main/java/com/shakebug/ShakebugSDKScreenShotModule.java +196 -0
  144. package/android/src/main/java/com/shakebug/SharedPreferencesModule.java +39 -0
  145. package/android/src/main/java/com/shakebug/UnitConverter.java +48 -0
  146. package/android/src/main/java/com/shakebug/Utility.java +29 -0
  147. package/android/src/main/java/com/shakebug/Utils.java +593 -0
  148. package/android/src/main/java/com/shakebug/VideoMetadata.java +91 -0
  149. package/android/src/main/java/com/shakebug/VideoPlayerModule.java +199 -0
  150. package/android/src/main/java/com/shakebug/VideoThumbnailModule.java +215 -0
  151. package/android/src/main/java/com/shakebug/VideoTrimModule.java +372 -0
  152. package/android/src/main/java/com/shakebug/ViewShot.java +627 -0
  153. package/android/src/main/java/com/shakebug/adapters/VideoTrimmerAdapter.java +54 -0
  154. package/android/src/main/java/com/shakebug/callback/SingleCallback.java +11 -0
  155. package/android/src/main/java/com/shakebug/interfaces/IVideoTrimmerView.java +5 -0
  156. package/android/src/main/java/com/shakebug/interfaces/VideoPlayerListner.java +5 -0
  157. package/android/src/main/java/com/shakebug/interfaces/VideoTrimListener.java +10 -0
  158. package/android/src/main/java/com/shakebug/resolver/DeviceIdResolver.java +87 -0
  159. package/android/src/main/java/com/shakebug/resolver/DeviceTypeResolver.java +94 -0
  160. package/android/src/main/java/com/shakebug/thread/BackgroundExecutor.java +246 -0
  161. package/android/src/main/java/com/shakebug/thread/UiThreadExecutor.java +120 -0
  162. package/android/src/main/java/com/shakebug/types/CellularGeneration.java +60 -0
  163. package/android/src/main/java/com/shakebug/types/ConnectionType.java +26 -0
  164. package/android/src/main/java/com/shakebug/utils/StorageUtil.java +139 -0
  165. package/android/src/main/java/com/shakebug/utils/VideoTrimmerUtil.java +89 -0
  166. package/android/src/main/java/com/shakebug/widgets/RangeSeekBarView.java +534 -0
  167. package/android/src/main/java/com/shakebug/widgets/SpacesItemDecoration2.java +32 -0
  168. package/android/src/main/java/com/shakebug/widgets/VideoPlayerView.java +429 -0
  169. package/android/src/main/java/com/shakebug/widgets/VideoTrimmerView.java +477 -0
  170. package/android/src/main/java/com/shakebug/widgets/ZVideoView.java +48 -0
  171. package/android/src/main/res/drawable/custom_progress.xml +16 -0
  172. package/android/src/main/res/drawable/custom_thumb.xml +4 -0
  173. package/android/src/main/res/drawable/ic_close_button.xml +10 -0
  174. package/android/src/main/res/drawable/ic_video_pause_black.png +0 -0
  175. package/android/src/main/res/drawable/ic_video_play_black.png +0 -0
  176. package/android/src/main/res/drawable/ic_video_thumb_handle.png +0 -0
  177. package/android/src/main/res/drawable/icon_seek_bar.png +0 -0
  178. package/android/src/main/res/layout/video_player_view.xml +121 -0
  179. package/android/src/main/res/layout/video_thumb_item_layout.xml +16 -0
  180. package/android/src/main/res/layout/video_trimmer_view.xml +148 -0
  181. package/android/src/main/res/values/colors.xml +17 -0
  182. package/android/src/main/res/values/strings.xml +14 -0
  183. package/android/src/main/res/xml/imagepicker_provider_paths.xml +4 -0
  184. package/ios/CammeraPermission/RNCameraPermission.h +16 -0
  185. package/ios/CammeraPermission/RNCameraPermission.m +46 -0
  186. package/ios/DeviceInfo/DeviceUID.h +14 -0
  187. package/ios/DeviceInfo/DeviceUID.m +202 -0
  188. package/ios/DeviceInfo/EnvironmentUtil.h +41 -0
  189. package/ios/DeviceInfo/EnvironmentUtil.m +56 -0
  190. package/ios/DeviceInfo/RNDeviceInfo.h +22 -0
  191. package/ios/DeviceInfo/RNDeviceInfo.m +918 -0
  192. package/ios/GetLocals/ShakebugSDKRNLocalize.h +21 -0
  193. package/ios/GetLocals/ShakebugSDKRNLocalize.m +296 -0
  194. package/ios/GetLocation/SettingsUtil.h +16 -0
  195. package/ios/GetLocation/SettingsUtil.m +21 -0
  196. package/ios/GetLocation/ShakebugSDKLocationModule.h +17 -0
  197. package/ios/GetLocation/ShakebugSDKLocationModule.m +218 -0
  198. package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerManager.h +40 -0
  199. package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerManager.m +588 -0
  200. package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerUtils.h +26 -0
  201. package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerUtils.m +194 -0
  202. package/ios/MicrophonePermissionManager.h +14 -0
  203. package/ios/MicrophonePermissionManager.m +35 -0
  204. package/ios/NetInfo/RNCConnectionState.h +42 -0
  205. package/ios/NetInfo/RNCConnectionState.m +119 -0
  206. package/ios/NetInfo/RNCConnectionStateWatcher.h +31 -0
  207. package/ios/NetInfo/RNCConnectionStateWatcher.m +136 -0
  208. package/ios/NetInfo/RNCNetInfo.h +13 -0
  209. package/ios/NetInfo/RNCNetInfo.m +269 -0
  210. package/ios/RecordScreen/ShakebugSDKRecordScreen.h +31 -0
  211. package/ios/RecordScreen/ShakebugSDKRecordScreen.m +309 -0
  212. package/ios/ScreenShot/ShakebugSDKRNViewShot.h +6 -0
  213. package/ios/ScreenShot/ShakebugSDKRNViewShot.m +186 -0
  214. package/ios/ScreenshotDetector/ScreenShotDetector.h +12 -0
  215. package/ios/ScreenshotDetector/ScreenShotDetector.m +37 -0
  216. package/ios/Senors/RNSensorsAccelerometer.h +22 -0
  217. package/ios/Senors/RNSensorsAccelerometer.m +162 -0
  218. package/ios/Senors/RNSensorsBarometer.h +22 -0
  219. package/ios/Senors/RNSensorsBarometer.m +141 -0
  220. package/ios/Senors/RNSensorsGravity.h +22 -0
  221. package/ios/Senors/RNSensorsGravity.m +165 -0
  222. package/ios/Senors/RNSensorsGyroscope.h +22 -0
  223. package/ios/Senors/RNSensorsGyroscope.m +160 -0
  224. package/ios/Senors/RNSensorsMagnetometer.h +22 -0
  225. package/ios/Senors/RNSensorsMagnetometer.m +163 -0
  226. package/ios/Senors/RNSensorsOrientation.h +22 -0
  227. package/ios/Senors/RNSensorsOrientation.m +189 -0
  228. package/ios/Senors/RNSensorsUtils.h +7 -0
  229. package/ios/Senors/RNSensorsUtils.m +9 -0
  230. package/ios/Shakebug.h +7 -0
  231. package/ios/Shakebug.m +16 -0
  232. package/ios/Shakebug.xcodeproj/project.pbxproj +872 -0
  233. package/ios/Shakebug.xcodeproj/xcshareddata/xcschemes/Shakebug.xcscheme +66 -0
  234. package/ios/Shakebug.xcworkspace/contents.xcworkspacedata +10 -0
  235. package/ios/Shakebug.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  236. package/ios/SketchCanvas/DrawingView.h +18 -0
  237. package/ios/SketchCanvas/DrawingView.m +96 -0
  238. package/ios/SketchCanvas/DrawingViewManager.h +12 -0
  239. package/ios/SketchCanvas/DrawingViewManager.m +35 -0
  240. package/ios/Storage/SharedPreferencesModule.h +13 -0
  241. package/ios/Storage/SharedPreferencesModule.m +35 -0
  242. package/ios/Thumbnaill/VideoThumbnailManager.h +12 -0
  243. package/ios/Thumbnaill/VideoThumbnailManager.m +73 -0
  244. package/ios/TrimVideo/ShakebugSDKVideoTrim.swift +372 -0
  245. package/ios/TrimVideo/VideoTrim-Bridging-Header.h +10 -0
  246. package/ios/TrimVideo/VideoTrim.m +23 -0
  247. package/ios/TrimVideo/VideoTrimmer.swift +810 -0
  248. package/ios/TrimVideo/VideoTrimmerThumb.swift +119 -0
  249. package/ios/TrimVideo/VideoTrimmerViewController.swift +301 -0
  250. package/ios/VideoPlayer/VideoPlayerModule.h +14 -0
  251. package/ios/VideoPlayer/VideoPlayerModule.m +29 -0
  252. package/ios/VideoPlayer/VideoPlayerViewController.h +18 -0
  253. package/ios/VideoPlayer/VideoPlayerViewController.m +29 -0
  254. package/package.json +45 -0
  255. package/shakebug-react-native.podspec +50 -0
  256. package/src/APIs/AddIssue.js +70 -0
  257. package/src/APIs/EndSession.js +32 -0
  258. package/src/APIs/Event.js +39 -0
  259. package/src/APIs/MatchKey.js +40 -0
  260. package/src/APIs/StartSession.js +84 -0
  261. package/src/Assets/images/OpenSketch.png +0 -0
  262. package/src/Assets/images/Push.png +0 -0
  263. package/src/Assets/images/RemoveTextView.png +0 -0
  264. package/src/Assets/images/black.png +0 -0
  265. package/src/Assets/images/blue.png +0 -0
  266. package/src/Assets/images/borderdBlack.png +0 -0
  267. package/src/Assets/images/borderdBlue.png +0 -0
  268. package/src/Assets/images/borderdGreen.png +0 -0
  269. package/src/Assets/images/borderdRed.png +0 -0
  270. package/src/Assets/images/borderdYellow.png +0 -0
  271. package/src/Assets/images/clear.png +0 -0
  272. package/src/Assets/images/close.png +0 -0
  273. package/src/Assets/images/green.png +0 -0
  274. package/src/Assets/images/next.png +0 -0
  275. package/src/Assets/images/play.png +0 -0
  276. package/src/Assets/images/red.png +0 -0
  277. package/src/Assets/images/shake.png +0 -0
  278. package/src/Assets/images/shakebugLogo.png +0 -0
  279. package/src/Assets/images/stopButton.png +0 -0
  280. package/src/Assets/images/text_icon.png +0 -0
  281. package/src/Assets/images/yellow.png +0 -0
  282. package/src/Componanats/CustomAlert.js +80 -0
  283. package/src/Componanats/ErrorHandler.js +80 -0
  284. package/src/Componanats/GlobalStateContext.js +22 -0
  285. package/src/Componanats/KeyboardAvoidingWrapper.js +43 -0
  286. package/src/Componanats/NavigationContext.js +42 -0
  287. package/src/Componanats/ShakeFunction.js +562 -0
  288. package/src/Componanats/localization.js +482 -0
  289. package/src/Screens/AddDetailsScreen.js +462 -0
  290. package/src/Screens/FirstScreen.js +629 -0
  291. package/src/Screens/Shakebug.js +487 -0
  292. package/src/Screens/StrockView.js +20 -0
  293. package/src/Screens/TrimVideoScreen.js +81 -0
  294. package/src/Screens/TutorialScreen.js +36 -0
  295. package/src/index.tsx +117 -0
  296. package/trimVideo/src/index.tsx +141 -0
@@ -0,0 +1,1036 @@
1
+ package com.shakebug;
2
+
3
+ import android.Manifest;
4
+ import android.annotation.SuppressLint;
5
+ import android.app.KeyguardManager;
6
+ import android.content.BroadcastReceiver;
7
+ import android.content.Context;
8
+ import android.content.SharedPreferences;
9
+ import android.content.Intent;
10
+ import android.content.IntentFilter;
11
+ import android.content.pm.PackageInfo;
12
+ import android.content.pm.PackageManager;
13
+ import android.content.pm.FeatureInfo;
14
+ import android.location.LocationManager;
15
+ import android.media.AudioManager;
16
+ import android.media.MediaCodecInfo;
17
+ import android.media.MediaCodecList;
18
+ import android.net.wifi.WifiManager;
19
+ import android.net.wifi.WifiInfo;
20
+ import android.os.Build;
21
+ import android.os.Environment;
22
+ import android.os.PowerManager;
23
+ import android.os.StatFs;
24
+ import android.os.BatteryManager;
25
+ import android.os.Debug;
26
+ import android.os.Process;
27
+ import android.provider.Settings;
28
+ import android.webkit.WebSettings;
29
+ import android.telephony.TelephonyManager;
30
+ import android.text.TextUtils;
31
+ import android.app.ActivityManager;
32
+ import android.hardware.Camera;
33
+ import android.hardware.camera2.CameraManager;
34
+
35
+ import androidx.annotation.Nullable;
36
+
37
+ import com.facebook.react.bridge.Arguments;
38
+ import com.facebook.react.bridge.ReactApplicationContext;
39
+ import com.facebook.react.bridge.ReactContext;
40
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
41
+ import com.facebook.react.bridge.ReactMethod;
42
+ import com.facebook.react.bridge.Promise;
43
+ import com.facebook.react.bridge.WritableArray;
44
+ import com.facebook.react.bridge.WritableMap;
45
+ import com.facebook.react.bridge.WritableNativeArray;
46
+ import com.facebook.react.module.annotations.ReactModule;
47
+ import com.facebook.react.modules.core.DeviceEventManagerModule;
48
+ import com.shakebug.resolver.DeviceIdResolver;
49
+ import com.shakebug.resolver.DeviceTypeResolver;
50
+
51
+ import java.lang.reflect.Method;
52
+ import java.net.InetAddress;
53
+ import java.nio.ByteBuffer;
54
+ import java.nio.ByteOrder;
55
+ import java.util.Collections;
56
+ import java.util.HashMap;
57
+ import java.util.List;
58
+ import java.lang.Runtime;
59
+ import java.net.NetworkInterface;
60
+ import java.math.BigInteger;
61
+ import java.util.Locale;
62
+ import java.util.Map;
63
+
64
+ import javax.annotation.Nonnull;
65
+
66
+ import static android.content.Context.ACTIVITY_SERVICE;
67
+ import static android.os.BatteryManager.BATTERY_STATUS_CHARGING;
68
+ import static android.os.BatteryManager.BATTERY_STATUS_FULL;
69
+ import static android.provider.Settings.Secure.getString;
70
+
71
+ @ReactModule(name = RNDeviceModule.NAME)
72
+ public class RNDeviceModule extends ReactContextBaseJavaModule {
73
+ public static final String NAME = "ShakebugSDKRNDeviceInfo";
74
+ private final DeviceTypeResolver deviceTypeResolver;
75
+ private final DeviceIdResolver deviceIdResolver;
76
+ private BroadcastReceiver receiver;
77
+ private BroadcastReceiver headphoneConnectionReceiver;
78
+ private RNInstallReferrerClient installReferrerClient;
79
+
80
+ private double mLastBatteryLevel = -1;
81
+ private String mLastBatteryState = "";
82
+ private boolean mLastPowerSaveState = false;
83
+
84
+ private static String BATTERY_STATE = "batteryState";
85
+ private static String BATTERY_LEVEL= "batteryLevel";
86
+ private static String LOW_POWER_MODE = "lowPowerMode";
87
+
88
+ public RNDeviceModule(ReactApplicationContext reactContext) {
89
+ super(reactContext);
90
+ this.deviceTypeResolver = new DeviceTypeResolver(reactContext);
91
+ this.deviceIdResolver = new DeviceIdResolver(reactContext);
92
+ this.installReferrerClient = new RNInstallReferrerClient(reactContext.getBaseContext());
93
+ }
94
+
95
+ @Override
96
+ public void initialize() {
97
+ IntentFilter filter = new IntentFilter();
98
+ filter.addAction(Intent.ACTION_BATTERY_CHANGED);
99
+ filter.addAction(Intent.ACTION_POWER_CONNECTED);
100
+ filter.addAction(Intent.ACTION_POWER_DISCONNECTED);
101
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
102
+ filter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
103
+ }
104
+
105
+ receiver = new BroadcastReceiver() {
106
+ @Override
107
+ public void onReceive(Context context, Intent intent) {
108
+ WritableMap powerState = getPowerStateFromIntent(intent);
109
+
110
+ if(powerState == null) {
111
+ return;
112
+ }
113
+
114
+ String batteryState = powerState.getString(BATTERY_STATE);
115
+ Double batteryLevel = powerState.getDouble(BATTERY_LEVEL);
116
+ Boolean powerSaveState = powerState.getBoolean(LOW_POWER_MODE);
117
+
118
+ if(!mLastBatteryState.equalsIgnoreCase(batteryState) || mLastPowerSaveState != powerSaveState) {
119
+ sendEvent(getReactApplicationContext(), "RNDeviceInfo_powerStateDidChange", batteryState);
120
+ mLastBatteryState = batteryState;
121
+ mLastPowerSaveState = powerSaveState;
122
+ }
123
+
124
+ if(mLastBatteryLevel != batteryLevel) {
125
+ sendEvent(getReactApplicationContext(), "RNDeviceInfo_batteryLevelDidChange", batteryLevel);
126
+
127
+ if(batteryLevel <= .15) {
128
+ sendEvent(getReactApplicationContext(), "RNDeviceInfo_batteryLevelIsLow", batteryLevel);
129
+ }
130
+
131
+ mLastBatteryLevel = batteryLevel;
132
+ }
133
+ }
134
+ };
135
+
136
+ getReactApplicationContext().registerReceiver(receiver, filter);
137
+ initializeHeadphoneConnectionReceiver();
138
+ }
139
+
140
+ private void initializeHeadphoneConnectionReceiver() {
141
+ IntentFilter filter = new IntentFilter();
142
+ filter.addAction(AudioManager.ACTION_HEADSET_PLUG);
143
+ filter.addAction(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED);
144
+
145
+ headphoneConnectionReceiver = new BroadcastReceiver() {
146
+ @Override
147
+ public void onReceive(Context context, Intent intent) {
148
+ boolean isConnected = isHeadphonesConnectedSync();
149
+ sendEvent(getReactApplicationContext(), "RNDeviceInfo_headphoneConnectionDidChange", isConnected);
150
+ }
151
+ };
152
+
153
+ getReactApplicationContext().registerReceiver(headphoneConnectionReceiver, filter);
154
+ }
155
+
156
+
157
+ @Override
158
+ public void onCatalystInstanceDestroy() {
159
+ getReactApplicationContext().unregisterReceiver(receiver);
160
+ getReactApplicationContext().unregisterReceiver(headphoneConnectionReceiver);
161
+ }
162
+
163
+
164
+ @Override
165
+ @Nonnull
166
+ public String getName() {
167
+ return NAME;
168
+ }
169
+
170
+ public static SharedPreferences getRNDISharedPreferences(Context context) {
171
+ return context.getSharedPreferences("react-native-device-info", Context.MODE_PRIVATE);
172
+ }
173
+
174
+ @SuppressLint("MissingPermission")
175
+ private WifiInfo getWifiInfo() {
176
+ WifiManager manager = (WifiManager) getReactApplicationContext().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
177
+ if (manager != null) {
178
+ return manager.getConnectionInfo();
179
+ }
180
+ return null;
181
+ }
182
+
183
+ @Nonnull
184
+ private Boolean isLowRamDevice() {
185
+ ActivityManager am = (ActivityManager) getReactApplicationContext().getSystemService(ACTIVITY_SERVICE);
186
+ boolean isLowRamDevice = false;
187
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
188
+ isLowRamDevice = am.isLowRamDevice();
189
+ }
190
+ return isLowRamDevice;
191
+ }
192
+
193
+ @Override
194
+ public Map<String, Object> getConstants() {
195
+ String appVersion, buildNumber, appName;
196
+
197
+ try {
198
+ appVersion = getPackageInfo().versionName;
199
+ buildNumber = Integer.toString(getPackageInfo().versionCode);
200
+ appName = getReactApplicationContext().getApplicationInfo().loadLabel(getReactApplicationContext().getPackageManager()).toString();
201
+ } catch (Exception e) {
202
+ appVersion = "unknown";
203
+ buildNumber = "unknown";
204
+ appName = "unknown";
205
+ }
206
+
207
+ final Map<String, Object> constants = new HashMap<>();
208
+
209
+ constants.put("deviceId", Build.BOARD);
210
+ constants.put("bundleId", getReactApplicationContext().getPackageName());
211
+ constants.put("systemName", "Android");
212
+ constants.put("systemVersion", Build.VERSION.RELEASE);
213
+ constants.put("appVersion", appVersion);
214
+ constants.put("buildNumber", buildNumber);
215
+ constants.put("isTablet", deviceTypeResolver.isTablet());
216
+ constants.put("isLowRamDevice", isLowRamDevice());
217
+ constants.put("appName", appName);
218
+ constants.put("brand", Build.BRAND);
219
+ constants.put("model", Build.MODEL);
220
+ constants.put("deviceType", deviceTypeResolver.getDeviceType().getValue());
221
+
222
+ return constants;
223
+ }
224
+
225
+ @ReactMethod
226
+ public void addListener(String eventName) {
227
+ // Keep: Required for RN built in Event Emitter Calls.
228
+ }
229
+
230
+ @ReactMethod
231
+ public void removeListeners(Integer count) {
232
+ // Keep: Required for RN built in Event Emitter Calls.
233
+ }
234
+
235
+ @ReactMethod
236
+ public void isEmulator(Promise p) {
237
+ p.resolve(isEmulatorSync());
238
+ }
239
+
240
+ @SuppressLint("HardwareIds")
241
+ @ReactMethod(isBlockingSynchronousMethod = true)
242
+ public boolean isEmulatorSync() {
243
+ return Build.FINGERPRINT.startsWith("generic")
244
+ || Build.FINGERPRINT.startsWith("unknown")
245
+ || Build.MODEL.contains("google_sdk")
246
+ || Build.MODEL.toLowerCase(Locale.ROOT).contains("droid4x")
247
+ || Build.MODEL.contains("Emulator")
248
+ || Build.MODEL.contains("Android SDK built for x86")
249
+ || Build.MANUFACTURER.contains("Genymotion")
250
+ || Build.HARDWARE.contains("goldfish")
251
+ || Build.HARDWARE.contains("ranchu")
252
+ || Build.HARDWARE.contains("vbox86")
253
+ || Build.PRODUCT.contains("sdk")
254
+ || Build.PRODUCT.contains("google_sdk")
255
+ || Build.PRODUCT.contains("sdk_google")
256
+ || Build.PRODUCT.contains("sdk_x86")
257
+ || Build.PRODUCT.contains("vbox86p")
258
+ || Build.PRODUCT.contains("emulator")
259
+ || Build.PRODUCT.contains("simulator")
260
+ || Build.BOARD.toLowerCase(Locale.ROOT).contains("nox")
261
+ || Build.BOOTLOADER.toLowerCase(Locale.ROOT).contains("nox")
262
+ || Build.HARDWARE.toLowerCase(Locale.ROOT).contains("nox")
263
+ || Build.PRODUCT.toLowerCase(Locale.ROOT).contains("nox")
264
+ || Build.SERIAL.toLowerCase(Locale.ROOT).contains("nox")
265
+ || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"));
266
+ }
267
+
268
+ @ReactMethod(isBlockingSynchronousMethod = true)
269
+ public float getFontScaleSync() { return getReactApplicationContext().getResources().getConfiguration().fontScale; }
270
+ @ReactMethod
271
+ public void getFontScale(Promise p) { p.resolve(getFontScaleSync()); }
272
+
273
+ @ReactMethod(isBlockingSynchronousMethod = true)
274
+ public boolean isPinOrFingerprintSetSync() {
275
+ KeyguardManager keyguardManager = (KeyguardManager) getReactApplicationContext().getSystemService(Context.KEYGUARD_SERVICE);
276
+ if (keyguardManager != null) {
277
+ return keyguardManager.isKeyguardSecure();
278
+ }
279
+ System.err.println("Unable to determine keyguard status. KeyguardManager was null");
280
+ return false;
281
+ }
282
+ @ReactMethod
283
+ public void isPinOrFingerprintSet(Promise p) { p.resolve(isPinOrFingerprintSetSync()); }
284
+
285
+ @ReactMethod(isBlockingSynchronousMethod = true)
286
+ @SuppressWarnings("ConstantConditions")
287
+ public String getIpAddressSync() {
288
+ try {
289
+ return
290
+ InetAddress.getByAddress(
291
+ ByteBuffer
292
+ .allocate(4)
293
+ .order(ByteOrder.LITTLE_ENDIAN)
294
+ .putInt(getWifiInfo().getIpAddress())
295
+ .array())
296
+ .getHostAddress();
297
+ } catch (Exception e) {
298
+ return "unknown";
299
+ }
300
+ }
301
+
302
+ @ReactMethod
303
+ public void getIpAddress(Promise p) { p.resolve(getIpAddressSync()); }
304
+
305
+ @SuppressWarnings("deprecation")
306
+ @ReactMethod(isBlockingSynchronousMethod = true)
307
+ public boolean isCameraPresentSync() {
308
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
309
+ CameraManager manager=(CameraManager)getReactApplicationContext().getSystemService(Context.CAMERA_SERVICE);
310
+ try {
311
+ return manager.getCameraIdList().length > 0;
312
+ } catch (Exception e) {
313
+ return false;
314
+ }
315
+ } else {
316
+ return Camera.getNumberOfCameras()> 0;
317
+ }
318
+ }
319
+ @ReactMethod
320
+ public void isCameraPresent(Promise p) { p.resolve(isCameraPresentSync()); }
321
+
322
+ @SuppressLint("HardwareIds")
323
+ @ReactMethod(isBlockingSynchronousMethod = true)
324
+ public String getMacAddressSync() {
325
+ WifiInfo wifiInfo = getWifiInfo();
326
+ String macAddress = "";
327
+ if (wifiInfo != null) {
328
+ macAddress = wifiInfo.getMacAddress();
329
+ }
330
+
331
+ String permission = "android.permission.INTERNET";
332
+ int res = getReactApplicationContext().checkCallingOrSelfPermission(permission);
333
+
334
+ if (res == PackageManager.PERMISSION_GRANTED) {
335
+ try {
336
+ List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
337
+ for (NetworkInterface nif : all) {
338
+ if (!nif.getName().equalsIgnoreCase("wlan0")) continue;
339
+
340
+ byte[] macBytes = nif.getHardwareAddress();
341
+ if (macBytes == null) {
342
+ macAddress = "";
343
+ } else {
344
+
345
+ StringBuilder res1 = new StringBuilder();
346
+ for (byte b : macBytes) {
347
+ res1.append(String.format("%02X:",b));
348
+ }
349
+
350
+ if (res1.length() > 0) {
351
+ res1.deleteCharAt(res1.length() - 1);
352
+ }
353
+
354
+ macAddress = res1.toString();
355
+ }
356
+ }
357
+ } catch (Exception ex) {
358
+ // do nothing
359
+ }
360
+ }
361
+
362
+ return macAddress;
363
+ }
364
+
365
+ @ReactMethod
366
+ public void getMacAddress(Promise p) { p.resolve(getMacAddressSync()); }
367
+
368
+ @ReactMethod(isBlockingSynchronousMethod = true)
369
+ public String getCarrierSync() {
370
+ TelephonyManager telMgr = (TelephonyManager) getReactApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
371
+ if (telMgr != null) {
372
+ return telMgr.getNetworkOperatorName();
373
+ } else {
374
+ System.err.println("Unable to get network operator name. TelephonyManager was null");
375
+ return "unknown";
376
+ }
377
+ }
378
+ @ReactMethod
379
+ public void getCarrier(Promise p) { p.resolve(getCarrierSync()); }
380
+
381
+ @ReactMethod(isBlockingSynchronousMethod = true)
382
+ public double getTotalDiskCapacitySync() {
383
+ try {
384
+ StatFs rootDir = new StatFs(Environment.getRootDirectory().getAbsolutePath());
385
+ StatFs dataDir = new StatFs(Environment.getDataDirectory().getAbsolutePath());
386
+
387
+ BigInteger rootDirCapacity = getDirTotalCapacity(rootDir);
388
+ BigInteger dataDirCapacity = getDirTotalCapacity(dataDir);
389
+
390
+ return rootDirCapacity.add(dataDirCapacity).doubleValue();
391
+ } catch (Exception e) {
392
+ return -1;
393
+ }
394
+ }
395
+ @ReactMethod
396
+ public void getTotalDiskCapacity(Promise p) { p.resolve(getTotalDiskCapacitySync()); }
397
+
398
+ private BigInteger getDirTotalCapacity(StatFs dir) {
399
+ boolean intApiDeprecated = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
400
+ long blockCount = intApiDeprecated ? dir.getBlockCountLong() : dir.getBlockCount();
401
+ long blockSize = intApiDeprecated ? dir.getBlockSizeLong() : dir.getBlockSize();
402
+ return BigInteger.valueOf(blockCount).multiply(BigInteger.valueOf(blockSize));
403
+ }
404
+
405
+ @ReactMethod(isBlockingSynchronousMethod = true)
406
+ public double getFreeDiskStorageSync() {
407
+ try {
408
+ StatFs rootDir = new StatFs(Environment.getRootDirectory().getAbsolutePath());
409
+ StatFs dataDir = new StatFs(Environment.getDataDirectory().getAbsolutePath());
410
+
411
+ Boolean intApiDeprecated = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
412
+ long rootAvailableBlocks = getTotalAvailableBlocks(rootDir, intApiDeprecated);
413
+ long rootBlockSize = getBlockSize(rootDir, intApiDeprecated);
414
+ double rootFree = BigInteger.valueOf(rootAvailableBlocks).multiply(BigInteger.valueOf(rootBlockSize)).doubleValue();
415
+
416
+ long dataAvailableBlocks = getTotalAvailableBlocks(dataDir, intApiDeprecated);
417
+ long dataBlockSize = getBlockSize(dataDir, intApiDeprecated);
418
+ double dataFree = BigInteger.valueOf(dataAvailableBlocks).multiply(BigInteger.valueOf(dataBlockSize)).doubleValue();
419
+
420
+ return rootFree + dataFree;
421
+ } catch (Exception e) {
422
+ return -1;
423
+ }
424
+ }
425
+ @ReactMethod
426
+ public void getFreeDiskStorage(Promise p) { p.resolve(getFreeDiskStorageSync()); }
427
+
428
+ private long getTotalAvailableBlocks(StatFs dir, Boolean intApiDeprecated) {
429
+ return (intApiDeprecated ? dir.getAvailableBlocksLong() : dir.getAvailableBlocks());
430
+ }
431
+
432
+ private long getBlockSize(StatFs dir, Boolean intApiDeprecated) {
433
+ return (intApiDeprecated ? dir.getBlockSizeLong() : dir.getBlockSize());
434
+ }
435
+
436
+ @Deprecated
437
+ @ReactMethod(isBlockingSynchronousMethod = true)
438
+ public double getTotalDiskCapacityOldSync() {
439
+ try {
440
+ StatFs root = new StatFs(Environment.getRootDirectory().getAbsolutePath());
441
+ return BigInteger.valueOf(root.getBlockCount()).multiply(BigInteger.valueOf(root.getBlockSize())).doubleValue();
442
+ } catch (Exception e) {
443
+ return -1;
444
+ }
445
+ }
446
+ @ReactMethod
447
+ public void getTotalDiskCapacityOld(Promise p) { p.resolve(getTotalDiskCapacityOldSync()); }
448
+
449
+ @ReactMethod(isBlockingSynchronousMethod = true)
450
+ public double getFreeDiskStorageOldSync() {
451
+ try {
452
+ StatFs external = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath());
453
+ long availableBlocks;
454
+ long blockSize;
455
+
456
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
457
+ availableBlocks = external.getAvailableBlocks();
458
+ blockSize = external.getBlockSize();
459
+ } else {
460
+ availableBlocks = external.getAvailableBlocksLong();
461
+ blockSize = external.getBlockSizeLong();
462
+ }
463
+
464
+ return BigInteger.valueOf(availableBlocks).multiply(BigInteger.valueOf(blockSize)).doubleValue();
465
+ } catch (Exception e) {
466
+ return -1;
467
+ }
468
+ }
469
+ @ReactMethod
470
+ public void getFreeDiskStorageOld(Promise p) { p.resolve(getFreeDiskStorageOldSync()); }
471
+
472
+ @ReactMethod(isBlockingSynchronousMethod = true)
473
+ public boolean isBatteryChargingSync(){
474
+ IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
475
+ Intent batteryStatus = getReactApplicationContext().registerReceiver(null, ifilter);
476
+ int status = 0;
477
+ if (batteryStatus != null) {
478
+ status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
479
+ }
480
+ return status == BATTERY_STATUS_CHARGING;
481
+ }
482
+ @ReactMethod
483
+ public void isBatteryCharging(Promise p) { p.resolve(isBatteryChargingSync()); }
484
+
485
+ @ReactMethod(isBlockingSynchronousMethod = true)
486
+ public double getUsedMemorySync() {
487
+ ActivityManager actMgr = (ActivityManager) getReactApplicationContext().getSystemService(ACTIVITY_SERVICE);
488
+ if (actMgr != null) {
489
+ int pid = android.os.Process.myPid();
490
+ android.os.Debug.MemoryInfo[] memInfos = actMgr.getProcessMemoryInfo(new int[]{pid});
491
+
492
+ if(memInfos.length != 1) {
493
+ System.err.println("Unable to getProcessMemoryInfo. getProcessMemoryInfo did not return any info for the PID");
494
+ return -1;
495
+ }
496
+
497
+ android.os.Debug.MemoryInfo memInfo = memInfos[0];
498
+
499
+ return memInfo.getTotalPss() * 1024D;
500
+ } else {
501
+ System.err.println("Unable to getProcessMemoryInfo. ActivityManager was null");
502
+ return -1;
503
+ }
504
+ }
505
+
506
+ @ReactMethod
507
+ public void getUsedMemory(Promise p) { p.resolve(getUsedMemorySync()); }
508
+
509
+ @ReactMethod(isBlockingSynchronousMethod = true)
510
+ public WritableMap getPowerStateSync() {
511
+ Intent intent = getReactApplicationContext().registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
512
+ return getPowerStateFromIntent(intent);
513
+ }
514
+
515
+ @ReactMethod
516
+ public void getPowerState(Promise p) { p.resolve(getPowerStateSync()); }
517
+
518
+ @ReactMethod(isBlockingSynchronousMethod = true)
519
+ public double getBatteryLevelSync() {
520
+ Intent intent = getReactApplicationContext().registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
521
+ WritableMap powerState = getPowerStateFromIntent(intent);
522
+
523
+ if(powerState == null) {
524
+ return 0;
525
+ }
526
+
527
+ return powerState.getDouble(BATTERY_LEVEL);
528
+ }
529
+
530
+ @ReactMethod
531
+ public void getBatteryLevel(Promise p) { p.resolve(getBatteryLevelSync()); }
532
+
533
+ @ReactMethod(isBlockingSynchronousMethod = true)
534
+ public boolean isAirplaneModeSync() {
535
+ boolean isAirplaneMode;
536
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
537
+ isAirplaneMode = Settings.System.getInt(getReactApplicationContext().getContentResolver(),Settings.System.AIRPLANE_MODE_ON, 0) != 0;
538
+ } else {
539
+ isAirplaneMode = Settings.Global.getInt(getReactApplicationContext().getContentResolver(),Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
540
+ }
541
+ return isAirplaneMode;
542
+ }
543
+ @ReactMethod
544
+ public void isAirplaneMode(Promise p) { p.resolve(isAirplaneModeSync()); }
545
+
546
+ @ReactMethod(isBlockingSynchronousMethod = true)
547
+ public boolean hasGmsSync() {
548
+ try {
549
+ Class<?> googleApiAvailability = Class.forName("com.google.android.gms.common.GoogleApiAvailability");
550
+ Method getInstanceMethod = googleApiAvailability.getMethod("getInstance");
551
+ Object gmsObject = getInstanceMethod.invoke(null);
552
+ Method isGooglePlayServicesAvailableMethod = gmsObject.getClass().getMethod("isGooglePlayServicesAvailable", Context.class);
553
+ int isGMS = (int) isGooglePlayServicesAvailableMethod.invoke(gmsObject, getReactApplicationContext());
554
+ return isGMS == 0; // ConnectionResult.SUCCESS
555
+ } catch (Exception e) {
556
+ return false;
557
+ }
558
+ }
559
+ @ReactMethod
560
+ public void hasGms(Promise p) { p.resolve(hasGmsSync()); }
561
+
562
+ @ReactMethod(isBlockingSynchronousMethod = true)
563
+ public boolean hasHmsSync() {
564
+ try {
565
+ Class<?> huaweiApiAvailability = Class.forName("com.huawei.hms.api.HuaweiApiAvailability");
566
+ Method getInstanceMethod = huaweiApiAvailability.getMethod("getInstance");
567
+ Object hmsObject = getInstanceMethod.invoke(null);
568
+ Method isHuaweiMobileServicesAvailableMethod = hmsObject.getClass().getMethod("isHuaweiMobileServicesAvailable", Context.class);
569
+ int isHMS = (int) isHuaweiMobileServicesAvailableMethod.invoke(hmsObject, getReactApplicationContext());
570
+ return isHMS == 0; // ConnectionResult.SUCCESS
571
+ } catch (Exception e) {
572
+ return false;
573
+ }
574
+ }
575
+ @ReactMethod
576
+ public void hasHms(Promise p) { p.resolve(hasHmsSync()); }
577
+
578
+ @ReactMethod(isBlockingSynchronousMethod = true)
579
+ public boolean hasSystemFeatureSync(String feature) {
580
+ if (feature == null || feature.equals("")) {
581
+ return false;
582
+ }
583
+
584
+ return getReactApplicationContext().getPackageManager().hasSystemFeature(feature);
585
+ }
586
+ @ReactMethod
587
+ public void hasSystemFeature(String feature, Promise p) { p.resolve(hasSystemFeatureSync(feature)); }
588
+
589
+ @ReactMethod(isBlockingSynchronousMethod = true)
590
+ public WritableArray getSystemAvailableFeaturesSync() {
591
+ final FeatureInfo[] featureList = getReactApplicationContext().getPackageManager().getSystemAvailableFeatures();
592
+
593
+ WritableArray promiseArray = Arguments.createArray();
594
+ for (FeatureInfo f : featureList) {
595
+ if (f.name != null) {
596
+ promiseArray.pushString(f.name);
597
+ }
598
+ }
599
+
600
+ return promiseArray;
601
+ }
602
+ @ReactMethod
603
+ public void getSystemAvailableFeatures(Promise p) { p.resolve(getSystemAvailableFeaturesSync()); }
604
+
605
+ @ReactMethod(isBlockingSynchronousMethod = true)
606
+ public boolean isLocationEnabledSync() {
607
+ boolean locationEnabled;
608
+
609
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
610
+ LocationManager mLocationManager = (LocationManager) getReactApplicationContext().getSystemService(Context.LOCATION_SERVICE);
611
+ try {
612
+ locationEnabled = mLocationManager.isLocationEnabled();
613
+ } catch (Exception e) {
614
+ System.err.println("Unable to determine if location enabled. LocationManager was null");
615
+ return false;
616
+ }
617
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
618
+ int locationMode = Settings.Secure.getInt(getReactApplicationContext().getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
619
+ locationEnabled = locationMode != Settings.Secure.LOCATION_MODE_OFF;
620
+ } else {
621
+ String locationProviders = getString(getReactApplicationContext().getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
622
+ locationEnabled = !TextUtils.isEmpty(locationProviders);
623
+ }
624
+
625
+ return locationEnabled;
626
+ }
627
+ @ReactMethod
628
+ public void isLocationEnabled(Promise p) { p.resolve(isLocationEnabledSync()); }
629
+
630
+ @ReactMethod(isBlockingSynchronousMethod = true)
631
+ public boolean isHeadphonesConnectedSync() {
632
+ AudioManager audioManager = (AudioManager)getReactApplicationContext().getSystemService(Context.AUDIO_SERVICE);
633
+ return audioManager.isWiredHeadsetOn() || audioManager.isBluetoothA2dpOn();
634
+ }
635
+ @ReactMethod
636
+ public void isHeadphonesConnected(Promise p) {p.resolve(isHeadphonesConnectedSync());}
637
+
638
+ @ReactMethod(isBlockingSynchronousMethod = true)
639
+ public WritableMap getAvailableLocationProvidersSync() {
640
+ LocationManager mLocationManager = (LocationManager) getReactApplicationContext().getSystemService(Context.LOCATION_SERVICE);
641
+ WritableMap providersAvailability = Arguments.createMap();
642
+ try {
643
+ List<String> providers = mLocationManager.getProviders(false);
644
+ for (String provider : providers) {
645
+ providersAvailability.putBoolean(provider, mLocationManager.isProviderEnabled(provider));
646
+ }
647
+ } catch (Exception e) {
648
+ System.err.println("Unable to get location providers. LocationManager was null");
649
+ }
650
+
651
+ return providersAvailability;
652
+ }
653
+ @ReactMethod
654
+ public void getAvailableLocationProviders(Promise p) { p.resolve(getAvailableLocationProvidersSync()); }
655
+
656
+ @ReactMethod(isBlockingSynchronousMethod = true)
657
+ public String getInstallReferrerSync() {
658
+ SharedPreferences sharedPref = getRNDISharedPreferences(getReactApplicationContext());
659
+ return sharedPref.getString("installReferrer", Build.UNKNOWN);
660
+ }
661
+ @ReactMethod
662
+ public void getInstallReferrer(Promise p) { p.resolve(getInstallReferrerSync()); }
663
+
664
+ private PackageInfo getPackageInfo() throws Exception {
665
+ return getReactApplicationContext().getPackageManager().getPackageInfo(getReactApplicationContext().getPackageName(), 0);
666
+ }
667
+
668
+ @ReactMethod(isBlockingSynchronousMethod = true)
669
+ public String getInstallerPackageNameSync() {
670
+ String packageName = getReactApplicationContext().getPackageName();
671
+ String installerPackageName = getReactApplicationContext().getPackageManager().getInstallerPackageName(packageName);
672
+
673
+ if (installerPackageName == null) {
674
+ return "unknown";
675
+ }
676
+
677
+ return installerPackageName;
678
+ }
679
+
680
+ @ReactMethod
681
+ public void getInstallerPackageName(Promise p) { p.resolve(getInstallerPackageNameSync()); }
682
+
683
+ @ReactMethod(isBlockingSynchronousMethod = true)
684
+ public double getFirstInstallTimeSync() {
685
+ try {
686
+ return (double)getPackageInfo().firstInstallTime;
687
+ } catch (Exception e) {
688
+ return -1;
689
+ }
690
+ }
691
+ @ReactMethod
692
+ public void getFirstInstallTime(Promise p) { p.resolve(getFirstInstallTimeSync()); }
693
+
694
+ @ReactMethod(isBlockingSynchronousMethod = true)
695
+ public double getLastUpdateTimeSync() {
696
+ try {
697
+ return (double)getPackageInfo().lastUpdateTime;
698
+ } catch (Exception e) {
699
+ return -1;
700
+ }
701
+ }
702
+ @ReactMethod
703
+ public void getLastUpdateTime(Promise p) { p.resolve(getLastUpdateTimeSync()); }
704
+
705
+ @ReactMethod(isBlockingSynchronousMethod = true)
706
+ public String getDeviceNameSync() {
707
+ try {
708
+ if (Build.VERSION.SDK_INT <= 31) {
709
+ String bluetoothName = Settings.Secure.getString(getReactApplicationContext().getContentResolver(), "bluetooth_name");
710
+ if (bluetoothName != null) {
711
+ return bluetoothName;
712
+ }
713
+ }
714
+
715
+ if (Build.VERSION.SDK_INT >= 25) {
716
+ String deviceName = Settings.Global.getString(getReactApplicationContext().getContentResolver(), Settings.Global.DEVICE_NAME);
717
+ if (deviceName != null) {
718
+ return deviceName;
719
+ }
720
+ }
721
+ } catch (Exception e) {
722
+ // same as default unknown return
723
+ }
724
+ return "unknown";
725
+ }
726
+ @ReactMethod
727
+ public void getDeviceName(Promise p) { p.resolve(getDeviceNameSync()); }
728
+
729
+ @SuppressLint({"HardwareIds", "MissingPermission"})
730
+ @ReactMethod(isBlockingSynchronousMethod = true)
731
+ public String getSerialNumberSync() {
732
+ try {
733
+ if (Build.VERSION.SDK_INT >= 26) {
734
+ // There are a lot of conditions to access to getSerial api
735
+ // For details, see https://developer.android.com/reference/android/os/Build#getSerial()
736
+ // Rather than check each one, just try and rely on the catch below, for discussion on this approach, refer to
737
+ // https://github.com/react-native-device-info/react-native-device-info/issues/1320
738
+ return Build.getSerial();
739
+ } else {
740
+ return Build.SERIAL;
741
+ }
742
+ } catch (Exception e) {
743
+ // This is almost always a PermissionException. We will log it but return unknown
744
+ System.err.println("getSerialNumber failed, it probably should not be used: " + e.getMessage());
745
+ }
746
+
747
+ return "unknown";
748
+ }
749
+ @ReactMethod
750
+ public void getSerialNumber(Promise p) { p.resolve(getSerialNumberSync()); }
751
+
752
+ @ReactMethod(isBlockingSynchronousMethod = true)
753
+ public String getDeviceSync() { return Build.DEVICE; }
754
+ @ReactMethod
755
+ public void getDevice(Promise p) { p.resolve(getDeviceSync()); }
756
+
757
+ @ReactMethod(isBlockingSynchronousMethod = true)
758
+ public String getBuildIdSync() { return Build.ID; }
759
+ @ReactMethod
760
+ public void getBuildId(Promise p) { p.resolve(getBuildIdSync()); }
761
+
762
+ @ReactMethod(isBlockingSynchronousMethod = true)
763
+ public int getApiLevelSync() { return Build.VERSION.SDK_INT; }
764
+ @ReactMethod
765
+ public void getApiLevel(Promise p) { p.resolve(getApiLevelSync()); }
766
+
767
+ @ReactMethod(isBlockingSynchronousMethod = true)
768
+ public String getBootloaderSync() { return Build.BOOTLOADER; }
769
+ @ReactMethod
770
+ public void getBootloader(Promise p) { p.resolve(getBootloaderSync()); }
771
+
772
+ @ReactMethod(isBlockingSynchronousMethod = true)
773
+ public String getDisplaySync() { return Build.DISPLAY; }
774
+ @ReactMethod
775
+ public void getDisplay(Promise p) { p.resolve(getDisplaySync()); }
776
+
777
+ @ReactMethod(isBlockingSynchronousMethod = true)
778
+ public String getFingerprintSync() { return Build.FINGERPRINT; }
779
+ @ReactMethod
780
+ public void getFingerprint(Promise p) { p.resolve(getFingerprintSync()); }
781
+
782
+ @ReactMethod(isBlockingSynchronousMethod = true)
783
+ public String getHardwareSync() { return Build.HARDWARE; }
784
+ @ReactMethod
785
+ public void getHardware(Promise p) { p.resolve(getHardwareSync()); }
786
+
787
+ @ReactMethod(isBlockingSynchronousMethod = true)
788
+ public String getHostSync() { return Build.HOST; }
789
+ @ReactMethod
790
+ public void getHost(Promise p) { p.resolve(getHostSync()); }
791
+
792
+ @ReactMethod(isBlockingSynchronousMethod = true)
793
+ public String getProductSync() { return Build.PRODUCT; }
794
+ @ReactMethod
795
+ public void getProduct(Promise p) { p.resolve(getProductSync()); }
796
+
797
+ @ReactMethod(isBlockingSynchronousMethod = true)
798
+ public String getTagsSync() { return Build.TAGS; }
799
+ @ReactMethod
800
+ public void getTags(Promise p) { p.resolve(getTagsSync()); }
801
+
802
+ @ReactMethod(isBlockingSynchronousMethod = true)
803
+ public String getTypeSync() { return Build.TYPE; }
804
+ @ReactMethod
805
+ public void getType(Promise p) { p.resolve(getTypeSync()); }
806
+
807
+ @ReactMethod(isBlockingSynchronousMethod = true)
808
+ public String getSystemManufacturerSync() { return Build.MANUFACTURER; }
809
+ @ReactMethod
810
+ public void getSystemManufacturer(Promise p) { p.resolve(getSystemManufacturerSync()); }
811
+
812
+ @ReactMethod(isBlockingSynchronousMethod = true)
813
+ public String getCodenameSync() { return Build.VERSION.CODENAME; }
814
+ @ReactMethod
815
+ public void getCodename(Promise p) { p.resolve(getCodenameSync()); }
816
+
817
+ @ReactMethod(isBlockingSynchronousMethod = true)
818
+ public String getIncrementalSync() { return Build.VERSION.INCREMENTAL; }
819
+ @ReactMethod
820
+ public void getIncremental(Promise p) { p.resolve(getIncrementalSync()); }
821
+
822
+ @SuppressLint("HardwareIds")
823
+ @ReactMethod(isBlockingSynchronousMethod = true)
824
+ public String getUniqueIdSync() { return getString(getReactApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID); }
825
+ @ReactMethod
826
+ public void getUniqueId(Promise p) {
827
+ p.resolve(getUniqueIdSync());
828
+ }
829
+
830
+ @SuppressLint("HardwareIds")
831
+ @ReactMethod(isBlockingSynchronousMethod = true)
832
+ public String getAndroidIdSync() { return getUniqueIdSync(); }
833
+ @ReactMethod
834
+ public void getAndroidId(Promise p) { p.resolve(getAndroidIdSync()); }
835
+
836
+ @ReactMethod(isBlockingSynchronousMethod = true)
837
+ public double getMaxMemorySync() { return (double)Runtime.getRuntime().maxMemory(); }
838
+ @ReactMethod
839
+ public void getMaxMemory(Promise p) { p.resolve(getMaxMemorySync()); }
840
+
841
+ @ReactMethod(isBlockingSynchronousMethod = true)
842
+ public double getTotalMemorySync() {
843
+ ActivityManager actMgr = (ActivityManager) getReactApplicationContext().getSystemService(ACTIVITY_SERVICE);
844
+ ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
845
+ if (actMgr != null) {
846
+ actMgr.getMemoryInfo(memInfo);
847
+ } else {
848
+ System.err.println("Unable to getMemoryInfo. ActivityManager was null");
849
+ return -1;
850
+ }
851
+ return (double)memInfo.totalMem;
852
+ }
853
+ @ReactMethod
854
+ public void getTotalMemory(Promise p) { p.resolve(getTotalMemorySync()); }
855
+
856
+ @ReactMethod(isBlockingSynchronousMethod = true)
857
+ @SuppressWarnings({"ConstantConditions", "deprecation"})
858
+ public String getInstanceIdSync() {
859
+ return deviceIdResolver.getInstanceIdSync();
860
+ }
861
+ @ReactMethod
862
+ public void getInstanceId(Promise p) { p.resolve(getInstanceIdSync()); }
863
+
864
+ @ReactMethod(isBlockingSynchronousMethod = true)
865
+ public String getBaseOsSync() {
866
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
867
+ return Build.VERSION.BASE_OS;
868
+ }
869
+ return "unknown";
870
+ }
871
+ @ReactMethod
872
+ public void getBaseOs(Promise p) { p.resolve(getBaseOsSync()); }
873
+
874
+ @ReactMethod(isBlockingSynchronousMethod = true)
875
+ public String getPreviewSdkIntSync() {
876
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
877
+ return Integer.toString(Build.VERSION.PREVIEW_SDK_INT);
878
+ }
879
+ return "unknown";
880
+ }
881
+ @ReactMethod
882
+ public void getPreviewSdkInt(Promise p) { p.resolve(getPreviewSdkIntSync()); }
883
+
884
+ @ReactMethod(isBlockingSynchronousMethod = true)
885
+ public String getSecurityPatchSync() {
886
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
887
+ return Build.VERSION.SECURITY_PATCH;
888
+ }
889
+ return "unknown";
890
+ }
891
+ @ReactMethod
892
+ public void getSecurityPatch(Promise p) { p.resolve(getSecurityPatchSync()); }
893
+
894
+ @ReactMethod(isBlockingSynchronousMethod = true)
895
+ public String getUserAgentSync() {
896
+ try {
897
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
898
+ return WebSettings.getDefaultUserAgent(getReactApplicationContext());
899
+ } else {
900
+ return System.getProperty("http.agent");
901
+ }
902
+ } catch (RuntimeException e) {
903
+ return System.getProperty("http.agent");
904
+ }
905
+ }
906
+ @ReactMethod
907
+ public void getUserAgent(Promise p) { p.resolve(getUserAgentSync()); }
908
+
909
+ @SuppressLint({"HardwareIds", "MissingPermission"})
910
+ @ReactMethod(isBlockingSynchronousMethod = true)
911
+ public String getPhoneNumberSync() {
912
+ if (getReactApplicationContext() != null &&
913
+ (getReactApplicationContext().checkCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED ||
914
+ (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && getReactApplicationContext().checkCallingOrSelfPermission(Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED) ||
915
+ (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && getReactApplicationContext().checkCallingOrSelfPermission(Manifest.permission.READ_PHONE_NUMBERS) == PackageManager.PERMISSION_GRANTED))) {
916
+ TelephonyManager telMgr = (TelephonyManager) getReactApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
917
+ if (telMgr != null) {
918
+ try {
919
+ return telMgr.getLine1Number();
920
+ } catch (SecurityException e) {
921
+ System.err.println("getLine1Number called with permission, but threw anyway: " + e.getMessage());
922
+ }
923
+ } else {
924
+ System.err.println("Unable to getPhoneNumber. TelephonyManager was null");
925
+ }
926
+ }
927
+ return "unknown";
928
+ }
929
+ @ReactMethod
930
+ public void getPhoneNumber(Promise p) { p.resolve(getPhoneNumberSync()); }
931
+
932
+ @ReactMethod(isBlockingSynchronousMethod = true)
933
+ public WritableArray getSupportedAbisSync() {
934
+ WritableArray array = new WritableNativeArray();
935
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
936
+ for (String abi : Build.SUPPORTED_ABIS) {
937
+ array.pushString(abi);
938
+ }
939
+ } else {
940
+ array.pushString(Build.CPU_ABI);
941
+ }
942
+ return array;
943
+ }
944
+ @ReactMethod
945
+ public void getSupportedAbis(Promise p) { p.resolve(getSupportedAbisSync()); }
946
+
947
+ @ReactMethod(isBlockingSynchronousMethod = true)
948
+ public WritableArray getSupported32BitAbisSync() {
949
+ WritableArray array = new WritableNativeArray();
950
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
951
+ for (String abi : Build.SUPPORTED_32_BIT_ABIS) {
952
+ array.pushString(abi);
953
+ }
954
+ }
955
+ return array;
956
+ }
957
+ @ReactMethod
958
+ public void getSupported32BitAbis(Promise p) { p.resolve(getSupported32BitAbisSync()); }
959
+
960
+ @ReactMethod(isBlockingSynchronousMethod = true)
961
+ public WritableArray getSupported64BitAbisSync() {
962
+ WritableArray array = new WritableNativeArray();
963
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
964
+ for (String abi : Build.SUPPORTED_64_BIT_ABIS) {
965
+ array.pushString(abi);
966
+ }
967
+ }
968
+ return array;
969
+ }
970
+ @ReactMethod
971
+ public void getSupported64BitAbis(Promise p) { p.resolve(getSupported64BitAbisSync()); }
972
+
973
+
974
+ private WritableMap getPowerStateFromIntent (Intent intent) {
975
+ if(intent == null) {
976
+ return null;
977
+ }
978
+
979
+ int batteryLevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
980
+ int batteryScale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
981
+ int isPlugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
982
+ int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
983
+
984
+ float batteryPercentage = batteryLevel / (float)batteryScale;
985
+
986
+ String batteryState = "unknown";
987
+
988
+ if(isPlugged == 0) {
989
+ batteryState = "unplugged";
990
+ } else if(status == BATTERY_STATUS_CHARGING) {
991
+ batteryState = "charging";
992
+ } else if(status == BATTERY_STATUS_FULL) {
993
+ batteryState = "full";
994
+ }
995
+
996
+ PowerManager powerManager = (PowerManager)getReactApplicationContext().getSystemService(Context.POWER_SERVICE);
997
+ boolean powerSaveMode = false;
998
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
999
+ powerSaveMode = powerManager.isPowerSaveMode();
1000
+ }
1001
+
1002
+ WritableMap powerState = Arguments.createMap();
1003
+ powerState.putString(BATTERY_STATE, batteryState);
1004
+ powerState.putDouble(BATTERY_LEVEL, batteryPercentage);
1005
+ powerState.putBoolean(LOW_POWER_MODE, powerSaveMode);
1006
+
1007
+ return powerState;
1008
+ }
1009
+
1010
+ private void sendEvent(ReactContext reactContext,
1011
+ String eventName,
1012
+ @Nullable Object data) {
1013
+ reactContext
1014
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
1015
+ .emit(eventName, data);
1016
+ }
1017
+
1018
+ @ReactMethod(isBlockingSynchronousMethod = true)
1019
+ public WritableArray getSupportedMediaTypeListSync() {
1020
+ WritableArray writableArray = new WritableNativeArray();
1021
+ for (int i = 0; i < MediaCodecList.getCodecCount(); i++) {
1022
+ MediaCodecInfo mediaCodecInfo = MediaCodecList.getCodecInfoAt(i);
1023
+ String[] supportedTypes = mediaCodecInfo.getSupportedTypes();
1024
+ for (int j = 0; j < supportedTypes.length; j++) {
1025
+ writableArray.pushString(supportedTypes[j]);
1026
+ }
1027
+ }
1028
+ return writableArray;
1029
+
1030
+ }
1031
+
1032
+ @ReactMethod
1033
+ public void getSupportedMediaTypeList(Promise promise) {
1034
+ promise.resolve(getSupportedMediaTypeListSync());
1035
+ }
1036
+ }