2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
센서
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Android 센서는 애플리케이션에 휴대기기의 기본 물리적 센서에 대한 액세스 권한을 부여합니다. Android 센서는 데이터를 제공하는 가상 기기이며, 센서 HAL(하드웨어 추상화 계층)인 sensors.h에 의해 정의됩니다.
Android 센서란?
Android 센서는 가속도계, 자이로스코프, 자기계, 기압계, 습도, 압력, 빛, 근접, 심박수 센서를 비롯한 여러 물리 센서에서 발생하는 데이터를 제공하는 가상 기기입니다.
데이터를 제공하는 실제 기기 목록에 포함되지 않은 항목으로는 카메라, 지문 센서, 마이크, 터치스크린 등이 있습니다. 이러한 기기에는 자체 보고 메커니즘이 있습니다. 구분은 임의적이지만 일반적으로 Android 센서는 저대역 데이터를 제공합니다. 예를 들어 가속도계는 '100hz x 3 채널', 카메라는 '25hz x 8 MP x 3 채널', 마이크는 '44kHz x 1 채널'입니다.
Android는 서로 다른 물리적 센서가 단일 칩 시스템(SoC)에 연결되는 방식을 정의하지 않습니다.
- 센서 칩은 데이터의 어느 정도 저전력 모니터링 및 처리가 가능하도록 센서 허브를 통해 SoC에 연결되는 경우가 많습니다.
- I2C(Inter-Integrated Circuit) 또는 SPI(직렬 주변기기 인터페이스)가 전송 메커니즘에 사용되는 경우가 많습니다.
- 전력 소모를 줄이기 위해 일부 아키텍처는 계층 구조로 이루어집니다. 여기서는 최소 처리의 일부가 가속도계 칩의 모션 감지와 같은 ASIC(애플리케이션별 직접회로)에서 이루어지며 마이크로 컨트롤러에서 센서 허브의 단계 감지와 같이 더 많은 처리가 이루어집니다.
- 정확도, 전력, 가격 및 포장 크기 특성을 토대로 기기 제조업체에서 아키텍처를 선택합니다. 자세한 내용은 센서 스택을 참조하세요.
- 일괄 처리 기능은 전력 최적화와 관련된 중요한 고려사항입니다. 자세한 내용은 일괄 처리를 참조하세요.
각 Android 센서에는 센서 동작 방식과 센서를 통해 제공되는 데이터를 나타내는 '유형'이 있습니다.
- 공식적인 Android 센서 유형은 SENSOR_TYPE_… 아래의 sensors.h에 정의되어 있습니다.
- 대부분의 센서에는 공식 센서 유형이 있습니다.
- 이러한 유형은 Android SDK에 문서화됩니다.
- 이러한 유형을 가진 센서의 동작은 Android CTS(호환성 테스트 도구 모음)에서 테스트됩니다.
- Android 기기에 새로운 유형의 센서를 통합한 제조업체는 자체적인 임시 유형을 정의하여 이를 참조할 수 있습니다.
- 이러한 유형은 문서화되지 않으므로 애플리케이션 개발자가 사용할 가능성이 낮습니다. 이는 애플리케이션 개발자가 유형에 관해 모르거나 존재하는 경우가 드물다(이 구체적인 제조업체의 기기 중 일부에만)는 점을 알기 때문입니다.
- 이러한 유형은 CTS로 테스트되지 않습니다.
- Android가 이러한 센서 유형의 공식 센서 유형을 정의하면 제조업체는 자체적인 임시 유형의 사용을 멈추고 공식 유형을 사용해야 합니다. 이렇게 하면 더 많은 애플리케이션 개발자가 센서를 사용하게 됩니다.
- 기기에 존재하는 모든 센서의 목록은 HAL 구현에 의해 보고됩니다.
- 유형이 같은 여러 센서가 존재할 수 있으며, 2개의 근접 센서나 2개의 가속도계를 예로 들 수 있습니다.
- 대부분의 애플리케이션은 지정된 유형으로 하나의 센서만 요청합니다. 예를 들어 기본 가속도계를 요청하는 애플리케이션은 목록의 첫 번째 가속도계를 얻게 됩니다.
- 센서는 보통 wake-up 및 non-wake-up 쌍으로 정의됩니다. 두 센서는 같은 유형을 공유하지만 활성화 특성이 다릅니다.
Android 센서는 일련의 센서 이벤트로 데이터를 제공합니다.
각 이벤트에는 다음이 포함됩니다.
보고된 데이터의 해석은 센서 유형에 따라 다릅니다. 센서 유형별로 보고되는 데이터에 관한 자세한 내용은 센서 유형 정의를 참조하세요.
기존 문서
개발자 타겟팅
-
- SDK 참조
- Stack Overflow 및 튜토리얼 웹사이트
- 간혹 센서 관련 문서가 부족했던 관계로 개발자는 Stack Overflow와 같은 Q&A 웹사이트에서 답을 얻었습니다.
- 몇몇 튜토리얼 웹사이트도 존재하지만 일괄 처리, 중요 모션 및 게임 회전 벡터와 같은 최신 기능에 관한 정보를 다루는 곳은 없습니다.
- 이러한 웹사이트의 정보는 정확하지 않을 때도 있으며 추가 문서가 필요한 부분을 보여줍니다.
제조업체 타겟팅
- 개요
- 하드웨어 추상화 계층(HAL)
- Android CDD(호환성 정의 문서)
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2024-05-07(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-05-07(UTC)"],[],[],null,["# Sensors\n\nAndroid sensors give applications access to a mobile device's underlying\nphysical sensors. They are data-providing virtual devices defined by [sensors.h](https://android.googlesource.com/platform/hardware/libhardware/+/android16-release/include/hardware/sensors.h), the sensor Hardware Abstraction Layer (HAL).\n\nWhat are Android sensors?\n-------------------------\n\nAndroid sensors are virtual devices that provide data coming from a set of\nphysical sensors: accelerometers, gyroscopes, magnetometers, barometer, humidity,\npressure, light, proximity and heart rate sensors.\n\nNot included in the list of physical devices providing data are camera,\nfingerprint sensor, microphone, and touch screen. These devices have their own\nreporting mechanism; the separation is arbitrary, but in general, Android sensors\nprovide lower bandwidth data. For example, \"100hz x 3 channels\" for an\naccelerometer versus \"25hz x 8 MP x 3 channels\" for a camera or \"44kHz x 1\nchannel\" for a microphone.\n\nAndroid does not define how the different physical sensors are connected\nto the system on chip (SoC).\n\n- Often, sensor chips are connected to the SoC through a [sensor hub](/docs/core/interaction/sensors/sensor-stack#sensor_hub), allowing some low-power monitoring and processing of the data.\n- Often, Inter-Integrated Circuit (I2C) or Serial Peripheral Interface (SPI) is used as the transport mechanism.\n- To reduce power consumption, some architectures are hierarchical, with some minimal processing being done in the application-specific integrated circuit (ASIC - like motion detection on the accelerometer chip), and more is done in a microcontroller (like step detection in a sensor hub).\n- It is up to the device manufacturer to choose an architecture based on accuracy, power, price and package-size characteristics. See [Sensor stack](/docs/core/interaction/sensors/sensor-stack) for more information.\n- Batching capabilities are an important consideration for power optimization. See [Batching](/docs/core/interaction/sensors/batching) for more information.\n\nEach Android sensor has a \"type\" representing how the sensor behaves and\nwhat data it provides.\n\n- The official Android [Sensor\n types](/docs/core/interaction/sensors/sensor-types) are defined in [sensors.h](https://android.googlesource.com/platform/hardware/libhardware/+/android16-release/include/hardware/sensors.h) under the names SENSOR_TYPE_...\n - The vast majority of sensors have an official sensor type.\n - Those types are documented in the Android SDK.\n - Behavior of sensors with those types are tested in the Android Compatibility Test Suite (CTS).\n- If a manufacturer integrates a new kind of sensor on an Android device, the manufacturer can define its own temporary type to refer to it.\n - Those types are undocumented, so application developers are unlikely to use them, either because they don't know about them, or know that they are rarely present (only on some devices from this specific manufacturer).\n - They are not tested by CTS.\n - Once Android defines an official sensor type for this kind of sensor, manufacturers must stop using their own temporary type and use the official type instead. This way, the sensor will be used by more application developers.\n- The list of all sensors present on the device is reported by the HAL implementation.\n - There can be several sensors of the same type. For example, two proximity sensors or two accelerometers.\n - The vast majority of applications request only a single sensor of a given type. For example, an application requesting the default accelerometer will get the first accelerometer in the list.\n - Sensors are often defined by [wake-up](/docs/core/interaction/sensors/suspend-mode#wake-up_sensors) and [non-wake-up](/docs/core/interaction/sensors/suspend-mode#non-wake-up_sensors) pairs, both sensors sharing the same type, but differing by their wake-up characteristic.\n\nAndroid sensors provide data as a series of sensor events.\n\nEach [event](/docs/core/interaction/sensors/hal-interface#sensors_event_t)\ncontains:\n\n- a handle to the sensor that generated it\n- the timestamp at which the event was detected or measured, based on [`SystemClock.elapsedRealtimeNanos()`](https://developer.android.com/reference/android/os/SystemClock#elapsedRealtimeNanos())\n- and some data\n\nThe interpretation of the reported data depends on the sensor type. See\nthe [sensor type](/docs/core/interaction/sensors/sensor-types)\ndefinitions for details on what data is reported for each sensor type.\n\nExisting documentation\n----------------------\n\n### Targeted at developers\n\n- Overview\n - \u003chttps://developer.android.com/guide/topics/sensors/sensors_overview.html\u003e\n- SDK reference\n - \u003chttps://developer.android.com/reference/android/hardware/SensorManager\u003e\n - \u003chttps://developer.android.com/reference/android/hardware/SensorEventListener\u003e\n - \u003chttps://developer.android.com/reference/android/hardware/SensorEvent\u003e\n - \u003chttps://developer.android.com/reference/android/hardware/Sensor\u003e\n- Stack Overflow and tutorial websites\n - Because sensors documentation was sometimes lacking, developers resorted to Q\\&A websites like Stack Overflow to find answers.\n - Some tutorial websites exist as well, but do not cover the latest features like batching, significant motion and game rotation vectors.\n - The answers over there are not always right, and show where more documentation is needed.\n\n### Targeted at manufacturers\n\n- Overview\n - This [Sensors](/docs/core/interaction/sensors) page and its sub-pages.\n- Hardware abstraction layer (HAL)\n - [/platform/hardware/libhardware/+/android16-release/include/hardware/sensors.h](https://android.googlesource.com/platform/hardware/libhardware/+/android16-release/include/hardware/sensors.h)\n - Also known as \"sensors.h\"\n - The source of truth. First document to be updated when new features are developed.\n- Android CDD (Compatibility Definition Document)\n - [/compatibility/android-cdd.pdf](/static/docs/compatibility/android-cdd.pdf)\n - See sections relative to sensors.\n - The CDD is lenient, so satisfying the CDD requirements is not enough to ensure high quality sensors."]]