ARMCLOUD Documentation Center
  • 简体中文
  • English
  • 简体中文
  • English
  • Product introduction
  • Product billing
  • Server OpenAPI
    • Interface Documentation
    • List of Instance Properties
  • Android SDK
    • Example Construction
    • Interface Description
    • Callback Function
    • Error Code
    • Changelog
  • Web H5 SDK
    • Example Build
    • API description
    • Callback Functions
    • Error Code
    • Change log
  • Windows PC SDK
    • Example Setup
    • API Documentation
    • Callback Functions
    • Changelog
  • Edge-Cloud Communication Development
    • System service interface (aidl)
  • Scenario solutions
    • XP-like LSP Hook framework
    • Dynamic simulation of sensor data
  • Similar to XP, LSP Hook framework
  • Related agreements
    • Cloud Mobile SDK Privacy Policy

Introduction

ARMCLOUD cloud phone supports dynamic data simulation for various mobile device sensors, including gravity sensors, gyroscopes, magnetometers, accelerometers, and more. By simulating realistic sensor data, it provides authentic device state simulation for various application scenarios.

Supported Sensor Types

1. Motion Sensors

Accelerometer (acceleration)

  • Format: acceleration:x:y:z
  • Function: Simulates device acceleration changes on X, Y, Z axes
  • Unit: m/s²
  • Use Cases: Gravity-sensing games, pedometer apps, screen rotation control

Linear Accelerometer (linear-acceleration)

  • Format: linear-acceleration:x:y:z
  • Function: Simulates linear acceleration excluding gravity
  • Unit: m/s²
  • Use Cases: Precise motion detection, gesture recognition

Uncalibrated Accelerometer (acceleration-uncalibrated)

  • Format: acceleration-uncalibrated:x:y:z
  • Function: Raw acceleration data including bias
  • Unit: m/s²

Gyroscope (gyroscope)

  • Format: gyroscope:x:y:z
  • Function: Simulates device angular velocity changes around three axes
  • Unit: rad/s
  • Use Cases: Motion-sensing games, VR/AR applications, camera stabilization

Uncalibrated Gyroscope (gyroscope-uncalibrated)

  • Format: gyroscope-uncalibrated:x:y:z
  • Function: Raw gyroscope data including bias
  • Unit: rad/s

Gravity Sensor (gravity)

  • Format: gravity:x:y:z
  • Function: Simulates gravity components in device coordinate system
  • Unit: m/s²
  • Use Cases: Level apps, attitude detection

2. Position Sensors

Magnetometer (magnetic-field)

  • Format: magnetic-field:x:y:z
  • Function: Simulates device magnetic field strength and direction detection
  • Unit: μT (microtesla)
  • Use Cases: Compass apps, navigation software, metal detectors

Uncalibrated Magnetometer (magnetic-field-uncalibrated)

  • Format: magnetic-field-uncalibrated:x:y:z
  • Function: Raw magnetic field data including bias
  • Unit: μT

Orientation Sensor (orientation)

  • Format: orientation:azimuth:pitch:roll
  • Function: Simulates device Euler angle attitude
  • Unit: degrees (deprecated, recommend using rotation vector)

3. Rotation Sensors

Rotation Vector (rotation-vector)

  • Format: rotation-vector:x:y:z
  • Function: Simulates device rotation state (first three components of quaternion)
  • Use Cases: 3D applications, VR/AR, attitude control

Game Rotation Vector (game-rotation-vector)

  • Format: game-rotation-vector:x:y:z
  • Function: Rotation vector without magnetometer
  • Use Cases: Game control, magnetic interference-free scenarios

Geomagnetic Rotation Vector (geomagnetic_roation)

  • Format: geomagnetic_roation:x:y:z
  • Function: Rotation vector based on accelerometer and magnetometer
  • Use Cases: Compass, navigation apps

4. Environmental Sensors

Light Sensor (light)

  • Format: light:value
  • Function: Simulates ambient light intensity
  • Unit: lux
  • Use Cases: Automatic screen brightness adjustment, photography scene detection

