[請益] android透過反射去呼叫LocationManager的

作者: mouse21 (小鼠)   2016-08-11 03:20:10
看到 LocationManager
大家可能都可以猜到我想幹嘛
Fack GPS之類的APP都是透過 Mock Location去達到改變位置的效果
我就想從LocationManager 去著手,想從GPS晶片上來的路中做修改。
目前研究到 LocationManager有綁定到一個名為 LocationManagerService的物件
中間的介面為 ILocationManager
在LocationManager裡有一個mService物件 形態為ILocationManaer
從別人的分析中找到 這個Interface中有一個很重要的Method是
reportLocation 對應於 gps_location_callback
也就是從他開始把GPS位置往上傳遞到各個 LocationListener
幾個關鍵方法
ListenerTransport transport = wrapListener(listener, looper);
//其中的一個function
@Override
public void onLocationChanged(Location location) {
Message msg = Message.obtain();
msg.what = TYPE_LOCATION_CHANGED;
msg.obj = location;
mListenerHandler.sendMessage(msg);
}
mService.requestLocationUpdates(request, transport(上面的物件), intent, packageName);
mService中
public void reportLocation(Location location ,boolean){
//略過部分
if(mContext.checkCallingOrSelfPermission(
INSTALL_LOCATION_PROVIDER
)!=PcakagerManager.PERMISSION_GRANTER){
throw new SecurityException("Requires INSTALL_LOCATION_
PROVIDER permission")
}
Message m = Message.obtain(mLocationHandler,MESSAGE_LOCATION_CHANGED,location);
}
由此得知,透過reportLocation 可以將坐標傳往所有註冊的locationlistener
不過當我找到 reportLocation 並且呼叫他之後
出現了
Requires INSTALL_LOCATION_PROVIDER permission
也就是上面那個IF的內容QQ
那我現在是改成找到Handler ...
並且Message m = Message.obtain(mLocationHandler,MESSAGE_LOCATION_CHANGED,location);
成功的機會比較大嗎QQ
(苦惱
避免誤會
我的權限內有加上
<uses-permission
android:name="android.permission.INSTALL_LOCATION_PROVIDER"></uses-permission>
作者: galic (嘎利)   2016-08-11 09:18:00
怎不發在Android開發版
作者: hicoy   2016-08-11 10:23:00
有root嗎?或者是system app嗎?
作者: ssccg (23)   2016-08-11 11:58:00
有些權限你必須是系統app才有用,自己加了也沒用
作者: y3k (激流を制するは静水)   2016-08-11 12:25:00
你有要權限 不代表別人會給你
作者: willyp (阿皮 )   2016-08-11 23:19:00
可以查系統定義這permission的權限 我看好像是signature|privileged 你自己寫的ap應該無法跟他sign同樣的key // Not for use by third-party applications
作者: jiahansu (Jiahan)   2016-08-12 19:01:00
location service是透過ipc跟其他的app互動的,跟摟主的app不是在同一個process,這樣做根本沒用。
作者: kimmyariel (Davy)   2016-08-14 15:06:00
要直接改android framework才有用吧?

Links booklink

Contact Us: admin [ a t ] ucptt.com