Help Center/ Cloud Phone Host/ User Guide/ Using AOSP/ Simulating Location Information
Updated on 2023-10-11 GMT+08:00

Simulating Location Information

Function

The simulated positioning information of CPH includes GPS data, base station information, and Wi-Fi Basic Service Set Identifier (BSSID). CPH also provides the geocoding and reverse geocoding.

How to Use

  • Injection of GPS data and base station information

Use the adb shell of the cloud phone, and run the echo "(parameters" > /data/gps/fifo command. Parameters are separated by colons.

Example:
echo "longitude=113.370592:latitude=23.123642:cell_type=GSM:mcc=460:mnc=2:lac=37107:cid=263496967" > /data/gps/fifo
  • Continuous GPS data injection (Non-blocking injection is recommended.)

Use self-developed or third-party SDK application code to continuously inject GPS data in O_NONBLOCK (non-blocking) mode.

Example:

#define GPSFifoName "/data/gps/fifo"
if((fifo_fd = open(GPSFifoName, O_WRONLY | O_NONBLOCK)) < 0) {
ALOGE("open fifo "%s" (write) fail, error = %s\n", GPSFifoName, strerror(errno));
return;
}
//Note: Use colons (:) to separate cmd parameters.
char* cmd = "longitude=113.370592:latitude=23.123642:cell_type=GSM:mcc=460:mnc=2:lac= 37107:cid=263496967";
len = strlen(cmd);
if(write(fifo_fd, cmd, len) != len) {
ALOGE("%s: write "%s" to "%s" fail: %s", FUNCTION, cmd, GPSFifoName, strerror(errno));
}
  • Wi-Fi BSSID simulation

Set com.cph.wifi.bssid attribute to simulate which Wi-Fi a cloud phone is connected to.

Example:

setprop com.cph.wifi.bssid 02:00:00:00:00:00

Constraints

  • Parameters related to GPS data and base station information
    Table 1 GPS data

    Parameter

    Description

    Mandatory

    Default Value

    Constraints

    latitude

    Specifies the latitude.

    The north latitude is positive and the south latitude is negative.

    Yes

    22.657501

    Value range: –90.000000 to 90.000000

    Unit: Degree (°)

    longitude

    Specifies the longitude

    The east longitude is positive and the west longitude is negative.

    Yes

    114.055939

    Value range: –180.000000 to 180.000000

    Unit: Degree (°)

    altitude

    Specifies the altitude.

    No

    51.0

    Unit: Meter

    speed

    Specifies the speed.

    No

    0.0

    Unit: Meter

    bearing

    Specifies the azimuth.

    0° indicates due north, 90° indicates due east, 180° indicates due south, and 270° indicates due west.

    No

    30.0

    Value range: 0.0 to 360.0

    Unit: Degree (°)

    accuracy

    Specifies the positioning accuracy.

    No

    90.0

    Unit: Meter

    Table 2 Base station information

    Parameter

    Description

    Mandatory

    Constraints

    cell_type

    Specifies the base station type.

    Yes

    The type can GSM, CDMA, WCDMA, and LTE.

    mcc

    Specifies the country code.

    No

    Example: 460

    mnc

    Specifies the mobile network code of a base station.

    No

    For Code-division multiple access (CDMA), only system id is available. mnc is used for injection.

    lac

    Specifies the area code of a base station.

    Yes

    For CDMA, only network id is available. lac is used for injection.

    For Long Term Evolution (LTE), only tac is available. lac is used for injection.

    cid

    Specifies the base station ID.

    Yes

    For CDMA, only base station id is available. cid is used for injection.

    For LTE, only ci is available. cid is used for injection.

  • All characters are English characters.
  • The World Geodetic System 1984 (WGS84) is used for GPS data.
  • Both LocationManager GPS_PROVIDER and NETWORK_PROVIDER use the longitude and latitude information of the GPS.
  • Geocoder that supports geocoding and reverse geocoding is supported only in the Chinese Mainland, Hong Kong, and Macao.
  • The setting takes effect immediately.