Proximity Sensor (proximity)

  • Format: proximity:distance
  • Function: Simulates distance between object and device
  • Unit: cm
  • Use Cases: Screen off during calls, gesture control

Temperature Sensor (temperature)

  • Format: temperature:value
  • Function: Simulates ambient temperature
  • Unit: ℃
  • Use Cases: Weather apps, temperature monitoring

Pressure Sensor (pressure)

  • Format: pressure:value
  • Function: Simulates atmospheric pressure
  • Unit: hPa (hectopascal)
  • Use Cases: Altitude measurement, weather prediction

Humidity Sensor (humidity)

  • Format: humidity:value
  • Function: Simulates relative humidity
  • Unit: % (relative humidity percentage)
  • Use Cases: Weather apps, indoor environment monitoring

5. Motion Detection Sensors

Step Counter (step-counter)

  • Format: step-counter:count
  • Function: Cumulative step count statistics
  • Unit: steps (integer)
  • Use Cases: Health apps, activity tracking

Step Detector (step-detector)

  • Format: step-detector:value
  • Function: Detects occurrence of each step
  • Use Cases: Real-time step detection, motion analysis

Significant Motion (significant-motion)

  • Format: significant-motion:value
  • Function: Detects significant device movement
  • Use Cases: Power saving mode, location update triggering

Motion Detection (motion-detect)

  • Format: motion-detect:value
  • Function: General motion detection
  • Use Cases: Security monitoring, energy saving control

Tilt Detector (tilt-detector)

  • Format: tilt-detector:value
  • Function: Detects device tilt state changes
  • Use Cases: Screen orientation lock, tilt control

Pick-up Gesture (pick-up)

  • Format: pick-up:value
  • Function: Detects device pick-up action
  • Use Cases: Auto screen wake, gesture activation

6. Biometric Sensors

Heart Rate Sensor (heart-rate)

  • Format: heart-rate:bpm
  • Function: Simulates heart rate data
  • Unit: BPM (beats per minute)
  • Use Cases: Health monitoring, fitness tracking

7. Foldable Device Sensors

Hinge Angle Sensor (hinge-angle0/1/2)

  • Format: hinge-angle0:angle, hinge-angle1:angle, hinge-angle2:angle
  • Function: Simulates foldable device folding angle
  • Unit: degrees
  • Use Cases: Foldable screen device adaptation, multi-screen display control

8. Wearable Device Sensors

Wrist Tilt Gesture (wrist-tilt)

  • Format: wrist-tilt:value:measurementId
  • Function: Detects wrist lift action
  • Use Cases: Smartwatch screen wake, gesture recognition

Usage Methods

System Property Configuration (Recommended)

1. Set System Property

Set system property to specify sensor data file path:

setprop persist.sys.cloud.sensor.tpl_dp /data/local/tmp/sensor1.txt

2. Create Sensor Data File

Create sensor data file at specified path with the following format:

# /data/local/tmp/sensor1.txt
acceleration:-0.62871414:2.946163:9.217153
gyroscope:-3.625:-0.8125:1.2125
magnetic-field:1.4375:24.475:-18.362501
delay:50
acceleration:-0.52871414:2.846163:9.317153
gyroscope:-3.525:-0.7125:1.3125
magnetic-field:1.5375:24.575:-18.262501
delay:50

3. Data File Format Description

