天天看點

Android GMS無法通過網絡定位

前言

         歡迎大家我分享和推薦好用的代碼段~~

聲明

         歡迎轉載,但請保留文章原始出處:

         CSDN:

         雨季o莫憂離:

正文

預置KK GMS後,打開系統定位功能,Google Maps等應用無法通過網絡定位

有兩個部分需要确認:

1.系統對提供LocationProvider的應用需要進行申明,而KK GMS将NetworkLocation應用的功能內建到了GmsCore(Google Play Service)中,是以需要添加GmsCore的packageName進去:

framework/base/core/res/res/values/config.xml

<string-array name="config_locationProviderPackageNames" translatable="false">

        <!-- The standard AOSP fused location provider -->

        <item>com.android.location.fused</item>

        <!-- MTK add for GMS -->

        <item>com.google.android.location</item>

        <item>com.google.android.gms</item>

        <!-- MTK add end -->

</string-array>

2.GMS4.4_r3(包含r3)之後版本在滿足1條件下依然可能存在無法使用網絡定位功能,請繼續按照如下修改操作:

請在alps\external\wpa_supplicant_8\wpa_supplicant\bss.c中的如下函數中修改

static void wpa_bss_copy_res(struct wpa_bss *dst, struct wpa_scan_res *src,

        struct os_time *fetch_time)

{

    struct timespec ts;//add this line;

    dst->flags = src->flags;

    os_memcpy(dst->bssid, src->bssid, ETH_ALEN);

    dst->freq = src->freq;

    dst->beacon_int = src->beacon_int;

    dst->caps = src->caps;

    dst->qual = src->qual;

    dst->noise = src->noise;

    dst->level = src->level;

    /* dst->tsf = src->tsf;*/ //delete this line

    //add below code

    if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)

        dst->tsf = src->tsf;

    else 

        dst->tsf = ts.tv_sec*1000000 + ts.tv_nsec/1000;

    //end

    calculate_update_time(fetch_time, src->age, &dst->last_update); 

}

如果是編譯子產品進行驗證,請先執行./mk &project_name mm external/wpa_supplicant_8/wpa_supplicant

将alps/out/target/product/project_name/system/bin/wpa_supplicant push到system/bin/下,再執行指令

adb shell chmod 755 system/bin/wpa_supplicant

重新開機系統後驗證

謝謝!