Introduction
ARMCLOUD Cloud Phone supports dynamic data simulation of various sensors on mobile devices, including gravity sensors, gyroscopes, magnetometers, accelerometers, and more. By simulating real sensor data, realistic device status simulations can be provided for various application scenarios.
Supported sensor types
1. Motion sensors
Accelerometer (acceleration)
- Format:
acceleration:x:y:z - Function: Simulates acceleration changes of the device along the X, Y, and Z axes
- Unit: m/s²
- Application Scenarios: Gravity sensing games, pedometer apps, screen rotation control
Linear Accelerometer
- Format:
linear-acceleration:x:y:z - Function: Simulates linear acceleration after removing the effects of gravity
- Unit: m/s²
- Application Scenarios: Precise motion detection, gesture recognition
Uncalibrated Accelerometer
- Format:
acceleration-uncalibrated:x:y:z - Function: Raw acceleration data containing deviations
- Unit: m/s²
Gyroscope
- Format:
gyroscope:x:y:z - Function: Simulates the angular velocity changes of the device around three axes
- Unit: rad/s
- Application Scenarios: Motion-sensing games, VR/AR applications, camera stabilization
Uncalibrated Gyroscope
- Format:
gyroscope-uncalibrated:x:y:z - Function: Raw gyroscope data containing bias
- Unit: rad/s
Gravity Sensor
- Format:
gravity:x:y:z - Function: Simulates the component of gravity in the device's coordinate system
- Unit: m/s²
- Application Scenarios: Level applications, posture detection
2. Position sensors
Magnetic-field
- Format:
magnetic-field:x:y:z - Function: The analog device detects magnetic field strength and direction
- Unit: μT (micro-Tesla)
- Application scenarios: compass applications, navigation software, metal detectors
Uncalibrated Magnetometer
- Format:
magnetic-field-uncalibrated:x:y:z - Function: Raw magnetic field data containing deviations
- Unit: μT
Orientation Sensor
- Format:
orientation:azimuth:pitch:roll - Function: Simulates the device's Euler angle posture
- Unit: Degrees (obsolete, rotation vector recommended)
3. Rotation sensor
Rotation-vector
- Format:
rotation-vector:x:y:z - Function: Simulates the rotation state of the device (the first three components of quaternions)
- Application Scenarios: 3D applications, VR/AR, attitude control
Game-rotation-vector
- Format:
game-rotation-vector:x:y:z - Function: Does not use the magnetometer's rotation vector
- Application Scenarios: Game control, anti-magnetic interference scenarios
Geomagnetic Rotation Vector (geomagnetic_roation)
- Format:
geomagnetic_roation:x:y:z - Function: Rotation vectors based on accelerometers and magnetometers
- Application Scenarios: Compass, navigation apps
4. Environmental sensors
Light Sensor
- Format:
light:value - Function: Simulates ambient light intensity
- Unit: lux
- Application Scenarios: Automatic screen brightness adjustment, photo scene detection
Proximity Sensor
- Format:
proximity:distance - Function: Simulates the distance between objects and devices
- Unit: cm
- Application Scenarios: Screen off during calls, gesture control
Temperature Sensor
- Format:
temperature:value - Function: Simulates ambient temperature
- Unit: °C
- Application Scenarios: Weather applications, temperature monitoring
Air Pressure Sensor (PRESSURE)
- Format:
pressure:value - Function: Simulates atmospheric pressure
- Unit: hPa (hPa)
- Application Scenarios: Height measurement, weather forecasting
Humidity Sensor
- Format:
humidity:value - Function: Simulates relative humidity
- Unit: % (relative humidity percentage)
- Application Scenarios: Weather applications, indoor environment monitoring
5. Motion detection sensors
Pedometer (step-counter)
- Format:
step-counter:count - Function: Accumulated step count statistics
- Unit: Steps (integer)
- Application Scenarios: Health apps, exercise tracking
Step Detector
- Format:
step-detector:value - Function: Detects the occurrence of each step
- Application Scenarios: Real-time walking detection, motion analysis
Significant-motion
- Format:
significant-motion:value - Function: Detects significant movement of equipment
- Application Scenarios: Power-saving mode, location update triggers
Motion Detection
- Format:
motion-detect:value - Function: Universal motion detection
- Application Scenarios: Security monitoring, energy-saving control
Tilt Detector
- Format:
tilt-detector:value - Function: Detects changes in equipment tilt status
- Application Scenarios: Screen orientation lock, tilt control
Pick-up Gesture
- Format:
pick-up:value - Function: Detects the action of the device being picked up
- Application Scenarios: Automatic screen on-screen, gesture wake-up
6. Biosensor
Heart Rate Sensor
- Format:
heart-rate:bpm - Function: Simulates heart rate data
- Unit: BPM (heartbeats per minute)
- Application Scenarios: Health monitoring, exercise tracking
7. Foldable device sensors
Hinge Angle Sensor (hinge-angle 0/1/2)
- Format:
hinge-angle0:angle,hinge-angle1:angle,hinge-angle2:angle - Function: Simulates the folding angle of foldable devices
- Unit: Degree
- Application Scenarios: Foldable screen device adaptation, multi-screen display control
8. Wearable device sensors
Wrist-tilt gesture
- Format:
wrist-tilt:value:measurementId - Function: Detects wrist lifting motion
- Application Scenarios: Smartwatch screen activation, gesture recognition
How to use
Configuring System Attributes (Recommended Methods)
1. Set system properties
Specify the sensor data file path by setting system properties:
setprop persist.sys.cloud.sensor.tpl_dp /data/local/tmp/sensor1.txt
2. Create sensor data files
Create sensor data files in the specified path, formatted as follows:
# /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 sensor (x:y:z format)
| Sensor type | Format example | Unit | Explanation |
|---|---|---|---|
acceleration | acceleration:-0.628:2.946:9.217 | m/s² | Accelerometer data |
linear-acceleration | linear-acceleration:0.1:-0.2:0.05 | m/s² | Linear acceleration |
acceleration-uncalibrated | acceleration-uncalibrated:-0.63:2.95:9.22 | m/s² | Acceleration not calibrated |
gyroscope | gyroscope:-3.625:-0.8125:1.2125 | rad/s | Gyroscope data |
gyroscope-uncalibrated | gyroscope-uncalibrated:-3.62:-0.81:1.21 | rad/s | The gyroscope was not calibrated |
gravity | gravity:0.0:0.0:9.8 | m/s² | Gravity sensor |
magnetic-field | magnetic-field:1.4375:24.475:-18.3625 | μT | Magnetometer data |
magnetic-field-uncalibrated | magnetic-field-uncalibrated:1.44:24.48:-18.36 | μT | The magnetometer was not calibrated |
orientation | orientation:45.0:10.5:-5.2 | Degree | Direction Sensor (Obsolete) |
rotation-vector | rotation-vector:0.1:0.2:0.3 | - | Rotation vector |
game-rotation-vector | game-rotation-vector:0.15:0.25:0.35 | - | Game rotation vector |
geomagnetic_roation | geomagnetic_roation:0.12:0.22:0.32 | - | Geomagnetic rotation vector |
Single-value sensor (value format)
| Sensor type | Format example | Unit | Explanation |
|---|---|---|---|
light | light:500.0 | lux | Light intensity |
proximity | proximity:0.0 | cm | Distance sensor |
temperature | temperature:25.5 | ℃ | Ambient temperature |
pressure | pressure:1013.25 | hPa | Atmospheric pressure |
humidity | humidity:65.0 | % | Relative humidity |
step-counter | step-counter:1250 | Step | Accumulate steps |
step-detector | step-detector:1.0 | - | Walking detection |
significant-motion | significant-motion:1.0 | - | Significant movement |
motion-detect | motion-detect:1.0 | - | Motion detection |
tilt-detector | tilt-detector:1.0 | - | Tilt detection |
pick-up | pick-up:1.0 | - | Hold up the gesture |
heart-rate | heart-rate:72.0 | BPM | Heart rate |
hinge-angle0 | hinge-angle0:90.0 | Degree | Hinge angle 0 |
hinge-angle1 | hinge-angle1:45.0 | Degree | Hinge angle 1 |
hinge-angle2 | hinge-angle2:0.0 | Degree | Hinge angle 2 |
Special-format sensors
| Sensor type | Format example | Explanation |
|---|---|---|
wrist-tilt | wrist-tilt:1.0:12345 | Wrist tilt: Value: Measurement ID |
delay | delay:50 | Delay interval, unit: milliseconds |
4. File restrictions
- Maximum file size: 1GB
- Supported Formats: Plain text files
- Encoding requirements: UTF-8
- Permission Requirements: Files must have readable permissions
Data Collection and Generation
1. Real device data collection
Simulation files can be generated by collecting sensor data from real devices:
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)
# Simulating the decomposition of gravity at different angles
acc_x = 9.8 * math.sin(rad)
acc_y = 0
acc_z = 9.8 * math.cos(rad)
# Simulates angular velocity during rotation
gyro_x = 0.1 if angle < 180 else -0.1
gyro_y = 0
gyro_z = 0
# The magnetometer data remained 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 the shake gesture"""
with open(output_file, 'w') as f:
for shake in range(10): # shake 10 times
# Shake to the 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 to the 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 stillness
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")
# Use examples
generate_rotation_data("/data/local/tmp/rotation.txt")
generate_shake_data("/data/local/tmp/shake.txt")
Dynamic simulation scenarios
1. Equipment rotation simulation
Using Data File Mode
# 1. Generate the rotation data file
python3 generate_rotation.py
# 2. Upload to Cloud Phone
adb push rotation.txt /data/local/tmp/
# 3. Set system properties to enable simulation
adb shell setprop persist.sys.cloud.sensor.tpl_dp /data/local/tmp/rotation.txt
# 4. Restart the target app to check the results
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 files
adb push shake.txt /data/local/tmp/
adb shell setprop persist.sys.cloud.sensor.tpl_dp /data/local/tmp/shake.txt
# Launch apps like WeChat that support Shake to test it
adb shell am start com.tencent.mm/.ui.LauncherUI
Actual Operation Process
1. Complete operation example
# Connect to cloud phones
adb connect your-cloud-phone-ip:5555
# Upload the prepared sensor data file
adb push sensor_walking.txt /data/local/tmp/
# Set file reading permissions
adb shell chmod 644 /data/local/tmp/sensor_walking.txt
# Set system properties
adb shell setprop persist.sys.cloud.sensor.tpl_dp /data/local/tmp/sensor_walking.txt
# Verify property settings
adb shell getprop persist.sys.cloud.sensor.tpl_dp
# Restart the target application to activate sensor data
adb shell am force-stop com.example.walkingapp
adb shell am start com.example.walkingapp/.MainActivity
# View the validation effect of application logs
adb logcat | grep SensorManager
2. Switch between different scenario data
# Switch to Shake Data
adb shell setprop persist.sys.cloud.sensor.tpl_dp /data/local/tmp/shake.txt
# Switch to rotating data
adb shell setprop persist.sys.cloud.sensor.tpl_dp /data/local/tmp/rotation.txt
# Disable sensor simulation (clear properties)
adb shell setprop persist.sys.cloud.sensor.tpl_dp ""
Best Practices
1. Data file management
- Naming conventions: Use meaningful file names, such as
walking_5min.txtorcar_driving.txt - Data Integrity: Ensure each set of sensor data has a corresponding delay value
- File Size: Reasonably control file size to avoid the 1GB limit that affects performance
2. Data Validity
- Accelerometer: At rest, the Z-axis should be about 9.8 m/s² (gravitational acceleration)
- Gyroscope: The three-axis value at rest should be close to 0
- Magnetometer: A typical Earth's magnetic field strength is about 25-65μT
3. Update frequency optimization
- Gaming Apps: Recommended delay: 16 (60Hz)
- Navigation Apps: Recommended delay: 200-1000 (1-5Hz)
- General Applications: Recommended delay: 50-100 (10-20Hz)
4. Data smoothness
When generating data files, ensure smooth transitions between values:
# Examples of smooth transitions
def smooth_transition(start_value, end_value, steps):
"""Smooth interpolation is performed between two values"""
return [start_value + (end_value - start_value) * i / steps
for i in range(steps + 1)]
# Applied 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 test
- Simulate different device postures to test gravity-sensing games
- Batch testing the impact of device rotation on the game interface
2. Navigation application testing
- Simulates complex driving routes to test navigation accuracy
- Test map display effects at different locations
3. Health application testing
- Simulates movements such as walking and running
- Test pedometer and movement trajectory recording functions
Notes
Performance Impact: Frequent sensor data updates may affect system performance; adjust update frequency according to actual needs
Application Permissions: Ensure the target application has obtained the corresponding sensor usage permissions
Data Consistency: Data from different sensors should maintain physical consistency to avoid conflicting data combinations
Application Compatibility: Some older versions of applications may have limited support for certain sensor data
Device Compatibility: Cloud phone sensor support depends on the real model being simulated; some sensors are only available on specific models:
humidity(humidity sensor) - Not supported by most mid- to low-end modelstemperature(temperature sensor) - Supported only on some high-end modelsheart-rate(heart rate sensor) - mainly found in specific models such as the Samsung Galaxy seriestilt-detector(Tilt Detector) - Some gyroscope implementations may not be supported on some modelsmotion-detect(motion detection) - a motion coprocessor dependent on the devicehinge-angle0/1/2/3(hinge angle sensor) - Supported only on foldable devices such as Samsung Galaxy Fold, Huawei Mate X, etc
Suggestion: Choose an appropriate device template, or verify before use that the model simulated by your current cloud server instance supports the target sensor
Troubleshooting
Frequently Asked Questions
Q: Application does not respond after setting sensor data
A: Check if the app has obtained sensor permissions, or try restarting the app to reinitialize the sensor listening
Q: Data updates are not smooth, causing jumps
A: Appropriately reduce update frequency or add interpolation transitions between data
Q: Sensor simulation does not take effect after system property settings
A: Check whether the system attribute path is correct, confirm that the data file exists and has read permissions (chmod 644), and verify that the file format is correct. You can attempt to restart the target application
Q: Some sensor data settings still do not respond to the application
A: It may be that the current models simulated in cloud computing instances do not support this type of sensor. Especially sensors for humidity, temperature, heart rate, and hinge angle are only present on specific real models; cloud platforms determine sensor support based on the model being simulated. It is recommended to first test using basic sensors (accelerometer, gyroscope, magnetometer) or choose a model template that supports the target sensor