Three-axis Sensors (x:y:z format)
Sensor TypeFormat ExampleUnitDescription
accelerationacceleration:-0.628:2.946:9.217m/s²Accelerometer data
linear-accelerationlinear-acceleration:0.1:-0.2:0.05m/s²Linear acceleration
acceleration-uncalibratedacceleration-uncalibrated:-0.63:2.95:9.22m/s²Uncalibrated acceleration
gyroscopegyroscope:-3.625:-0.8125:1.2125rad/sGyroscope data
gyroscope-uncalibratedgyroscope-uncalibrated:-3.62:-0.81:1.21rad/sUncalibrated gyroscope
gravitygravity:0.0:0.0:9.8m/s²Gravity sensor
magnetic-fieldmagnetic-field:1.4375:24.475:-18.3625μTMagnetometer data
magnetic-field-uncalibratedmagnetic-field-uncalibrated:1.44:24.48:-18.36μTUncalibrated magnetometer
orientationorientation:45.0:10.5:-5.2degreesOrientation sensor (deprecated)
rotation-vectorrotation-vector:0.1:0.2:0.3-Rotation vector
game-rotation-vectorgame-rotation-vector:0.15:0.25:0.35-Game rotation vector
geomagnetic_roationgeomagnetic_roation:0.12:0.22:0.32-Geomagnetic rotation vector
Single-value Sensors (value format)
Sensor TypeFormat ExampleUnitDescription
lightlight:500.0luxLight intensity
proximityproximity:0.0cmDistance sensor
temperaturetemperature:25.5℃Ambient temperature
pressurepressure:1013.25hPaAtmospheric pressure
humidityhumidity:65.0%Relative humidity
step-counterstep-counter:1250stepsCumulative steps
step-detectorstep-detector:1.0-Step detection
significant-motionsignificant-motion:1.0-Significant motion
motion-detectmotion-detect:1.0-Motion detection
tilt-detectortilt-detector:1.0-Tilt detection
pick-uppick-up:1.0-Pick-up gesture
heart-rateheart-rate:72.0BPMHeart rate
hinge-angle0hinge-angle0:90.0degreesHinge angle 0
hinge-angle1hinge-angle1:45.0degreesHinge angle 1
hinge-angle2hinge-angle2:0.0degreesHinge angle 2
Special Format Sensors
Sensor TypeFormat ExampleDescription
wrist-tiltwrist-tilt:1.0:12345Wrist tilt:value:measurement ID
delaydelay:50Delay interval in milliseconds

4. File Limitations

  • Maximum file size: 1GB
  • Supported format: Plain text files
  • Encoding requirement: UTF-8
  • Permission requirement: File must have read permissions

Data Collection and Generation

1. Real Device Data Collection

You can collect sensor data from real devices to generate simulation files:

Android Data Collection Example

public class SensorDataCollector implements SensorEventListener {
    private SensorManager sensorManager;
    private FileWriter fileWriter;
    
