1

I detected an issue that on the nexus 5x with android 8.1 and security patch from august calling a method by reflection freezes the app, this same call works on 10 other devices with android 8.0, android 7.1.1 etc. Is it possible to find out what is causing the problem when making a call by reflection, I am not even getting an exception or some helpfull log, nothing, it justs freezes.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
            try {
                final TelephonyManager telMan = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
                final Class<?> classTemp = Class.forName(telMan.getClass().getName());
                final Method methodTemp = classTemp.getDeclaredMethod("getITelephony");
                methodTemp.setAccessible(true);
                ITelephony telephonyService = (ITelephony) methodTemp.invoke(telMan);                
                telephonyService.endCall();
                return true;
            } catch (Exception ex) {
               return false;
            }
        } else {

The freeze happens at telephonyService.endCall(); and no exception is thrown. The "Get thread dump" shows follwing:

"main@8285" prio=5 tid=0x2 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
      at android.os.BinderProxy.transactNative(Binder.java:-1)
      at android.os.BinderProxy.transact(Binder.java:764)
      at com.android.internal.telephony.ITelephony$Stub$Proxy.endCall(ITelephony.java:2026)
David
  • 3,971
  • 1
  • 26
  • 65
  • can you maybe check at what exact line that freeze happens (add some log prints each line or go line by line in debugger)? Also what is a point of `Class.forName(telMan.getClass().getName());`? – GotoFinal Aug 24 '18 at 14:46
  • I updated the question. – David Aug 24 '18 at 14:48
  • Yes, yes I tried, but it does not lead to anything. – David Aug 24 '18 at 14:59
  • Did you ever get to know why that happened? – Edw590 Sep 30 '20 at 19:26
  • @DADi590 I haven't – David Oct 09 '20 at 11:09
  • As I didn't find an answer too on that day or near, I decided to put reflection stuff on a service that I call and after the call is done (if needed I may put the program waiting a bit - like 5 seconds at most, depending on the needed function), I kill the service with its PID. If I just stop it, it won't stop. Like a thread. Interrupt won't stop it. So I kill the PID. It must be running in a separate process though, or the entire app will shutdown. Just putting here my kinda workaround for this. Works perfectly, even though it's not what one would want. – Edw590 Oct 09 '20 at 11:13

0 Answers0