Rate This Document
Findability
Accuracy
Completeness
Readability

Example Configuration

  1. 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
    
  2. Check the current GPS properties.
    1
    getprop | grep "persist.gps.mock."
    

    The following is a command output example:

    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."
  3. 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:
    1
    dumpsys location | grep -A 1 "gps provider:"
    

    Check whether the GPS properties take effect based on the returned value. The command output is displayed as follows:

    1
    2
        gps provider:
          last location=Location[gps 30.188433,120.199818 hAcc=20 et=+2h17m10s384ms alt=0.0 vel=0.0 bear=0.0 vAcc=??? sAcc=??? bAcc=??? {Bundle[{}]}]
    

    Returned Frame Parameter

    Description

    gps

    Location information. The format is [Latitude],[Longitude].

    hAcc

    Current positioning precision, in meters

    alt

    Altitude, in meters

    bear

    Current steering angle, in degrees

    vel

    Current moving speed, in meters per second

  4. Check whether the GPS data of the location service matches the preset value.