@100mslive/react-native-hms 1.1.0 → 1.2.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 (101) hide show
  1. package/README.md +145 -340
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +205 -75
  4. package/android/src/main/java/com/reactnativehmssdk/HMSHelper.kt +127 -127
  5. package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +153 -115
  6. package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +147 -17
  7. package/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManager.kt +7 -7
  8. package/ios/HMSDecoder.swift +205 -129
  9. package/ios/HMSHelper.swift +3 -3
  10. package/ios/HMSManager.m +3 -0
  11. package/ios/HMSManager.swift +22 -1
  12. package/ios/HMSRNSDK.swift +228 -79
  13. package/ios/HMSView.m +2 -0
  14. package/ios/HMSView.swift +35 -3
  15. package/ios/Hmssdk.xcodeproj/project.xcworkspace/xcuserdata/yogesh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  16. package/lib/commonjs/classes/HMSBrowserRecordingState.js.map +1 -1
  17. package/lib/commonjs/classes/HMSChangeTrackStateRequest.js.map +1 -1
  18. package/lib/commonjs/classes/HMSEncoder.js +133 -84
  19. package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
  20. package/lib/commonjs/classes/HMSHLSStreamingState.js.map +1 -1
  21. package/lib/commonjs/classes/HMSLocalVideoTrack.js +0 -2
  22. package/lib/commonjs/classes/HMSLocalVideoTrack.js.map +1 -1
  23. package/lib/commonjs/classes/HMSMessageRecipient.js +1 -1
  24. package/lib/commonjs/classes/HMSMessageRecipient.js.map +1 -1
  25. package/lib/commonjs/classes/HMSNativeEventEmitter.js +106 -0
  26. package/lib/commonjs/classes/HMSNativeEventEmitter.js.map +1 -0
  27. package/lib/commonjs/classes/HMSPeer.js +4 -0
  28. package/lib/commonjs/classes/HMSPeer.js.map +1 -1
  29. package/lib/commonjs/classes/HMSPublishSettings.js +0 -6
  30. package/lib/commonjs/classes/HMSPublishSettings.js.map +1 -1
  31. package/lib/commonjs/classes/HMSRole.js +0 -6
  32. package/lib/commonjs/classes/HMSRole.js.map +1 -1
  33. package/lib/commonjs/classes/HMSRoleChangeRequest.js +3 -1
  34. package/lib/commonjs/classes/HMSRoleChangeRequest.js.map +1 -1
  35. package/lib/commonjs/classes/HMSRtmpStreamingState.js.map +1 -1
  36. package/lib/commonjs/classes/HMSSDK.js +465 -137
  37. package/lib/commonjs/classes/HMSSDK.js.map +1 -1
  38. package/lib/commonjs/classes/HMSServerRecordingState.js.map +1 -1
  39. package/lib/commonjs/classes/HMSSubscribeSettings.js +0 -2
  40. package/lib/commonjs/classes/HMSSubscribeSettings.js.map +1 -1
  41. package/lib/commonjs/index.js.map +1 -1
  42. package/lib/module/classes/HMSBrowserRecordingState.js.map +1 -1
  43. package/lib/module/classes/HMSChangeTrackStateRequest.js.map +1 -1
  44. package/lib/module/classes/HMSEncoder.js +133 -84
  45. package/lib/module/classes/HMSEncoder.js.map +1 -1
  46. package/lib/module/classes/HMSHLSStreamingState.js.map +1 -1
  47. package/lib/module/classes/HMSLocalVideoTrack.js +0 -2
  48. package/lib/module/classes/HMSLocalVideoTrack.js.map +1 -1
  49. package/lib/module/classes/HMSMessageRecipient.js +1 -1
  50. package/lib/module/classes/HMSMessageRecipient.js.map +1 -1
  51. package/lib/module/classes/HMSNativeEventEmitter.js +99 -0
  52. package/lib/module/classes/HMSNativeEventEmitter.js.map +1 -0
  53. package/lib/module/classes/HMSPeer.js +4 -0
  54. package/lib/module/classes/HMSPeer.js.map +1 -1
  55. package/lib/module/classes/HMSPublishSettings.js +0 -6
  56. package/lib/module/classes/HMSPublishSettings.js.map +1 -1
  57. package/lib/module/classes/HMSRole.js +0 -6
  58. package/lib/module/classes/HMSRole.js.map +1 -1
  59. package/lib/module/classes/HMSRoleChangeRequest.js +3 -1
  60. package/lib/module/classes/HMSRoleChangeRequest.js.map +1 -1
  61. package/lib/module/classes/HMSRtmpStreamingState.js.map +1 -1
  62. package/lib/module/classes/HMSSDK.js +466 -138
  63. package/lib/module/classes/HMSSDK.js.map +1 -1
  64. package/lib/module/classes/HMSServerRecordingState.js.map +1 -1
  65. package/lib/module/classes/HMSSubscribeSettings.js +0 -2
  66. package/lib/module/classes/HMSSubscribeSettings.js.map +1 -1
  67. package/lib/module/index.js.map +1 -1
  68. package/lib/typescript/classes/HMSBrowserRecordingState.d.ts +4 -4
  69. package/lib/typescript/classes/HMSChangeTrackStateRequest.d.ts +2 -2
  70. package/lib/typescript/classes/HMSEncoder.d.ts +3 -0
  71. package/lib/typescript/classes/HMSHLSStreamingState.d.ts +2 -2
  72. package/lib/typescript/classes/HMSLocalVideoTrack.d.ts +0 -2
  73. package/lib/typescript/classes/HMSMessageRecipient.d.ts +2 -2
  74. package/lib/typescript/classes/HMSNativeEventEmitter.d.ts +13 -0
  75. package/lib/typescript/classes/HMSPublishSettings.d.ts +8 -15
  76. package/lib/typescript/classes/HMSRole.d.ts +0 -6
  77. package/lib/typescript/classes/HMSRoleChangeRequest.d.ts +2 -2
  78. package/lib/typescript/classes/HMSRtmpStreamingState.d.ts +4 -4
  79. package/lib/typescript/classes/HMSSDK.d.ts +2 -12
  80. package/lib/typescript/classes/HMSServerRecordingState.d.ts +2 -2
  81. package/lib/typescript/classes/HMSSubscribeSettings.d.ts +0 -2
  82. package/lib/typescript/index.d.ts +1 -0
  83. package/package.json +6 -4
  84. package/react-native-hms.podspec +1 -1
  85. package/sdk-versions.json +5 -0
  86. package/src/classes/HMSBrowserRecordingState.ts +4 -4
  87. package/src/classes/HMSChangeTrackStateRequest.ts +2 -2
  88. package/src/classes/HMSEncoder.ts +186 -99
  89. package/src/classes/HMSHLSStreamingState.ts +2 -2
  90. package/src/classes/HMSLocalVideoTrack.ts +0 -2
  91. package/src/classes/HMSMessageRecipient.ts +3 -3
  92. package/src/classes/HMSNativeEventEmitter.ts +86 -0
  93. package/src/classes/HMSPeer.ts +4 -0
  94. package/src/classes/HMSPublishSettings.ts +8 -18
  95. package/src/classes/HMSRole.ts +0 -9
  96. package/src/classes/HMSRoleChangeRequest.ts +5 -3
  97. package/src/classes/HMSRtmpStreamingState.ts +4 -4
  98. package/src/classes/HMSSDK.tsx +629 -269
  99. package/src/classes/HMSServerRecordingState.ts +2 -2
  100. package/src/classes/HMSSubscribeSettings.ts +1 -7
  101. package/src/index.ts +1 -0
@@ -3,11 +3,8 @@ package com.reactnativehmssdk
3
3
  import android.app.Activity
4
4
  import android.app.Application
5
5
  import android.app.PendingIntent
6
- import android.app.PictureInPictureParams
7
- import android.app.RemoteAction
8
6
  import android.content.Intent
9
7
  import android.content.pm.PackageManager
10
- import android.graphics.drawable.Icon
11
8
  import android.os.Build
12
9
  import android.os.Bundle
13
10
  import android.util.Rational
@@ -450,6 +447,27 @@ class HMSManager(reactContext: ReactApplicationContext) :
450
447
  hms?.getSessionMetaData(callback)
451
448
  }
452
449
 
450
+ @ReactMethod
451
+ fun enableEvent(data: ReadableMap, promise: Promise?) {
452
+ val hms = HMSHelper.getHms(data, hmsCollection)
453
+
454
+ hms?.enableEvent(data, promise)
455
+ }
456
+
457
+ @ReactMethod
458
+ fun disableEvent(data: ReadableMap, promise: Promise?) {
459
+ val hms = HMSHelper.getHms(data, hmsCollection)
460
+
461
+ hms?.disableEvent(data, promise)
462
+ }
463
+
464
+ @ReactMethod()
465
+ fun restrictData(data: ReadableMap, promise: Promise?) {
466
+ val hms = HMSHelper.getHms(data, hmsCollection)
467
+
468
+ hms?.restrictData(data, promise)
469
+ }
470
+
453
471
  // region Person-In-Person Mode Action handing
