Example Configuration
This section provides an example of configuring GPS properties.
- Call the setprop method to set property values. The following uses gps.mock.latitude and gps.mock.longitude as an example. The methods for setting other properties are the same.
1 2
setprop persist.gps.mock.latitude 30.188433 setprop persist.gps.mock.longitude 120.193818
- Check the current GPS properties.
1getprop | grep "persist.gps.mock."
Example command output:
1 2
[persist.gps.mock.latitude]: [30.188433] [persist.gps.mock.longitude]: [120.193818]
To query string texts on Windows, use the findstr command instead of the grep command. In the following scenarios where the grep command is used in this chapter, perform operations based on your service scenario.
adb -s ip:port shell getprop | findstr "persist.gps.mock."
- After the container is restarted, query the GPS data of the location service. Run the following command in the container to query the latest GPS data:
1dumpsys location | grep "last location"
Check whether the GPS properties take effect based on the returned value. Example command output:
1 2
last location=Location[gps 30.188433,120.193818 hAcc=20.0 et=+3d21h54m53s533ms alt=0.0 mslAlt=-8.068903955722352 vel=0.0 bear=0.0 {Bundle[{satellites=0, maxCn0=0, meanCn0=0}]}]
Returned Frame Parameter
Description
gps
Location information. The format is [Latitude],[Longitude].
hAcc
Current positioning error, in meters
alt
Altitude, in meters
bear
Current steering angle, in degrees
vel
Current moving speed, in meters per second
- Check whether the GPS data of the location service matches the preset value.
Parent topic: Configuring GPS Properties