@qusaieilouti99/call-manager 0.1.71 → 0.1.72

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.
@@ -18,5 +18,8 @@
18
18
  <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
19
19
  <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
20
20
 
21
+
22
+ <!-- For knowing the activity state-->
23
+ <uses-permission android:name="android.permission.GET_TASKS" />
21
24
  <!-- No components needed here - they're declared in app manifest -->
22
25
  </manifest>
@@ -1,5 +1,6 @@
1
1
  package com.margelo.nitro.qusaieilouti99.callmanager
2
2
 
3
+ import android.app.ActivityManager
3
4
  import android.app.Activity
4
5
  import android.app.Application
5
6
  import android.app.Notification
@@ -1001,16 +1002,25 @@ object CallEngine {
1001
1002
  val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
1002
1003
 
1003
1004
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
1004
- val tasks = activityManager.getAppTasks()
1005
- if (tasks.isNotEmpty()) {
1006
- val taskInfo = tasks[0].taskInfo
1007
- return taskInfo.topActivity?.className?.contains("MainActivity") == true
1005
+ try {
1006
+ val tasks = activityManager.appTasks
1007
+ if (tasks.isNotEmpty()) {
1008
+ val taskInfo = tasks[0].taskInfo
1009
+ return taskInfo.topActivity?.className?.contains("MainActivity") == true
1010
+ }
1011
+ } catch (e: Exception) {
1012
+ Log.w(TAG, "Failed to get app tasks: ${e.message}")
1008
1013
  }
1009
1014
  } else {
1010
- @Suppress("DEPRECATION")
1011
- val tasks = activityManager.getRunningTasks(1)
1012
- if (tasks.isNotEmpty()) {
1013
- return tasks[0].topActivity?.className?.contains("MainActivity") == true
1015
+ try {
1016
+ @Suppress("DEPRECATION")
1017
+ val tasks = activityManager.getRunningTasks(1)
1018
+ if (tasks.isNotEmpty()) {
1019
+ val runningTaskInfo = tasks[0]
1020
+ return runningTaskInfo.topActivity?.className?.contains("MainActivity") == true
1021
+ }
1022
+ } catch (e: Exception) {
1023
+ Log.w(TAG, "Failed to get running tasks: ${e.message}")
1014
1024
  }
1015
1025
  }
1016
1026
  return false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qusaieilouti99/call-manager",
3
- "version": "0.1.71",
3
+ "version": "0.1.72",
4
4
  "description": "Call manager",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",