Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ sensor types #621

Closed
tam2016 opened this issue Jan 19, 2018 · 7 comments
Closed

C++ sensor types #621

tam2016 opened this issue Jan 19, 2018 · 7 comments

Comments

@tam2016
Copy link

tam2016 commented Jan 19, 2018

Description

I am looking for some information about sensor types that are not listen in the NDK documentation in ASENSOR_TYPE enum, but are available in Java (for example TYPE_ROTATION_VECTOR, TYPE_PRESSURE, TYPE_GRAVITY, etc.).

Besides not being int he documentation, they seem to work fine in C++ if we assume that their type ID-s are the same as in Java. I have tested if the provided sensor data is correct for TYPE_ROTATION_VECTOR, and it is working with no issues.
Also, if we print out the names and types of the sensors we get using ASensorManager_getSensorList(), they seem to match the Java type definitions.

So my questions are:

  1. Are these sensor types supported and safe to use, or do they only work in some cases?
  2. Is there any information about them in the documentation or anywhere else that I may have missed?
  3. Are their type ID-s defined in the C++ code somewhere?

Code:

ASensorManager *sensorManager = ASensorManager_getInstance();
ASensorList availableSensors = nullptr;
int numberOfSensors =
    ASensorManager_getSensorList(sensorManager, &availableSensors);
for (int i = 0; i < numberOfSensors; ++i) {
	ASensor *sensor = (ASensor *) availableSensors[i];
	DLOG(INFO) << "***Sensors-----------------------------------------\n"
		   << "name = " << ASensor_getName(sensor) << "\n"
		   << "type = " << ASensor_getType(sensor) << "\n";
}

Output:

01-19 14:02:59.601 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = MPU6515 Accelerometer
                                                                                      type = 1
01-19 14:02:59.601 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = AK8963 Magnetometer
                                                                                      type = 2
01-19 14:02:59.601 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = AK8963 Magnetometer Uncalibrated
                                                                                      type = 14
01-19 14:02:59.601 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = MPU6515 Gyroscope
                                                                                      type = 4
01-19 14:02:59.603 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = MPU6515 Gyroscope Uncalibrated
                                                                                      type = 16
01-19 14:02:59.603 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = APDS-9930/QPDS-T930 Proximity & Light
                                                                                      type = 8
01-19 14:02:59.603 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = APDS-9930/QPDS-T930 Proximity & Light
                                                                                      type = 5
01-19 14:02:59.603 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = BMP280 Barometer
                                                                                      type = 6
01-19 14:02:59.603 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = Gravity
                                                                                      type = 9
01-19 14:02:59.603 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = Linear Acceleration
                                                                                      type = 10
01-19 14:02:59.606 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = Rotation Vector
                                                                                      type = 11
01-19 14:02:59.608 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = Step Detector
                                                                                      type = 18
01-19 14:02:59.609 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = Step Counter
                                                                                      type = 19
01-19 14:02:59.609 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = Significant Motion Detector
                                                                                      type = 17
01-19 14:02:59.611 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = Game Rotation Vector
                                                                                      type = 15
01-19 14:02:59.611 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = GeoMagnetic Rotation Vector
                                                                                      type = 20
01-19 14:02:59.611 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = Orientation
                                                                                      type = 3
01-19 14:02:59.611 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = Tilt Detector
                                                                                      type = 22
01-19 14:02:59.611 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = MPU6515 Game Rotation Vector Secondary
                                                                                      type = 15
01-19 14:02:59.614 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = AMD
                                                                                      type = 33171006
01-19 14:02:59.615 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = RMD
                                                                                      type = 33171007
01-19 14:02:59.615 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = Basic Gestures
                                                                                      type = 33171000
01-19 14:02:59.615 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = Tap
                                                                                      type = 33171001
01-19 14:02:59.618 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = Facing
                                                                                      type = 33171002
01-19 14:02:59.618 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = Tilt
                                                                                      type = 33171003
01-19 14:02:59.618 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = Pedometer
                                                                                      type = 33171009
01-19 14:02:59.618 28737-28882/com.customlbs.android I/SensorProviderAndroid.cpp:280: ***Sensors-----------------------------------------
                                                                                      name = PEDESTRIAN-ACTIVITY-MONITOR
                                                                                      type = 33171010

Environment Details

  • NDK Version: 16.1.4479499
  • Phone: Nexus 5
@enh
Copy link
Contributor

enh commented Jan 19, 2018

looks like pengxu owns both Sensor.java and sensor.h, so i've forwarded this internally...

@enh
Copy link
Contributor

enh commented Jan 23, 2018

apparently ashutoshj was the right person to ask.

Are these sensor types supported and safe to use, or do they only work in some cases?

i'm told your assumption should be safe: the C++ values should be the same as the corresponding Java enum.

Is there any information about them in the documentation or anywhere else that I may have missed?

in the Java documentation.

Are their type ID-s defined in the C++ code somewhere?

no, but we'll add them to get the Sensors.java and sensors.h back in sync.

@enh
Copy link
Contributor

enh commented Jan 23, 2018

@tam2016
Copy link
Author

tam2016 commented Jan 24, 2018

Great! Thank you for your answer!

@enh
Copy link
Contributor

enh commented Jan 24, 2018

did you notice anything else missing compared to the Java API, or was it just the constants?

@DanAlbert
Copy link
Member

BoredOutOfMyGit pushed a commit to codeaurora-unofficial/platform-frameworks-native that referenced this issue Jan 26, 2018
This matches Sensor.java
(https://developer.android.com/reference/android/hardware/Sensor.html).

I've included the types for a few of the easy cases, but I've added a
link to the Java documentation for the rest: the Java documentation is
much better and actively maintained. Duplicating it here doesn't seem
worthwhile, and <android/multinetwork.h> already takes this approach.

Bug: android/ndk#621
Test: builds
Change-Id: Icffd85071e56bd7f45e8f3dc9d300a495859dbcb
@tam2016
Copy link
Author

tam2016 commented Jan 26, 2018

Related question: #631

miodragdinic pushed a commit to MIPS/prebuilts-ndk that referenced this issue Apr 17, 2018
Test: ndk/checkbuild.py && ndk/validate.py
Bug: android/ndk#621
Change-Id: I66503c08af191f519e2e2241c96a2cf4879dd2b2
h7su pushed a commit to h7su/android_platform_frameworks_native that referenced this issue Apr 22, 2024
This matches Sensor.java
(https://developer.android.com/reference/android/hardware/Sensor.html).

I've included the types for a few of the easy cases, but I've added a
link to the Java documentation for the rest: the Java documentation is
much better and actively maintained. Duplicating it here doesn't seem
worthwhile, and <android/multinetwork.h> already takes this approach.

Bug: android/ndk#621
Test: builds
Change-Id: Icffd85071e56bd7f45e8f3dc9d300a495859dbcb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants