[FP6] All 43 sensors unavailable due to SELinux label timing issue in init.target.rc
## Device
- **Device:** Fairphone 6 (FP6)
- **/e/OS version:** 3.4-a15 (Android 15)
- **Build:** BP1A.250505.005
- **Firmware:** FP6.QREL.15.162.0
## Problem
All 43 hardware sensors are unavailable on /e/OS a15 for FP6:
- Accelerometer (ICM4x6xx) - **not working**
- Gyroscope (ICM4x6xx) - **not working**
- Magnetometer (QMC630x) - **not working**
- Light sensor (STK3BCx) - **not working**
- Proximity sensor (STK3BCx) - **not working**
- Pressure sensor (SPL07) - **not working**
- All fusion sensors (gravity, rotation vector, etc.) - **not working**
This means **auto-rotate, adaptive brightness, compass, and proximity-based screen-off during calls** are all broken.
## Root Cause
SELinux file label timing issue in `device/fairphone/FP6/init/init.target.rc`.
The sensor directories are created by vendor init scripts (`init.vendor.sensors.rc`) during `early-boot`, but `restorecon_recursive /mnt/vendor/persist` runs earlier during `on fs`. Since the directories don't exist yet when restorecon runs, they get created later with wrong SELinux labels:
| Path | Expected Label | Actual Label |
|------|----------------|--------------|
| `/mnt/vendor/persist/sensors/` | `vendor_persist_sensors_file` | `mnt_vendor_file` |
| `/data/vendor/sensors/` | `vendor_sensors_vendor_data_file` | `vendor_data_file` |
This blocks `sscrpcd` (vendor_sensors) and `sensors.qti` (vendor_sensors_qti) from accessing their data directories, preventing all sensor initialization on the Qualcomm Sensor Core (SSC).
The Qcom vendor SELinux policy already has the correct `file_contexts` and `allow` rules — they just never get applied because the directories don't exist at restorecon time.
## Fix
7-line change to `init/init.target.rc`. Create sensor directories **before** the existing `restorecon_recursive` call:
```diff
on fs
start hwservicemanager
mount_all /vendor/etc/fstab.qcom --early
chown root system /mnt/vendor/persist
chmod 0771 /mnt/vendor/persist
+ mkdir /mnt/vendor/persist/sensors 0775 system system
+ mkdir /mnt/vendor/persist/sensors/registry 0775 system system
+ mkdir /mnt/vendor/persist/sensors/registry/registry 0775 system system
restorecon_recursive /mnt/vendor/persist
mkdir /mnt/vendor/persist/secnvm 0770 system system
on post-fs-data
mkdir /vendor/data/tombstones 0771 system system
+ # Sensor data directories
+ mkdir /data/vendor/sensors 0770 system system
+ mkdir /data/vendor/sensors/scripts 0770 system system
+ mkdir /data/vendor/sensors/diag_cfg 0770 system system
+ restorecon_recursive /data/vendor/sensors
# Enable WLAN cold boot calibration
write /sys/kernel/cnss/fs_ready 1
```
No sepolicy `.te` file changes needed.
## Testing
- Tested on FP6 with /e/OS 3.4-a15, SELinux **enforcing**
- All 43 hardware sensors operational after reboot
- Zero SELinux denials in dmesg
- Auto-rotate, adaptive brightness, proximity all confirmed working
- Accelerometer returning valid data (ICM4x6xx, 1-500Hz)
## Verification Steps
To verify on a rooted device:
```bash
# Check current (wrong) labels
adb shell "su -c 'ls -Z /mnt/vendor/persist/sensors/'"
# Shows: mnt_vendor_file (WRONG)
# Fix labels
adb shell "su -c 'restorecon -Rv /mnt/vendor/persist/sensors/'"
adb shell "su -c 'restorecon -Rv /data/vendor/sensors/'"
# Restart sensors
adb shell "su -c 'stop vendor.sensors-hal-multihal && stop vendor.sensors && stop vendor.sensors.qti'"
adb shell "su -c 'start vendor.sensors && start vendor.sensors.qti && sleep 2 && start vendor.sensors-hal-multihal'"
# Verify
adb shell dumpsys sensorservice | head -3
# Should show: Total 43 h/w sensors
```
issue