454
472
  private val pipReceiver by lazy {
455
473
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@@ -471,10 +489,13 @@ class HMSManager(reactContext: ReactApplicationContext) :
471
489
  }
472
490
  }
473
491
 
474
- private var pipRemoteActionsList: MutableList<RemoteAction> = mutableListOf()
492
+ private var pipRemoteActionsList: MutableList<Any> = mutableListOf()
475
493
 
476
494
  @RequiresApi(Build.VERSION_CODES.O)
477
495
  private fun toggleLocalAudio() {
496
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
497
+ return
498
+ }
478
499
  val hmssdk = getHmsInstance()[PipActionReceiver.sdkIdForPIP!!]?.hmsSDK
479
500
 
480
501
  val localAudioTrack = hmssdk?.getLocalPeer()?.audioTrack
@@ -487,6 +508,9 @@ class HMSManager(reactContext: ReactApplicationContext) :
487
508
 
488
509
  @RequiresApi(Build.VERSION_CODES.O)
489
510
  private fun toggleLocalVideo() {
511
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
512
+ return
513
+ }
490
514
  val hmssdk = getHmsInstance()[PipActionReceiver.sdkIdForPIP!!]?.hmsSDK
491
515
 
492
516
  val localVideoTrack = hmssdk?.getLocalPeer()?.videoTrack
@@ -499,6 +523,9 @@ class HMSManager(reactContext: ReactApplicationContext) :
499
523
 
500
524
  @RequiresApi(Build.VERSION_CODES.O)
501
525
  private fun endMeeting() {
526
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
527
+ return
528
+ }
502
529
  val hms = getHmsInstance()[PipActionReceiver.sdkIdForPIP!!]
503
530
 
504
531
  hms?.leave(callback = null, fromPIP = true)
@@ -506,6 +533,10 @@ class HMSManager(reactContext: ReactApplicationContext) :
506
533
 
507
534
  @RequiresApi(Build.VERSION_CODES.O)
508
535
  private fun updatePIPRemoteActions(code: Int) {
536
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
537
+ return
538
+ }
539
+
509
540
  val activity = currentActivity
510
541
 
