天天看點

Android 使用GSM定位

最近有客戶需要在Android添加谷歌架構,但是GSMcore經常彈出一個視窗,

無法使用位置資訊

所有應用的裝置位置資訊均已關閉。萬一您的裝置丢失,您可能無法定位裝置。

網上找了一些資料,說是要添加NetworkLocation.apk.

比如:

手機定位折騰記(1):安卓手機的網絡定位與NetworkLocation.apk

【android】網絡定位服務NetworkLocationProvider

于是,滿世界的找NetworkLocation.apk,終于在github上覓到了它的身影

android_packages_apps_UnifiedNlp

将它push到闆子的system/priv-app下以後GSM還是無法定位。

随後注意到一句話:

Make sure that no Google geolocation tool is installed (it is usually listed as Google Play Services in Apps)

好吧,看起來GSM自己有定位功能,把它加進去:

diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index ee626d6..2156b81 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -777,6 +777,7 @@
     <string-array name="config_locationProviderPackageNames" translatable="false">
         <!-- The standard AOSP fused location provider -->
                <item>com.google.android.location</item>
+               <item>com.google.android.gms</item>
         <item>com.android.location.fused</item>
     </string-array>
           

OK,搞定!