前言
分享下相关笔记跟概念吧,具体流程不好外传,MTK 有相关文档的
书籍参考 《深入理解 Android: WiFi 模块 NFC 和 GPS 卷》
相关概念
MTK GPS Log 解析
相关流程接口
LocationManager
GPSLP
AGPS
GPS JNI 与 HAL 层
Gps 应用编程
public class LocationTest extends Activity
{
private LocationManager mLocationManager = null;
public void onCreate(Bundle savedInstanceState) {
mLocationManager = (LocationManager)getSystemService(context.LOCATION_SERVICE);
}
public void onResume() {
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, null, null, mLocListener);
mLocationManager.addGpsStatusListener(mGpsListener);
}
public void onPause() {
mLocationManager.removeUpdates(mLocListener);
mLocationManager.removeGpsStatusListener(mGpsListener);
}
public final LocationListener mLocListener = new LocationListener()
{
public void onLocationChanged(Location location) {/*TODO*/}
public void onProviderDisabled(String provider) {/*TODO*/}
public void onProviderEnabled(String provider) {/*TODO*/}
public void onStatusChanged(String provider, int status, Bundle extras)
{
if (status == LocationProvider.AVAILABLE) {}
else if (status == LocationProvider.OUT_OF_SERVICE) {}
else if (status == LocationProvider.TEMPORARILY_UNAVAILABLE) {}
}
}
public final GpsStatus.Listener mGpsListener = new GpsStatus.Listener()
{
public void onGpsStatusChanged(int event)
{
if (event == GpsStatus.GPS_EVENT_STARTED) {}
else if (event == GpsStatus.GPS_EVENT_STOPPED) {}
else if (event == GpsStatus.GPS_EVENT_FIRST_FIX) {}
else if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) {}
}
}
}
MTK GPS 搜星类型修改
位置:
Gps_controller.c (vendor\mediatek\proprietary\hardware\connectivity\gps\mtk_mnld\mnld_entity\src)
static MNL_CONFIG_T mnl_config ={
.GNSSOPMode = 2, // 0: G+Gl; 1: G+B, 2:G+Gl+B,3:G, 4:B,5:Gl,6:G+Gl+B+Ga
}
结构体位置:
typedef enum
{
MTK_CONFIG_GPS_GLONASS = 0,
MTK_CONFIG_GPS_BEIDOU,
MTK_CONFIG_GPS_GLONASS_BEIDOU,
MTK_CONFIG_GPS_ONLY,
MTK_CONFIG_BEIDOU_ONLY,
MTK_CONFIG_GLONASS_ONLY,
MTK_CONFIG_GPS_GLONASS_BEIDOU_GALILEO
} MTK_GNSS_CONFIGURATION;
位置:Mtk_gps_type.h (vendor\mediatek\proprietary\hardware\connectivity\gps\mtk_mnld\mnl\inc)