1

I am trying to use Java reflection to access CallManager and detect the call state which I always get the call idle. Please help me on this. Btw I use the following code to access CallManager:

try{ 
    class classCallManager = class.forname("com.android.internal.telephony.CallManager");
    Method methodGetInstance = classCallManager .getDeclaredMethod("getInstance");
    methodGetInstance.setAccessible(true);
    Object objectCallManager = methodGetInstance.invoke(null);
    Method methodGetActiveFgCallState = classCallManager.getDeclaredMethod("getActiveFgCallState");
}catch (Exception e) {}
0

1 Answer 1

1

I can confirm that unfortunately even trying to get active fg call fails: the return value is always false

    val classCallManagerName = "com.android.internal.telephony.CallManager"

    log log "get class name manager"

    val classCallManager = Class.forName(classCallManagerName)

    future {
      var msec = 15000

      val sleeptime = 500

      while (
        msec > 0
      ) {
        log log "get method instance"

        //getDeclaredMethod
        val methodGetInstance = classCallManager.getMethod("getInstance")

        log log "set method get instance accessible"

        methodGetInstance.setAccessible(true)

        log log "invoke get instance"

        val objectCallManager = methodGetInstance.invoke(null) //null for static methods

        log log "getMethod hasActiveFgCall"

        //getActiveFgCallState
        val hasActiveFgCall = classCallManager.getMethod("hasActiveFgCall")

        log log "hasActiveFgCall setAccessible(true)"

        hasActiveFgCall.setAccessible(true)

        log log "has active fg call: " + hasActiveFgCall.invoke(objectCallManager)

        Thread.sleep(sleeptime)

        msec -= sleeptime
      }
    }

note that the code is in Scala

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.