├── Provision ├── MODULE_LICENSE_APACHE2 ├── proguard.flags ├── Android.bp ├── AndroidManifest.xml ├── CleanSpec.mk └── src │ └── com │ └── android │ └── provision │ └── DefaultActivity.java ├── sepolicy ├── bootanim.te ├── priv_app.te ├── mediaserver.te ├── mediaswcodec.te ├── mediaprovider.te ├── surfaceflinger.te ├── property.te ├── untrusted_app_all.te ├── bluetooth.te ├── hal_graphics_allocator_default.te ├── hal_power_default.te ├── netd.te ├── platform_app.te ├── device.te ├── cameraserver.te ├── init.te ├── system_server.te ├── hal_camera_default.te ├── system_app.te ├── hal_graphics_composer_default.te ├── btuart.te ├── file.te ├── kernel.te ├── te_macros ├── gpiosetd.te ├── switch_boot.te ├── hal_bluetooth_rpi4.te ├── property_contexts ├── hal_drm_widevine.te ├── gpiod.te ├── genfs_contexts └── file_contexts ├── wifi ├── p2p_supplicant_overlay.conf └── wpa_supplicant_overlay.conf ├── scripts ├── fix_quotas.zip ├── resize_userdata.zip ├── switch_boot_rom.zip ├── fix_quotas.sh ├── switch_boot_recovery.sh ├── switch_boot.sh ├── resize_userdata.sh ├── update-raspi64-image.sh └── mk-raspi64-large-image.sh ├── hostapd ├── hostapd.deny └── hostapd.accept ├── recovery ├── root │ ├── sbin │ │ ├── keystore │ │ ├── keystore_auth │ │ ├── servicemanager │ │ ├── hwservicemanager │ │ ├── android.hardware.gatekeeper@1.0-service │ │ └── android.hardware.keymaster@3.0-service │ ├── vendor │ │ ├── lib │ │ │ ├── hw │ │ │ │ ├── gatekeeper.rpi4.so │ │ │ │ ├── android.hardware.gatekeeper@1.0-impl.so │ │ │ │ └── android.hardware.keymaster@3.0-impl.so │ │ │ ├── libkeymaster3device.so │ │ │ └── libpuresoftkeymasterdevice.so │ │ ├── lib64 │ │ │ ├── hw │ │ │ │ ├── gatekeeper.rpi4.so │ │ │ │ ├── android.hardware.keymaster@3.0-impl.so │ │ │ │ └── android.hardware.gatekeeper@1.0-impl.so │ │ │ ├── libkeymaster3device.so │ │ │ └── libpuresoftkeymasterdevice.so │ │ ├── compatibility_matrix.xml │ │ └── manifest.xml │ ├── system │ │ ├── etc │ │ │ ├── recovery.sd.fstab │ │ │ └── recovery.usb.fstab │ │ └── manifest.xml │ └── init.recovery.rpi4.rc ├── recovery.fstab └── init.rc ├── bluetooth ├── btuart │ ├── BCM4345C0.hcd │ ├── BCM4345C5.hcd │ ├── Android.mk │ └── hciattach_rpi4.h ├── cfg │ ├── bt_vendor.conf │ ├── bdroid_buildcfg.h │ └── vnd_rpi4.txt ├── hal │ ├── android.hardware.bluetooth@1.0-service.rpi4.rc │ ├── Android.bp │ ├── service.cc │ ├── hci_packetizer.h │ ├── hci_internals.h │ ├── h4_protocol.h │ ├── async_fd_watcher.h │ ├── bluetooth_hci.h │ ├── hci_packetizer.cc │ ├── h4_protocol.cc │ └── async_fd_watcher.cc └── Android.mk ├── DeviceParts ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── drawable-xxhdpi │ │ └── ic_launcher.png │ ├── drawable-xxxhdpi │ │ └── ic_launcher.png │ ├── values │ │ ├── styles.xml │ │ ├── arrays.xml │ │ └── strings.xml │ └── xml │ │ └── main.xml ├── Android.mk ├── src │ └── org │ │ └── omnirom │ │ └── device │ │ ├── Startup.java │ │ ├── DeviceSettingsActivity.java │ │ ├── KeyHandler.java │ │ └── Utils.java └── AndroidManifest.xml ├── compatibility_matrix.device.xml ├── repo └── local_manifest.xml ├── overlay ├── packages │ └── apps │ │ ├── OpenDelta │ │ └── res │ │ │ └── values │ │ │ └── config.xml │ │ ├── Launcher3 │ │ └── quickstep │ │ │ └── res │ │ │ ├── values │ │ │ └── config.xml │ │ │ └── xml │ │ │ ├── default_workspace_5x5.xml │ │ │ └── device_profiles.xml │ │ ├── Bluetooth │ │ └── res │ │ │ └── values │ │ │ └── config.xml │ │ ├── ThemePicker │ │ └── res │ │ │ └── values │ │ │ └── override.xml │ │ └── Settings │ │ └── res │ │ └── values │ │ └── config.xml └── frameworks │ └── base │ ├── core │ └── res │ │ └── res │ │ ├── values │ │ ├── dimens.xml │ │ └── arrays.xml │ │ └── values-land │ │ └── dimens.xml │ └── packages │ └── SystemUI │ └── res │ ├── values-sw600dp-port │ └── dimens.xml │ ├── values-sw720dp-land │ └── dimens.xml │ ├── values-sw900dp-land │ └── dimens.xml │ ├── values-sw600dp-land │ └── dimens.xml │ ├── values-sw900dp │ ├── dimens.xml │ └── config.xml │ ├── values-land │ └── dimens.xml │ ├── values-sw600dp │ └── config.xml │ ├── values-sw720dp │ └── config.xml │ └── values │ ├── dimens.xml │ ├── arrays.xml │ └── config.xml ├── init ├── Android.bp └── init_rpi4.cpp ├── TODO ├── gps ├── gnsshal │ └── Android.bp ├── README.md └── LICENSE ├── gpio ├── scripts │ └── template.sh ├── Android.bp └── src │ ├── tools-common.h │ ├── tools-common.cpp │ └── gpiosetd.cpp ├── AndroidProducts.mk ├── media_codecs.xml ├── ueventd.rpi4.rc ├── power ├── Android.bp ├── utils.h ├── power.c └── utils.c ├── system.prop ├── external_camera_config.xml ├── omni_rpi4.mk ├── fstab.rpi4 ├── init.system.rpi4.rc ├── init.rpi4.usb.rc ├── omni.dependencies ├── init.vendor.rpi4.rc ├── README.build ├── audio_policy_configuration.xml ├── README.gpio ├── BoardConfig.mk └── manifest.xml /Provision/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sepolicy/bootanim.te: -------------------------------------------------------------------------------- 1 | gpu_access(bootanim) 2 | -------------------------------------------------------------------------------- /sepolicy/priv_app.te: -------------------------------------------------------------------------------- 1 | gpu_access(priv_app) 2 | -------------------------------------------------------------------------------- /sepolicy/mediaserver.te: -------------------------------------------------------------------------------- 1 | gpu_access(mediaserver) 2 | -------------------------------------------------------------------------------- /sepolicy/mediaswcodec.te: -------------------------------------------------------------------------------- 1 | gpu_access(mediaswcodec) 2 | -------------------------------------------------------------------------------- /sepolicy/mediaprovider.te: -------------------------------------------------------------------------------- 1 | gpu_access(mediaprovider) 2 | -------------------------------------------------------------------------------- /sepolicy/surfaceflinger.te: -------------------------------------------------------------------------------- 1 | gpu_access(surfaceflinger) 2 | -------------------------------------------------------------------------------- /wifi/p2p_supplicant_overlay.conf: -------------------------------------------------------------------------------- 1 | disable_scan_offload=1 -------------------------------------------------------------------------------- /sepolicy/property.te: -------------------------------------------------------------------------------- 1 | system_public_prop(rpi4_system_prop) 2 | -------------------------------------------------------------------------------- /sepolicy/untrusted_app_all.te: -------------------------------------------------------------------------------- 1 | gpu_access(untrusted_app_all) 2 | -------------------------------------------------------------------------------- /Provision/proguard.flags: -------------------------------------------------------------------------------- 1 | -keep class * extends android.app.Activity 2 | -------------------------------------------------------------------------------- /sepolicy/bluetooth.te: -------------------------------------------------------------------------------- 1 | allow bluetooth rfkill_device:chr_file rw_file_perms; 2 | -------------------------------------------------------------------------------- /sepolicy/hal_graphics_allocator_default.te: -------------------------------------------------------------------------------- 1 | gpu_access(hal_graphics_allocator_default) 2 | -------------------------------------------------------------------------------- /sepolicy/hal_power_default.te: -------------------------------------------------------------------------------- 1 | allow hal_power_default sysfs_devices_system_cpu:file rw_file_perms; -------------------------------------------------------------------------------- /wifi/wpa_supplicant_overlay.conf: -------------------------------------------------------------------------------- 1 | disable_scan_offload=1 2 | p2p_disabled=1 3 | tdls_external_control=1 -------------------------------------------------------------------------------- /sepolicy/netd.te: -------------------------------------------------------------------------------- 1 | dontaudit netd self:capability sys_module; 2 | allow netd kernel:system module_request; 3 | -------------------------------------------------------------------------------- /sepolicy/platform_app.te: -------------------------------------------------------------------------------- 1 | gpu_access(platform_app) 2 | allow platform_app sysfs_thermal:file r_file_perms; -------------------------------------------------------------------------------- /scripts/fix_quotas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/scripts/fix_quotas.zip -------------------------------------------------------------------------------- /hostapd/hostapd.deny: -------------------------------------------------------------------------------- 1 | # List of MAC addresses that are not allowed to authenticate (IEEE 802.11) 2 | # with the AP. 3 | -------------------------------------------------------------------------------- /sepolicy/device.te: -------------------------------------------------------------------------------- 1 | type rfkill_device, dev_type, mlstrustedobject; 2 | type gpio_dev, dev_type, mlstrustedobject; 3 | -------------------------------------------------------------------------------- /recovery/root/sbin/keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/sbin/keystore -------------------------------------------------------------------------------- /scripts/resize_userdata.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/scripts/resize_userdata.zip -------------------------------------------------------------------------------- /scripts/switch_boot_rom.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/scripts/switch_boot_rom.zip -------------------------------------------------------------------------------- /bluetooth/btuart/BCM4345C0.hcd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/bluetooth/btuart/BCM4345C0.hcd -------------------------------------------------------------------------------- /bluetooth/btuart/BCM4345C5.hcd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/bluetooth/btuart/BCM4345C5.hcd -------------------------------------------------------------------------------- /sepolicy/cameraserver.te: -------------------------------------------------------------------------------- 1 | allow cameraserver gpu_device:chr_file rw_file_perms; 2 | allow cameraserver gpu_device:dir search; 3 | -------------------------------------------------------------------------------- /recovery/root/sbin/keystore_auth: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/sbin/keystore_auth -------------------------------------------------------------------------------- /recovery/root/sbin/servicemanager: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/sbin/servicemanager -------------------------------------------------------------------------------- /recovery/root/sbin/hwservicemanager: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/sbin/hwservicemanager -------------------------------------------------------------------------------- /DeviceParts/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/DeviceParts/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /DeviceParts/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/DeviceParts/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /DeviceParts/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/DeviceParts/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /DeviceParts/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/DeviceParts/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /DeviceParts/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/DeviceParts/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /recovery/root/vendor/lib/hw/gatekeeper.rpi4.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/vendor/lib/hw/gatekeeper.rpi4.so -------------------------------------------------------------------------------- /recovery/root/vendor/lib/libkeymaster3device.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/vendor/lib/libkeymaster3device.so -------------------------------------------------------------------------------- /recovery/root/vendor/lib64/hw/gatekeeper.rpi4.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/vendor/lib64/hw/gatekeeper.rpi4.so -------------------------------------------------------------------------------- /sepolicy/init.te: -------------------------------------------------------------------------------- 1 | allow init kernel:system module_request; 2 | allow init tmpfs:lnk_file create; 3 | allow init sysfs_devices_system_cpu:file rw_file_perms; 4 | -------------------------------------------------------------------------------- /sepolicy/system_server.te: -------------------------------------------------------------------------------- 1 | gpu_access(system_server) 2 | allow system_server self:capability sys_module; 3 | allow system_server gpio_dev:chr_file rw_file_perms; -------------------------------------------------------------------------------- /recovery/root/vendor/lib64/libkeymaster3device.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/vendor/lib64/libkeymaster3device.so -------------------------------------------------------------------------------- /recovery/root/vendor/lib/libpuresoftkeymasterdevice.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/vendor/lib/libpuresoftkeymasterdevice.so -------------------------------------------------------------------------------- /compatibility_matrix.device.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /recovery/root/sbin/android.hardware.gatekeeper@1.0-service: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/sbin/android.hardware.gatekeeper@1.0-service -------------------------------------------------------------------------------- /recovery/root/sbin/android.hardware.keymaster@3.0-service: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/sbin/android.hardware.keymaster@3.0-service -------------------------------------------------------------------------------- /recovery/root/vendor/lib64/libpuresoftkeymasterdevice.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/vendor/lib64/libpuresoftkeymasterdevice.so -------------------------------------------------------------------------------- /sepolicy/hal_camera_default.te: -------------------------------------------------------------------------------- 1 | vndbinder_use(hal_camera_default); 2 | allow hal_camera_default gpu_device:chr_file rw_file_perms; 3 | allow hal_camera_default gpu_device:dir search; 4 | -------------------------------------------------------------------------------- /sepolicy/system_app.te: -------------------------------------------------------------------------------- 1 | allow system_app selinuxfs:file r_file_perms; 2 | gpu_access(system_app) 3 | allow system_app gpio_dev:chr_file rw_file_perms; 4 | set_prop(system_app, rpi4_system_prop); 5 | -------------------------------------------------------------------------------- /recovery/root/vendor/lib/hw/android.hardware.gatekeeper@1.0-impl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/vendor/lib/hw/android.hardware.gatekeeper@1.0-impl.so -------------------------------------------------------------------------------- /recovery/root/vendor/lib/hw/android.hardware.keymaster@3.0-impl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/vendor/lib/hw/android.hardware.keymaster@3.0-impl.so -------------------------------------------------------------------------------- /recovery/root/vendor/lib64/hw/android.hardware.keymaster@3.0-impl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/vendor/lib64/hw/android.hardware.keymaster@3.0-impl.so -------------------------------------------------------------------------------- /recovery/root/vendor/lib64/hw/android.hardware.gatekeeper@1.0-impl.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwen/android_device_brcm_rpi4/HEAD/recovery/root/vendor/lib64/hw/android.hardware.gatekeeper@1.0-impl.so -------------------------------------------------------------------------------- /repo/local_manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /sepolicy/hal_graphics_composer_default.te: -------------------------------------------------------------------------------- 1 | vndbinder_use(hal_graphics_composer_default) 2 | gpu_access(hal_graphics_composer_default) 3 | allow hal_graphics_composer_default self:netlink_kobject_uevent_socket read; 4 | -------------------------------------------------------------------------------- /sepolicy/btuart.te: -------------------------------------------------------------------------------- 1 | # btuart service 2 | type btuart, domain; 3 | type btuart_exec, exec_type, file_type, vendor_file_type; 4 | 5 | init_daemon_domain(btuart) 6 | 7 | allow btuart hci_attach_dev:chr_file {rw_file_perms}; -------------------------------------------------------------------------------- /overlay/packages/apps/OpenDelta/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | true 6 | 7 | 8 | -------------------------------------------------------------------------------- /sepolicy/file.te: -------------------------------------------------------------------------------- 1 | type sysfs_gpu, fs_type, sysfs_type; 2 | type mediadrm_vendor_data_file, file_type, data_file_type; 3 | type sysfs_gpio, fs_type, sysfs_type; 4 | type gpiod_data_file, file_type, data_file_type, core_data_file_type; 5 | 6 | -------------------------------------------------------------------------------- /sepolicy/kernel.te: -------------------------------------------------------------------------------- 1 | allow kernel self:capability mknod; 2 | allow kernel self:system module_request; 3 | allow kernel device:dir { create write add_name remove_name rmdir }; 4 | allow kernel device:chr_file { create setattr getattr unlink }; 5 | -------------------------------------------------------------------------------- /bluetooth/cfg/bt_vendor.conf: -------------------------------------------------------------------------------- 1 | # UART device port where Bluetooth controller is attached 2 | UartPort = /dev/ttyAMA0 3 | # Firmware patch file location 4 | FwPatchFilePath = /lib/firmware/brcm 5 | # Firmware Name 6 | FwPatchFileName = BCM43430A1.hcd 7 | -------------------------------------------------------------------------------- /hostapd/hostapd.accept: -------------------------------------------------------------------------------- 1 | # List of MAC addresses that are allowed to authenticate (IEEE 802.11) 2 | # with the AP. Optional VLAN ID can be assigned for clients based on the 3 | # MAC address if dynamic VLANs (hostapd.conf dynamic_vlan option) are used. 4 | -------------------------------------------------------------------------------- /bluetooth/hal/android.hardware.bluetooth@1.0-service.rpi4.rc: -------------------------------------------------------------------------------- 1 | service btrpi4-1.0 /vendor/bin/hw/android.hardware.bluetooth@1.0-service.rpi4 2 | class hal 3 | user bluetooth 4 | group bluetooth net_admin net_bt_admin 5 | capabilities NET_ADMIN 6 | -------------------------------------------------------------------------------- /bluetooth/cfg/bdroid_buildcfg.h: -------------------------------------------------------------------------------- 1 | #ifndef _BDROID_BUILDCFG_H 2 | #define _BDROID_BUILDCFG_H 3 | 4 | #define BTM_DEF_LOCAL_NAME "RPI4" 5 | 6 | #define BTA_DM_COD {0x1A, 0x01, 0x20} 7 | 8 | #define KERNEL_MISSING_CLOCK_BOOTTIME_ALARM TRUE 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /overlay/packages/apps/Launcher3/quickstep/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | true 3 | true 4 | false 5 | false 6 | 7 | -------------------------------------------------------------------------------- /init/Android.bp: -------------------------------------------------------------------------------- 1 | cc_library_static { 2 | name: "libinit_rpi4", 3 | 4 | include_dirs: [ 5 | "system/core/base/include", 6 | "system/core/init", 7 | ], 8 | cflags: [ 9 | "-Wall", 10 | ], 11 | srcs: ["init_rpi4.cpp"], 12 | recovery_available: true, 13 | } 14 | 15 | -------------------------------------------------------------------------------- /sepolicy/te_macros: -------------------------------------------------------------------------------- 1 | ##################################### 2 | # gpu_access(client_domain) 3 | # Allow client_domain to communicate with the GPU 4 | define(`gpu_access', ` 5 | allow $1 gpu_device:dir { open read search getattr }; 6 | allow $1 gpu_device:chr_file { open read getattr ioctl map }; 7 | allow $1 sysfs_gpu:file { getattr open read }; 8 | ') 9 | -------------------------------------------------------------------------------- /sepolicy/gpiosetd.te: -------------------------------------------------------------------------------- 1 | # gpiod service 2 | type gpiosetd, domain; 3 | type gpiosetd_exec, exec_type, file_type, system_file_type; 4 | typeattribute gpiosetd coredomain; 5 | 6 | init_daemon_domain(gpiosetd) 7 | 8 | allow gpiosetd gpio_dev:chr_file rw_file_perms; 9 | allow gpiosetd sysfs_gpio:file r_file_perms; 10 | allow gpiosetd device:dir r_file_perms; -------------------------------------------------------------------------------- /sepolicy/switch_boot.te: -------------------------------------------------------------------------------- 1 | # switch_boot service 2 | type switch_boot, domain; 3 | type switch_boot_exec, exec_type, file_type, system_file_type; 4 | typeattribute switch_boot coredomain; 5 | 6 | init_daemon_domain(switch_boot) 7 | 8 | allow switch_boot shell_exec:file rx_file_perms; 9 | # TODO 10 | #allow switch_boot su_exec:file rx_file_perms; 11 | -------------------------------------------------------------------------------- /Provision/Android.bp: -------------------------------------------------------------------------------- 1 | android_app { 2 | name: "Provision", 3 | srcs: ["**/*.java"], 4 | platform_apis: true, 5 | system_ext_specific: true, 6 | certificate: "platform", 7 | privileged: true, 8 | required: ["privapp_whitelist_com.android.provision"], 9 | optimize: { 10 | proguard_flags_files: ["proguard.flags"], 11 | }, 12 | } 13 | -------------------------------------------------------------------------------- /bluetooth/cfg/vnd_rpi4.txt: -------------------------------------------------------------------------------- 1 | BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyAMA0" 2 | FW_PATCHFILE_LOCATION = "/lib/firmware/" 3 | BT_WAKE_VIA_PROC = FALSE 4 | BT_WAKE_VIA_USERIAL_IOCTL = FALSE 5 | LPM_IDLE_TIMEOUT_MULTIPLE = 5 6 | SCO_CFG_INCLUDED = FALSE 7 | SCO_PCM_IF_CLOCK_RATE = 2 8 | BTVND_DBG = FALSE 9 | BTHW_DBG = FALSE 10 | VNDUSERIAL_DBG = FALSE 11 | UPIO_DBG = FALSE 12 | UART_TARGET_BAUD_RATE = 921600 13 | USE_CONTROLLER_BDADDR = FALSE 14 | -------------------------------------------------------------------------------- /sepolicy/hal_bluetooth_rpi4.te: -------------------------------------------------------------------------------- 1 | type hal_bluetooth_rpi4, domain; 2 | hal_server_domain(hal_bluetooth_rpi4, hal_bluetooth) 3 | 4 | type hal_bluetooth_rpi4_exec, exec_type, vendor_file_type, file_type; 5 | init_daemon_domain(hal_bluetooth_rpi4) 6 | 7 | allow hal_bluetooth_rpi4 self:bluetooth_socket { create bind read write }; 8 | 9 | r_dir_file(hal_bluetooth_rpi4, sysfs_type) 10 | allow hal_bluetooth_rpi4 sysfs_bluetooth_writable:file rw_file_perms; 11 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | TODO: 2 | 3 | -p2p e.g. screencast 4 | -fix chromium 5 | -think about how to handle OTA 6 | -kernel cmdline option for default gps device (custom init sets property then) 7 | -support usb cameras - preview works capture not (v3d_bo_map_unsynchronized) 8 | -screen distortion on higher resolutions (seems to be on hdmi 1 only - maybe my device port is broken) 9 | -video playback - lets start easy with even a simple screen record (v3d_bo_map_unsynchronized) 10 | -------------------------------------------------------------------------------- /gps/gnsshal/Android.bp: -------------------------------------------------------------------------------- 1 | cc_library_shared { 2 | name: "gps.rpi4", 3 | relative_install_path: "hw", 4 | proprietary: true, 5 | srcs: ["gps_zkw.c"], 6 | header_libs: ["libhardware_headers"], 7 | shared_libs: [ 8 | "liblog", 9 | "libcutils", 10 | "libhardware", 11 | "libc", 12 | "libutils" 13 | ], 14 | cflags: ["-Wall", "-Werror", "-Wno-unused-parameter", "-Wno-unused-variable", "-Wno-format", "-Wno-unused-function"], 15 | } 16 | -------------------------------------------------------------------------------- /gpio/scripts/template.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | # $1 gpio 4 | # $2 0 rising 1 falling edge 5 | # $3 timestamp 6 | # log -t gpiod $* 7 | 8 | case $1 in 9 | 23) 10 | if [ $2 -eq 0 ]; then 11 | log -t gpiod "23 rising edge" $3 12 | am start "org.omnirom.omnijaws/.WeatherActivity" 13 | fi 14 | ;; 15 | 3) 16 | if [ $2 -eq 1 ]; then 17 | log -t gpiod "3 falling edge" $3 18 | reboot -p 19 | fi 20 | ;; 21 | esac -------------------------------------------------------------------------------- /gps/README.md: -------------------------------------------------------------------------------- 1 | # 卫星定位接收机HAL驱动 2 | 3 | 针对Android7.0或以上版本. 4 | 对于Android4.x 5.x 或 6.x, 请使用项目[android_hal_gpsbds](https://github.com/zxcwhale/android_hal_gpsbds). 5 | 6 | ## 使用方法 7 | 8 | 1. 修改gps_zkw.c文件中的`GPS_CHANNEL_NAME`为接收机的TTY号. 9 | 2. 修改gps_zkw.c文件中的`TTY_BAUD`为接收机实际的波特率, 默认为`B9600`. 10 | 3. 在Android开发环境下编译. 11 | 4. 将编译结果gps.XXXX.so文件用adb push到Android设备的/system/lib/hw目录下. 如果是64位Android, 则push到/system/lib64/hw目录. 12 | 13 | ## 可能的问题 14 | 15 | 1. 如果编译出现找不到`ALOGD`, `ALOGE`的报错, 可以尝试将`ALOGD`改为`LOGD`, `ALOGE`改为`LOGE`. 16 | -------------------------------------------------------------------------------- /sepolicy/property_contexts: -------------------------------------------------------------------------------- 1 | persist.rpi4.cpufreq.max_freq u:object_r:rpi4_system_prop:s0 exact string 2 | persist.rpi4.cpufreq.governor u:object_r:rpi4_system_prop:s0 exact string 3 | persist.rpi4.gpiod.lines u:object_r:rpi4_system_prop:s0 exact string 4 | persist.rpi4.gpiod.options u:object_r:rpi4_system_prop:s0 exact string 5 | persist.rpi4.gpiosetd.values u:object_r:rpi4_system_prop:s0 exact string 6 | persist.rpi4.gpiosetd.options u:object_r:rpi4_system_prop:s0 exact string 7 | -------------------------------------------------------------------------------- /scripts/fix_quotas.sh: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | # called from recovery 3 | # based on resize script from https://konstakang.com/ 4 | 5 | # detect storage device 6 | if [ -b "/dev/block/mmcblk0" ]; then 7 | DEVICE=mmcblk0 8 | PARTITION=p4 9 | else 10 | DEVICE=sda 11 | PARTITION=4 12 | fi 13 | 14 | # make sure we have project quotas 15 | tune2fs -O project,quota /dev/block/$DEVICE$PARTITION 1>> /tmp/tune2fs.log 2>&1 16 | 17 | EXIT=$? 18 | if [ $EXIT != "0" ]; then 19 | echo $EXIT >> /tmp/tune2fs.log 20 | exit $EXIT 21 | fi 22 | 23 | exit 0 24 | -------------------------------------------------------------------------------- /recovery/root/vendor/compatibility_matrix.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | android.hidl.manager 8 | 1.0 9 | 10 | IServiceManager 11 | default 12 | 13 | 14 | 15 | 29 16 | 17 | 18 | -------------------------------------------------------------------------------- /gpio/Android.bp: -------------------------------------------------------------------------------- 1 | cc_binary { 2 | name: "gpiod", 3 | srcs: ["src/gpiod.cpp", "src/tools-common.cpp"], 4 | shared_libs: [ 5 | "libgpiod", 6 | "liblog", 7 | "libutils", 8 | ], 9 | cflags: [ 10 | "-Werror", 11 | "-Wno-format-security" 12 | ], 13 | } 14 | 15 | cc_binary { 16 | name: "gpiosetd", 17 | srcs: ["src/gpiosetd.cpp", "src/tools-common.cpp"], 18 | shared_libs: [ 19 | "libgpiod", 20 | "liblog", 21 | "libutils", 22 | ], 23 | cflags: [ 24 | "-Werror", 25 | "-Wno-format-security" 26 | ], 27 | } -------------------------------------------------------------------------------- /sepolicy/hal_drm_widevine.te: -------------------------------------------------------------------------------- 1 | # define SELinux domain 2 | type hal_drm_widevine, domain; 3 | hal_server_domain(hal_drm_widevine, hal_drm) 4 | 5 | type hal_drm_widevine_exec, exec_type, vendor_file_type, file_type; 6 | init_daemon_domain(hal_drm_widevine) 7 | 8 | allow hal_drm mediacodec:fd use; 9 | allow hal_drm { appdomain -isolated_app }:fd use; 10 | 11 | vndbinder_use(hal_drm_widevine); 12 | hal_client_domain(hal_drm_widevine, hal_graphics_composer); 13 | allow hal_drm_widevine hal_allocator_server:fd use; 14 | allow hal_drm_widevine mediadrm_vendor_data_file:dir create_dir_perms; 15 | allow hal_drm_widevine mediadrm_vendor_data_file:file create_file_perms; 16 | -------------------------------------------------------------------------------- /sepolicy/gpiod.te: -------------------------------------------------------------------------------- 1 | # gpiod service 2 | type gpiod, domain; 3 | type gpiod_exec, exec_type, file_type, system_file_type; 4 | typeattribute gpiod coredomain; 5 | 6 | init_daemon_domain(gpiod) 7 | 8 | allow gpiod gpio_dev:chr_file rw_file_perms; 9 | allow gpiod sysfs_gpio:file r_file_perms; 10 | allow gpiod device:dir r_file_perms; 11 | allow gpiod gpiod_data_file:file r_file_perms; 12 | allow gpiod gpiod_data_file:dir search; 13 | allow gpiod shell_exec:file rx_file_perms; 14 | allow gpiod toolbox_exec:file rx_file_perms; 15 | allow gpiod system_file:file execute_no_trans; 16 | allow gpiod system_server:binder { call transfer }; 17 | allow gpiod servicemanager:binder { call }; 18 | -------------------------------------------------------------------------------- /bluetooth/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2018 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH := $(call my-dir) 16 | 17 | include $(call all-makefiles-under,$(LOCAL_PATH)) 18 | -------------------------------------------------------------------------------- /AndroidProducts.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2020 The LineageOS Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | PRODUCT_MAKEFILES := \ 18 | $(LOCAL_DIR)/omni_rpi4.mk 19 | 20 | COMMON_LUNCH_CHOICES := \ 21 | omni_rpi4-userdebug 22 | -------------------------------------------------------------------------------- /scripts/switch_boot_recovery.sh: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | # called from recovery 3 | 4 | if [ -u $1 ]; then 5 | # shortcut called from flashable zip 6 | CONFIG_FILE_SOURCE=config.txt.rom 7 | fi 8 | 9 | CONFIG_FILE_TARGET=config.txt 10 | 11 | if [ $1 == "rom" ]; then 12 | CONFIG_FILE_SOURCE=config.txt.rom 13 | elif [ $1 == "recovery" ]; then 14 | CONFIG_FILE_SOURCE=config.txt.twrp 15 | else 16 | echo "will switch to rom" 17 | fi 18 | 19 | if [ -b "/dev/block/mmcblk0p1" ]; then 20 | mount /dev/block/mmcblk0p1 /boot 21 | cp /boot/$CONFIG_FILE_SOURCE /boot/$CONFIG_FILE_TARGET 22 | umount /boot 23 | #/system/bin/reboot 24 | elif [ -b "/dev/block/sda1" ]; then 25 | mount /dev/block/sda1 /boot 26 | cp /boot/$CONFIG_FILE_SOURCE /boot/$CONFIG_FILE_TARGET 27 | umount /boot 28 | #/system/bin/reboot 29 | fi 30 | 31 | exit 1 -------------------------------------------------------------------------------- /recovery/root/system/etc/recovery.sd.fstab: -------------------------------------------------------------------------------- 1 | # Android fstab file. 2 | # The filesystem that contains the filesystem checker binary (typically /system) cannot 3 | # specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK 4 | # 5 | # 6 | 7 | # these partitions are defined by default from dt using overlay so just keeping here for reference or if ever needed 8 | 9 | /dev/block/mmcblk0p1 /boot vfat defaults 10 | /dev/block/mmcblk0p2 /system ext4 defaults 11 | /dev/block/mmcblk0p3 /vendor ext4 defaults 12 | /dev/block/mmcblk0p4 /data ext4 noatime,nosuid,nodev,barrier=1,noauto_da_alloc fileencryption=aes-256-xts 13 | /dev/block/sda1 /usb auto defaults 14 | -------------------------------------------------------------------------------- /recovery/root/system/etc/recovery.usb.fstab: -------------------------------------------------------------------------------- 1 | # Android fstab file. 2 | # The filesystem that contains the filesystem checker binary (typically /system) cannot 3 | # specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK 4 | # 5 | # 6 | 7 | # these partitions are defined by default from dt using overlay so just keeping here for reference or if ever needed 8 | 9 | /dev/block/sda1 /boot vfat defaults 10 | /dev/block/sda2 /system ext4 defaults 11 | /dev/block/sda3 /vendor ext4 defaults 12 | /dev/block/sda4 /data ext4 noatime,nosuid,nodev,barrier=1,noauto_da_alloc fileencryption=aes-256-xts 13 | /dev/block/sdb1 /usb auto defaults 14 | -------------------------------------------------------------------------------- /overlay/frameworks/base/core/res/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 36dp 21 | 22 | -------------------------------------------------------------------------------- /overlay/packages/apps/Bluetooth/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | true 17 | true 18 | 19 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SystemUI/res/values-sw600dp-port/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 550dp 21 | 22 | -------------------------------------------------------------------------------- /overlay/frameworks/base/core/res/res/values-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 40dp 20 | 168dp 21 | 22 | -------------------------------------------------------------------------------- /media_codecs.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SystemUI/res/values-sw720dp-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 8dp 20 | 10dp 21 | 22 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SystemUI/res/values-sw900dp-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 8dp 20 | 10dp 21 | 22 | -------------------------------------------------------------------------------- /ueventd.rpi4.rc: -------------------------------------------------------------------------------- 1 | # Bluetooth 2 | /dev/ttyAMA0 0660 bluetooth bluetooth 3 | /dev/rfkill 0660 bluetooth bluetooth 4 | /sys/devices/platform/soc/fe201000.serial/tty/ttyAMA0/hci0/rfkill1 state 0660 bluetooth bluetooth 5 | /sys/devices/platform/soc/fe201000.serial/tty/ttyAMA0/hci0/rfkill1 type 0440 bluetooth bluetooth 6 | 7 | # Camera 8 | /dev/video* 0660 system camera 9 | 10 | # GPS 11 | /dev/ttyACM0 0660 gps gps 12 | 13 | /dev/ion 0664 system system 14 | /dev/video0 0660 system camera 15 | /dev/video1 0660 system camera 16 | 17 | # cpufreq 18 | /sys/devices/system/cpu/cpu* cpufreq/scaling_governor 0664 system system -------------------------------------------------------------------------------- /gpio/src/tools-common.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 | /* 3 | * This file is part of libgpiod. 4 | * 5 | * Copyright (C) 2017-2018 Bartosz Golaszewski 6 | */ 7 | 8 | #ifndef __GPIOD_TOOLS_COMMON_H__ 9 | #define __GPIOD_TOOLS_COMMON_H__ 10 | 11 | /* 12 | * Various helpers for the GPIO tools. 13 | * 14 | * NOTE: This is not a stable interface - it's only to avoid duplicating 15 | * common code. 16 | */ 17 | 18 | #define NORETURN __attribute__((noreturn)) 19 | #define PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg))) 20 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) 21 | 22 | #define GETOPT_NULL_LONGOPT NULL, 0, NULL, 0 23 | 24 | void die(const char *fmt, ...) NORETURN PRINTF(1, 2); 25 | void die_perror(const char *fmt, ...) NORETURN PRINTF(1, 2); 26 | void die_logd(const char *fmt, ...) NORETURN PRINTF(1, 2); 27 | void print_version(void); 28 | 29 | #endif /* __GPIOD_TOOLS_COMMON_H__ */ 30 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SystemUI/res/values-sw600dp-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 8dp 20 | 10dp 21 | 128dp 22 | 23 | -------------------------------------------------------------------------------- /scripts/switch_boot.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # called from rom 3 | 4 | if [ -u $1 ]; then 5 | echo "provide argument rom or recovery" 6 | exit 0 7 | fi 8 | 9 | CONFIG_FILE_TARGET=config.txt 10 | 11 | if [ $1 == "rom" ]; then 12 | CONFIG_FILE_SOURCE=config.txt.rom 13 | elif [ $1 == "recovery" ]; then 14 | CONFIG_FILE_SOURCE=config.txt.twrp 15 | else 16 | echo "provide argument rom or recovery" 17 | exit 0 18 | fi 19 | 20 | if [ ! -d "/mnt/boot" ]; then 21 | su root mkdir /mnt/boot 22 | fi 23 | 24 | 25 | if [ -b "/dev/block/mmcblk0p1" ]; then 26 | su root mount /dev/block/mmcblk0p1 /mnt/boot 27 | su root cp /mnt/boot/$CONFIG_FILE_SOURCE /mnt/boot/$CONFIG_FILE_TARGET 28 | su root umount /mnt/boot 29 | #/system/bin/reboot 30 | elif [ -b "/dev/block/sda1" ]; then 31 | su root mount /dev/block/sda1 /mnt/boot 32 | su root cp /mnt/boot/$CONFIG_FILE_SOURCE /mnt/boot/$CONFIG_FILE_TARGET 33 | su root umount /mnt/boot 34 | #/system/bin/reboot 35 | fi 36 | 37 | exit 1 -------------------------------------------------------------------------------- /power/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | cc_library_shared { 16 | name: "power.rpi4", 17 | relative_install_path: "hw", 18 | proprietary: true, 19 | srcs: ["power.c", "utils.c"], 20 | cflags: ["-Wall", "-Werror"], 21 | header_libs: [ 22 | "libhardware_headers", 23 | "libutils_headers", 24 | ], 25 | shared_libs: ["liblog"], 26 | } 27 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SystemUI/res/values-sw900dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 36dp 21 | 128dp 22 | 48dip 23 | 24 | 25 | -------------------------------------------------------------------------------- /overlay/frameworks/base/core/res/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /sepolicy/genfs_contexts: -------------------------------------------------------------------------------- 1 | genfscon sysfs /devices/platform/v3dbus/fec00000.v3d/uevent u:object_r:sysfs_gpu:s0 2 | genfscon sysfs /devices/platform/gpu/uevent u:object_r:sysfs_gpu:s0 3 | genfscon sysfs /firmware/devicetree/base/serial-number u:object_r:sysfs_dt_firmware_android:s0 4 | genfscon sysfs /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/wakeup/wakeup0/event_count u:object_r:sysfs_wakeup:s0 5 | genfscon sysfs /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/wakeup/wakeup0 u:object_r:sysfs_wakeup:s0 6 | genfscon sysfs /devices/platform/soc/fe200000.gpio/gpiochip0/dev u:object_r:sysfs_gpio:s0 7 | genfscon sysfs /devices/platform/soc/fe200000.gpio/gpiochip1/dev u:object_r:sysfs_gpio:s0 8 | genfscon sysfs /devices/platform/soc/soc:firmware/soc:firmware:gpio/gpiochip0/dev u:object_r:sysfs_gpio:s0 9 | genfscon sysfs /devices/platform/soc/soc:firmware/soc:firmware:gpio/gpiochip1/dev u:object_r:sysfs_gpio:s0 10 | genfscon sysfs /devices/virtual/thermal/thermal_zone0/temp u:object_r:sysfs_thermal:s0 11 | 12 | -------------------------------------------------------------------------------- /DeviceParts/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 20 | 21 | 23 | 24 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SystemUI/res/values-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 8dp 20 | 10dp 21 | 28dp 22 | 48dp 23 | 24 | -------------------------------------------------------------------------------- /gps/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Jarod Lee 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SystemUI/res/values-sw600dp/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 22 | 23 | 24 | 25 | left;volup,voldown,back,home,recent,power;right 26 | 27 | 28 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SystemUI/res/values-sw720dp/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 22 | 23 | 24 | 25 | left;volup,voldown,back,home,recent,power;right 26 | 27 | 28 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SystemUI/res/values-sw900dp/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 22 | 23 | 24 | 25 | left;volup,voldown,back,home,recent,power;right 26 | 27 | 28 | -------------------------------------------------------------------------------- /system.prop: -------------------------------------------------------------------------------- 1 | # Change for a different screen resolutions 2 | # can be set during ruintime by using persist.debug.drm.mode.force 3 | # but value here will overrule if set 4 | #debug.drm.mode.force=1280x800 5 | 6 | #gralloc.drm.device=/dev/dri/card0 7 | #gralloc.drm.kms=/dev/dri/card1 8 | 9 | hwc.drm.scale_with_gpu=1 10 | ro.hardware.egl=mesa 11 | ro.hardware.hwcomposer=drm 12 | ro.hardware.gralloc=gbm 13 | 14 | ro.opengles.version=131072 15 | ro.sf.lcd_density=180 16 | 17 | # GPS 18 | gps.device.path=/dev/ttyACM0 19 | 20 | # Media 21 | persist.media.treble_omx=false 22 | 23 | # USB 24 | persist.sys.usb.config=mtp 25 | 26 | # Wifi 27 | wifi.interface=wlan0 28 | ro.boot.wificountrycode=00 29 | 30 | # R 31 | ro.kernel.ebpf.supported=true 32 | 33 | # DONT ADD THIS 34 | #ro.apex.updatable=true 35 | 36 | # Audio 37 | # card 0 = hdmi 38 | # card 1 = headphone jack 39 | # can be overwrittem by persist.audio.pcm.card - used in DeviceParts 40 | audio.pcm.card=0 41 | audio.pcm.device=0 42 | 43 | # we are not caf 44 | sys.vendor.qti.servicetracker.disable=true 45 | 46 | # no flickering for now 47 | debug.sf.disable_hwc_overlays=1 48 | 49 | # used in DeviceParts 50 | sys.rpi4.boot_mode=rom 51 | 52 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SystemUI/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 10dp 21 | 22 | 23 | 10dp 24 | 25 | 26 | 10dp 27 | 28 | 29 | 14dp 30 | 31 | 32 | 8dp 33 | 34 | -------------------------------------------------------------------------------- /DeviceParts/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | ifeq ($(TARGET_DEVICE),$(filter $(TARGET_DEVICE),rpi4)) 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE_TAGS := optional 6 | LOCAL_STATIC_ANDROID_LIBRARIES := \ 7 | androidx.core_core \ 8 | androidx.preference_preference 9 | 10 | LOCAL_SRC_FILES := $(call all-java-files-under, src) 11 | LOCAL_PACKAGE_NAME := DeviceParts 12 | LOCAL_CERTIFICATE := platform 13 | LOCAL_PRIVILEGED_MODULE := true 14 | LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res 15 | LOCAL_USE_AAPT2 := true 16 | LOCAL_PRIVATE_PLATFORM_APIS := true 17 | 18 | package_resource_overlays := $(strip \ 19 | $(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \ 20 | $(addprefix $(dir)/, packages/apps/DeviceParts/res))) \ 21 | $(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \ 22 | $(addprefix $(dir)/, packages/apps/DeviceParts/res)))) 23 | 24 | LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR) 25 | LOCAL_PROGUARD_ENABLED := disabled 26 | LOCAL_DEX_PREOPT := false 27 | 28 | include frameworks/base/packages/SettingsLib/common.mk 29 | 30 | include packages/apps/OmniLib/common.mk 31 | 32 | include $(BUILD_PACKAGE) 33 | 34 | include $(call all-makefiles-under,$(LOCAL_PATH)) 35 | endif 36 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SystemUI/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | default 22 | left;volup,voldown,back[120A],home[120A],recent[120A],power;right 23 | left,back[120A],home[120A],recent[120A],volup,voldown,power,right;space;space 24 | space;space;left,volup,voldown,power,back[120A],home[120A],recent[120A],right 25 | 26 | 27 | -------------------------------------------------------------------------------- /overlay/packages/apps/ThemePicker/res/values/override.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | com.android.settings 22 | com.android.documentsui 23 | org.omnirom.logcat 24 | com.android.contacts 25 | org.omnirom.omnichange 26 | org.omnirom.omnistore 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /external_camera_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /DeviceParts/src/org/omnirom/device/Startup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2020 The OmniROM Project 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | */ 18 | package org.omnirom.device; 19 | 20 | import android.content.BroadcastReceiver; 21 | import android.content.Context; 22 | import android.content.Intent; 23 | import android.content.SharedPreferences; 24 | import androidx.preference.PreferenceManager; 25 | import android.provider.Settings; 26 | import android.text.TextUtils; 27 | 28 | public class Startup extends BroadcastReceiver { 29 | 30 | @Override 31 | public void onReceive(final Context context, final Intent bootintent) { 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /gpio/src/tools-common.cpp: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 | /* 3 | * This file is part of libgpiod. 4 | * 5 | * Copyright (C) 2017-2018 Bartosz Golaszewski 6 | */ 7 | 8 | /* Common code for GPIO tools. */ 9 | 10 | #include 11 | #include "tools-common.h" 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | void die(const char *fmt, ...) 23 | { 24 | va_list va; 25 | 26 | va_start(va, fmt); 27 | vfprintf(stderr, fmt, va); 28 | fprintf(stderr, "\n"); 29 | va_end(va); 30 | 31 | exit(EXIT_FAILURE); 32 | } 33 | 34 | void die_perror(const char *fmt, ...) 35 | { 36 | va_list va; 37 | 38 | va_start(va, fmt); 39 | vfprintf(stderr, fmt, va); 40 | fprintf(stderr, ": %s\n", strerror(errno)); 41 | va_end(va); 42 | 43 | exit(EXIT_FAILURE); 44 | } 45 | 46 | void die_logd(const char *fmt, ...) 47 | { 48 | ALOGE(fmt); 49 | 50 | exit(EXIT_FAILURE); 51 | } 52 | 53 | void print_version(void) 54 | { 55 | printf("Copyright (C) 2017-2018 Bartosz Golaszewski\n"); 56 | printf("License: LGPLv2.1\n"); 57 | printf("This is free software: you are free to change and redistribute it.\n"); 58 | printf("There is NO WARRANTY, to the extent permitted by law.\n"); 59 | } 60 | -------------------------------------------------------------------------------- /bluetooth/hal/Android.bp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 The Android Open Source Project 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | cc_binary { 17 | name: "android.hardware.bluetooth@1.0-service.rpi4", 18 | proprietary: true, 19 | relative_install_path: "hw", 20 | srcs: [ 21 | "hci_packetizer.cc", 22 | "h4_protocol.cc", 23 | "bluetooth_hci.cc", 24 | "async_fd_watcher.cc", 25 | "service.cc" 26 | ], 27 | cflags: ["-Wall", "-Werror"], 28 | header_libs: ["libbluetooth_headers"], 29 | shared_libs: [ 30 | "android.hardware.bluetooth@1.0", 31 | "libbase", 32 | "libcutils", 33 | "libhidlbase", 34 | "liblog", 35 | "libutils", 36 | ], 37 | conlyflags: [ 38 | "-std=c99", 39 | ], 40 | init_rc: ["android.hardware.bluetooth@1.0-service.rpi4.rc"], 41 | } 42 | 43 | -------------------------------------------------------------------------------- /scripts/resize_userdata.sh: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | # called from recovery 3 | # based on resize script from https://konstakang.com/ 4 | 5 | # detect storage device 6 | if [ -b "/dev/block/mmcblk0" ]; then 7 | DEVICE=mmcblk0 8 | PARTITION=p4 9 | else 10 | DEVICE=sda 11 | PARTITION=4 12 | fi 13 | 14 | # unmount partitions 15 | umount /data 16 | umount /sdcard 17 | 18 | # remove existing data partition and create new partition table entry 19 | ( 20 | echo d 21 | echo 4 22 | echo n 23 | echo p 24 | echo 25 | echo 26 | echo n 27 | echo w 28 | ) | /tmp/fdisk /dev/block/$DEVICE 1>> /tmp/resize.log 2>&1 29 | EXIT=$? 30 | if [ $EXIT != "0" ]; then 31 | echo $EXIT >> /tmp/resize.log 32 | exit $EXIT 33 | fi 34 | 35 | # calculate new filesystem size 36 | CURSIZE=$(/tmp/fdisk -l /dev/block/$DEVICE | grep $DEVICE$PARTITION | awk '{print $4}') 37 | NEWSIZE=$(expr \( $CURSIZE \* 512 \) / 4096) 38 | echo $CURSIZE >> /tmp/resize.log 39 | echo $NEWSIZE >> /tmp/resize.log 40 | 41 | # resize filesystem 42 | resize2fs -f /dev/block/$DEVICE$PARTITION $NEWSIZE 1>> /tmp/resize.log 2>&1 43 | 44 | EXIT=$? 45 | if [ $EXIT != "0" ]; then 46 | echo $EXIT >> /tmp/resize.log 47 | exit $EXIT 48 | fi 49 | 50 | # make sure we have project quotas 51 | # resize2fs should retain - but better save then sorry 52 | tune2fs -O project,quota /dev/block/$DEVICE$PARTITION 1>> /tmp/resize.log 2>&1 53 | 54 | EXIT=$? 55 | if [ $EXIT != "0" ]; then 56 | echo $EXIT >> /tmp/resize.log 57 | exit $EXIT 58 | fi 59 | 60 | exit 0 61 | -------------------------------------------------------------------------------- /bluetooth/hal/service.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 The Android Open Source Project 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #define LOG_TAG "android.hardware.bluetooth@1.0-service.btrpi4" 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "bluetooth_hci.h" 25 | 26 | using ::android::hardware::configureRpcThreadpool; 27 | using ::android::hardware::bluetooth::V1_0::IBluetoothHci; 28 | using ::android::hardware::bluetooth::V1_0::btrpi4::BluetoothHci; 29 | using ::android::hardware::joinRpcThreadpool; 30 | using ::android::sp; 31 | 32 | int main(int /* argc */, char** /* argv */) { 33 | sp bluetooth = new BluetoothHci; 34 | configureRpcThreadpool(1, true); 35 | android::status_t status = bluetooth->registerAsService(); 36 | if (status == android::OK) 37 | joinRpcThreadpool(); 38 | else 39 | ALOGE("Could not register as a service!"); 40 | } 41 | -------------------------------------------------------------------------------- /omni_rpi4.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2020 The LineageOS Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | # Inherit device configuration 18 | DEVICE_PATH := device/brcm/rpi4 19 | 20 | PRODUCT_QUOTA_PROJID := 1 21 | PRODUCT_PROPERTY_OVERRIDES += external_storage.projid.enabled=1 22 | PRODUCT_PROPERTY_OVERRIDES += external_storage.sdcardfs.enabled=0 23 | 24 | $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk) 25 | $(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base.mk) 26 | 27 | DEVICE_PACKAGE_OVERLAYS += $(DEVICE_PATH)/overlay 28 | 29 | $(call inherit-product, vendor/omni/config/common_tablet.mk) 30 | $(call inherit-product, device/brcm/rpi4/device.mk) 31 | 32 | # Boot animation 33 | TARGET_BOOTANIMATION_SIZE := 720p 34 | 35 | # Device identifier. This must come after all inclusions 36 | PRODUCT_DEVICE := rpi4 37 | PRODUCT_NAME := omni_rpi4 38 | PRODUCT_BRAND := Raspberry 39 | PRODUCT_MODEL := Raspberry Pi 4 40 | PRODUCT_MANUFACTURER := Raspberry 41 | PRODUCT_RELEASE_NAME := Raspberry Pi 4 42 | 43 | $(call inherit-product, vendor/brcm/rpi4/rpi4-vendor.mk) 44 | -------------------------------------------------------------------------------- /fstab.rpi4: -------------------------------------------------------------------------------- 1 | # Android fstab file. 2 | # The filesystem that contains the filesystem checker binary (typically /system) cannot 3 | # specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK 4 | # 5 | # 6 | 7 | # these partitions are defined by default from dt using overlay so just keeping here for reference or if ever needed 8 | 9 | #/dev/block/mmcblk0p2 /system ext4 ro,barrier=1 wait,first_stage_mount 10 | #/dev/block/sda2 /system ext4 ro,barrier=1 wait,first_stage_mount 11 | 12 | #/dev/block/mmcblk0p3 /vendor ext4 ro,barrier=1 wait,first_stage_mount 13 | #/dev/block/sda3 /vendor ext4 ro,barrier=1 wait,first_stage_mount 14 | 15 | # TODO fileencryption=aes-256-xts 16 | #/dev/block/mmcblk0p4 /data ext4 noatime,nosuid,nodev,nomblk_io_submit latemount,wait,check,quota 17 | #/dev/block/sda4 /data ext4 noatime,nosuid,nodev,nomblk_io_submit latemount,wait,check,quota 18 | 19 | # TODO fileencryption=aes-256-xts 20 | # relies on the userdata parition beeing number 4 or named sda4 or mmcblk0p4 21 | /dev/block/by-name/userdata /data ext4 noatime,nosuid,nodev,nomblk_io_submit latemount,wait,check,quota 22 | 23 | /devices/platform/scb/*.pcie/*/*/*/usb* auto auto defaults voldmanaged=usb:auto 24 | -------------------------------------------------------------------------------- /recovery/recovery.fstab: -------------------------------------------------------------------------------- 1 | # Android fstab file. 2 | # The filesystem that contains the filesystem checker binary (typically /system) cannot 3 | # specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK 4 | # 5 | # 6 | 7 | # these partitions are defined by default from dt using overlay so just keeping here for reference or if ever needed 8 | 9 | /dev/block/mmcblk0p2 /system ext4 ro,barrier=1 wait,first_stage_mount 10 | #/dev/block/sda2 /system ext4 ro,barrier=1 wait,first_stage_mount 11 | 12 | /dev/block/mmcblk0p3 /vendor ext4 ro,barrier=1 wait,first_stage_mount 13 | #/dev/block/sda3 /vendor ext4 ro,barrier=1 wait,first_stage_mount 14 | 15 | # TODO fileencryption=aes-256-xts 16 | #/dev/block/mmcblk0p4 /data ext4 noatime,nosuid,nodev,nomblk_io_submit latemount,wait,check,quota 17 | #/dev/block/sda4 /data ext4 noatime,nosuid,nodev,nomblk_io_submit latemount,wait,check,quota 18 | 19 | # TODO fileencryption=aes-256-xts 20 | # relies on the userdata parition beeing number 4 or named sda4 or mmcblk0p4 21 | #/dev/block/by-name/userdata /data ext4 noatime,nosuid,nodev,nomblk_io_submit latemount,wait,check,quota 22 | 23 | #/devices/platform/scb/*.pcie/*/*/*/usb* auto auto defaults voldmanaged=usb:auto 24 | -------------------------------------------------------------------------------- /bluetooth/btuart/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2016 http://www.brobwind.com 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH := $(my-dir) 16 | 17 | include $(CLEAR_VARS) 18 | 19 | LOCAL_MODULE_TAGS := optional 20 | 21 | LOCAL_MODULE := BCM4345C0.hcd 22 | LOCAL_MODULE_CLASS := DATA 23 | LOCAL_SRC_FILES := $(LOCAL_MODULE) 24 | 25 | LOCAL_MODULE_PATH := \ 26 | $(TARGET_OUT_VENDOR)/etc/firmware/brcm/ 27 | 28 | include $(BUILD_PREBUILT) 29 | 30 | include $(CLEAR_VARS) 31 | 32 | LOCAL_MODULE_TAGS := optional 33 | 34 | LOCAL_MODULE := BCM4345C5.hcd 35 | LOCAL_MODULE_CLASS := DATA 36 | LOCAL_SRC_FILES := $(LOCAL_MODULE) 37 | 38 | LOCAL_MODULE_PATH := \ 39 | $(TARGET_OUT_VENDOR)/etc/firmware/brcm/ 40 | 41 | include $(BUILD_PREBUILT) 42 | 43 | include $(CLEAR_VARS) 44 | 45 | LOCAL_MODULE := btuart 46 | LOCAL_PROPRIETARY_MODULE := true 47 | 48 | LOCAL_REQUIRED_MODULES := \ 49 | BCM4345C0.hcd \ 50 | BCM4345C5.hcd 51 | 52 | LOCAL_SRC_FILES := \ 53 | hciattach_rpi4.c 54 | 55 | LOCAL_CFLAGS := \ 56 | -DFIRMWARE_DIR=\"/vendor/etc/firmware/brcm/\" 57 | 58 | LOCAL_SHARED_LIBRARIES := \ 59 | libcutils liblog 60 | 61 | include $(BUILD_EXECUTABLE) 62 | -------------------------------------------------------------------------------- /bluetooth/hal/hci_packetizer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 The Android Open Source Project 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include "hci_internals.h" 24 | 25 | namespace android { 26 | namespace hardware { 27 | namespace bluetooth { 28 | namespace hci { 29 | 30 | using ::android::hardware::hidl_vec; 31 | using HciPacketReadyCallback = std::function; 32 | 33 | class HciPacketizer { 34 | public: 35 | HciPacketizer(HciPacketReadyCallback packet_cb) 36 | : packet_ready_cb_(packet_cb){}; 37 | void OnDataReady(int fd, HciPacketType packet_type); 38 | void CbHciPacket(uint8_t* data, size_t length); 39 | const hidl_vec& GetPacket() const; 40 | 41 | protected: 42 | enum State { HCI_PREAMBLE, HCI_PAYLOAD }; 43 | State state_{HCI_PREAMBLE}; 44 | uint8_t preamble_[HCI_PREAMBLE_SIZE_MAX]; 45 | hidl_vec packet_; 46 | size_t bytes_remaining_{0}; 47 | size_t bytes_read_{0}; 48 | HciPacketReadyCallback packet_ready_cb_; 49 | }; 50 | 51 | } // namespace hci 52 | } // namespace bluetooth 53 | } // namespace hardware 54 | } // namespace android 55 | -------------------------------------------------------------------------------- /Provision/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /bluetooth/hal/hci_internals.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016 The Android Open Source Project 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | // HCI UART transport packet types (Volume 4, Part A, 2) 22 | enum HciPacketType { 23 | HCI_PACKET_TYPE_UNKNOWN = 0, 24 | HCI_PACKET_TYPE_COMMAND = 1, 25 | HCI_PACKET_TYPE_ACL_DATA = 2, 26 | HCI_PACKET_TYPE_SCO_DATA = 3, 27 | HCI_PACKET_TYPE_EVENT = 4 28 | }; 29 | 30 | // 2 bytes for opcode, 1 byte for parameter length (Volume 2, Part E, 5.4.1) 31 | const size_t HCI_COMMAND_PREAMBLE_SIZE = 3; 32 | const size_t HCI_LENGTH_OFFSET_CMD = 2; 33 | 34 | // 2 bytes for handle, 2 bytes for data length (Volume 2, Part E, 5.4.2) 35 | const size_t HCI_ACL_PREAMBLE_SIZE = 4; 36 | const size_t HCI_LENGTH_OFFSET_ACL = 2; 37 | 38 | // 2 bytes for handle, 1 byte for data length (Volume 2, Part E, 5.4.3) 39 | const size_t HCI_SCO_PREAMBLE_SIZE = 3; 40 | const size_t HCI_LENGTH_OFFSET_SCO = 2; 41 | 42 | // 1 byte for event code, 1 byte for parameter length (Volume 2, Part E, 5.4.4) 43 | const size_t HCI_EVENT_PREAMBLE_SIZE = 2; 44 | const size_t HCI_LENGTH_OFFSET_EVT = 1; 45 | 46 | const size_t HCI_PREAMBLE_SIZE_MAX = HCI_ACL_PREAMBLE_SIZE; 47 | 48 | // Event codes (Volume 2, Part E, 7.7.14) 49 | const uint8_t HCI_COMMAND_COMPLETE_EVENT = 0x0E; 50 | -------------------------------------------------------------------------------- /init.system.rpi4.rc: -------------------------------------------------------------------------------- 1 | on post-fs-data 2 | chmod 0660 /sys/class/rfkill/rfkill0/state 3 | chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state 4 | chown bluetooth bluetooth /sys/class/rfkill/rfkill0/type 5 | 6 | # gpio 7 | chown system system /dev/gpiochip0 8 | chmod 0666 /dev/gpiochip0 9 | chown system system /dev/gpiochip1 10 | chmod 0666 /dev/gpiochip1 11 | mkdir /data/gpio 0777 system system 12 | 13 | # cpufreq tuning 14 | on property:persist.rpi4.cpufreq.governor=* 15 | write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ${persist.rpi4.cpufreq.governor} 16 | 17 | on property:persist.rpi4.cpufreq.max_freq=* 18 | write /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq ${persist.rpi4.cpufreq.max_freq} 19 | 20 | on property:sys.rpi4.boot_mode=recovery 21 | start switch_boot_recovery 22 | 23 | on property:sys.rpi4.boot_mode=rom 24 | start switch_boot_rom 25 | 26 | service switch_boot_recovery /system/xbin/switch_boot recovery 27 | user root 28 | group system 29 | disabled 30 | oneshot 31 | 32 | service switch_boot_rom /system/xbin/switch_boot rom 33 | user root 34 | group system 35 | disabled 36 | oneshot 37 | 38 | on property:persist.rpi4.gpiod.options=* && property:persist.rpi4.gpiod.lines=* && property:sys.boot_completed=1 39 | stop gpiod 40 | start gpiod 41 | 42 | service gpiod /system/bin/gpiod ${persist.rpi4.gpiod.options} ${persist.rpi4.gpiod.lines} 43 | user root 44 | group system 45 | disabled 46 | oneshot 47 | 48 | on property:persist.rpi4.gpiosetd.options=* && property:persist.rpi4.gpiosetd.values=* && property:sys.boot_completed=1 49 | stop gpiosetd 50 | start gpiosetd 51 | 52 | service gpiosetd /system/bin/gpiosetd ${persist.rpi4.gpiosetd.options} ${persist.rpi4.gpiosetd.values} 53 | user system 54 | group system 55 | disabled 56 | oneshot -------------------------------------------------------------------------------- /overlay/packages/apps/Settings/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | 20 | false 21 | 22 | 23 | false 24 | 25 | 26 | false 27 | 28 | 29 | false 30 | 31 | 32 | false 33 | 34 | 35 | false 36 | 37 | 38 | false 39 | 40 | false 41 | 42 | 43 | -------------------------------------------------------------------------------- /overlay/packages/apps/Launcher3/quickstep/res/xml/default_workspace_5x5.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | 20 | 29 | 30 | 31 | 35 | 36 | 37 | 38 | 44 | 45 | -------------------------------------------------------------------------------- /bluetooth/hal/h4_protocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 The Android Open Source Project 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #include "async_fd_watcher.h" 22 | #include "hci_internals.h" 23 | #include "hci_packetizer.h" 24 | 25 | namespace android { 26 | namespace hardware { 27 | namespace bluetooth { 28 | namespace hci { 29 | 30 | using ::android::hardware::hidl_vec; 31 | using PacketReadCallback = std::function&)>; 32 | 33 | class H4Protocol { 34 | public: 35 | H4Protocol(int fd, PacketReadCallback event_cb, PacketReadCallback acl_cb, 36 | PacketReadCallback sco_cb) 37 | : uart_fd_(fd), 38 | event_cb_(event_cb), 39 | acl_cb_(acl_cb), 40 | sco_cb_(sco_cb), 41 | hci_packetizer_([this]() { OnPacketReady(); }) {} 42 | 43 | size_t Send(uint8_t type, const uint8_t* data, size_t length); 44 | 45 | void OnPacketReady(); 46 | 47 | void OnDataReady(int fd); 48 | 49 | private: 50 | int uart_fd_; 51 | 52 | PacketReadCallback event_cb_; 53 | PacketReadCallback acl_cb_; 54 | PacketReadCallback sco_cb_; 55 | 56 | HciPacketType hci_packet_type_{HCI_PACKET_TYPE_UNKNOWN}; 57 | HciPacketizer hci_packetizer_; 58 | }; 59 | 60 | } // namespace hci 61 | } // namespace bluetooth 62 | } // namespace hardware 63 | } // namespace android 64 | -------------------------------------------------------------------------------- /overlay/frameworks/base/packages/SystemUI/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 22 | 23 | 24 | left,volup,voldown,back;home;recent,power,right 25 | 26 | 27 | wifi,dnd,bt,airplane,location,hotspot,inversion,dark,work,night,screenrecord,reverse 28 | 29 | 30 | 31 | wifi,bt,location,airplane,dark,screenrecord 32 | 33 | 34 | true 35 | 36 | 37 | /sys/class/thermal/thermal_zone0/temp 38 | 39 | 40 | 1000 41 | 42 | 43 | 0 44 | 45 | -------------------------------------------------------------------------------- /init.rpi4.usb.rc: -------------------------------------------------------------------------------- 1 | on boot 2 | mount configfs none /config 3 | mkdir /config/usb_gadget/g1 0770 shell shell 4 | mkdir /config/usb_gadget/g1/strings/0x409 0770 shell shell 5 | write /config/usb_gadget/g1/bcdDevice 0x0223 6 | write /config/usb_gadget/g1/bcdUSB 0x0200 7 | write /config/usb_gadget/g1/idVendor 0x18d1 8 | write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno} 9 | write /config/usb_gadget/g1/strings/0x409/manufacturer "Raspberry" 10 | write /config/usb_gadget/g1/strings/0x409/product "Pi 4" 11 | mkdir /config/usb_gadget/g1/functions/ffs.adb 12 | mkdir /config/usb_gadget/g1/functions/mtp.gs0 13 | mkdir /config/usb_gadget/g1/functions/accessory.gs2 14 | mkdir /config/usb_gadget/g1/configs/b.1 0770 shell shell 15 | mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell 16 | write /config/usb_gadget/g1/configs/b.1/MaxPower 500 17 | mkdir /dev/usb-ffs 0775 shell shell 18 | mkdir /dev/usb-ffs/adb 0770 shell shell 19 | mkdir /dev/usb-ffs/mtp 0770 mtp mtp 20 | mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000 21 | mount functionfs mtp /dev/usb-ffs/mtp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1 22 | setprop sys.usb.mtp.device_type 3 23 | setprop sys.usb.configfs 1 24 | symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1 25 | 26 | on property:sys.usb.config=mtp && property:sys.usb.configfs=1 27 | write /config/usb_gadget/g1/idProduct 0x4ee1 28 | 29 | on property:sys.usb.config=adb && property:sys.usb.configfs=1 30 | write /config/usb_gadget/g1/idProduct 0x4ee7 31 | #setprop service.adb.tcp.port 5555 32 | 33 | on property:sys.usb.config=accessory && property:sys.usb.configfs=1 34 | write /config/usb_gadget/g1/idVendor 0x18d1 35 | write /config/usb_gadget/g1/idProduct 0x2d00 36 | 37 | on property:sys.usb.config=accessory,adb && property:sys.usb.configfs=1 38 | write /config/usb_gadget/g1/idVendor 0x18d1 39 | write /config/usb_gadget/g1/idProduct 0x2d01 40 | -------------------------------------------------------------------------------- /bluetooth/btuart/hciattach_rpi4.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __HCIATTACH_RPI3_H 3 | #define __HCIATTACH_RPI3_H 4 | 5 | #include 6 | 7 | #ifndef N_HCI 8 | #define N_HCI 15 9 | #endif 10 | 11 | #define HCIUARTSETPROTO _IOW('U', 200, int) 12 | #define HCIUARTGETPROTO _IOR('U', 201, int) 13 | #define HCIUARTGETDEVICE _IOR('U', 202, int) 14 | #define HCIUARTSETFLAGS _IOW('U', 203, int) 15 | #define HCIUARTGETFLAGS _IOR('U', 204, int) 16 | 17 | #define HCI_UART_H4 0 18 | #define HCI_UART_BCM 7 19 | 20 | #define HCI_UART_RAW_DEVICE 0 21 | #define HCI_UART_RESET_ON_INIT 1 22 | #define HCI_UART_CREATE_AMP 2 23 | #define HCI_UART_INIT_PENDING 3 24 | #define HCI_UART_EXT_CONFIG 4 25 | #define HCI_UART_VND_DETECT 5 26 | 27 | static inline unsigned int tty_get_speed(int speed) 28 | { 29 | switch (speed) { 30 | case 9600: 31 | return B9600; 32 | case 19200: 33 | return B19200; 34 | case 38400: 35 | return B38400; 36 | case 57600: 37 | return B57600; 38 | case 115200: 39 | return B115200; 40 | case 230400: 41 | return B230400; 42 | case 460800: 43 | return B460800; 44 | case 500000: 45 | return B500000; 46 | case 576000: 47 | return B576000; 48 | case 921600: 49 | return B921600; 50 | case 1000000: 51 | return B1000000; 52 | case 1152000: 53 | return B1152000; 54 | case 1500000: 55 | return B1500000; 56 | case 2000000: 57 | return B2000000; 58 | #ifdef B2500000 59 | case 2500000: 60 | return B2500000; 61 | #endif 62 | #ifdef B3000000 63 | case 3000000: 64 | return B3000000; 65 | #endif 66 | #ifdef B3500000 67 | case 3500000: 68 | return B3500000; 69 | #endif 70 | #ifdef B3710000 71 | case 3710000: 72 | return B3710000; 73 | #endif 74 | #ifdef B4000000 75 | case 4000000: 76 | return B4000000; 77 | #endif 78 | } 79 | 80 | return 0; 81 | } 82 | 83 | int read_hci_event(int fd, unsigned char *buf, int size); 84 | int set_speed(int fd, struct termios *ti, int speed); 85 | int uart_speed(int speed); 86 | 87 | int bcm43xx_init(int fd, int def_speed, int speed, struct termios *ti, 88 | const char *bdaddr); 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /DeviceParts/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | @string/rotation_lock_off 19 | @string/rotation_lock_landscape 20 | @string/rotation_lock_portrait 21 | @string/rotation_lock_portrait_reverse 22 | @string/rotation_lock_landscape_reverse 23 | 24 | 25 | 26 | 0 27 | 1 28 | 2 29 | 3 30 | 4 31 | 32 | 33 | 34 | @string/audio_card_hdmi 35 | @string/audio_card_headphone_jack 36 | 37 | 38 | 39 | 0 40 | 1 41 | 42 | 43 | 44 | @string/boot_mode_rom 45 | @string/boot_mode_recovery 46 | 47 | 48 | 49 | rom 50 | recovery 51 | 52 | -------------------------------------------------------------------------------- /bluetooth/hal/async_fd_watcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016 The Android Open Source Project 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | namespace android { 24 | namespace hardware { 25 | namespace bluetooth { 26 | namespace async { 27 | 28 | using ReadCallback = std::function; 29 | using TimeoutCallback = std::function; 30 | 31 | class AsyncFdWatcher { 32 | public: 33 | AsyncFdWatcher() = default; 34 | ~AsyncFdWatcher(); 35 | 36 | int WatchFdForNonBlockingReads(int file_descriptor, 37 | const ReadCallback& on_read_fd_ready_callback); 38 | int ConfigureTimeout(const std::chrono::milliseconds timeout, 39 | const TimeoutCallback& on_timeout_callback); 40 | void StopWatchingFileDescriptors(); 41 | 42 | private: 43 | AsyncFdWatcher(const AsyncFdWatcher&) = delete; 44 | AsyncFdWatcher& operator=(const AsyncFdWatcher&) = delete; 45 | 46 | int tryStartThread(); 47 | int stopThread(); 48 | int notifyThread(); 49 | void ThreadRoutine(); 50 | 51 | std::atomic_bool running_{false}; 52 | std::thread thread_; 53 | std::mutex internal_mutex_; 54 | std::mutex timeout_mutex_; 55 | 56 | std::map watched_fds_; 57 | int notification_listen_fd_; 58 | int notification_write_fd_; 59 | TimeoutCallback timeout_cb_; 60 | std::chrono::milliseconds timeout_ms_; 61 | }; 62 | 63 | 64 | } // namespace async 65 | } // namespace bluetooth 66 | } // namespace hardware 67 | } // namespace android 68 | -------------------------------------------------------------------------------- /DeviceParts/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | Advanced 18 | Work in progress 19 | Force rotation 20 | Off 21 | Landscape 22 | Portrait 23 | Reverse Portrait 24 | Reverse Landscape 25 | Enable system keys suppprt 26 | Allow to emulate power, volume up and volume down keys 27 | Boot mode 28 | Audio output - reboot required 29 | HDMI 30 | Headphone Jack 31 | ROM 32 | Recovery 33 | Governor 34 | Maximum frequency 35 | CPU scaling 36 | Display 37 | System 38 | 39 | 40 | -------------------------------------------------------------------------------- /power/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above 10 | * copyright notice, this list of conditions and the following 11 | * disclaimer in the documentation and/or other materials provided 12 | * with the distribution. 13 | * * Neither the name of The Linux Foundation nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #define SCALING_GOVERNOR_PATH "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" 31 | #define SCALING_MAX_FREQ "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" 32 | #define SCALING_MIN_FREQ "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq" 33 | 34 | int sysfs_read(char *path, char *s, int num_bytes); 35 | int sysfs_write(char *path, char *s); 36 | int get_scaling_governor(char governor[], int size); 37 | int get_scaling_max_freq(char max_freq[], int size); 38 | int get_scaling_min_freq(char min_freq[], int size); -------------------------------------------------------------------------------- /omni.dependencies: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "remote": "github", 4 | "repository": "android_kernel_brcm_arpi", 5 | "target_path": "kernel/brcm/arpi", 6 | "revision": "android-11" 7 | }, 8 | { 9 | "remote": "github", 10 | "repository": "android_hardware_arpi", 11 | "target_path": "hardware/arpi", 12 | "revision": "android-11" 13 | }, 14 | { 15 | "remote": "github", 16 | "repository": "proprietary_vendor_brcm", 17 | "target_path": "vendor/brcm", 18 | "revision": "android-11" 19 | }, 20 | { 21 | "remote": "github", 22 | "repository": "android_external_gbm_gralloc", 23 | "target_path": "external/gbm_gralloc", 24 | "revision": "android-11" 25 | }, 26 | { 27 | "remote": "github", 28 | "repository": "android_external_libgpiod", 29 | "target_path": "external/libgpiod", 30 | "revision": "android-11" 31 | }, 32 | { 33 | "remote": "github", 34 | "override": "platform/external/drm_hwcomposer", 35 | "repository": "lineage-rpi/android_external_drm_hwcomposer", 36 | "target_path": "external/drm_hwcomposer", 37 | "revision": "lineage-17.1" 38 | }, 39 | { 40 | "remote": "github", 41 | "override": "platform/external/libdrm", 42 | "repository": "lineage-rpi/android_external_libdrm", 43 | "target_path": "external/libdrm", 44 | "revision": "lineage-17.1" 45 | }, 46 | { 47 | "remote": "github", 48 | "override": "platform/external/minigbm", 49 | "repository": "lineage-rpi/android_external_minigbm", 50 | "target_path": "external/minigbm", 51 | "revision": "lineage-17.1" 52 | }, 53 | { 54 | "remote": "github", 55 | "override": "platform/external/mesa3d", 56 | "repository": "maxwen/android_external_mesa3d", 57 | "target_path": "external/mesa3d", 58 | "revision": "android-11-v20.2" 59 | }, 60 | { 61 | "remove": "platform/packages/apps/Provision" 62 | }, 63 | { 64 | "remove": "platform/packages/apps/Camera2" 65 | }, 66 | { 67 | "remove": "android_packages_apps_OmniChromium" 68 | }, 69 | { 70 | "remote": "aosp", 71 | "repository": "platform/external/chromium-webview", 72 | "target_path": "external/chromium-webview", 73 | "revision": "refs/tags/android-11.0.0_r3" 74 | } 75 | ] -------------------------------------------------------------------------------- /DeviceParts/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 21 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /init.vendor.rpi4.rc: -------------------------------------------------------------------------------- 1 | import /vendor/etc/init/hw/init.rpi4.usb.rc 2 | 3 | on init 4 | # Support legacy paths 5 | symlink /sdcard /mnt/sdcard 6 | symlink /sdcard /storage/sdcard0 7 | 8 | on fs 9 | mount_all /vendor/etc/fstab.rpi4 10 | 11 | on post-fs-data 12 | # Create the directories used by the Wireless subsystem 13 | mkdir /data/vendor/wifi 0770 wifi wifi 14 | mkdir /data/vendor/wifi/wpa 0770 wifi wifi 15 | mkdir /data/vendor/wifi/wpa/sockets 0770 wifi wifi 16 | 17 | # Set indication (checked by vold) that we have finished this action 18 | setprop vold.post_fs_data_done 1 19 | 20 | on zygote-start 21 | # Create the directories used by the Wireless subsystem 22 | mkdir /data/vendor/wifi 0770 wifi wifi 23 | mkdir /data/vendor/wifi/sockets 0770 wifi wifi 24 | mkdir /data/vendor/wifi/hostapd 0770 wifi wifi 25 | mkdir /data/vendor/wifi/hostapd/ctrl 0770 wifi wifi 26 | mkdir /data/vendor/wifi/wpa_supplicant 0770 wifi wifi 27 | mkdir /data/vendor/wifi/wigig_hostapd 0770 wifi wifi 28 | mkdir /data/vendor/wifi/wpa 0770 wifi wifi 29 | mkdir /data/vendor/wifi/wpa/sockets 0770 wifi wifi 30 | 31 | # Create directories for Location services 32 | mkdir /data/vendor/location 0770 gps gps 33 | 34 | on boot 35 | setprop net.dns1 8.8.8.8 36 | setprop net.dns2 8.8.4.4 37 | 38 | # fake some battery state 39 | #setprop status.battery.state Slow 40 | #setprop status.battery.level 100 41 | #setprop status.battery.level_raw 50 42 | #setprop status.battery.level_scale 9 43 | 44 | #setprop service.adb.tcp.port 5555 45 | #start adbd 46 | 47 | on property:ro.revision=* 48 | start btuart 49 | 50 | service btuart /vendor/bin/btuart /dev/ttyAMA0 bcm43xx 3000000 flow - ${ro.serialno} 51 | user bluetooth 52 | group bluetooth net_bt_admin system 53 | 54 | service wpa_supplicant /vendor/bin/hw/wpa_supplicant \ 55 | -O/data/vendor/wifi/wpa/sockets -puse_p2p_group_interface=1 -dd \ 56 | -g@android:wpa_wlan0 57 | interface android.hardware.wifi.supplicant@1.0::ISupplicant default 58 | interface android.hardware.wifi.supplicant@1.1::ISupplicant default 59 | interface android.hardware.wifi.supplicant@1.2::ISupplicant default 60 | interface android.hardware.wifi.supplicant@1.3::ISupplicant default 61 | class main 62 | socket wpa_wlan0 dgram 660 wifi wifi 63 | disabled 64 | oneshot 65 | -------------------------------------------------------------------------------- /DeviceParts/src/org/omnirom/device/DeviceSettingsActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2020 The OmniROM Project 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | */ 18 | package org.omnirom.device; 19 | 20 | import android.app.Activity; 21 | import android.app.AlertDialog; 22 | import android.app.Dialog; 23 | import android.app.DialogFragment; 24 | import android.app.Fragment; 25 | import android.content.DialogInterface; 26 | import android.os.Bundle; 27 | import androidx.preference.PreferenceFragment; 28 | import androidx.preference.PreferenceManager; 29 | import android.view.Menu; 30 | import android.view.MenuInflater; 31 | import android.view.MenuItem; 32 | 33 | public class DeviceSettingsActivity extends Activity { 34 | 35 | private DeviceSettings mDeviceSettingsFragment; 36 | 37 | @Override 38 | protected void onCreate(Bundle savedInstanceState) { 39 | super.onCreate(savedInstanceState); 40 | 41 | getActionBar().setDisplayHomeAsUpEnabled(true); 42 | 43 | Fragment fragment = getFragmentManager().findFragmentById(android.R.id.content); 44 | if (fragment == null) { 45 | mDeviceSettingsFragment = new DeviceSettings(); 46 | getFragmentManager().beginTransaction() 47 | .add(android.R.id.content, mDeviceSettingsFragment) 48 | .commit(); 49 | } else { 50 | mDeviceSettingsFragment = (DeviceSettings) fragment; 51 | } 52 | } 53 | 54 | @Override 55 | public boolean onOptionsItemSelected(MenuItem item) { 56 | switch (item.getItemId()) { 57 | case android.R.id.home: 58 | finish(); 59 | return true; 60 | default: 61 | break; 62 | } 63 | return super.onOptionsItemSelected(item); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /sepolicy/file_contexts: -------------------------------------------------------------------------------- 1 | /dev/dri u:object_r:gpu_device:s0 2 | /dev/dri/card0 u:object_r:gpu_device:s0 3 | /dev/dri/card1 u:object_r:gpu_device:s0 4 | /dev/dri/renderD128 u:object_r:gpu_device:s0 5 | /dev/rfkill u:object_r:rfkill_device:s0 6 | /dev/ttyAMA0 u:object_r:hci_attach_dev:s0 7 | /dev/gpiochip0 u:object_r:gpio_dev:s0 8 | /dev/gpiochip1 u:object_r:gpio_dev:s0 9 | 10 | /vendor/bin/hw/android\.hardware\.gatekeeper@1\.0-service.software u:object_r:hal_gatekeeper_default_exec:s0 11 | /vendor/bin/hw/android\.hardware\.graphics\.allocator@2\.0-service\.rpi4 u:object_r:hal_graphics_allocator_default_exec:s0 12 | /vendor/bin/hw/android\.hardware\.graphics\.composer@2\.1-service\.rpi4 u:object_r:hal_graphics_composer_default_exec:s0 13 | /vendor/lib(64)?/hw/android\.hardware\.graphics\.mapper@2\.0-impl\.rpi4\.so u:object_r:same_process_hal_file:s0 14 | 15 | /vendor/bin/btuart u:object_r:btuart_exec:s0 16 | /vendor/bin/hw/android\.hardware\.bluetooth@1\.0-service\.rpi4 u:object_r:hal_bluetooth_rpi4_exec:s0 17 | /vendor/bin/hw/android\.hardware\.camera\.provider@2\.4-external-service\.rpi4 u:object_r:hal_camera_default_exec:s0 18 | /vendor/bin/hw/android\.hardware\.drm@1\.3-service\.widevine u:object_r:hal_drm_widevine_exec:s0 19 | 20 | /vendor/lib(64)?/hw/gralloc\.rpi4\.so u:object_r:same_process_hal_file:s0 21 | /vendor/lib(64)?/hw/gralloc\.gbm\.so u:object_r:same_process_hal_file:s0 22 | /vendor/lib(64)?/dri/gallium_dri\.so u:object_r:same_process_hal_file:s0 23 | /vendor/lib(64)?/libgralloc_drm\.so u:object_r:same_process_hal_file:s0 24 | /vendor/lib(64)?/libdrm\.so u:object_r:same_process_hal_file:s0 25 | /vendor/lib(64)?/libgbm\.so u:object_r:same_process_hal_file:s0 26 | /vendor/lib(64)?/libgbm_mesa\.so u:object_r:same_process_hal_file:s0 27 | /vendor/lib(64)?/libglapi\.so u:object_r:same_process_hal_file:s0 28 | 29 | /dev/block/mmcblk0p4 u:object_r:userdata_block_device:s0 30 | 31 | /data/vendor/mediadrm(/.*)? u:object_r:mediadrm_vendor_data_file:s0 32 | 33 | /system/xbin/switch_boot u:object_r:switch_boot_exec:s0 34 | /system/bin/gpiod u:object_r:gpiod_exec:s0 35 | /system/bin/gpiosetd u:object_r:gpiosetd_exec:s0 36 | /data/gpio(/.*)? u:object_r:gpiod_data_file:s0 37 | -------------------------------------------------------------------------------- /DeviceParts/res/xml/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 19 | 20 | 26 | 27 | 28 | 30 | 31 | 36 | 37 | 42 | 43 | 44 | 46 | 47 | 54 | 55 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /README.build: -------------------------------------------------------------------------------- 1 | Builds as 64bit only so make sure you have propper firmware! 2 | 3 | # sync omni source 4 | 5 | Refer to http://source.android.com/source/downloading.html 6 | Refer to https://github.com/omnirom/android 7 | 8 | $ repo init -u git://github.com/omnirom/android.git -b android-11 9 | 10 | If you want to use the contents of omni-private.xml please check 11 | https://github.com/omnirom/android/README and head over to send us a short 12 | email notice. Otherwise you can simple remove the include of that xml 13 | file and build without 14 | 15 | If you want to build with microG add the contents of /repo/local_manifest.xml 16 | 17 | $ repo sync 18 | 19 | # Build Android source 20 | 21 | Refer to http://source.android.com/source/building.html 22 | 23 | # prepare environment 24 | 25 | $ export ROM_BUILDTYPE= 26 | $ export TEMPORARY_DISABLE_PATH_RESTRICTIONS=true 27 | $ export ALLOW_MISSING_DEPENDENCIES=true 28 | $ source build/envsetup.sh 29 | $ lunch omni_rpi4-userdebug 30 | 31 | # build 32 | 33 | Use -j[n] option with make, if build host has a good number of CPU cores. 34 | 35 | # prepare boot device (sdcard or USB device) 36 | 37 | Devices with GPT partition table cant be used as an USB boot device 38 | You must use MBR (msdos) parition table 39 | 40 | The boot devices MUST contain 4 partitions with the following layout 41 | (parition sizes here are the minimum - userdata should be made bigger 42 | if you have the space) 43 | 44 | Device Start End Sectors Size Id Type 45 | boot 2 262145 262144 128M c W95 FAT32 (LBA) 46 | system 264192 4458495 4194304 2G 83 Linux 47 | vendor 4458496 4982783 524288 256M 83 Linux 48 | userdata 4982784 16777215 11794432 5.6G 83 Linux 49 | 50 | THE PARTITION ORDER MUST BE LIKE THIS 51 | 52 | Starting with android-11 project quotas are mandatory in userdata 53 | parition. Prebuilt images have it enabled but if you recreate your 54 | userdata you MUST enable project quotas with e.g. 55 | 56 | tune2fs -O project,quota 57 | 58 | # boot order 59 | 60 | Switching between booting from sdcard and USB is done in config.txt 61 | by enabling the needed overlay 62 | 63 | ... 64 | # booting from sdcard 65 | dtoverlay=rpi-android-sdcard 66 | 67 | # booting from usb 68 | dtoverlay=rpi-android-usb 69 | .... 70 | 71 | You can still mess with the fstab if you want and dont use the overlay 72 | 73 | Note 74 | 75 | the files in scripts are what I use to create and update 76 | feel free to adjust and update to your needs if you want 77 | 78 | # flash to boot device with e.g. dd 79 | -------------------------------------------------------------------------------- /Provision/CleanSpec.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2007 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # If you don't need to do a full clean build but would like to touch 17 | # a file or delete some intermediate files, add a clean step to the end 18 | # of the list. These steps will only be run once, if they haven't been 19 | # run before. 20 | # 21 | # E.g.: 22 | # $(call add-clean-step, touch -c external/sqlite/sqlite3.h) 23 | # $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) 24 | # 25 | # Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with 26 | # files that are missing or have been moved. 27 | # 28 | # Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. 29 | # Use $(OUT_DIR) to refer to the "out" directory. 30 | # 31 | # If you need to re-do something that's already mentioned, just copy 32 | # the command and add it to the bottom of the list. E.g., if a change 33 | # that you made last week required touching a file and a change you 34 | # made today requires touching the same file, just copy the old 35 | # touch step and add it to the end of the list. 36 | # 37 | # ************************************************ 38 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 39 | # ************************************************ 40 | 41 | # For example: 42 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) 43 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) 44 | #$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) 45 | #$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) 46 | $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/Provision) 47 | $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/product/priv-app/Provision) 48 | $(call add-clean-step, rm -rf $(PRODUCT_OUT)/product/priv-app/Provision) 49 | 50 | # ************************************************ 51 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 52 | # ************************************************ 53 | -------------------------------------------------------------------------------- /bluetooth/hal/bluetooth_hci.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016 The Android Open Source Project 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #ifndef HIDL_GENERATED_android_hardware_bluetooth_V1_0_BluetoothHci_H_ 18 | #define HIDL_GENERATED_android_hardware_bluetooth_V1_0_BluetoothHci_H_ 19 | 20 | #include 21 | 22 | #include 23 | 24 | #include "async_fd_watcher.h" 25 | #include "h4_protocol.h" 26 | #include "hci_internals.h" 27 | 28 | namespace android { 29 | namespace hardware { 30 | namespace bluetooth { 31 | namespace V1_0 { 32 | namespace btrpi4 { 33 | 34 | using ::android::hardware::Return; 35 | using ::android::hardware::hidl_vec; 36 | 37 | class BluetoothDeathRecipient; 38 | 39 | class BluetoothHci : public IBluetoothHci { 40 | public: 41 | BluetoothHci(); 42 | Return initialize( 43 | const ::android::sp& cb) override; 44 | Return sendHciCommand(const hidl_vec& packet) override; 45 | Return sendAclData(const hidl_vec& data) override; 46 | Return sendScoData(const hidl_vec& data) override; 47 | Return close() override; 48 | 49 | private: 50 | async::AsyncFdWatcher fd_watcher_; 51 | hci::H4Protocol* hci_handle_; 52 | int bt_soc_fd_; 53 | char *rfkill_state_; 54 | 55 | const uint8_t HCI_DATA_TYPE_COMMAND = 1; 56 | const uint8_t HCI_DATA_TYPE_ACL = 2; 57 | const uint8_t HCI_DATA_TYPE_SCO = 3; 58 | 59 | int waitHciDev(int hci_interface); 60 | int findRfKill(void); 61 | int rfKill(int block); 62 | int openBtHci(void); 63 | void closeBtHci(void); 64 | 65 | void sendDataToController(const uint8_t type, const hidl_vec& data); 66 | ::android::sp death_recipient_; 67 | std::function&)> unlink_cb_; 68 | }; 69 | 70 | extern "C" IBluetoothHci* HIDL_FETCH_IBluetoothHci(const char* name); 71 | 72 | } // namespace btrpi4 73 | } // namespace V1_0 74 | } // namespace bluetooth 75 | } // namespace hardware 76 | } // namespace android 77 | 78 | #endif // HIDL_GENERATED_android_hardware_bluetooth_V1_0_BluetoothHci_H_ 79 | -------------------------------------------------------------------------------- /audio_policy_configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Speaker 7 | 8 | Speaker 9 | 10 | 11 | 13 | 14 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Provision/src/com/android/provision/DefaultActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.provision; 18 | 19 | import android.app.Activity; 20 | import android.content.ComponentName; 21 | import android.content.pm.PackageManager; 22 | import android.os.BatteryManager; 23 | import android.os.Bundle; 24 | import android.os.UserHandle; 25 | import android.provider.Settings; 26 | import android.util.Log; 27 | 28 | import com.android.internal.widget.LockPatternUtils; 29 | 30 | /** 31 | * Application that sets the provisioned bit, like SetupWizard does. 32 | */ 33 | public class DefaultActivity extends Activity { 34 | 35 | @Override 36 | protected void onCreate(Bundle icicle) { 37 | super.onCreate(icicle); 38 | 39 | // Add a persistent setting to allow other apps to know the device has been provisioned. 40 | Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1); 41 | Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1); 42 | 43 | // set useful defaults for raspi 44 | Settings.Secure.putInt(getContentResolver(), "qs_show_brightness", 0); 45 | Settings.Secure.putString(getContentResolver(), "icon_blacklist", "rotate,headset"); 46 | // enable always on -> TODO assumes fake charging is set 47 | Settings.Global.putInt(getContentResolver(), Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 48 | BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB 49 | | BatteryManager.BATTERY_PLUGGED_WIRELESS); 50 | 51 | // disable screen lock -> TODO on first boot it still comes up with initial swipe 52 | LockPatternUtils lockPatternUtils = new LockPatternUtils(getApplicationContext()); 53 | lockPatternUtils.setLockScreenDisabled(true, UserHandle.myUserId()); 54 | 55 | PackageManager pm = getPackageManager(); 56 | ComponentName name = new ComponentName(this, DefaultActivity.class); 57 | pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 58 | PackageManager.DONT_KILL_APP); 59 | 60 | // terminate the activity. 61 | finish(); 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /recovery/root/init.recovery.rpi4.rc: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009-2012, 2014-2015, The Linux Foundation. All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without 4 | # modification, are permitted provided that the following conditions are met: 5 | # * Redistributions of source code must retain the above copyright 6 | # notice, this list of conditions and the following disclaimer. 7 | # * Redistributions in binary form must reproduce the above copyright 8 | # notice, this list of conditions and the following disclaimer in the 9 | # documentation and/or other materials provided with the distribution. 10 | # * Neither the name of The Linux Foundation nor 11 | # the names of its contributors may be used to endorse or promote 12 | # products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | # 27 | 28 | service hwservicemanager /sbin/hwservicemanager 29 | user root 30 | group root 31 | disabled 32 | onrestart setprop hwservicemanager.ready false 33 | seclabel u:r:recovery:s0 34 | 35 | service servicemanager /sbin/servicemanager 36 | user root 37 | group root readproc 38 | disabled 39 | seclabel u:r:recovery:s0 40 | 41 | service keystore_auth /sbin/keystore_auth 42 | oneshot 43 | user system 44 | group root 45 | disabled 46 | seclabel u:r:recovery:s0 47 | 48 | # keystore is started and stopped on demand by TWRP 49 | service keystore /sbin/keystore /tmp/misc/keystore 50 | user root 51 | group root drmrpc readproc 52 | disabled 53 | seclabel u:r:recovery:s0 54 | 55 | service gatekeeper-1-0 /sbin/android.hardware.gatekeeper@1.0-service 56 | user root 57 | group root 58 | disabled 59 | seclabel u:r:recovery:s0 60 | 61 | service keymaster-3-0 /sbin/android.hardware.keymaster@3.0-service 62 | user root 63 | group root 64 | disabled 65 | seclabel u:r:recovery:s0 66 | 67 | on init 68 | start servicemanager 69 | start hwservicemanager 70 | setprop crypto.ready 1 71 | 72 | on property:crypto.ready=0 73 | stop keymaster-3-0 74 | stop gatekeeper-1-0 75 | stop servicemanager 76 | 77 | on property:crypto.ready=1 78 | start keymaster-3-0 79 | start gatekeeper-1-0 80 | start servicemanager 81 | -------------------------------------------------------------------------------- /README.gpio: -------------------------------------------------------------------------------- 1 | Overview: 2 | 3 | gpio support is based on libgpiod (version 1.3) 4 | https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/ 5 | 6 | You can test using the tools that are part of the libgpiod package like 7 | -gpiodetect 8 | -gpiofind 9 | -gpioget 10 | -gpioinfo 11 | -gpiomon 12 | -gpioset 13 | 14 | As described e.g. here 15 | https://microhobby.com.br/blog/2020/02/02/new-linux-kernel-5-5-new-interfaces-in-gpiolib/ 16 | 17 | Monitor gpio lines and trigger actions: 18 | 19 | gpiod is a modified build of gpiomon adapted to run as an android service 20 | 21 | Is is located in /system/gin/gpiod and can be configured by two properties 22 | and a script that defines what shell actions should be executed when gpio lines change 23 | The service is started automatically if you set the two properties correct 24 | and also checks if the script is in place else it will do nothing 25 | or dont even start. 26 | 27 | You can monitor messages from the service in logcat with the tag gpiod 28 | e.g. 29 | 11-28 17:38:53.743 959 959 I gpiod : event: RISING EDGE offset: 23 timestamp: [1606581533.731186464] 30 | 11-28 17:38:53.864 959 959 I gpiod : event: FALLING EDGE offset: 23 timestamp: [1606581533.731535612] 31 | 32 | persist.rpi4.gpiod.options 33 | can be used to set the options for gpiod. To see available options 34 | simply start gpiod on cmdline with -h 35 | 36 | Usage: gpiod [OPTIONS] ... 37 | 38 | Chip name is mandatory and in 99.9% of cases this is gpiochip0 39 | which is the main gpio port of the raspberry pi 40 | 41 | persist.rpi4.gpiod.lines 42 | Is a list of gpio lines you want to monitor e.g. "3 23" 43 | 44 | You can modiy these properties using a local terminal or adb shell 45 | like 46 | 47 | adb shell setprop persist.rpi4.gpiod.options "-d -r gpiochip0" 48 | adb shell setprop persist.rpi4.gpiod.lines "3 23" 49 | 50 | Trigger script 51 | 52 | The trigger script is a shell script that gets the following parameters 53 | # $1 gpio 54 | # $2 0 rising 1 falling edge 55 | # $3 timestamp 56 | 57 | You can find an exmple template at 58 | https://github.com/maxwen/android_device_brcm_rpi4/blob/android-11/gpio/scripts/template.sh 59 | 60 | #!/system/bin/sh 61 | # $1 gpio 62 | # $2 0 rising 1 falling edge 63 | # $3 timestamp 64 | # log -t gpiod $* 65 | 66 | case $1 in 67 | 23) 68 | if [ $2 -eq 0 ]; then 69 | log -t gpiod "23 rising edge" $3 70 | # any shell action e.g. 71 | am start "org.omnirom.omnijaws/.WeatherActivity" 72 | # this will start the weather activity 73 | fi 74 | ;; 75 | esac 76 | 77 | You must copy yoru version of the trigger script to 78 | /data/gpio/triggers.sh 79 | 80 | To allow writing into /data you MUST use adb root 81 | then use e.g. adb push /data/gpio/triggers.sh 82 | 83 | ATTENTION 84 | Make sure the file has UNIX file format and not MSDOS 85 | 86 | Set gpio lines: 87 | 88 | Similiar to gpiod vs gpiomon - gpiosetd is a modified version of gpioset 89 | suitable to run as service and configurable by two properties 90 | 91 | Located in 92 | /system/gin/gpiosetd 93 | 94 | Configured with 95 | persist.rpi4.gpiosetd.options "-d gpiochip0" 96 | persist.rpi4.gpiosetd.values "17=1 18=0" 97 | -------------------------------------------------------------------------------- /bluetooth/hal/hci_packetizer.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 The Android Open Source Project 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #include "hci_packetizer.h" 18 | 19 | #define LOG_TAG "android.hardware.bluetooth.hci_packetizer" 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | namespace { 27 | 28 | const size_t preamble_size_for_type[] = { 29 | 0, HCI_COMMAND_PREAMBLE_SIZE, HCI_ACL_PREAMBLE_SIZE, HCI_SCO_PREAMBLE_SIZE, 30 | HCI_EVENT_PREAMBLE_SIZE}; 31 | const size_t packet_length_offset_for_type[] = { 32 | 0, HCI_LENGTH_OFFSET_CMD, HCI_LENGTH_OFFSET_ACL, HCI_LENGTH_OFFSET_SCO, 33 | HCI_LENGTH_OFFSET_EVT}; 34 | 35 | size_t HciGetPacketLengthForType(HciPacketType type, const uint8_t* preamble) { 36 | size_t offset = packet_length_offset_for_type[type]; 37 | if (type != HCI_PACKET_TYPE_ACL_DATA) return preamble[offset]; 38 | return (((preamble[offset + 1]) << 8) | preamble[offset]); 39 | } 40 | 41 | } // namespace 42 | 43 | namespace android { 44 | namespace hardware { 45 | namespace bluetooth { 46 | namespace hci { 47 | 48 | const hidl_vec& HciPacketizer::GetPacket() const { return packet_; } 49 | 50 | void HciPacketizer::CbHciPacket(uint8_t *data, size_t len) { 51 | packet_.setToExternal(data, len); 52 | packet_ready_cb_(); 53 | } 54 | 55 | void HciPacketizer::OnDataReady(int fd, HciPacketType packet_type) { 56 | switch (state_) { 57 | case HCI_PREAMBLE: { 58 | size_t bytes_read = TEMP_FAILURE_RETRY( 59 | read(fd, preamble_ + bytes_read_, 60 | preamble_size_for_type[packet_type] - bytes_read_)); 61 | CHECK(bytes_read > 0); 62 | bytes_read_ += bytes_read; 63 | if (bytes_read_ == preamble_size_for_type[packet_type]) { 64 | size_t packet_length = 65 | HciGetPacketLengthForType(packet_type, preamble_); 66 | packet_.resize(preamble_size_for_type[packet_type] + packet_length); 67 | memcpy(packet_.data(), preamble_, preamble_size_for_type[packet_type]); 68 | bytes_remaining_ = packet_length; 69 | state_ = HCI_PAYLOAD; 70 | bytes_read_ = 0; 71 | } 72 | break; 73 | } 74 | 75 | case HCI_PAYLOAD: { 76 | size_t bytes_read = TEMP_FAILURE_RETRY(read( 77 | fd, 78 | packet_.data() + preamble_size_for_type[packet_type] + bytes_read_, 79 | bytes_remaining_)); 80 | CHECK(bytes_read > 0); 81 | bytes_remaining_ -= bytes_read; 82 | bytes_read_ += bytes_read; 83 | if (bytes_remaining_ == 0) { 84 | packet_ready_cb_(); 85 | state_ = HCI_PREAMBLE; 86 | bytes_read_ = 0; 87 | } 88 | break; 89 | } 90 | } 91 | } 92 | 93 | } // namespace hci 94 | } // namespace bluetooth 95 | } // namespace hardware 96 | } // namespace android 97 | -------------------------------------------------------------------------------- /recovery/root/system/manifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | android.frameworks.displayservice 8 | hwbinder 9 | 1.0 10 | 11 | IDisplayService 12 | default 13 | 14 | @1.0::IDisplayService/default 15 | 16 | 17 | android.frameworks.schedulerservice 18 | hwbinder 19 | 1.0 20 | 21 | ISchedulingPolicyService 22 | default 23 | 24 | @1.0::ISchedulingPolicyService/default 25 | 26 | 27 | android.frameworks.sensorservice 28 | hwbinder 29 | 1.0 30 | 31 | ISensorManager 32 | default 33 | 34 | @1.0::ISensorManager/default 35 | 36 | 37 | android.hidl.manager 38 | hwbinder 39 | 1.2 40 | 41 | IServiceManager 42 | default 43 | 44 | @1.2::IServiceManager/default 45 | 46 | 47 | android.hidl.memory 48 | passthrough 49 | 1.0 50 | 51 | IMapper 52 | ashmem 53 | 54 | @1.0::IMapper/ashmem 55 | 56 | 57 | android.hidl.token 58 | hwbinder 59 | 1.0 60 | 61 | ITokenManager 62 | default 63 | 64 | @1.0::ITokenManager/default 65 | 66 | 67 | android.system.net.netd 68 | hwbinder 69 | 1.1 70 | 71 | INetd 72 | default 73 | 74 | @1.1::INetd/default 75 | 76 | 77 | android.system.wifi.keystore 78 | hwbinder 79 | 1.0 80 | 81 | IKeystore 82 | default 83 | 84 | @1.0::IKeystore/default 85 | 86 | 87 | netutils-wrapper 88 | 89 | 1.0 90 | 91 | 92 | 29 93 | 94 | 95 | 28 96 | 29 97 | 98 | 99 | -------------------------------------------------------------------------------- /scripts/update-raspi64-image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #IN_IMAGE_DIR=$OUT_DIR/target/product/rpi4/ 4 | #IN_BOOT_FILES=$ANDROID_BUILD_TOP/vendor/brcm/rpi4/proprietary/boot/ 5 | #SD_CARD_DEVICE=/dev/sdc 6 | #UPDATE_BOOT_PARTITION=1 7 | 8 | if [ -z $ROM_BUILDTYPE ]; then 9 | echo "missing ROM_BUILDTYPE" 10 | exit 0 11 | fi 12 | 13 | options=$(getopt -o nhi:d:b: -- "$@") 14 | [ $? -eq 0 ] || { 15 | echo "Incorrect options provided" 16 | exit 1 17 | } 18 | eval set -- "$options" 19 | while true; do 20 | case "$1" in 21 | -i) 22 | shift 23 | IN_IMAGE_DIR=$1 24 | shift 25 | ;; 26 | -d) 27 | shift 28 | SD_CARD_DEVICE=$1 29 | shift 30 | ;; 31 | -b) 32 | shift 33 | IN_BOOT_FILES=$1 34 | shift 35 | ;; 36 | -n) 37 | UPDATE_BOOT_PARTITION=0 38 | shift 39 | ;; 40 | -h) 41 | echo "-i -b -d -n" 42 | echo "e.g. -i $OUT_DIR/target/product/rpi4/ -b $ANDROID_BUILD_TOP/vendor/brcm/rpi4/proprietary/boot/ -d /dev/sdc" 43 | echo "-n dont update boot partition" 44 | exit 0 45 | ;; 46 | --) 47 | shift 48 | break 49 | ;; 50 | esac 51 | done 52 | 53 | if [ -z $IN_IMAGE_DIR ]; then 54 | echo "missing -i " 55 | exit 0 56 | fi 57 | 58 | if [ -z $SD_CARD_DEVICE ]; then 59 | echo "missing -d e.g. /dev/sdc" 60 | exit 0 61 | fi 62 | 63 | if [ ! -f "$IN_IMAGE_DIR/system.img" ]; then 64 | echo "no /system.img" 65 | exit 0 66 | fi 67 | 68 | if [ ! -f "$IN_IMAGE_DIR/vendor.img" ]; then 69 | echo "no /vendor.img" 70 | exit 0 71 | fi 72 | 73 | if [ ! -f "$IN_IMAGE_DIR/obj/KERNEL_OBJ/arch/arm64/boot/Image" ]; then 74 | echo "no /obj/KERNEL_OBJ/arch/arm64/boot/Image" 75 | exit 0 76 | fi 77 | 78 | if [ ! -b $SD_CARD_DEVICE ]; then 79 | echo "no " 80 | exit 0 81 | fi 82 | 83 | if [ ! -d $IN_BOOT_FILES ]; then 84 | echo "no " 85 | exit 0 86 | fi 87 | 88 | if [ ! -f "$IN_BOOT_FILES/config.txt" ]; then 89 | echo "no /config.txt" 90 | exit 0 91 | fi 92 | 93 | echo "update: images $IN_IMAGE_DIR + boot files $IN_BOOT_FILES -> $SD_CARD_DEVICE" 94 | 95 | if [ $UPDATE_BOOT_PARTITION -eq 1 ]; then 96 | echo update boot partition on $SD_CARD_DEVICE"1" 97 | sudo mkdir /mnt/tmp 98 | sudo mount $SD_CARD_DEVICE"1" /mnt/tmp 99 | sudo cp "$IN_IMAGE_DIR/ramdisk.img" /mnt/tmp 100 | sudo cp "$IN_IMAGE_DIR/obj/KERNEL_OBJ/arch/arm64/boot/Image" /mnt/tmp/Image 101 | sudo cp "$IN_IMAGE_DIR/obj/KERNEL_OBJ/arch/arm64/boot/dts/broadcom/bcm2711-rpi-4-b.dtb" /mnt/tmp 102 | sudo mkdir /mnt/tmp/overlays/ 103 | sudo cp $IN_IMAGE_DIR/obj/KERNEL_OBJ/arch/arm64/boot/dts/overlays/* /mnt/tmp/overlays/ 104 | sudo cp $IN_BOOT_FILES/* /mnt/tmp/ 105 | sync 106 | fi 107 | 108 | echo write system.img to $SD_CARD_DEVICE"2" 109 | sudo dd if=$IN_IMAGE_DIR/system.img of=$SD_CARD_DEVICE"2" bs=1M 110 | echo write vendor.img to $SD_CARD_DEVICE"3" 111 | sudo dd if=$IN_IMAGE_DIR/vendor.img of=$SD_CARD_DEVICE"3" bs=1M 112 | 113 | echo "enable project quota" 114 | sudo tune2fs -O project,quota $SD_CARD_DEVICE"4" 115 | 116 | sudo umount /mnt/tmp 117 | sudo rm -fr /mnt/tmp 118 | 119 | exit 1 120 | -------------------------------------------------------------------------------- /power/power.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #define LOG_TAG "rpi4 PowerHAL" 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #include "utils.h" 32 | 33 | #define UNUSED_ARGUMENT __attribute((unused)) 34 | 35 | // in seconds 36 | #define PERFORMANCE_BOOT_TIMEOUT 2 37 | 38 | static pthread_t tid = -1; 39 | static char min_freq[1024]; 40 | static char max_freq[1024]; 41 | static int DEBUG = 0; 42 | static void *performance_boost_thread(UNUSED_ARGUMENT void *data) 43 | { 44 | get_scaling_max_freq(max_freq, 1024); 45 | get_scaling_min_freq(min_freq, 1024); 46 | 47 | if (!strcmp(min_freq, max_freq)) { 48 | tid = -1; 49 | return NULL; 50 | } 51 | if (DEBUG) ALOGD("performnace_boost start %s -> %s", min_freq, max_freq); 52 | 53 | sysfs_write(SCALING_MIN_FREQ, max_freq); 54 | sleep(PERFORMANCE_BOOT_TIMEOUT); 55 | sysfs_write(SCALING_MIN_FREQ, min_freq); 56 | 57 | if (DEBUG) ALOGD("performnace_boost end"); 58 | 59 | tid = -1; 60 | return NULL; 61 | } 62 | 63 | static int start_performance_boost() 64 | { 65 | if (tid != -1) { 66 | return 0; 67 | } 68 | 69 | return pthread_create(&tid, NULL, performance_boost_thread, NULL); 70 | } 71 | 72 | static void power_init(struct power_module *module UNUSED_ARGUMENT) 73 | { 74 | } 75 | 76 | static void power_set_interactive(struct power_module *module UNUSED_ARGUMENT, 77 | int on UNUSED_ARGUMENT) 78 | { 79 | } 80 | 81 | static void power_hint(struct power_module *module UNUSED_ARGUMENT, 82 | power_hint_t hint, 83 | void *data UNUSED_ARGUMENT) { 84 | switch (hint) { 85 | case POWER_HINT_INTERACTION: 86 | //ALOGD("POWER_HINT_INTERACTION"); 87 | break; 88 | case POWER_HINT_LAUNCH: 89 | if (tid != -1) { 90 | break; 91 | } 92 | if (DEBUG) ALOGD("POWER_HINT_LAUNCH"); 93 | start_performance_boost(); 94 | break; 95 | default: 96 | break; 97 | } 98 | } 99 | 100 | static struct hw_module_methods_t power_module_methods = { 101 | .open = NULL, 102 | }; 103 | 104 | struct power_module HAL_MODULE_INFO_SYM = { 105 | .common = { 106 | .tag = HARDWARE_MODULE_TAG, 107 | .module_api_version = POWER_MODULE_API_VERSION_0_2, 108 | .hal_api_version = HARDWARE_HAL_API_VERSION, 109 | .id = POWER_HARDWARE_MODULE_ID, 110 | .name = "rpi4 Power HAL", 111 | .author = "The Android Open Source Project", 112 | .methods = &power_module_methods, 113 | }, 114 | 115 | .init = power_init, 116 | .setInteractive = power_set_interactive, 117 | .powerHint = power_hint, 118 | }; 119 | -------------------------------------------------------------------------------- /DeviceParts/src/org/omnirom/device/KeyHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2020 The OmniROM Project 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | */ 18 | package org.omnirom.device; 19 | 20 | import android.app.ActivityManagerNative; 21 | import android.app.NotificationManager; 22 | import android.content.BroadcastReceiver; 23 | import android.content.ComponentName; 24 | import android.content.Context; 25 | import android.content.Intent; 26 | import android.content.IntentFilter; 27 | import android.database.ContentObserver; 28 | import android.hardware.Sensor; 29 | import android.hardware.SensorEvent; 30 | import android.hardware.SensorEventListener; 31 | import android.hardware.SensorManager; 32 | import android.media.IAudioService; 33 | import android.media.AudioManager; 34 | import android.media.session.MediaSessionLegacyHelper; 35 | import android.net.Uri; 36 | import android.text.TextUtils; 37 | import android.os.FileObserver; 38 | import android.os.Handler; 39 | import android.os.Message; 40 | import android.os.PowerManager; 41 | import android.os.PowerManager.WakeLock; 42 | import android.os.RemoteException; 43 | import android.os.ServiceManager; 44 | import android.os.SystemClock; 45 | import android.os.SystemProperties; 46 | import android.os.UEventObserver; 47 | import android.os.UserHandle; 48 | import android.os.VibrationEffect; 49 | import android.os.Vibrator; 50 | import android.provider.Settings; 51 | import android.provider.Settings.Global; 52 | import android.telecom.PhoneAccountHandle; 53 | import android.telecom.TelecomManager; 54 | import android.telephony.SubscriptionInfo; 55 | import android.telephony.SubscriptionManager; 56 | import android.util.Log; 57 | import android.view.KeyEvent; 58 | import android.view.HapticFeedbackConstants; 59 | import android.view.WindowManagerGlobal; 60 | 61 | import com.android.internal.util.omni.DeviceKeyHandler; 62 | import com.android.internal.util.omni.PackageUtils; 63 | import com.android.internal.util.ArrayUtils; 64 | import com.android.internal.util.omni.OmniUtils; 65 | import org.omnirom.omnilib.utils.OmniVibe; 66 | import com.android.internal.statusbar.IStatusBarService; 67 | 68 | public class KeyHandler implements DeviceKeyHandler { 69 | 70 | private static final String TAG = "KeyHandler"; 71 | private static final boolean DEBUG = true; 72 | 73 | protected final Context mContext; 74 | 75 | public KeyHandler(Context context) { 76 | mContext = context; 77 | Log.d(TAG, "He is alive"); 78 | } 79 | 80 | @Override 81 | public boolean handleKeyEvent(KeyEvent event) { 82 | return false; 83 | } 84 | 85 | @Override 86 | public boolean canHandleKeyEvent(KeyEvent event) { 87 | return false; 88 | } 89 | 90 | @Override 91 | public boolean isDisabledKeyEvent(KeyEvent event) { 92 | return false; 93 | } 94 | 95 | @Override 96 | public boolean isCameraLaunchEvent(KeyEvent event) { 97 | return false; 98 | } 99 | 100 | @Override 101 | public boolean isWakeEvent(KeyEvent event){ 102 | return false; 103 | } 104 | 105 | @Override 106 | public Intent isActivityLaunchEvent(KeyEvent event) { 107 | return null; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /scripts/mk-raspi64-large-image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #IN_IMAGE_DIR=$OUT_DIR/target/product/rpi4/ 4 | #IN_BOOT_FILES=$ANDROID_BUILD_TOP/vendor/brcm/rpi4/proprietary/boot/ 5 | #OUT_IMAGE_FILE=$HOME/raspberrypi/omni-$ROM_BUILDTYPE.img 6 | 7 | if [ -z $ROM_BUILDTYPE ]; then 8 | echo "missing ROM_BUILDTYPE" 9 | exit 0 10 | fi 11 | 12 | options=$(getopt -o ho:i:b: -- "$@") 13 | [ $? -eq 0 ] || { 14 | echo "Incorrect options provided" 15 | exit 1 16 | } 17 | eval set -- "$options" 18 | while true; do 19 | case "$1" in 20 | -o) 21 | shift 22 | OUT_IMAGE_FILE=$1 23 | shift 24 | ;; 25 | -i) 26 | shift 27 | IN_IMAGE_DIR=$1 28 | shift 29 | ;; 30 | -b) 31 | shift 32 | IN_BOOT_FILES=$1 33 | shift 34 | ;; 35 | -h) 36 | echo "-i -b -o " 37 | echo "e.g. -i $OUT_DIR/target/product/rpi4/ -b $ANDROID_BUILD_TOP/vendor/brcm/rpi4/proprietary/boot/ -o /tmp/omni.img" 38 | exit 0 39 | ;; 40 | --) 41 | shift 42 | break 43 | ;; 44 | esac 45 | done 46 | 47 | if [ -z $IN_IMAGE_DIR ]; then 48 | echo "missing -i " 49 | exit 0 50 | fi 51 | 52 | if [ -z $OUT_IMAGE_FILE ]; then 53 | echo "missing -o " 54 | exit 0 55 | fi 56 | 57 | if [ -z $IN_BOOT_FILES ]; then 58 | echo "missing -b " 59 | exit 0 60 | fi 61 | 62 | if [ ! -f "$IN_IMAGE_DIR/system.img" ]; then 63 | echo "no /system.img" 64 | exit 0 65 | fi 66 | 67 | if [ ! -f "$IN_IMAGE_DIR/vendor.img" ]; then 68 | echo "no /vendor.img" 69 | exit 0 70 | fi 71 | 72 | if [ ! -f "$IN_IMAGE_DIR/obj/KERNEL_OBJ/arch/arm64/boot/Image" ]; then 73 | echo "no /obj/KERNEL_OBJ/arch/arm64/boot/Image" 74 | exit 0 75 | fi 76 | 77 | if [ ! -d $IN_BOOT_FILES ]; then 78 | echo "no " 79 | exit 0 80 | fi 81 | 82 | if [ ! -f "$IN_BOOT_FILES/config.txt" ]; then 83 | echo "no /config.txt" 84 | exit 0 85 | fi 86 | 87 | echo "create: images $IN_IMAGE_DIR + boot files $IN_BOOT_FILES -> $OUT_IMAGE_FILE" 88 | 89 | if [ -f $OUT_IMAGE_FILE ]; then 90 | rm $OUT_IMAGE_FILE 91 | fi 92 | 93 | echo "create empty image" 94 | dd if=/dev/zero of="$OUT_IMAGE_FILE" bs=1M count=8192 95 | 96 | echo "create partitions" 97 | sudo sfdisk "$OUT_IMAGE_FILE" << EOF 98 | 2,262144,0xC,* 99 | 264192,4194304,0x83,- 100 | 4458496,524288,0x83,- 101 | 4982784,,- 102 | EOF 103 | 104 | echo "mount partitions" 105 | sudo kpartx -av "$OUT_IMAGE_FILE" 106 | 107 | echo "create file systems" 108 | sudo mkfs.vfat /dev/mapper/loop0p1 -n boot 109 | sudo mkfs.ext4 /dev/mapper/loop0p2 -L system 110 | sudo mkfs.ext4 /dev/mapper/loop0p3 -L vendor 111 | sudo mkfs.ext4 /dev/mapper/loop0p4 -L userdata 112 | echo "enable project quota" 113 | sudo tune2fs -O project,quota /dev/mapper/loop0p4 114 | 115 | echo "write system.img" 116 | sudo dd if="$IN_IMAGE_DIR/system.img" of=/dev/mapper/loop0p2 bs=1M 117 | echo "write vendor.img" 118 | sudo dd if="$IN_IMAGE_DIR/vendor.img" of=/dev/mapper/loop0p3 bs=1M 119 | 120 | echo "write boot patition" 121 | sudo mkdir /mnt/tmp 122 | sudo mount /dev/mapper/loop0p1 /mnt/tmp 123 | sudo cp "$IN_IMAGE_DIR/ramdisk.img" /mnt/tmp/ 124 | sudo cp "$IN_IMAGE_DIR/obj/KERNEL_OBJ/arch/arm64/boot/Image" /mnt/tmp/Image 125 | sudo cp "$IN_IMAGE_DIR/obj/KERNEL_OBJ/arch/arm64/boot/dts/broadcom/bcm2711-rpi-4-b.dtb" /mnt/tmp/ 126 | sudo mkdir /mnt/tmp/overlays/ 127 | sudo cp $IN_IMAGE_DIR/obj/KERNEL_OBJ/arch/arm64/boot/dts/overlays/* /mnt/tmp/overlays/ 128 | sudo cp $IN_BOOT_FILES/* /mnt/tmp/ 129 | sync 130 | 131 | echo "unmounting" 132 | sudo umount /mnt/tmp 133 | sudo rm -fr /mnt/tmp 134 | 135 | sudo kpartx -dv "$OUT_IMAGE_FILE" 136 | 137 | echo "now write $OUT_IMAGE_FILE to a sdcard" 138 | 139 | exit 1 140 | -------------------------------------------------------------------------------- /BoardConfig.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2020 The OmniROM Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | DEVICE_PATH := device/brcm/rpi4 18 | 19 | # Platform 20 | TARGET_NO_BOOTLOADER := true 21 | TARGET_NO_CHARGER := true 22 | TARGET_BOARD_PLATFORM := bcm2711 23 | 24 | BOARD_VNDK_VERSION := current 25 | PRODUCT_FULL_TREBLE_OVERRIDE := true 26 | 27 | TARGET_ARCH := arm64 28 | TARGET_ARCH_VARIANT := armv8-a 29 | TARGET_CPU_VARIANT := cortex-a72 30 | TARGET_CPU_ABI := arm64-v8a 31 | TARGET_CPU_ABI2 := 32 | 33 | TARGET_2ND_ARCH := arm 34 | TARGET_2ND_ARCH_VARIANT := armv7-a-neon 35 | TARGET_2ND_CPU_VARIANT := cortex-a72 36 | TARGET_2ND_CPU_ABI := armeabi-v7a 37 | TARGET_2ND_CPU_ABI2 := armeabi 38 | 39 | USE_OPENGL_RENDERER := true 40 | TARGET_USES_HWC2 := true 41 | BOARD_GPU_DRIVERS := v3d kmsro 42 | TARGET_USES_64_BIT_BINDER := true 43 | 44 | #BOARD_USES_DRM_GRALLOC := true 45 | TARGET_USE_V3D_KMSRO := true 46 | 47 | #wifi 48 | BOARD_WLAN_DEVICE := bcmdhd 49 | BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_bcmdhd 50 | BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_bcmdhd 51 | BOARD_HOSTAPD_DRIVER := NL80211 52 | WPA_SUPPLICANT_VERSION := VER_0_8_X 53 | BOARD_WPA_SUPPLICANT_DRIVER := NL80211 54 | 55 | # Kernel 56 | BOARD_KERNEL_IMAGE_NAME := Image 57 | BOARD_KERNEL_SEPARATED_DTBO := false 58 | TARGET_KERNEL_SOURCE := kernel/brcm/arpi 59 | TARGET_KERNEL_CONFIG := omni_rpi4_defconfig 60 | TARGET_KERNEL_ARCH := arm64 61 | TARGET_KERNEL_HEADER_ARCH := arm64 62 | TARGET_KERNEL_CLANG_COMPILE := true 63 | 64 | TARGET_COPY_OUT_PRODUCT := system/product 65 | TARGET_COPY_OUT_SYSTEM_EXT := system/system_ext 66 | TARGET_COPY_OUT_VENDOR := vendor 67 | BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4 68 | BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE := ext4 69 | BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648 # 2G 70 | BOARD_VENDORIMAGE_PARTITION_SIZE := 268435456 # 256M 71 | TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true 72 | TARGET_USERIMAGES_USE_EXT4 := true 73 | BOARD_BOOTIMAGE_PARTITION_SIZE := 268435456 # 256M 74 | 75 | USE_XML_AUDIO_POLICY_CONF := 1 76 | DEVICE_MANIFEST_FILE := $(DEVICE_PATH)/manifest.xml 77 | DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE := $(DEVICE_PATH)/compatibility_matrix.device.xml 78 | 79 | BOARD_SEPOLICY_DIRS += \ 80 | $(DEVICE_PATH)/sepolicy 81 | 82 | TARGET_SYSTEM_PROP := $(DEVICE_PATH)/system.prop 83 | TARGET_INIT_VENDOR_LIB := //$(DEVICE_PATH):libinit_rpi4 84 | TARGET_VOLD_VENDOR_LIB := //$(DEVICE_PATH):libinit_rpi4 85 | BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := $(DEVICE_PATH)/bluetooth/cfg 86 | 87 | BUILD_FINGERPRINT := Raspberry/omni_rpi4/rpi4:10/QKQ1.190716.003/1910071200:userdebug/release-keys 88 | 89 | # recovery 90 | # change to false when building recoveryimage 91 | TARGET_NO_RECOVERY := true 92 | BOARD_USES_RECOVERY_AS_BOOT := true 93 | TARGET_RECOVERY_FSTAB := $(DEVICE_PATH)/recovery/recovery.fstab 94 | TARGET_RECOVERY_PIXEL_FORMAT := "RGB_565" 95 | TARGET_RECOVERY_FORCE_PIXEL_FORMAT := "RGB_565" 96 | TW_BRIGHTNESS_PATH := "/sys/class/backlight/rpi_backlight/brightness" 97 | TW_EXCLUDE_MTP := true 98 | TW_INCLUDE_CRYPTO := true 99 | TW_NO_BATT_PERCENT := true 100 | TW_NO_REBOOT_BOOTLOADER := true 101 | TW_NO_REBOOT_RECOVERY := true 102 | TW_NO_SCREEN_TIMEOUT := true 103 | TW_THEME := landscape_hdpi 104 | TW_USE_TOOLBOX := true 105 | TWRP_INCLUDE_LOGCAT := true 106 | TARGET_USES_LOGD := true 107 | TW_EXTERNAL_STORAGE_PATH := "/usb" 108 | -------------------------------------------------------------------------------- /DeviceParts/src/org/omnirom/device/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 The OmniROM Project 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | */ 18 | package org.omnirom.device; 19 | 20 | import java.io.File; 21 | import java.io.FileNotFoundException; 22 | import java.io.FileOutputStream; 23 | import java.io.IOException; 24 | import java.io.BufferedReader; 25 | import java.io.FileReader; 26 | 27 | import java.util.ArrayList; 28 | import java.util.Arrays; 29 | import java.util.List; 30 | 31 | public class Utils { 32 | 33 | /** 34 | * Write a string value to the specified file. 35 | * @param filename The filename 36 | * @param value The value 37 | */ 38 | public static void writeValue(String filename, String value) { 39 | if (filename == null) { 40 | return; 41 | } 42 | try { 43 | FileOutputStream fos = new FileOutputStream(new File(filename)); 44 | fos.write(value.getBytes()); 45 | fos.flush(); 46 | fos.close(); 47 | } catch (FileNotFoundException e) { 48 | // ignore 49 | } catch (IOException e) { 50 | // ignore 51 | } 52 | } 53 | 54 | /** 55 | * Check if the specified file exists. 56 | * @param filename The filename 57 | * @return Whether the file exists or not 58 | */ 59 | public static boolean fileExists(String filename) { 60 | if (filename == null) { 61 | return false; 62 | } 63 | return new File(filename).exists(); 64 | } 65 | 66 | public static boolean fileWritable(String filename) { 67 | return fileExists(filename) && new File(filename).canWrite(); 68 | } 69 | 70 | public static String readLine(String filename) { 71 | if (filename == null) { 72 | return null; 73 | } 74 | BufferedReader br = null; 75 | String line = null; 76 | try { 77 | br = new BufferedReader(new FileReader(filename), 1024); 78 | line = br.readLine(); 79 | } catch (IOException e) { 80 | return null; 81 | } finally { 82 | if (br != null) { 83 | try { 84 | br.close(); 85 | } catch (IOException e) { 86 | // ignore 87 | } 88 | } 89 | } 90 | return line; 91 | } 92 | 93 | public static List readLineAsArray(String filename) { 94 | if (filename == null) { 95 | return null; 96 | } 97 | List lines = new ArrayList<>(); 98 | String line = readLine(filename); 99 | if (line != null){ 100 | lines.addAll(Arrays.asList(line.split("\\s+"))); 101 | } 102 | 103 | return lines; 104 | } 105 | 106 | public static boolean getFileValueAsBoolean(String filename, boolean defValue) { 107 | String fileValue = readLine(filename); 108 | if(fileValue!=null){ 109 | return (fileValue.equals("0")?false:true); 110 | } 111 | return defValue; 112 | } 113 | 114 | public static String getFileValue(String filename, String defValue) { 115 | String fileValue = readLine(filename); 116 | if(fileValue!=null){ 117 | return fileValue; 118 | } 119 | return defValue; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /bluetooth/hal/h4_protocol.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2017 The Android Open Source Project 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #include "h4_protocol.h" 18 | 19 | #define LOG_TAG "android.hardware.bluetooth-hci-h4" 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace android { 27 | namespace hardware { 28 | namespace bluetooth { 29 | namespace hci { 30 | 31 | size_t H4Protocol::Send(uint8_t type, const uint8_t* data, size_t length) { 32 | /* For HCI communication over USB dongle, multiple write results in 33 | * response timeout as driver expect type + data at once to process 34 | * the command, so using "writev"(for atomicity) here. 35 | */ 36 | struct iovec iov[2]; 37 | ssize_t ret = 0; 38 | iov[0].iov_base = &type; 39 | iov[0].iov_len = sizeof(type); 40 | iov[1].iov_base = (void *)data; 41 | iov[1].iov_len = length; 42 | while (1) { 43 | ret = TEMP_FAILURE_RETRY(writev(uart_fd_, iov, 2)); 44 | if (ret == -1) { 45 | if (errno == EAGAIN) { 46 | ALOGE("%s error writing to UART (%s)", __func__, strerror(errno)); 47 | continue; 48 | } 49 | } else if (ret == 0) { 50 | // Nothing written :( 51 | ALOGE("%s zero bytes written - something went wrong...", __func__); 52 | break; 53 | } 54 | break; 55 | } 56 | return ret; 57 | } 58 | 59 | void H4Protocol::OnPacketReady() { 60 | switch (hci_packet_type_) { 61 | case HCI_PACKET_TYPE_EVENT: 62 | event_cb_(hci_packetizer_.GetPacket()); 63 | break; 64 | case HCI_PACKET_TYPE_ACL_DATA: 65 | acl_cb_(hci_packetizer_.GetPacket()); 66 | break; 67 | case HCI_PACKET_TYPE_SCO_DATA: 68 | sco_cb_(hci_packetizer_.GetPacket()); 69 | break; 70 | default: { 71 | bool bad_packet_type = true; 72 | CHECK(!bad_packet_type); 73 | } 74 | } 75 | // Get ready for the next type byte. 76 | hci_packet_type_ = HCI_PACKET_TYPE_UNKNOWN; 77 | } 78 | 79 | void H4Protocol::OnDataReady(int fd) { 80 | if (hci_packet_type_ == HCI_PACKET_TYPE_UNKNOWN) { 81 | /** 82 | * read full buffer. ACL max length is 2 bytes, and SCO max length is 2 83 | * byte. so taking 64K as buffer length. 84 | * Question : Why to read in single chunk rather than multiple reads, 85 | * which can give parameter length arriving in response ? 86 | * Answer: The multiple reads does not work with BT USB dongle. At least 87 | * with Bluetooth 2.0 supported USB dongle. After first read, either 88 | * firmware/kernel (do not know who is responsible - inputs ??) driver 89 | * discard the whole message and successive read results in forever 90 | * blocking loop. - Is there any other way to make it work with multiple 91 | * reads, do not know yet (it can eliminate need of this function) ? 92 | * Reading in single shot gives expected response. 93 | */ 94 | const size_t max_plen = 64*1024; 95 | hidl_vec tpkt; 96 | tpkt.resize(max_plen); 97 | size_t bytes_read = TEMP_FAILURE_RETRY(read(fd, tpkt.data(), max_plen)); 98 | hci_packet_type_ = static_cast(tpkt.data()[0]); 99 | hci_packetizer_.CbHciPacket(tpkt.data()+1, bytes_read-1); 100 | } 101 | } 102 | 103 | } // namespace hci 104 | } // namespace bluetooth 105 | } // namespace hardware 106 | } // namespace android 107 | -------------------------------------------------------------------------------- /power/utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above 10 | * copyright notice, this list of conditions and the following 11 | * disclaimer in the documentation and/or other materials provided 12 | * with the distribution. 13 | * * Neither the name of The Linux Foundation nor the names of its 14 | * contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | #define LOG_NIDEBUG 0 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include "utils.h" 39 | 40 | #define LOG_TAG "rpi4 PowerHAL" 41 | #include 42 | 43 | int sysfs_read(char *path, char *s, int num_bytes) 44 | { 45 | char buf[80]; 46 | int count; 47 | int ret = 0; 48 | int fd = open(path, O_RDONLY); 49 | if (fd < 0) { 50 | strerror_r(errno, buf, sizeof(buf)); 51 | ALOGE("Error opening %s: %s\n", path, buf); 52 | return -1; 53 | } 54 | if ((count = read(fd, s, num_bytes - 1)) < 0) { 55 | strerror_r(errno, buf, sizeof(buf)); 56 | ALOGE("Error writing to %s: %s\n", path, buf); 57 | ret = -1; 58 | } else { 59 | s[count] = '\0'; 60 | } 61 | close(fd); 62 | return ret; 63 | } 64 | 65 | int sysfs_write(char *path, char *s) 66 | { 67 | char buf[80]; 68 | int len; 69 | int ret = 0; 70 | int fd = open(path, O_WRONLY); 71 | if (fd < 0) { 72 | strerror_r(errno, buf, sizeof(buf)); 73 | ALOGE("Error opening %s: %s\n", path, buf); 74 | return -1 ; 75 | } 76 | len = write(fd, s, strlen(s)); 77 | if (len < 0) { 78 | strerror_r(errno, buf, sizeof(buf)); 79 | ALOGE("Error writing to %s: %s\n", path, buf); 80 | ret = -1; 81 | } 82 | close(fd); 83 | return ret; 84 | } 85 | 86 | int get_scaling_governor(char governor[], int size) 87 | { 88 | if (sysfs_read(SCALING_GOVERNOR_PATH, governor, 89 | size) == -1) { 90 | // Can't obtain the scaling governor. Return. 91 | return -1; 92 | } else { 93 | // Strip newline at the end. 94 | int len = strlen(governor); 95 | len--; 96 | while (len >= 0 && (governor[len] == '\n' || governor[len] == '\r')) 97 | governor[len--] = '\0'; 98 | } 99 | return 0; 100 | } 101 | 102 | int get_scaling_max_freq(char max_freq[], int size) 103 | { 104 | if (sysfs_read(SCALING_MAX_FREQ, max_freq, 105 | size) == -1) { 106 | // Can't obtain the scaling max_freq. Return. 107 | return -1; 108 | } else { 109 | // Strip newline at the end. 110 | int len = strlen(max_freq); 111 | len--; 112 | while (len >= 0 && (max_freq[len] == '\n' || max_freq[len] == '\r')) 113 | max_freq[len--] = '\0'; 114 | } 115 | return 0; 116 | } 117 | 118 | int get_scaling_min_freq(char min_freq[], int size) 119 | { 120 | if (sysfs_read(SCALING_MIN_FREQ, min_freq, 121 | size) == -1) { 122 | // Can't obtain the scaling min_freq. Return. 123 | return -1; 124 | } else { 125 | // Strip newline at the end. 126 | int len = strlen(min_freq); 127 | len--; 128 | while (len >= 0 && (min_freq[len] == '\n' || min_freq[len] == '\r')) 129 | min_freq[len--] = '\0'; 130 | } 131 | return 0; 132 | } -------------------------------------------------------------------------------- /manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | android.hardware.audio 4 | hwbinder 5 | 2.0 6 | 7 | IDevicesFactory 8 | default 9 | 10 | @2.0::IDevicesFactory/default 11 | 12 | 13 | android.hardware.audio.effect 14 | hwbinder 15 | 2.0 16 | 17 | IEffectsFactory 18 | default 19 | 20 | @2.0::IEffectsFactory/default 21 | 22 | 23 | android.hardware.configstore 24 | hwbinder 25 | 1.1 26 | 27 | ISurfaceFlingerConfigs 28 | default 29 | 30 | 31 | 32 | android.hardware.graphics.allocator 33 | hwbinder 34 | 2.0 35 | 36 | IAllocator 37 | default 38 | 39 | 40 | 41 | android.hardware.graphics.mapper 42 | passthrough 43 | 2.1 44 | 45 | IMapper 46 | default 47 | 48 | 49 | 50 | android.hardware.graphics.composer 51 | hwbinder 52 | 2.1 53 | 54 | IComposer 55 | default 56 | 57 | 58 | 59 | android.hardware.memtrack 60 | hwbinder 61 | 1.0 62 | 63 | IMemtrack 64 | default 65 | 66 | 67 | 68 | android.hardware.media.omx 69 | hwbinder 70 | 1.0 71 | 72 | IOmx 73 | default 74 | 75 | 76 | IOmxStore 77 | default 78 | 79 | 80 | 81 | android.hardware.drm 82 | hwbinder 83 | 1.0 84 | 85 | ICryptoFactory 86 | default 87 | 88 | 89 | IDrmFactory 90 | default 91 | 92 | @1.3::ICryptoFactory/widevine 93 | @1.3::IDrmFactory/widevine 94 | 95 | 96 | android.hardware.keymaster 97 | hwbinder 98 | 3.0 99 | 100 | IKeymasterDevice 101 | default 102 | 103 | 104 | 105 | android.hardware.bluetooth 106 | hwbinder 107 | 1.0 108 | 109 | IBluetoothHci 110 | default 111 | 112 | 113 | 114 | android.hardware.gnss 115 | hwbinder 116 | 1.0 117 | 118 | IGnss 119 | default 120 | 121 | 122 | 123 | android.hardware.camera.provider 124 | hwbinder 125 | 2.5 126 | 127 | ICameraProvider 128 | external/0 129 | 130 | 131 | 132 | android.hardware.power 133 | hwbinder 134 | 1.0 135 | 136 | IPower 137 | default 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /init/init_rpi4.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2020 The OmniROM Project 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | * 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "uevent.h" 29 | 30 | #include 31 | #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ 32 | #include 33 | 34 | namespace android { 35 | namespace init { 36 | 37 | using android::base::GetProperty; 38 | 39 | 40 | template 41 | static T get(const std::string& path, const T& def) { 42 | std::ifstream file(path); 43 | T result; 44 | 45 | file >> result; 46 | return file.fail() ? def : result; 47 | } 48 | 49 | static void property_override(const std::string& name, const std::string& value) 50 | { 51 | size_t valuelen = value.size(); 52 | 53 | prop_info* pi = (prop_info*) __system_property_find(name.c_str()); 54 | if (pi != nullptr) { 55 | __system_property_update(pi, value.c_str(), valuelen); 56 | } 57 | else { 58 | int rc = __system_property_add(name.c_str(), name.size(), value.c_str(), valuelen); 59 | if (rc < 0) { 60 | LOG(ERROR) << "property_set(\"" << name << "\", \"" << value << "\") failed: " 61 | << "__system_property_add failed"; 62 | } 63 | } 64 | } 65 | 66 | static void set_revision_property() { 67 | std::string cpuinfo; 68 | android::base::ReadFileToString("/proc/cpuinfo", &cpuinfo); 69 | 70 | std::istringstream in(cpuinfo); 71 | std::string line; 72 | while (std::getline(in, line)) { 73 | std::vector pieces = android::base::Split(line, ":"); 74 | if (pieces.size() == 2) { 75 | if (android::base::Trim(pieces[0]) == "Revision") { 76 | property_override("ro.revision", android::base::Trim(pieces[1])); 77 | return; 78 | } 79 | } 80 | } 81 | } 82 | 83 | static void set_audio_card_property() { 84 | std::string card = android::base::GetProperty("persist.audio.pcm.card", ""); 85 | if (!card.empty()) { 86 | property_override("audio.pcm.card", card); 87 | } 88 | } 89 | 90 | // debug.drm.mode.force=1280x800 91 | static void set_drm_mode_property() { 92 | std::string drmModeFile = android::base::GetProperty("debug.drm.mode.force", ""); 93 | // security reset - if available always set value from /system/build.prop 94 | if (!drmModeFile.empty()) { 95 | property_override("persist.debug.drm.mode.force", ""); 96 | } else { 97 | std::string drmMode = android::base::GetProperty("persist.debug.drm.mode.force", ""); 98 | if (!drmMode.empty()) { 99 | property_override("debug.drm.mode.force", drmMode); 100 | } 101 | } 102 | } 103 | 104 | void vendor_load_properties() 105 | { 106 | // is done from kernel now 107 | //std::string serial = get("/proc/device-tree/serial-number", std::string("")); 108 | //property_override("ro.serialno", serial); 109 | 110 | set_revision_property(); 111 | 112 | set_audio_card_property(); 113 | 114 | set_drm_mode_property(); 115 | } 116 | 117 | void vendor_create_device_symlinks(const Uevent& uevent, std::vector& links) 118 | { 119 | LOG(INFO) << "vendor_create_device_symlinks: device " << uevent.device_name; 120 | 121 | // TODO raspi hardcode start 122 | int num = uevent.partition_num; 123 | if (num == 2 || uevent.device_name.find("sda2") != std::string::npos 124 | || uevent.device_name.find("mmcblk0p2") != std::string::npos) { 125 | links.emplace_back("/dev/block/by-name/system"); 126 | } else if (num == 3 || uevent.device_name.find("sda3") != std::string::npos 127 | || uevent.device_name.find("mmcblk0p3") != std::string::npos) { 128 | links.emplace_back("/dev/block/by-name/vendor"); 129 | } else if (num == 4 || uevent.device_name.find("sda4") != std::string::npos 130 | || uevent.device_name.find("mmcblk0p4") != std::string::npos) { 131 | links.emplace_back("/dev/block/by-name/userdata"); 132 | } 133 | } 134 | } 135 | } 136 | 137 | bool vendor_vold_add_device(std::string devName) 138 | { 139 | LOG(INFO) << "vendor_vold_add_device: device " << devName; 140 | 141 | std::string rootDev = android::base::GetProperty("dev.mnt.blk.root", ""); 142 | if (!rootDev.empty()) { 143 | if (rootDev.find(devName) != std::string::npos) { 144 | LOG(INFO) << "VolumeManager: skip dev = " << devName << " it is the boot device"; 145 | return false; 146 | } 147 | } 148 | return true; 149 | } 150 | -------------------------------------------------------------------------------- /bluetooth/hal/async_fd_watcher.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016 The Android Open Source Project 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | #include "async_fd_watcher.h" 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include "fcntl.h" 28 | #include "sys/select.h" 29 | #include "unistd.h" 30 | 31 | static const int INVALID_FD = -1; 32 | static const int BT_RT_PRIORITY = 1; 33 | 34 | namespace android { 35 | namespace hardware { 36 | namespace bluetooth { 37 | namespace async { 38 | 39 | int AsyncFdWatcher::WatchFdForNonBlockingReads( 40 | int file_descriptor, const ReadCallback& on_read_fd_ready_callback) { 41 | // Add file descriptor and callback 42 | { 43 | std::unique_lock guard(internal_mutex_); 44 | watched_fds_[file_descriptor] = on_read_fd_ready_callback; 45 | } 46 | 47 | // Start the thread if not started yet 48 | return tryStartThread(); 49 | } 50 | 51 | int AsyncFdWatcher::ConfigureTimeout( 52 | const std::chrono::milliseconds timeout, 53 | const TimeoutCallback& on_timeout_callback) { 54 | // Add timeout and callback 55 | { 56 | std::unique_lock guard(timeout_mutex_); 57 | timeout_cb_ = on_timeout_callback; 58 | timeout_ms_ = timeout; 59 | } 60 | 61 | notifyThread(); 62 | return 0; 63 | } 64 | 65 | void AsyncFdWatcher::StopWatchingFileDescriptors() { stopThread(); } 66 | 67 | AsyncFdWatcher::~AsyncFdWatcher() {} 68 | 69 | // Make sure to call this with at least one file descriptor ready to be 70 | // watched upon or the thread routine will return immediately 71 | int AsyncFdWatcher::tryStartThread() { 72 | if (std::atomic_exchange(&running_, true)) return 0; 73 | 74 | // Set up the communication channel 75 | int pipe_fds[2]; 76 | if (pipe2(pipe_fds, O_NONBLOCK)) return -1; 77 | 78 | notification_listen_fd_ = pipe_fds[0]; 79 | notification_write_fd_ = pipe_fds[1]; 80 | 81 | thread_ = std::thread([this]() { ThreadRoutine(); }); 82 | if (!thread_.joinable()) return -1; 83 | 84 | return 0; 85 | } 86 | 87 | int AsyncFdWatcher::stopThread() { 88 | if (!std::atomic_exchange(&running_, false)) return 0; 89 | 90 | notifyThread(); 91 | if (std::this_thread::get_id() != thread_.get_id()) { 92 | thread_.join(); 93 | } 94 | 95 | { 96 | std::unique_lock guard(internal_mutex_); 97 | watched_fds_.clear(); 98 | } 99 | 100 | { 101 | std::unique_lock guard(timeout_mutex_); 102 | timeout_cb_ = nullptr; 103 | } 104 | 105 | return 0; 106 | } 107 | 108 | int AsyncFdWatcher::notifyThread() { 109 | uint8_t buffer[] = {0}; 110 | if (TEMP_FAILURE_RETRY(write(notification_write_fd_, &buffer, 1)) < 0) { 111 | return -1; 112 | } 113 | return 0; 114 | } 115 | 116 | void AsyncFdWatcher::ThreadRoutine() { 117 | 118 | // Make watching thread RT. 119 | struct sched_param rt_params; 120 | rt_params.sched_priority = BT_RT_PRIORITY; 121 | if (sched_setscheduler(gettid(), SCHED_FIFO, &rt_params)) { 122 | ALOGE("%s unable to set SCHED_FIFO for pid %d, tid %d, error %s", __func__, 123 | getpid(), gettid(), strerror(errno)); 124 | } 125 | 126 | while (running_) { 127 | fd_set read_fds; 128 | FD_ZERO(&read_fds); 129 | FD_SET(notification_listen_fd_, &read_fds); 130 | int max_read_fd = INVALID_FD; 131 | for (auto& it : watched_fds_) { 132 | FD_SET(it.first, &read_fds); 133 | max_read_fd = std::max(max_read_fd, it.first); 134 | } 135 | 136 | struct timeval timeout; 137 | struct timeval* timeout_ptr = NULL; 138 | if (timeout_ms_ > std::chrono::milliseconds(0)) { 139 | timeout.tv_sec = timeout_ms_.count() / 1000; 140 | timeout.tv_usec = (timeout_ms_.count() % 1000) * 1000; 141 | timeout_ptr = &timeout; 142 | } 143 | 144 | // Wait until there is data available to read on some FD. 145 | int nfds = std::max(notification_listen_fd_, max_read_fd); 146 | int retval = select(nfds + 1, &read_fds, NULL, NULL, timeout_ptr); 147 | 148 | // There was some error. 149 | if (retval < 0) continue; 150 | 151 | // Timeout. 152 | if (retval == 0) { 153 | // Allow the timeout callback to modify the timeout. 154 | TimeoutCallback saved_cb; 155 | { 156 | std::unique_lock guard(timeout_mutex_); 157 | if (timeout_ms_ > std::chrono::milliseconds(0)) 158 | saved_cb = timeout_cb_; 159 | } 160 | if (saved_cb != nullptr) 161 | saved_cb(); 162 | continue; 163 | } 164 | 165 | // Read data from the notification FD. 166 | if (FD_ISSET(notification_listen_fd_, &read_fds)) { 167 | char buffer[] = {0}; 168 | TEMP_FAILURE_RETRY(read(notification_listen_fd_, buffer, 1)); 169 | continue; 170 | } 171 | 172 | // Invoke the data ready callbacks if appropriate. 173 | { 174 | // Hold the mutex to make sure that the callbacks are still valid. 175 | std::unique_lock guard(internal_mutex_); 176 | for (auto& it : watched_fds_) { 177 | if (FD_ISSET(it.first, &read_fds)) { 178 | it.second(it.first); 179 | } 180 | } 181 | } 182 | } 183 | } 184 | 185 | } // namespace async 186 | } // namespace bluetooth 187 | } // namespace hardware 188 | } // namespace android 189 | -------------------------------------------------------------------------------- /recovery/root/vendor/manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | android.hardware.audio 4 | hwbinder 5 | 2.0 6 | 7 | IDevicesFactory 8 | default 9 | 10 | @2.0::IDevicesFactory/default 11 | 12 | 13 | android.hardware.audio.effect 14 | hwbinder 15 | 2.0 16 | 17 | IEffectsFactory 18 | default 19 | 20 | @2.0::IEffectsFactory/default 21 | 22 | 23 | android.hardware.configstore 24 | hwbinder 25 | 1.1 26 | 27 | ISurfaceFlingerConfigs 28 | default 29 | 30 | 31 | 32 | android.hardware.gatekeeper 33 | hwbinder 34 | 1.0 35 | 36 | IGatekeeper 37 | default 38 | 39 | 40 | 41 | android.hardware.graphics.allocator 42 | hwbinder 43 | 2.0 44 | 45 | IAllocator 46 | default 47 | 48 | 49 | 50 | android.hardware.graphics.mapper 51 | passthrough 52 | 2.1 53 | 54 | IMapper 55 | default 56 | 57 | 58 | 59 | android.hardware.graphics.composer 60 | hwbinder 61 | 2.1 62 | 63 | IComposer 64 | default 65 | 66 | 67 | 68 | android.hardware.memtrack 69 | hwbinder 70 | 1.0 71 | 72 | IMemtrack 73 | default 74 | 75 | 76 | 77 | android.hardware.media.omx 78 | hwbinder 79 | 1.0 80 | 81 | IOmx 82 | default 83 | 84 | 85 | IOmxStore 86 | default 87 | 88 | 89 | 90 | android.hardware.wifi 91 | hwbinder 92 | 1.3 93 | 94 | IWifi 95 | default 96 | 97 | 98 | 99 | android.hardware.wifi.supplicant 100 | hwbinder 101 | 1.2 102 | 103 | ISupplicant 104 | default 105 | 106 | 107 | 108 | android.hardware.wifi.hostapd 109 | hwbinder 110 | 1.1 111 | 112 | IHostapd 113 | default 114 | 115 | 116 | 117 | android.hardware.drm 118 | hwbinder 119 | 1.0 120 | 121 | ICryptoFactory 122 | default 123 | 124 | 125 | IDrmFactory 126 | default 127 | 128 | @1.1::ICryptoFactory/widevine 129 | @1.1::IDrmFactory/widevine 130 | 131 | 132 | android.hardware.keymaster 133 | hwbinder 134 | 3.0 135 | 136 | IKeymasterDevice 137 | default 138 | 139 | 140 | 141 | android.hardware.bluetooth 142 | hwbinder 143 | 1.0 144 | 145 | IBluetoothHci 146 | default 147 | 148 | 149 | 150 | android.hardware.camera.provider 151 | hwbinder 152 | 2.4 153 | 154 | ICameraProvider 155 | external/0 156 | 157 | 158 | 159 | android.hardware.gnss 160 | hwbinder 161 | 1.0 162 | 163 | IGnss 164 | default 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /recovery/init.rc: -------------------------------------------------------------------------------- 1 | import /init.recovery.logd.rc 2 | import /init.recovery.ldconfig.rc 3 | import /init.recovery.mksh.rc 4 | import /init.recovery.usb.rc 5 | import /init.recovery.service.rc 6 | import /init.recovery.vold_decrypt.rc 7 | import /init.recovery.${ro.hardware}.rc 8 | 9 | on early-init 10 | # Set the security context of /postinstall if present. 11 | restorecon /postinstall 12 | 13 | # ueventd wants to write to /acct 14 | mount cgroup none /acct cpuacct 15 | mkdir /acct/uid 16 | start ueventd 17 | 18 | on init 19 | export PATH /sbin:/system/bin 20 | export LD_LIBRARY_PATH /system/lib64 21 | 22 | export ANDROID_ROOT /system 23 | export ANDROID_DATA /data 24 | export EXTERNAL_STORAGE /sdcard 25 | 26 | symlink /proc/self/fd/0 /dev/stdin 27 | symlink /proc/self/fd/1 /dev/stdout 28 | symlink /proc/self/fd/2 /dev/stderr 29 | 30 | symlink /system/bin /bin 31 | symlink /system/etc /etc 32 | 33 | mount cgroup none /acct cpuacct 34 | mkdir /acct/uid 35 | 36 | mkdir /system 37 | mkdir /data 38 | mkdir /cache 39 | mkdir /sideload 40 | mkdir /mnt/system 41 | mount tmpfs tmpfs /tmp 42 | 43 | chown root shell /tmp 44 | chmod 0775 /tmp 45 | 46 | write /proc/sys/kernel/panic_on_oops 1 47 | write /proc/sys/vm/max_map_count 1000000 48 | 49 | on fs 50 | mount pstore pstore /sys/fs/pstore 51 | mkdir /dev/usb-ffs 0770 shell shell 52 | mkdir /dev/usb-ffs/adb 0770 shell shell 53 | mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000 54 | 55 | on boot 56 | ifup lo 57 | hostname localhost 58 | domainname localdomain 59 | 60 | class_start default 61 | 62 | # Load properties, pre-Android 6.0 63 | on load_all_props_action 64 | load_all_props 65 | 66 | # Load properties, Android 6.0+ 67 | on load_system_props_action 68 | load_system_props 69 | 70 | # Load properties, Android 6.0+, vendor init lives here 71 | on load_persist_props_action 72 | load_persist_props 73 | 74 | on firmware_mounts_complete 75 | rm /dev/.booting 76 | 77 | # Mount filesystems and start core system services. 78 | on late-init 79 | trigger early-fs 80 | trigger fs 81 | trigger post-fs 82 | trigger post-fs-data 83 | 84 | # Load properties, pre-Android 6.0 85 | trigger load_all_props_action 86 | 87 | # Load properties from /system/ + /factory after fs mount. Place 88 | # this in another action so that the load will be scheduled after the prior 89 | # issued fs triggers have completed. 90 | trigger load_system_props_action 91 | 92 | # Load properties, Android 6.0+, vendor init lives here 93 | trigger load_persist_props_action 94 | 95 | # Remove a file to wake up anything waiting for firmware 96 | trigger firmware_mounts_complete 97 | 98 | trigger early-boot 99 | trigger boot 100 | 101 | start logd 102 | 103 | on property:sys.powerctl=* 104 | powerctl ${sys.powerctl} 105 | 106 | service ueventd /system/bin/ueventd 107 | critical 108 | seclabel u:r:ueventd:s0 109 | 110 | service adbd /system/bin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery 111 | class core 112 | disabled 113 | socket adbd seqpacket 660 system system 114 | seclabel u:r:adbd:s0 115 | 116 | # Always start adbd on userdebug and eng builds 117 | on property:ro.debuggable=1 118 | #write /sys/class/android_usb/android0/enable 1 119 | #start adbd 120 | setprop service.adb.root 1 121 | 122 | service fastbootd /system/bin/fastbootd 123 | disabled 124 | group system 125 | seclabel u:r:fastbootd:s0 126 | 127 | # Restart adbd so it can run as root 128 | on property:service.adb.root=1 129 | restart adbd 130 | 131 | # Always start adbd on userdebug and eng builds 132 | on fs && property:ro.debuggable=1 133 | setprop sys.usb.config adb 134 | 135 | on fs 136 | mount configfs none /config 137 | mkdir /config/usb_gadget/g1 0770 shell shell 138 | mkdir /config/usb_gadget/g1/strings/0x409 0770 shell shell 139 | write /config/usb_gadget/g1/bcdDevice 0x0223 140 | write /config/usb_gadget/g1/bcdUSB 0x0200 141 | write /config/usb_gadget/g1/idVendor 0x18d1 142 | write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno} 143 | write /config/usb_gadget/g1/strings/0x409/manufacturer "Raspberry" 144 | write /config/usb_gadget/g1/strings/0x409/product "Pi 4" 145 | mkdir /config/usb_gadget/g1/functions/ffs.adb 146 | mkdir /config/usb_gadget/g1/functions/mtp.gs0 147 | mkdir /config/usb_gadget/g1/configs/b.1 0770 shell shell 148 | mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell 149 | write /config/usb_gadget/g1/configs/b.1/MaxPower 500 150 | mkdir /dev/usb-ffs 0775 shell shell 151 | mkdir /dev/usb-ffs/adb 0770 shell shell 152 | mkdir /dev/usb-ffs/mtp 0770 mtp mtp 153 | mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000 154 | mount functionfs mtp /dev/usb-ffs/mtp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1 155 | setprop sys.usb.mtp.device_type 3 156 | setprop sys.usb.configfs 1 157 | symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1 158 | 159 | on property:sys.usb.config=adb 160 | start adbd 161 | 162 | on property:sys.usb.config=fastboot 163 | start fastbootd 164 | 165 | on property:sys.usb.config=none && property:sys.usb.configfs=0 166 | stop adbd 167 | stop fastboot 168 | write /sys/class/android_usb/android0/enable 0 169 | setprop sys.usb.state ${sys.usb.config} 170 | 171 | on property:sys.usb.config=adb && property:sys.usb.configfs=0 172 | write /sys/class/android_usb/android0/idProduct D001 173 | write /sys/class/android_usb/android0/functions adb 174 | write /sys/class/android_usb/android0/enable 1 175 | setprop sys.usb.state ${sys.usb.config} 176 | 177 | on property:sys.usb.config=sideload && property:sys.usb.configfs=0 178 | write /sys/class/android_usb/android0/idProduct D001 179 | write /sys/class/android_usb/android0/functions adb 180 | write /sys/class/android_usb/android0/enable 1 181 | setprop sys.usb.state ${sys.usb.config} 182 | 183 | on property:sys.usb.config=fastboot && property:sys.usb.configfs=0 184 | write /sys/class/android_usb/android0/idProduct 4EE0 185 | write /sys/class/android_usb/android0/functions fastboot 186 | write /sys/class/android_usb/android0/enable 1 187 | setprop sys.usb.state ${sys.usb.config} 188 | 189 | # Configfs triggers 190 | on property:sys.usb.config=none && property:sys.usb.configfs=1 191 | write /config/usb_gadget/g1/UDC "none" 192 | stop adbd 193 | stop fastbootd 194 | setprop sys.usb.ffs.ready 0 195 | rm /config/usb_gadget/g1/configs/b.1/f1 196 | setprop sys.usb.state ${sys.usb.config} 197 | 198 | on property:sys.usb.config=sideload && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 199 | write /config/usb_gadget/g1/idProduct 0xD001 200 | write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb" 201 | symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1 202 | write /config/usb_gadget/g1/UDC ${sys.usb.controller} 203 | setprop sys.usb.state ${sys.usb.config} 204 | 205 | on property:sys.usb.config=adb && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 206 | write /config/usb_gadget/g1/idProduct 0xD001 207 | write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb" 208 | symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1 209 | write /config/usb_gadget/g1/UDC ${sys.usb.controller} 210 | setprop sys.usb.state ${sys.usb.config} 211 | 212 | on property:sys.usb.config=fastboot && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 213 | write /config/usb_gadget/g1/idProduct 0x4EE0 214 | write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "fastboot" 215 | symlink /config/usb_gadget/g1/functions/ffs.fastboot /config/usb_gadget/g1/configs/b.1/f1 216 | write /config/usb_gadget/g1/UDC ${sys.usb.controller} 217 | setprop sys.usb.state ${sys.usb.config} 218 | -------------------------------------------------------------------------------- /overlay/packages/apps/Launcher3/quickstep/res/xml/device_profiles.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 30 | 31 | 38 | 39 | 46 | 47 | 48 | 58 | 59 | 66 | 67 | 74 | 75 | 76 | 86 | 87 | 94 | 95 | 102 | 103 | 104 | 114 | 115 | 122 | 123 | 130 | 131 | 132 | 142 | 143 | 150 | 151 | 158 | 159 | 160 | 170 | 171 | 178 | 179 | 186 | 187 | 188 | 198 | 199 | 206 | 207 | 214 | 215 | 216 | -------------------------------------------------------------------------------- /gpio/src/gpiosetd.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: LGPL-2.1-or-later 2 | /* 3 | * This file is part of libgpiod. 4 | * 5 | * Copyright (C) 2017-2018 Bartosz Golaszewski 6 | */ 7 | 8 | #include 9 | #include "tools-common.h" 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | static const struct option longopts[] = { 29 | { "help", no_argument, NULL, 'h' }, 30 | { "version", no_argument, NULL, 'v' }, 31 | { "active-low", no_argument, NULL, 'l' }, 32 | { "mode", required_argument, NULL, 'm' }, 33 | { "sec", required_argument, NULL, 's' }, 34 | { "usec", required_argument, NULL, 'u' }, 35 | { "background", no_argument, NULL, 'b' }, 36 | { "debug", no_argument, NULL, 'd' }, 37 | { GETOPT_NULL_LONGOPT }, 38 | }; 39 | 40 | static const char *const shortopts = "+hvlm:s:u:b:d"; 41 | 42 | static void print_help(void) 43 | { 44 | printf("Usage: gpioset [OPTIONS] = = ...\n"); 45 | printf("Set GPIO line values of a GPIO chip\n"); 46 | printf("\n"); 47 | printf("Options:\n"); 48 | printf(" -h, --help:\t\tdisplay this message and exit\n"); 49 | printf(" -v, --version:\tdisplay the version and exit\n"); 50 | printf(" -l, --active-low:\tset the line active state to low\n"); 51 | printf(" -m, --mode=[exit|wait|time|signal] (defaults to 'exit'):\n"); 52 | printf(" tell the program what to do after setting values\n"); 53 | printf(" -s, --sec=SEC:\tspecify the number of seconds to wait (only valid for --mode=time)\n"); 54 | printf(" -u, --usec=USEC:\tspecify the number of microseconds to wait (only valid for --mode=time)\n"); 55 | printf(" -b, --background:\tafter setting values: detach from the controlling terminal\n"); 56 | printf(" -d, --debug:\tlog all the things in logcat\n"); 57 | printf("\n"); 58 | printf("Modes:\n"); 59 | printf(" exit:\t\tset values and exit immediately\n"); 60 | printf(" wait:\t\tset values and wait for user to press ENTER\n"); 61 | printf(" time:\t\tset values and sleep for a specified amount of time\n"); 62 | printf(" signal:\tset values and wait for SIGINT or SIGTERM\n"); 63 | } 64 | 65 | struct callback_data { 66 | /* Replace with a union once we have more modes using callback data. */ 67 | struct timeval tv; 68 | bool daemonize; 69 | }; 70 | 71 | static bool debug; 72 | 73 | static void maybe_daemonize(bool daemonize) 74 | { 75 | int status; 76 | 77 | if (daemonize) { 78 | status = daemon(0, 0); 79 | if (status < 0) 80 | die("unable to daemonize: %s", strerror(errno)); 81 | } 82 | } 83 | 84 | static void wait_enter(void *data GPIOD_UNUSED) 85 | { 86 | getchar(); 87 | } 88 | 89 | static void wait_time(void *data) 90 | { 91 | struct callback_data *cbdata = (callback_data *)data; 92 | 93 | maybe_daemonize(cbdata->daemonize); 94 | select(0, NULL, NULL, NULL, &cbdata->tv); 95 | } 96 | 97 | static void wait_signal(void *data) 98 | { 99 | struct callback_data *cbdata = (callback_data *)data; 100 | int sigfd, status; 101 | struct pollfd pfd; 102 | sigset_t sigmask; 103 | 104 | sigemptyset(&sigmask); 105 | sigaddset(&sigmask, SIGTERM); 106 | sigaddset(&sigmask, SIGINT); 107 | 108 | status = sigprocmask(SIG_BLOCK, &sigmask, NULL); 109 | if (status < 0) 110 | die("error blocking signals: %s", strerror(errno)); 111 | 112 | sigfd = signalfd(-1, &sigmask, 0); 113 | if (sigfd < 0) 114 | die("error creating signalfd: %s", strerror(errno)); 115 | 116 | memset(&pfd, 0, sizeof(pfd)); 117 | pfd.fd = sigfd; 118 | pfd.events = POLLIN | POLLPRI; 119 | 120 | maybe_daemonize(cbdata->daemonize); 121 | 122 | for (;;) { 123 | status = poll(&pfd, 1, 1000 /* one second */); 124 | if (status < 0) 125 | die("error polling for signals: %s", strerror(errno)); 126 | else if (status > 0) 127 | break; 128 | } 129 | 130 | /* 131 | * Don't bother reading siginfo - it's enough to know that we 132 | * received any signal. 133 | */ 134 | close(sigfd); 135 | } 136 | 137 | enum { 138 | MODE_EXIT = 0, 139 | MODE_WAIT, 140 | MODE_TIME, 141 | MODE_SIGNAL, 142 | }; 143 | 144 | struct mode_mapping { 145 | int id; 146 | const char *name; 147 | gpiod_ctxless_set_value_cb callback; 148 | }; 149 | 150 | static const struct mode_mapping modes[] = { 151 | [MODE_EXIT] = { 152 | .id = MODE_EXIT, 153 | .name = "exit", 154 | .callback = NULL, 155 | }, 156 | [MODE_WAIT] = { 157 | .id = MODE_WAIT, 158 | .name = "wait", 159 | .callback = wait_enter, 160 | }, 161 | [MODE_TIME] = { 162 | .id = MODE_TIME, 163 | .name = "time", 164 | .callback = wait_time, 165 | }, 166 | [MODE_SIGNAL] = { 167 | .id = MODE_SIGNAL, 168 | .name = "signal", 169 | .callback = wait_signal, 170 | }, 171 | }; 172 | 173 | static const struct mode_mapping *parse_mode(const char *mode) 174 | { 175 | unsigned int i; 176 | 177 | for (i = 0; i < ARRAY_SIZE(modes); i++) 178 | if (strcmp(mode, modes[i].name) == 0) 179 | return &modes[i]; 180 | 181 | return NULL; 182 | } 183 | 184 | int main(int argc, char **argv) 185 | { 186 | const struct mode_mapping *mode = &modes[MODE_EXIT]; 187 | unsigned int *offsets, num_lines, i; 188 | int *values, status, optc, opti; 189 | struct callback_data cbdata; 190 | bool active_low = false; 191 | char *device, *end; 192 | std::vector argvList {}; 193 | std::vector argvStrings {}; 194 | 195 | int argcList = 0; 196 | int argvIndex = 0; 197 | 198 | memset(&cbdata, 0, sizeof(cbdata)); 199 | 200 | // split by space if needed when args are passed in quotes 201 | for (i = 0; i < argc; i++) { 202 | std::string buf; 203 | std::stringstream ss(argv[i]); 204 | 205 | while (ss >> buf) { 206 | argvStrings.push_back(buf); 207 | } 208 | } 209 | 210 | for (i = 0; i < argvStrings.size(); i++) { 211 | argvList.push_back(const_cast(argvStrings[i].c_str())); 212 | } 213 | argcList = argvList.size(); 214 | 215 | // signal is default for us 216 | mode = &modes[3]; 217 | 218 | for (;;) { 219 | optc = getopt_long(argcList, &argvList[0], shortopts, longopts, &opti); 220 | if (optc < 0) 221 | break; 222 | 223 | switch (optc) { 224 | case 'h': 225 | print_help(); 226 | return EXIT_SUCCESS; 227 | case 'v': 228 | print_version(); 229 | return EXIT_SUCCESS; 230 | case 'l': 231 | active_low = true; 232 | break; 233 | case 'm': 234 | mode = parse_mode(optarg); 235 | if (!mode) 236 | die("invalid mode: %s", optarg); 237 | break; 238 | case 's': 239 | cbdata.tv.tv_sec = strtoul(optarg, &end, 10); 240 | if (*end != '\0') 241 | die("invalid time value in seconds: %s", optarg); 242 | break; 243 | case 'u': 244 | cbdata.tv.tv_usec = strtoul(optarg, &end, 10); 245 | if (*end != '\0') 246 | die("invalid time value in microseconds: %s", 247 | optarg); 248 | break; 249 | case 'b': 250 | cbdata.daemonize = true; 251 | break; 252 | case 'd': 253 | debug = true; 254 | break; 255 | case '?': 256 | die("try gpioset --help"); 257 | default: 258 | abort(); 259 | } 260 | } 261 | 262 | if (debug) { 263 | for (i = 0; i < argcList; i++) { 264 | ALOGI("argv[%d] = %s", i, argvList[i]); 265 | } 266 | } 267 | 268 | argvIndex += optind; 269 | 270 | if (mode->id != MODE_TIME && (cbdata.tv.tv_sec || cbdata.tv.tv_usec)) 271 | die_logd("can't specify wait time in this mode"); 272 | 273 | if (mode->id != MODE_SIGNAL && 274 | mode->id != MODE_TIME && 275 | cbdata.daemonize) 276 | die_logd("can't daemonize in this mode"); 277 | 278 | if (argcList - argvIndex < 1) 279 | die_logd("gpiochip must be specified"); 280 | 281 | if (argcList - argvIndex < 2) 282 | die_logd("at least one GPIO line offset to value mapping must be specified"); 283 | 284 | device = argvList[argvIndex]; 285 | 286 | num_lines = argcList - argvIndex - 1; 287 | 288 | if (debug) ALOGI("device = %s num_lines = %d", device, num_lines); 289 | 290 | offsets = (unsigned int *)malloc(sizeof(*offsets) * num_lines); 291 | values = (int *)malloc(sizeof(*values) * num_lines); 292 | if (!values || !offsets) 293 | die_logd("out of memory"); 294 | 295 | for (i = 0; i < num_lines; i++) { 296 | int offsetsIndex = argvIndex + 1 + i; 297 | status = sscanf(argvList[offsetsIndex], "%u=%d", &offsets[i], &values[i]); 298 | if (status != 2) 299 | die_logd("invalid offset<->value mapping: %s", argvList[offsetsIndex]); 300 | 301 | if (values[i] != 0 && values[i] != 1) 302 | die_logd("value must be 0 or 1: %s", argvList[offsetsIndex]); 303 | 304 | if (offsets[i] > INT_MAX) 305 | die_logd("invalid offset: %s", argvList[offsetsIndex]); 306 | } 307 | 308 | if (debug) { 309 | for (i = 0; i < num_lines; i++) { 310 | ALOGI("offset %d = value %d", offsets[i], values[i]); 311 | } 312 | } 313 | 314 | status = gpiod_ctxless_set_value_multiple(device, offsets, values, 315 | num_lines, active_low, 316 | "gpioset", mode->callback, 317 | &cbdata); 318 | if (status < 0) 319 | die_perror("error setting the GPIO line values"); 320 | 321 | free(offsets); 322 | free(values); 323 | 324 | return EXIT_SUCCESS; 325 | } 326 | --------------------------------------------------------------------------------