Bluetooth, Sensors & Auto Quiz
ADVANCED › Emerging
On Android 12 (API 31) and higher, which permission must an app request to scan for nearby BLE devices?
- ACCESS_FINE_LOCATION only
- BLUETOOTH_SCAN
- BLUETOOTH_ADMIN
- BLUETOOTH_CONNECT
Answer: BLUETOOTH_SCAN
BLUETOOTH_SCAN is the runtime permission for discovering BLE devices on API 31+; with the neverForLocation flag it can even avoid requiring location permission.
In BLE, what distinguishes a GATT client from a GATT server?
- The client sends data requests; the server stores data and replies
- The client always advertises, while the server always scans nearby
- The server initiates the connection, and the client only accepts it
- They are identical BLE roles, just described with different names
Answer: The client sends data requests; the server stores data and replies
The GATT client requests data and the server fulfills those requests; this distinction is independent of the central/peripheral roles.
Why should a SensorEventListener typically be unregistered in onPause()?
- Sensors stop producing data automatically once an app is paused
- The framework throws an exception if a listener stays registered
- Sensors keep running and drain the battery even when the app isn't visible
- onSensorChanged fires only while the activity is in the resumed state
Answer: Sensors keep running and drain the battery even when the app isn't visible
The framework does not disable sensors based on the activity lifecycle, so leaving a listener registered keeps the sensor active and drains the battery.
Which of these is a software/composite sensor derived from other hardware sensors?
- TYPE_ACCELEROMETER (raw hardware motion sensor, not a composite one)
- TYPE_MAGNETIC_FIELD (direct magnetic-field sensor, not software-derived)
- TYPE_PRESSURE (barometer reading from hardware, not a composite sensor)
- TYPE_LINEAR_ACCELERATION (software-derived from raw sensor data)
Answer: TYPE_LINEAR_ACCELERATION (software-derived from raw sensor data)
Linear acceleration, like gravity and the rotation vector, is a composite sensor computed in software from raw hardware sensor data.
What is the key difference between Android Auto and Android Automotive OS (AAOS)?
- Android Auto runs natively on the car's head unit while AAOS projects from a phone
- Android Auto projects a phone app to the car screen; AAOS is a full OS on the car
- They are simply two different names for the exact same single product
- AAOS operates only when a phone is tethered over a USB connection
Answer: Android Auto projects a phone app to the car screen; AAOS is a full OS on the car
Android Auto is phone-based projection to a compatible display, whereas Android Automotive OS is the embedded operating system installed in the vehicle itself.
Which library do you use to build navigation and point-of-interest apps that run on both Android Auto and Android Automotive OS?
- android.bluetooth for device pairing and low-level audio
- MediaBrowserService for media playback and browsing only
- Android for Cars App Library (androidx.car.app)
- Jetpack Compose for Wear, which targets smartwatch UIs
Answer: Android for Cars App Library (androidx.car.app)
The Car App Library provides templated, distraction-optimized UI shared across Android Auto and AAOS for navigation, POI, and IoT apps.
Why does the Car App Library use a fixed set of templates instead of arbitrary custom UI?
- To enforce distraction-safety limits with a standardized UI
- Because car displays cannot render custom views at all
- Because the library was created before Jetpack Compose existed
- To reduce APK size and memory use by keeping UI code small
Answer: To enforce distraction-safety limits with a standardized UI
Templates cap interaction complexity to meet driver-distraction guidelines, so apps cannot draw arbitrary UI while the vehicle is in motion.
After a successful BLE connection on Android 12 (API 31)+, which runtime permission gates calling readCharacteristic() and writeCharacteristic()?
- BLUETOOTH_SCAN
- BLUETOOTH_ADVERTISE
- BLUETOOTH_CONNECT
- ACCESS_FINE_LOCATION
Answer: BLUETOOTH_CONNECT
BLUETOOTH_CONNECT is the runtime permission required to communicate with an already-bonded or connected device, including reading and writing characteristics; SCAN only covers discovery.
What does adding android:usesPermissionFlags="neverForLocation" to the BLUETOOTH_SCAN declaration accomplish?
- It grants the scan permission silently, without showing any runtime prompt
- It permits background BLE scanning without any foreground service
- It raises the scan duty cycle so nearby devices are discovered faster
- It asserts scans aren't used to derive location, so no ACCESS_FINE_LOCATION
Answer: It asserts scans aren't used to derive location, so no ACCESS_FINE_LOCATION
The neverForLocation flag tells the system the app does not use Bluetooth scans to infer location, which lets it scan on API 31+ without also requesting ACCESS_FINE_LOCATION.
To start receiving notifications from a characteristic, an app calls setCharacteristicNotification(). What additional step is required for the peripheral to actually push updates?
- Call discoverServices() again after each notification arrives
- Write the enable-notification value to the characteristic's CCCD
- Request a larger MTU with requestMtu() before notifications start
- Call connectGatt() again with autoConnect set to true
Answer: Write the enable-notification value to the characteristic's CCCD
setCharacteristicNotification() only configures the local stack; the peripheral starts sending notifications only after the client writes the enable value (0x0001) to the characteristic's CCCD descriptor.
What is the correct interpretation of the delay argument (e.g. SENSOR_DELAY_GAME) passed to registerListener()?
- It is only a hint; events may arrive faster or slower than requested
- It guarantees an exact, fixed sampling period for every event delivered
- It must be set to SENSOR_DELAY_FASTEST when step counting is enabled
- Lower-numbered delay constants always save battery and cut CPU usage
Answer: It is only a hint; events may arrive faster or slower than requested
The sampling rate is a hint only; the framework may deliver events at a different rate, and faster rates such as FASTEST or GAME actually increase battery and CPU usage.
What is the purpose of SensorManager.remapCoordinateSystem()?
- Converting raw accelerometer data into linear acceleration values
- Calibrating the magnetometer to offset hard-iron interference
- Reorienting a rotation matrix for a non-default device orientation
- Batching sensor events into the hardware FIFO buffer to save power
Answer: Reorienting a rotation matrix for a non-default device orientation
remapCoordinateSystem() reorients a rotation matrix (for example for a landscape app or a device mounted on a different axis) so that getOrientation() returns values relative to the desired frame of reference.
Which set of classes are the core building blocks of an app built with the Android for Cars App Library?
- Activity, Fragment, and ViewModel
- CarAppService, Session, and Screen
- CarActivity, CarFragment, and CarView
- MediaBrowserService, MediaSession, and MediaController
Answer: CarAppService, Session, and Screen
A Car App Library app declares a CarAppService, which creates a Session that hosts a stack of Screen objects, each returning a template; the standard Activity/Fragment stack is not used.
Which sensor is a one-shot trigger sensor that you register with requestTriggerSensor() and that disables itself after firing once?
- TYPE_ACCELEROMETER continuous motion sensor that streams readings constantly
- TYPE_STEP_COUNTER counts steps over time and keeps reporting accumulated totals
- TYPE_ROTATION_VECTOR estimates orientation from fused sensors, not a trigger
- TYPE_SIGNIFICANT_MOTION one-shot trigger sensor via requestTriggerSensor()
Answer: TYPE_SIGNIFICANT_MOTION one-shot trigger sensor via requestTriggerSensor()
TYPE_SIGNIFICANT_MOTION is a trigger sensor handled via TriggerEventListener and requestTriggerSensor(); it fires a single event when significant motion is detected and then automatically unregisters itself.