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

看板AndroidDev作者 (小鼠)時間7年前 (2016/08/11 14:52), 7年前編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
※ [本文轉錄自 Soft_Job 看板 #1Ngtvj-8 ] 作者: mouse21 (小鼠) 看板: Soft_Job 標題: [請益] android透過反射去呼叫LocationManager的 時間: Thu Aug 11 03:20:10 2016 看到 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> -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.132.33.232 ※ 文章網址: https://www.ptt.cc/bbs/Soft_Job/M.1470856813.A.F88.html ※ 編輯: mouse21 (220.132.33.232), 08/11/2016 03:29:24

08/11 09:18, , 1F
怎不發在Android開發版
08/11 09:18, 1F

08/11 10:23, , 2F
有root嗎?或者是system app嗎?
08/11 10:23, 2F

08/11 11:58, , 3F
有些權限你必須是系統app才有用,自己加了也沒用
08/11 11:58, 3F

08/11 12:25, , 4F
你有要權限 不代表別人會給你
08/11 12:25, 4F
※ 發信站: 批踢踢實業坊(ptt.cc) ※ 轉錄者: mouse21 (1.163.38.193), 08/11/2016 14:52:12
文章代碼(AID): #1Nh22T4y (AndroidDev)