2016-10-29 3 views
0

안드로이드에서 위치를 가짜로 만들고 싶습니다. 안드로이드에서는 PendingIntent을 사용하여 위치를 얻는 방법이 있습니다.Xposed : PendingIntent를 사용하여 메서드를 후킹하는 방법

public class LocationReceiver extends BroadcastReceiver { 
    @Override 
    public void onReceive(Context context, Intent intent) { 
     //Do this when the system sends the intent 
     Bundle b = intent.getExtras(); 
     Location loc = (Location)b.get(android.location.LocationManager.KEY_LOCATION_CHANGED); 
    } 
} 

그래서, 나는이 방법을 훅하려면 : 새 위치 변경시

 LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE); 
     String proximitys = "ACTION"; 
     IntentFilter filter = new IntentFilter(proximitys); 
     LocationReceiver mReceiver = new LocationReceiver(); 
     registerReceiver(mReceiver, filter); 
     Intent intent = new Intent(proximitys); 
     PendingIntent proximityIntent = PendingIntent.getBroadcast(this, 0, 
       intent, PendingIntent.FLAG_CANCEL_CURRENT); 

     service.requestLocationUpdates("network", 1000, 0.001f, proximityIntent); 

그리고 BroadcastReceiver 이벤트를 받게됩니다 예를 들면 다음과 같습니다. 그러나 나는 이런 종류의 방법을 연결하는 방법을 모른다 (즉 PendingIntent 사용). PendingIntent은 "미래의 미래"에 데이터를 가지고있을 것이고 언제 일어날 지 모른다. 따라서 메서드 requestLocationUpdates의 전후에 후킹은 그 당시에는 PendingIntent에 아직 데이터가 없기 때문에 작동하지 않는 것 같습니다.

어떻게하는지 알려주세요.

답변

0

보류중인 의도가 아닌 브로드 캐스트 리시버를 차단해야합니다. LocationReceiver.onReceive을 가로 채고 인 텐트의 내용을 변경할 수 있습니다.

이렇게하려면 onReceive을 가로 채고 beforeHookedMethod을 정의하십시오. 해당 매개 변수 (MethodHookParam params)를 사용하여 의도 (params.args[1])를 검색하고 해당 추가 기능 (intent.replaceExtras(bundle))을 변경하십시오.

새 번들이 동일한 키 (android.location.LocationManager.KEY_LOCATION_CHANGED)가 있는지 확인하고 값으로 당신은 당신의 자신의 위치를 ​​설정할 수 있습니다

Location loc = new Location("yourprovider"); 
loc.setLatitude(66.6); 
loc.setLongitude(66.6); 
관련 문제