511
542
  if (activity !== null) {
@@ -513,10 +544,10 @@ class HMSManager(reactContext: ReactApplicationContext) :
513
544
 
514
545
  when (code) {
515
546
  PipActionReceiver.PIPActions.localAudio.requestCode -> {
516
- val audioActionIdx = pipRemoteActionsList.indexOfFirst { it.title == PipActionReceiver.PIPActions.localAudio.title }
547
+ val audioActionIdx = pipRemoteActionsList.indexOfFirst { it is android.app.RemoteAction && it.title == PipActionReceiver.PIPActions.localAudio.title }
517
548
  if (audioActionIdx >= 0) {
518
- pipRemoteActionsList[audioActionIdx] = RemoteAction(
519
- Icon.createWithResource(
549
+ pipRemoteActionsList[audioActionIdx] = android.app.RemoteAction(
550
+ android.graphics.drawable.Icon.createWithResource(
520
551
  reactApplicationContext,
521
552
  if (hmssdk?.getLocalPeer()?.audioTrack?.isMute === true) R.drawable.ic_mic_off_24 else R.drawable.ic_mic_24
522
553
  ),
@@ -532,12 +563,14 @@ class HMSManager(reactContext: ReactApplicationContext) :
532
563
  }
533
564
  }
534
565
  PipActionReceiver.PIPActions.localVideo.requestCode -> {
535
- val videoActionIdx = pipRemoteActionsList.indexOfFirst { it.title == PipActionReceiver.PIPActions.localVideo.title }
566
+ val videoActionIdx = pipRemoteActionsList.indexOfFirst { it is android.app.RemoteAction && it.title == PipActionReceiver.PIPActions.localVideo.title }
536
567
  if (videoActionIdx >= 0) {
537
- pipRemoteActionsList[videoActionIdx] = RemoteAction(
538
- Icon.createWithResource(
568
+ val isVideoMute = hmssdk?.getLocalPeer()?.videoTrack?.isMute
569
+ val updatedIcon = if (isVideoMute === true) R.drawable.ic_camera_toggle_off else R.drawable.ic_camera_toggle_on
570
+ pipRemoteActionsList[videoActionIdx] = android.app.RemoteAction(
571
+ android.graphics.drawable.Icon.createWithResource(
539
572
  reactApplicationContext,
540
- if (hmssdk?.getLocalPeer()?.videoTrack?.isMute === true) R.drawable.ic_camera_toggle_off else R.drawable.ic_camera_toggle_on
573
+ updatedIcon
541
574
  ),
542
575
  PipActionReceiver.PIPActions.localVideo.title,
543
576
  PipActionReceiver.PIPActions.localVideo.description,
@@ -552,8 +585,8 @@ class HMSManager(reactContext: ReactApplicationContext) :
552
585
  }
553
586
  }
554
587
 
555
- val pipParams = PictureInPictureParams.Builder().let {
556
- it.setActions(pipRemoteActionsList)
588
+ val pipParams = android.app.PictureInPictureParams.Builder().let {
589
+ it.setActions(pipRemoteActionsList.filterIsInstance<android.app.RemoteAction>())
557
590
  it.build()
558
591
  }
559
592
 
@@ -603,82 +636,15 @@ class HMSManager(reactContext: ReactApplicationContext) :
603
636
  }
604
637
  }
605
638
 
639
+ // Builds and returns PictureInPictureParams as per given config
640
+ // `Any` type is used here to prevent crashes on "SDK < API level 26"
606
641
  @RequiresApi(Build.VERSION_CODES.O)
607
- private fun getPIPRemoteActions(endAction: Boolean = false, audioAction: Boolean = false, videoAction: Boolean = false): MutableList<RemoteAction> {
608
- val hmssdk = getHmsInstance()[PipActionReceiver.sdkIdForPIP!!]?.hmsSDK
609
-
610
- pipRemoteActionsList.clear()
611
-
612
- val localPeer = hmssdk?.getLocalPeer()
613
- val allowedPublishing = localPeer?.hmsRole?.publishParams?.allowed
614
-
615
- if (audioAction && allowedPublishing?.contains("audio") === true) {
616
- pipRemoteActionsList.add(
617
- RemoteAction(
618
- Icon.createWithResource(
619
- reactApplicationContext,
620
- if (localPeer?.audioTrack?.isMute === true) R.drawable.ic_mic_off_24 else R.drawable.ic_mic_24
621
- ),
622
- PipActionReceiver.PIPActions.localAudio.title,
623
- PipActionReceiver.PIPActions.localAudio.description,
624
- PendingIntent.getBroadcast(
625
- reactApplicationContext,
626
- PipActionReceiver.PIPActions.localAudio.requestCode,
627
- Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(PipActionReceiver.PIPActions.localAudio.title, PipActionReceiver.PIPActions.localAudio.requestCode),
628
- PendingIntent.FLAG_IMMUTABLE
629
- )
630
- )
631
- )
632
- }
633
-
634
- if (endAction) {
635
- pipRemoteActionsList.add(
636
- RemoteAction(
637
- Icon.createWithResource(reactApplicationContext, R.drawable.ic_call_end_24),
638
- PipActionReceiver.PIPActions.endMeet.title,
639
- PipActionReceiver.PIPActions.endMeet.description,
640
- PendingIntent.getBroadcast(
641
- reactApplicationContext,
642
- PipActionReceiver.PIPActions.endMeet.requestCode,
643
- Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(
644
- PipActionReceiver.PIPActions.endMeet.title,
645
- PipActionReceiver.PIPActions.endMeet.requestCode
646
- ),
647
- PendingIntent.FLAG_IMMUTABLE
648
- )
649
- )
650
- )
651
- }
652
-
653
- if (videoAction && allowedPublishing?.contains("video") === true) {
654
- pipRemoteActionsList.add(
655
- RemoteAction(
656
- Icon.createWithResource(
657
- reactApplicationContext,
658
- if (localPeer?.videoTrack?.isMute === true) R.drawable.ic_camera_toggle_off else R.drawable.ic_camera_toggle_on
659
- ),
660
- PipActionReceiver.PIPActions.localVideo.title,
661
- PipActionReceiver.PIPActions.localVideo.description,
662
- PendingIntent.getBroadcast(
663
- reactApplicationContext,
664
- PipActionReceiver.PIPActions.localVideo.requestCode,
665
- Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(
666
- PipActionReceiver.PIPActions.localVideo.title,
667
- PipActionReceiver.PIPActions.localVideo.requestCode
668
- ),
669
- PendingIntent.FLAG_IMMUTABLE
670
- )
671
- )
672
- )
642
+ private fun buildPipParams(config: PipParamConfig): Any? {
643
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
644
+ return null
673
645
  }
674
646
 
675
- return pipRemoteActionsList
676
- }
677
-
678
- // Builds and returns PictureInPictureParams as per given config
679
- @RequiresApi(Build.VERSION_CODES.O)
680
- private fun buildPipParams(config: PipParamConfig): PictureInPictureParams {
681
- val pipParams = PictureInPictureParams.Builder().let {
647
+ val pipParams = android.app.PictureInPictureParams.Builder().let {
682
648
  if (config.aspectRatio !== null) {
683
649
  it.setAspectRatio(
684
650
  Rational(
@@ -693,13 +659,76 @@ class HMSManager(reactContext: ReactApplicationContext) :
693
659
  // it.setAutoEnterEnabled(config.autoEnterEnabled)
694
660
  // }
695
661
 
696
- it.setActions(
697
- getPIPRemoteActions(
698
- endAction = config.showEndButton,
699
- audioAction = config.showAudioButton,
700
- videoAction = config.showVideoButton
662
+ // region Setting RemoteActions on PictureInPictureParams
663
+ val hmssdk = getHmsInstance()[PipActionReceiver.sdkIdForPIP!!]?.hmsSDK
664
+
665
+ pipRemoteActionsList.clear()
666
+
667
+ val localPeer = hmssdk?.getLocalPeer()
668
+ val allowedPublishing = localPeer?.hmsRole?.publishParams?.allowed
669
+
670
+ if (config.showAudioButton && allowedPublishing?.contains("audio") === true) {
671
+ pipRemoteActionsList.add(
672
+ android.app.RemoteAction(
673
+ android.graphics.drawable.Icon.createWithResource(
674
+ reactApplicationContext,
675
+ if (localPeer?.audioTrack?.isMute === true) R.drawable.ic_mic_off_24 else R.drawable.ic_mic_24
676
+ ),
677
+ PipActionReceiver.PIPActions.localAudio.title,
678
+ PipActionReceiver.PIPActions.localAudio.description,
679
+ PendingIntent.getBroadcast(
680
+ reactApplicationContext,
681
+ PipActionReceiver.PIPActions.localAudio.requestCode,
682
+ Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(PipActionReceiver.PIPActions.localAudio.title, PipActionReceiver.PIPActions.localAudio.requestCode),
683
+ PendingIntent.FLAG_IMMUTABLE
684
+ )
685
+ )
701
686
  )
702
- )
687
+ }
688
+
689
+ if (config.showEndButton) {
690
+ pipRemoteActionsList.add(
691
+ android.app.RemoteAction(
692
+ android.graphics.drawable.Icon.createWithResource(reactApplicationContext, R.drawable.ic_call_end_24),
693
+ PipActionReceiver.PIPActions.endMeet.title,
694
+ PipActionReceiver.PIPActions.endMeet.description,
695
+ PendingIntent.getBroadcast(
696
+ reactApplicationContext,
697
+ PipActionReceiver.PIPActions.endMeet.requestCode,
698
+ Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(
699
+ PipActionReceiver.PIPActions.endMeet.title,
700
+ PipActionReceiver.PIPActions.endMeet.requestCode
701
+ ),
702
+ PendingIntent.FLAG_IMMUTABLE
703
+ )
704
+ )
705
+ )
706
+ }
707
+
708
+ if (config.showVideoButton && allowedPublishing?.contains("video") === true) {
709
+ pipRemoteActionsList.add(
710
+ android.app.RemoteAction(
711
+ android.graphics.drawable.Icon.createWithResource(
712
+ reactApplicationContext,
713
+ if (localPeer?.videoTrack?.isMute === true) R.drawable.ic_camera_toggle_off else R.drawable.ic_camera_toggle_on
714
+ ),
715
+ PipActionReceiver.PIPActions.localVideo.title,
716
+ PipActionReceiver.PIPActions.localVideo.description,
717
+ PendingIntent.getBroadcast(
718
+ reactApplicationContext,
719
+ PipActionReceiver.PIPActions.localVideo.requestCode,
720
+ Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(
721
+ PipActionReceiver.PIPActions.localVideo.title,
722
+ PipActionReceiver.PIPActions.localVideo.requestCode
723
+ ),
724
+ PendingIntent.FLAG_IMMUTABLE
725
+ )
726
+ )
727
+ )
728
+ }
729
+
730
+ it.setActions(pipRemoteActionsList.filterIsInstance<android.app.RemoteAction>())
731
+ // endregion
703
732
 
704
733
  it.build()
705
734
  }
@@ -708,7 +737,11 @@ class HMSManager(reactContext: ReactApplicationContext) :
708
737
  }
709
738
 
710
739
  @RequiresApi(Build.VERSION_CODES.O)
711
- private fun readableMapToPipParamConfig(data: ReadableMap?): PipParamConfig {
740
+ private fun readableMapToPipParamConfig(data: ReadableMap?): PipParamConfig? {
741
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
742
+ return null
743
+ }
744
+
712
745
  var aspectRatio: Pair<Int, Int> = Pair(16, 9)
713
746
  var showEndButton = false
714
747
  var showAudioButton = false
@@ -772,22 +805,23 @@ class HMSManager(reactContext: ReactApplicationContext) :
772
805
 
773
806
  @RequiresApi(Build.VERSION_CODES.O)
774
807
  private fun setPictureInPictureParams(data: ReadableMap): Boolean {
808
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
809
+ return false
810
+ }
775
811
  try {
776
812
  if (!isPipModeSupported()) {
777
813
  throw Throwable(message = "PIP Mode is not supported!")
778
814
  }
779
815
 
780
- val activity = currentActivity
781
-
782
- if (activity !== null) {
783
- val pipParamConfig = readableMapToPipParamConfig(data)
784
- val pipParams = buildPipParams(pipParamConfig)
816
+ val activity = currentActivity ?: return false
817
+ val pipParamConfig = readableMapToPipParamConfig(data) ?: return false
818
+ val pipParams = buildPipParams(pipParamConfig) ?: return false
785
819
 
786
- activity.setPictureInPictureParams(pipParams)
787
- return true
820
+ if (pipParams !is android.app.PictureInPictureParams) {
821
+ return false
788
822
  }
789
-
790
- return false
823
+ activity.setPictureInPictureParams(pipParams)
824
+ return true
791
825
  } catch (e: Exception) {
792
826
  throw e
793
827
  }
@@ -795,31 +829,35 @@ class HMSManager(reactContext: ReactApplicationContext) :
795
829
 
796
830
  @RequiresApi(Build.VERSION_CODES.O)
797
831
  private fun isPipModeSupported(): Boolean {
832
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
833
+ return false
834
+ }
798
835
  return reactApplicationContext.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)
799
836
  }
800
837
 
801
838
  @RequiresApi(Build.VERSION_CODES.O)
802
839
  private fun enablePipMode(data: ReadableMap): Boolean {
840
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
841
+ return false
842
+ }
803
843
  try {
804
844
  if (!isPipModeSupported()) {
805
845
  throw Throwable(message = "PIP Mode is not supported!")
806
846
  }
807
847
 
808
- val activity = currentActivity
848
+ val activity = currentActivity ?: return false
849
+ val pipParamConfig = readableMapToPipParamConfig(data) ?: return false
850
+ val pipParams = buildPipParams(pipParamConfig) ?: return false
809
851
 
810
- if (activity !== null) {
811
- val pipParamConfig = readableMapToPipParamConfig(data)
812
- val pipParams = buildPipParams(pipParamConfig)
813
-
814
- pipReceiver?.register(activity)
815
- val entered = activity.enterPictureInPictureMode(pipParams)
816
- if (entered === false) {
817
- pipReceiver?.unregister(activity)
818
- }
819
- return entered
852
+ if (pipParams !is android.app.PictureInPictureParams) {
853
+ return false
820
854
  }
821
-
822
- return false
855
+ pipReceiver?.register(activity)
856
+ val entered = activity.enterPictureInPictureMode(pipParams)
857
+ if (entered === false) {
858
+ pipReceiver?.unregister(activity)
859
+ }
860
+ return entered
823
861
  } catch (e: Exception) {
824
862
  throw e
825
863
  }