    public void startCollection() {
        try {
            fileWriter = new FileWriter("/sdcard/sensor_data.txt");
            sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
            
            // Register sensor listeners
            sensorManager.registerListener(this, 
                sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
                SensorManager.SENSOR_DELAY_GAME);
            sensorManager.registerListener(this,
                sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE),
                SensorManager.SENSOR_DELAY_GAME);
            sensorManager.registerListener(this,
                sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD),
                SensorManager.SENSOR_DELAY_GAME);
                
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    @Override
    public void onSensorChanged(SensorEvent event) {
        try {
            String line = "";
            switch (event.sensor.getType()) {
                case Sensor.TYPE_ACCELEROMETER:
                    line = String.format("acceleration:%.8f:%.8f:%.8f\n",
                        event.values[0], event.values[1], event.values[2]);
                    break;
                case Sensor.TYPE_GYROSCOPE:
                    line = String.format("gyroscope:%.8f:%.8f:%.8f\n",
                        event.values[0], event.values[1], event.values[2]);
                    break;
                case Sensor.TYPE_MAGNETIC_FIELD:
                    line = String.format("magnetic-field:%.8f:%.8f:%.8f\n",
                        event.values[0], event.values[1], event.values[2]);
                    break;
            }
            
            fileWriter.write(line);
            fileWriter.write("delay:50\n");
            fileWriter.flush();
            
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

2. Data File Generation Script

Python Script Example

#!/usr/bin/env python3
import math
import time

def generate_rotation_data(output_file):
    """Generate sensor data for device rotation"""
    with open(output_file, 'w') as f:
        for angle in range(0, 361, 5):  # 0 to 360 degrees, one data point every 5 degrees
            rad = math.radians(angle)
            
            # Simulate gravity decomposition at different angles
            acc_x = 9.8 * math.sin(rad)
            acc_y = 0
            acc_z = 9.8 * math.cos(rad)
            
            # Simulate angular velocity during rotation
            gyro_x = 0.1 if angle < 180 else -0.1
            gyro_y = 0
            gyro_z = 0
            
            # Magnetometer data remains relatively stable
            mag_x = 25.0 * math.cos(rad)
            mag_y = 25.0 * math.sin(rad)
            mag_z = -18.0
            
            f.write(f"acceleration:{acc_x:.6f}:{acc_y:.6f}:{acc_z:.6f}\n")
            f.write(f"gyroscope:{gyro_x:.6f}:{gyro_y:.6f}:{gyro_z:.6f}\n")
            f.write(f"magnetic-field:{mag_x:.6f}:{mag_y:.6f}:{mag_z:.6f}\n")
            f.write("delay:100\n")

def generate_shake_data(output_file):
    """Generate sensor data for shake gesture"""
    with open(output_file, 'w') as f:
        for shake in range(10):  # 10 shake motions
            # Shake left
            f.write("acceleration:-15.0:0.0:9.8\n")
            f.write("gyroscope:0.0:0.0:5.0\n")
            f.write("magnetic-field:1.4375:24.475:-18.362501\n")
            f.write("delay:100\n")
            
            # Shake right
            f.write("acceleration:15.0:0.0:9.8\n")
            f.write("gyroscope:0.0:0.0:-5.0\n")
            f.write("magnetic-field:1.4375:24.475:-18.362501\n")
            f.write("delay:100\n")
            
            # Return to rest
            f.write("acceleration:0.0:0.0:9.8\n")
            f.write("gyroscope:0.0:0.0:0.0\n")
            f.write("magnetic-field:1.4375:24.475:-18.362501\n")
            f.write("delay:200\n")

# Usage example
generate_rotation_data("/data/local/tmp/rotation.txt")
generate_shake_data("/data/local/tmp/shake.txt")

Dynamic Simulation Scenarios

1. Device Rotation Simulation

Using Data File Method

# 1. Generate rotation data file
python3 generate_rotation.py

# 2. Upload to cloud phone
adb push rotation.txt /data/local/tmp/

# 3. Set system property to enable simulation
adb shell setprop persist.sys.cloud.sensor.tpl_dp /data/local/tmp/rotation.txt

# 4. Restart target app to see effects
adb shell am force-stop com.example.app
adb shell am start com.example.app/.MainActivity

2. Shake Gesture Simulation

# Use pre-generated shake data file
adb push shake.txt /data/local/tmp/
adb shell setprop persist.sys.cloud.sensor.tpl_dp /data/local/tmp/shake.txt

# Start WeChat or other apps that support shake gesture for testing
adb shell am start com.tencent.mm/.ui.LauncherUI

Practical Operation Workflow

1. Complete Operation Example

# Connect to cloud phone
adb connect your-cloud-phone-ip:5555

# Upload prepared sensor data file
adb push sensor_walking.txt /data/local/tmp/

# Set file read permissions
adb shell chmod 644 /data/local/tmp/sensor_walking.txt

# Set system property
adb shell setprop persist.sys.cloud.sensor.tpl_dp /data/local/tmp/sensor_walking.txt

# Verify property setting
adb shell getprop persist.sys.cloud.sensor.tpl_dp

# Restart target app to make sensor data effective
adb shell am force-stop com.example.walkingapp
adb shell am start com.example.walkingapp/.MainActivity

# Check app logs to verify effects
adb logcat | grep SensorManager

2. Switching Between Different Scenario Data

# Switch to shake data
adb shell setprop persist.sys.cloud.sensor.tpl_dp /data/local/tmp/shake.txt

# Switch to rotation data  
adb shell setprop persist.sys.cloud.sensor.tpl_dp /data/local/tmp/rotation.txt

# Disable sensor simulation (clear property)
adb shell setprop persist.sys.cloud.sensor.tpl_dp ""

Best Practices

1. Data File Management

  • Naming Convention: Use meaningful file names like walking_5min.txt, car_driving.txt
  • Data Integrity: Ensure each sensor data group has corresponding delay values
  • File Size: Reasonably control file size to avoid approaching 1GB limit affecting performance

2. Data Reasonableness

  • Accelerometer: In stationary state, Z-axis should be approximately 9.8m/s² (gravitational acceleration)
  • Gyroscope: In stationary state, all three axes should be close to 0
  • Magnetometer: Typical Earth magnetic field strength is approximately 25-65μT

3. Update Frequency Optimization

  • Gaming apps: Recommend delay:16 (60Hz)
  • Navigation apps: Recommend delay:200-1000 (1-5Hz)
  • General apps: Recommend delay:50-100 (10-20Hz)

4. Data Smoothness

When generating data files, ensure smooth transitions between values:

# Smooth transition example
def smooth_transition(start_value, end_value, steps):
    """Smooth interpolation between two values"""
    return [start_value + (end_value - start_value) * i / steps 
            for i in range(steps + 1)]

# Apply to sensor data generation
for i, acc_x in enumerate(smooth_transition(0, 9.8, 20)):
    with open('smooth_data.txt', 'a') as f:
        f.write(f"acceleration:{acc_x:.6f}:0.0:9.8\n")
        f.write("delay:50\n")

Application Cases

1. Game Testing

  • Simulate different device orientations to test gravity-sensing games
  • Batch test device rotation effects on game interface

2. Navigation App Testing

  • Simulate complex driving routes to test navigation accuracy
  • Test map display effects at different positions

3. Health App Testing

  • Simulate walking, running and other motion states
  • Test pedometer and activity tracking functions

Important Notes

  1. Performance Impact: Frequent sensor data updates may affect system performance, please adjust update frequency according to actual needs

  2. App Permissions: Ensure target app has obtained corresponding sensor usage permissions

  3. Data Consistency: Data from different sensors should maintain physical consistency, avoid conflicting data combinations

  4. App Compatibility: Some older apps may have limited support for certain sensor data

  5. Device Model Compatibility: Cloud phone sensor support depends on the simulated real device model. Some sensors are only available on specific models:

    • humidity (Humidity Sensor) - Not supported by most mid-to-low end models
    • temperature (Temperature Sensor) - Only supported by some high-end models
    • heart-rate (Heart Rate Sensor) - Mainly available on Samsung Galaxy series and other specific models
    • tilt-detector (Tilt Detector) - Some device gyroscope implementations may not support this
    • motion-detect (Motion Detection) - Depends on device's motion coprocessor
    • hinge-angle0/1/2/3 (Hinge Angle Sensors) - Only supported by foldable devices like Samsung Galaxy Fold, Huawei Mate X, etc.

    Recommendation: Choose appropriate device model templates, or verify whether the current cloud phone instance's simulated model supports the target sensors before use

Troubleshooting

Common Issues

Q: App doesn't respond after setting sensor data

A: Check if the app has sensor permissions, or try restarting the app to reinitialize sensor listening

Q: Data updates are not smooth, showing jumps

A: Appropriately reduce update frequency, or add interpolation transitions between data points

Q: Sensor simulation doesn't work after setting system property

A: Check if system property path is correct, confirm data file exists and has read permissions (chmod 644), verify file format is correct, try restarting target app

Q: Some sensor data settings don't make app respond

A: This may be because the current cloud phone instance's simulated model doesn't support that sensor type. Particularly humidity, temperature, heart rate, hinge angle sensors only exist on specific real device models. Cloud phones determine sensor support based on the simulated model. Recommend testing with basic sensors (accelerometer, gyroscope, magnetometer) first, or choose device model templates that support target sensors

Prev
XP-like LSP Hook framework