jeudi 28 novembre 2019

Can not find method reportLocation() from "android.location.ILocationManager" in Android Q

I am trying to get method reportLocation() through reflection from "android.location.ILocationManager$Stub".

CODE:

Class mStub = Class.forName("android.location.ILocationManager$Stub"); Method getInterface = mStub.getMethod("asInterface", IBinder.class);

Class mServiceManager = Class.forName("android.os.ServiceManager"); Method getService = mServiceManager.getMethod("getService", String.class);

Object iBindermInterface = getService.invoke(null, "location"); Object mInterface = getInterface.invoke(null, (IBinder) iBindermInterface);

Method method = mInterface.getClass().getMethod("reportLocation", Location.class, Boolean.class);

ERROR:

java.lang.NoSuchMethodException: android.location.ILocationManager$Stub$Proxy.reportLocation [class android.location.Location, class java.lang.Boolean]

I do not see this method when I trying to print all methods from "android.location.ILocationManager$Stub":

Class mStub = Class.forName("android.location.ILocationManager$Stub"); Method[] getInterfaceAll = mStub.getMethods(); for (Method getInt : getInterfaceAll) Log.d(LOG_TAG, "getInt = "+getInt);

In Android P (SDK 28) I have no problem with it.

In Android Q (SDK 29) interface "android.location.ILocationManager" does not have "reportLocation()" method, instead, to my assumptions, interface "com.android.internal.location.ILocationProviderManager" has onReportLocation(). But this interface contains the abstract method onReportLocation() and I cannot get its implementation.

What interface contain this method or it has been changed (renamed) to another method?





Aucun commentaire:

Enregistrer un commentaire