I use android automotive 10, now I write fixed Latitude and longitude like this:
//写死的经纬度
frameworks\base\services\core\java\com\android\server\LocationManagerService.java
private void initLocationHandler() {
String latitude = SystemProperties.get("persist.sys.adan.latitude");
String longitude = SystemProperties.get("persist.sys.adan.longitude");
if(latitude == null || latitude.isEmpty()){
SystemProperties.set("persist.sys.adan.latitude","33.377631");
}
if(longitude == null || longitude.isEmpty()){
SystemProperties.set("persist.sys.adan.longitude","120.139998");
}
mLocationHandlerThread = new HandlerThread("initLocationHandler");
mLocationHandlerThread.start();
mLocationHandler = new Handler(mLocationHandlerThread.getLooper()) {
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
if (msg.what == MSG_GPS) {
reportLocation();
mLocationHandler.sendEmptyMessageDelayed(0, 1000);
}
}
};
mLocationHandler.sendEmptyMessageDelayed(0,2000);
}
/**
* upload gps position info
* */
private void reportLocation() {
Location location = new Location(LocationManager.GPS_PROVIDER);
String latitude = SystemProperties.get("persist.sys.adan.latitude");
String longitude = SystemProperties.get("persist.sys.adan.longitude");
location.setLongitude(Double.parseDouble(longitude));
location.setLatitude(Double.parseDouble(latitude));
location.setElapsedRealtimeNanos(System.nanoTime());
location.makeComplete();
LocationProvider mylocProvider = getLocationProviderLocked(LocationManager.GPS_PROVIDER);
if (mylocProvider != null) {
mylocProvider.onReportLocation(location);
Log.d(TAG, "onReportLocation success " + latitude + " " +longitude);
} else {
Log.d(TAG, "mylocProvider is NULL");
}
}
now there isn't information on launcher
But I can't see the right value with my Pixel2XL mobilephone which install In-vehicle software Amap apk like below
if someone can help me, thank you! and attach is my log
and the apk is :http://gofile.me/4ZJ1m/TaScxBcla password: 123123