diff --git a/Android.bp b/Android.bp new file mode 100644 index 00000000..6efaac11 --- /dev/null +++ b/Android.bp @@ -0,0 +1,6 @@ +subdirs = [ + "vr", + "vibrator", + "wifi_offload", + "usb", +] diff --git a/Android.mk b/Android.mk new file mode 100644 index 00000000..9d0ff710 --- /dev/null +++ b/Android.mk @@ -0,0 +1,22 @@ +# +# Copyright 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +LOCAL_PATH := $(call my-dir) + +ifeq ($(USES_DEVICE_GOOGLE_WAHOO),true) + subdir_makefiles=$(call first-makefiles-under,$(LOCAL_PATH)) + $(foreach mk,$(subdir_makefiles),$(info including $(mk) ...)$(eval include $(mk))) +endif diff --git a/BoardConfig.mk b/BoardConfig.mk new file mode 100644 index 00000000..fea92c99 --- /dev/null +++ b/BoardConfig.mk @@ -0,0 +1,168 @@ +# +# Copyright (C) 2016 The Android Open-Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +TARGET_BOARD_PLATFORM := msm8998 + +TARGET_ARCH := arm64 +TARGET_ARCH_VARIANT := armv8-a +TARGET_CPU_ABI := arm64-v8a +TARGET_CPU_ABI2 := +TARGET_CPU_VARIANT := cortex-a73 + +TARGET_2ND_ARCH := arm +TARGET_2ND_ARCH_VARIANT := armv7-a-neon +TARGET_2ND_CPU_ABI := armeabi-v7a +TARGET_2ND_CPU_ABI2 := armeabi +TARGET_2ND_CPU_VARIANT := cortex-a73 + +BOARD_KERNEL_CMDLINE += androidboot.hardware=$(TARGET_BOOTLOADER_BOARD_NAME) androidboot.console=ttyMSM0 lpm_levels.sleep_disabled=1 +BOARD_KERNEL_CMDLINE += user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 +BOARD_KERNEL_CMDLINE += service_locator.enable=1 +BOARD_KERNEL_CMDLINE += swiotlb=2048 +BOARD_KERNEL_CMDLINE += firmware_class.path=/vendor/firmware +BOARD_KERNEL_CMDLINE += loop.max_part=7 + +BOARD_KERNEL_BASE := 0x00000000 +BOARD_KERNEL_PAGESIZE := 4096 +ifeq ($(filter-out walleye_kasan, muskie_kasan, $(TARGET_PRODUCT)),) +BOARD_KERNEL_OFFSET := 0x80000 +BOARD_KERNEL_TAGS_OFFSET := 0x02500000 +BOARD_RAMDISK_OFFSET := 0x02700000 +BOARD_MKBOOTIMG_ARGS := --kernel_offset $(BOARD_KERNEL_OFFSET) --ramdisk_offset $(BOARD_RAMDISK_OFFSET) --tags_offset $(BOARD_KERNEL_TAGS_OFFSET) +else +BOARD_KERNEL_TAGS_OFFSET := 0x01E00000 +BOARD_RAMDISK_OFFSET := 0x02000000 +endif + +TARGET_NO_BOOTLOADER ?= true +TARGET_NO_KERNEL := false +TARGET_NO_RECOVERY := true +BOARD_USES_RECOVERY_AS_BOOT := true +BOARD_BUILD_SYSTEM_ROOT_IMAGE := true + +# Partitions (listed in the file) to be wiped under recovery. +TARGET_RECOVERY_WIPE := device/google/wahoo/recovery.wipe +TARGET_RECOVERY_FSTAB := device/google/wahoo/fstab.hardware + +BOARD_AVB_ENABLE := true + +BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2684354560 +BOARD_SYSTEMIMAGE_JOURNAL_SIZE := 0 +BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT := 4096 +TARGET_USERIMAGES_USE_EXT4 := true +BOARD_USERDATAIMAGE_PARTITION_SIZE := 26503790080 +BOARD_PERSISTIMAGE_PARTITION_SIZE := 33554432 +BOARD_PERSISTIMAGE_FILE_SYSTEM_TYPE := ext4 +BOARD_FLASH_BLOCK_SIZE := 131072 + +# DTBO partition definitions +BOARD_PREBUILT_DTBOIMAGE := device/google/wahoo-kernel/dtbo.img +BOARD_DTBOIMG_PARTITION_SIZE := 8388608 + +ENABLE_CPUSETS := true + +TARGET_COPY_OUT_VENDOR := vendor + +# Install odex files into the other system image +BOARD_USES_SYSTEM_OTHER_ODEX := true + +BOARD_ROOT_EXTRA_FOLDERS := persist firmware metadata + +BOARD_SEPOLICY_DIRS += device/google/wahoo/sepolicy/vendor +BOARD_PLAT_PUBLIC_SEPOLICY_DIR := device/google/wahoo/sepolicy/public +BOARD_PLAT_PRIVATE_SEPOLICY_DIR := device/google/wahoo/sepolicy/private +BOARD_SEPOLICY_DIRS += device/google/wahoo/sepolicy/verizon + +TARGET_ANDROID_FILESYSTEM_CONFIG_H := device/google/wahoo/android_filesystem_config.h + +QCOM_BOARD_PLATFORMS += msm8998 +BOARD_HAVE_BLUETOOTH_QCOM := true +BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/google/wahoo/bluetooth + +# Enable dex pre-opt to speed up initial boot +ifeq ($(HOST_OS),linux) + ifeq ($(WITH_DEXPREOPT),) + WITH_DEXPREOPT := true + WITH_DEXPREOPT_PIC := true + ifneq ($(TARGET_BUILD_VARIANT),user) + # Retain classes.dex in APK's for non-user builds + DEX_PREOPT_DEFAULT := nostripping + endif + endif +endif + +# Camera +TARGET_USES_AOSP := true +BOARD_QTI_CAMERA_32BIT_ONLY := true +CAMERA_DAEMON_NOT_PRESENT := true +TARGET_USES_ION := true +TARGET_USES_EASEL := true + +# GPS +TARGET_NO_RPC := true +BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE := default +BOARD_VENDOR_QCOM_LOC_PDK_FEATURE_SET := true + +# RenderScript +OVERRIDE_RS_DRIVER := libRSDriver_adreno.so + +# wlan +BOARD_WLAN_DEVICE := qcwcn +BOARD_WPA_SUPPLICANT_DRIVER := NL80211 +BOARD_HOSTAPD_DRIVER := NL80211 +WIFI_DRIVER_DEFAULT := qca_cld3 +WPA_SUPPLICANT_VERSION := VER_0_8_X +WIFI_DRIVER_FW_PATH_STA := "sta" +WIFI_DRIVER_FW_PATH_AP := "ap" +WIFI_DRIVER_FW_PATH_P2P := "p2p" +BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE) +BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE) +WIFI_HIDL_FEATURE_AWARE := true + +# Audio +BOARD_USES_ALSA_AUDIO := true +USE_XML_AUDIO_POLICY_CONF := 1 +AUDIO_FEATURE_ENABLED_MULTI_VOICE_SESSIONS := true +AUDIO_FEATURE_ENABLED_SND_MONITOR := true +AUDIO_FEATURE_ENABLED_USB_TUNNEL := true +BOARD_ROOT_EXTRA_SYMLINKS := /vendor/lib/dsp:/dsp + +# Include whaoo modules +USES_DEVICE_GOOGLE_WAHOO := true + +# Graphics +TARGET_USES_GRALLOC1 := true +TARGET_USES_HWC2 := true + +VSYNC_EVENT_PHASE_OFFSET_NS := 2000000 +SF_VSYNC_EVENT_PHASE_OFFSET_NS := 6000000 + +# Display +TARGET_HAS_WIDE_COLOR_DISPLAY := true +TARGET_HAS_HDR_DISPLAY := false +TARGET_USES_COLOR_METADATA := true + +# Charger Mode +BOARD_CHARGER_ENABLE_SUSPEND := true + +# Vendor Interface Manifest +DEVICE_MANIFEST_FILE := device/google/wahoo/manifest.xml +DEVICE_MATRIX_FILE := device/google/wahoo/compatibility_matrix.xml + +BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true + +# Use mke2fs to create ext4 images +TARGET_USES_MKE2FS := true diff --git a/CleanSpec.mk b/CleanSpec.mk new file mode 100644 index 00000000..af32e90a --- /dev/null +++ b/CleanSpec.mk @@ -0,0 +1,145 @@ +# Copyright 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# If you don't need to do a full clean build but would like to touch +# a file or delete some intermediate files, add a clean step to the end +# of the list. These steps will only be run once, if they haven't been +# run before. +# +# E.g.: +# $(call add-clean-step, touch -c external/sqlite/sqlite3.h) +# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) +# +# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with +# files that are missing or have been moved. +# +# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. +# Use $(OUT_DIR) to refer to the "out" directory. +# +# If you need to re-do something that's already mentioned, just copy +# the command and add it to the bottom of the list. E.g., if a change +# that you made last week required touching a file and a change you +# made today requires touching the same file, just copy the old +# touch step and add it to the end of the list. +# +# ************************************************ +# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST +# ************************************************ + +# For example: +#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) +#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) +#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) +#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/init.power.sh) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/init.radio.sh) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/init.$(PRODUCT_HARDWARE).rc) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/init.wahoo.usb.rc) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/init.$(PRODUCT_HARDWARE).diag.rc) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/ueventd.$(PRODUCT_HARDWARE).rc) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.camera.flash-autofocus.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.camera.front.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.camera.full.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.camera.raw.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.bluetooth.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.bluetooth_le.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.sensor.accelerometer.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.sensor.compass.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.sensor.gyroscope.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.sensor.light.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.sensor.proximity.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.sensor.barometer.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.sensor.stepcounter.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.sensor.stepdetector.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.sensor.hifi_sensors.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.location.gps.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.telephony.gsm.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.telephony.cdma.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.touchscreen.multitouch.jazzhand.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.wifi.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.wifi.direct.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.wifi.passpoint.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.software.sip.voip.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.usb.accessory.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.usb.host.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.opengles.aep.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.nfc.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.nfc.hce.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.nfc.hcef.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.vr.headtracking.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.vr.high_performance.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.vulkan.level.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/permissions/android.hardware.vulkan.version.xml) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/wifi/wpa_supplicant_overlay.conf) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/wifi/p2p_supplicant_overlay.conf) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/wifi/wifi_concurrency_cfg.txt) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/hw/lights.$(PRODUCT_HARDWARE).so) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib64/hw/lights.$(PRODUCT_HARDWARE).so) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/sec_config) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/audio_policy_configuration.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/a2dp_audio_policy_configuration.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/usb_audio_policy_configuration.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/r_submix_audio_policy_configuration.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/audio_policy_volumes.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/default_volume_tables.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/mixer_paths.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/mixer_paths_tasha.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/mixer_paths_tavil.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/audio_platform_info.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/audio_platform_info_tavil.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/sound_trigger_platform_info.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/sound_trigger_mixer_paths_wcd9340.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/graphite_ipc_platform_info.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/media_codecs.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/media_codecs_performance.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/media_codecs_google_audio.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/media_codecs_google_telephony.xml) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/media_codecs_google_video.xml) + +# Move /system/lib/vndk-sp to /system/lib/vndk-sp-26.1.0 +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/vndk-sp) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib64/vndk-sp) + +# Revert: Move /system/lib/vndk-sp to /system/lib/vndk-sp-26.1.0 +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/vndk-sp-*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib64/vndk-sp-*) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/lowi.conf) + +# Vibrator HAL 1.0 +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.vibrator@1.0-service.wahoo.rc) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.vibrator@1.0-service.wahoo) + +# Broadcast Radio HAL impl 1.0 +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib/hw/android.hardware.broadcastradio@1.0-impl.so) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib64/hw/android.hardware.broadcastradio@1.0-impl.so) + +# Revert /system/lib[64]/vndk-sp/libz.so +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libz.vndk-sp_*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/lib/vndk-sp/libz.so) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/lib64/vndk-sp/libz.so) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/vndk-sp/libz.so) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib64/vndk-sp/libz.so) + +# Remove eSIM OTA image +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/EuiccGoogle/esim.img) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/EuiccGoogle/esim2.img) diff --git a/android_filesystem_config.h b/android_filesystem_config.h new file mode 100644 index 00000000..775a7171 --- /dev/null +++ b/android_filesystem_config.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* This file is used to define the properties of the filesystem +** images generated by build tools (mkbootfs and mkyaffs2image) and +** by the device side of adb. +*/ + +#include + +static const struct fs_path_config android_device_dirs[] = { + { 00771, AID_SYSTEM, AID_SYSTEM, 0, "bt_firmware"}, +}; + +/* Rules for files. +** These rules are applied based on "first match", so they +** should start with the most specific path and work their +** way up to the root. Prefixes ending in * denotes wildcard +** and will allow partial matches. +*/ +static const struct fs_path_config android_device_files[] = { + { 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "vendor/bin/pm-service" }, + { 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "vendor/bin/cnss-daemon"}, + { 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE), "vendor/bin/imsdatadaemon" }, + { 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_NET_BIND_SERVICE) + | (1ULL << CAP_BLOCK_SUSPEND), "vendor/bin/cnd" }, + { 00755, AID_SYSTEM, AID_RADIO, (1ULL << CAP_NET_BIND_SERVICE), "vendor/bin/ims_rtp_daemon" }, + { 00755, AID_SYSTEM, AID_SYSTEM, (1ULL << CAP_SYS_NICE) | (1ULL << CAP_BLOCK_SUSPEND), "vendor/bin/wcnss_filter" }, +#ifdef NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS + { 00000, AID_ROOT, AID_ROOT, 0, "system/etc/fs_config_dirs" }, +#endif +}; diff --git a/apns-full-conf.xml b/apns-full-conf.xml new file mode 100644 index 00000000..e75d67c0 --- /dev/null +++ b/apns-full-conf.xml @@ -0,0 +1,32855 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/audio_policy_configuration.xml b/audio_policy_configuration.xml new file mode 100644 index 00000000..d74d187d --- /dev/null +++ b/audio_policy_configuration.xml @@ -0,0 +1,201 @@ + + + + + + + + + + Speaker + Speaker Safe + Earpiece + Telephony Tx + Built-In Mic + Built-In Back Mic + Telephony Rx + + Speaker + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bluetooth/bdroid_buildcfg.h b/bluetooth/bdroid_buildcfg.h new file mode 100644 index 00000000..63515b1f --- /dev/null +++ b/bluetooth/bdroid_buildcfg.h @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2013, The Linux Foundation. All rights reserved. + * Not a Contribution, Apache license notifications and license are retained + * for attribution purposes only. + * + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _BDROID_BUILDCFG_H +#define _BDROID_BUILDCFG_H + +// Wide-band speech support +#define BTM_WBS_INCLUDED TRUE +#define BTIF_HF_WBS_PREFERRED TRUE + +// Google VSC spec support +#define BLE_VND_INCLUDED TRUE + +// QCOM power management workaround +#define BT_CLEAN_TURN_ON_DISABLED TRUE + +#endif diff --git a/compatibility_matrix.xml b/compatibility_matrix.xml new file mode 100644 index 00000000..3082485c --- /dev/null +++ b/compatibility_matrix.xml @@ -0,0 +1,59 @@ + + + android.frameworks.schedulerservice + 1.0 + + ISchedulingPolicyService + default + + + + android.frameworks.sensorservice + 1.0 + + ISensorManager + default + + + + android.hidl.allocator + 1.0 + + IAllocator + ashmem + + + + android.hidl.manager + 1.0 + + IServiceManager + default + + + + android.hidl.memory + 1.0 + + IMapper + ashmem + + + + android.hidl.token + 1.0 + + ITokenManager + default + + + + android.system.wifi.keystore + 1.0 + + IKeystore + default + + + + diff --git a/default-permissions.xml b/default-permissions.xml new file mode 100644 index 00000000..92b0613b --- /dev/null +++ b/default-permissions.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/device.mk b/device.mk new file mode 100755 index 00000000..61184414 --- /dev/null +++ b/device.mk @@ -0,0 +1,608 @@ +# +# Copyright (C) 2016 The Android Open-Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +PRODUCT_PROPERTY_OVERRIDES += \ + keyguard.no_require_sim=true + +PRODUCT_COPY_FILES += \ + device/google/wahoo/default-permissions.xml:$(TARGET_COPY_OUT_VENDOR)/etc/default-permissions/default-permissions.xml \ + frameworks/native/data/etc/handheld_core_hardware.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/handheld_core_hardware.xml + +# Enforce privapp-permissions whitelist +PRODUCT_PROPERTY_OVERRIDES += \ + ro.control_privapp_permissions=enforce + +PRODUCT_PACKAGES += \ + messaging + +LOCAL_PATH := device/google/wahoo + +SRC_MEDIA_HAL_DIR := hardware/qcom/media/msm8998 +SRC_DISPLAY_HAL_DIR := hardware/qcom/display/msm8998 +SRC_CAMERA_HAL_DIR := hardware/qcom/camera/msm8998 + +TARGET_SYSTEM_PROP := $(LOCAL_PATH)/system.prop + +# Get kernel-headers +$(call inherit-product, hardware/qcom/msm8998/msm8998.mk) + +$(call inherit-product, device/google/wahoo/utils.mk) + +ifeq ($(TARGET_PREBUILT_KERNEL),) + LOCAL_KERNEL := device/google/wahoo-kernel/Image.lz4-dtb +else + LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL) +endif + +PRODUCT_CHARACTERISTICS := nosdcard +PRODUCT_SHIPPING_API_LEVEL := 26 +PRODUCT_COMPATIBILITY_MATRIX_LEVEL_OVERRIDE := 27 + +DEVICE_PACKAGE_OVERLAYS += $(LOCAL_PATH)/overlay + +PRODUCT_COPY_FILES += \ + $(LOCAL_KERNEL):kernel \ + $(LOCAL_PATH)/init.recovery.hardware.rc:root/init.recovery.$(PRODUCT_HARDWARE).rc \ + $(LOCAL_PATH)/init.hardware.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.$(PRODUCT_HARDWARE).rc \ + $(LOCAL_PATH)/init.hardware.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.wahoo.usb.rc \ + $(LOCAL_PATH)/ueventd.hardware.rc:$(TARGET_COPY_OUT_VENDOR)/ueventd.rc \ + $(LOCAL_PATH)/init.elabel.sh:$(TARGET_COPY_OUT_SYSTEM)/bin/init.elabel.sh \ + $(LOCAL_PATH)/init.power.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.power.sh \ + $(LOCAL_PATH)/init.radio.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.radio.sh \ + $(LOCAL_PATH)/uinput-fpc.kl:system/usr/keylayout/uinput-fpc.kl \ + $(LOCAL_PATH)/uinput-fpc.idc:system/usr/idc/uinput-fpc.idc \ + $(LOCAL_PATH)/init.qcom.devstart.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.qcom.devstart.sh \ + $(LOCAL_PATH)/init.qcom.ipastart.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.qcom.ipastart.sh \ + $(LOCAL_PATH)/init.insmod.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.insmod.sh \ + $(LOCAL_PATH)/init.ramoops.sh:$(TARGET_COPY_OUT_SYSTEM)/bin/init.ramoops.sh + +ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) + PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/init.hardware.diag.rc.userdebug:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.$(PRODUCT_HARDWARE).diag.rc +else + PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/init.hardware.diag.rc.user:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.$(PRODUCT_HARDWARE).diag.rc +endif + +MSM_VIDC_TARGET_LIST := msm8998 # Get the color format from kernel headers +MASTER_SIDE_CP_TARGET_LIST := msm8998 # ION specific settings + +# A/B support +PRODUCT_PACKAGES += \ + otapreopt_script \ + cppreopts.sh \ + update_engine \ + update_verifier + +PRODUCT_PACKAGES += \ + bootctrl.msm8998 + +PRODUCT_PROPERTY_OVERRIDES += \ + ro.cp_system_other_odex=1 + +AB_OTA_UPDATER := true + +AB_OTA_PARTITIONS += \ + boot \ + system \ + vbmeta \ + dtbo + +AB_OTA_POSTINSTALL_CONFIG += \ + RUN_POSTINSTALL_system=true \ + POSTINSTALL_PATH_system=system/bin/otapreopt_script \ + FILESYSTEM_TYPE_system=ext4 \ + POSTINSTALL_OPTIONAL_system=true + +# Enable update engine sideloading by including the static version of the +# boot_control HAL and its dependencies. +PRODUCT_STATIC_BOOT_CONTROL_HAL := \ + bootctrl.msm8998 \ + libgptutils \ + libz \ + libcutils + +PRODUCT_PACKAGES += \ + update_engine_sideload + +# The following modules are included in debuggable builds only. +PRODUCT_PACKAGES_DEBUG += \ + bootctl \ + update_engine_client + +PRODUCT_COPY_FILES += \ + frameworks/native/data/etc/android.hardware.camera.flash-autofocus.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.flash-autofocus.xml \ + frameworks/native/data/etc/android.hardware.camera.front.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.front.xml \ + frameworks/native/data/etc/android.hardware.camera.full.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.full.xml\ + frameworks/native/data/etc/android.hardware.camera.raw.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.raw.xml\ + frameworks/native/data/etc/android.hardware.bluetooth.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth.xml \ + frameworks/native/data/etc/android.hardware.bluetooth_le.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth_le.xml \ + frameworks/native/data/etc/android.hardware.sensor.accelerometer.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.accelerometer.xml \ + frameworks/native/data/etc/android.hardware.sensor.compass.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.compass.xml \ + frameworks/native/data/etc/android.hardware.sensor.gyroscope.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.gyroscope.xml \ + frameworks/native/data/etc/android.hardware.sensor.light.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.light.xml \ + frameworks/native/data/etc/android.hardware.sensor.proximity.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.proximity.xml \ + frameworks/native/data/etc/android.hardware.sensor.barometer.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.barometer.xml \ + frameworks/native/data/etc/android.hardware.sensor.stepcounter.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.stepcounter.xml \ + frameworks/native/data/etc/android.hardware.sensor.stepdetector.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.stepdetector.xml \ + frameworks/native/data/etc/android.hardware.sensor.hifi_sensors.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.hifi_sensors.xml \ + frameworks/native/data/etc/android.hardware.location.gps.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.location.gps.xml \ + frameworks/native/data/etc/android.hardware.telephony.gsm.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.telephony.gsm.xml \ + frameworks/native/data/etc/android.hardware.telephony.cdma.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.telephony.cdma.xml \ + frameworks/native/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.touchscreen.multitouch.jazzhand.xml \ + frameworks/native/data/etc/android.hardware.wifi.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.xml \ + frameworks/native/data/etc/android.hardware.wifi.direct.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.direct.xml \ + frameworks/native/data/etc/android.hardware.wifi.aware.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.aware.xml \ + frameworks/native/data/etc/android.hardware.wifi.passpoint.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.passpoint.xml \ + frameworks/native/data/etc/android.software.sip.voip.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.sip.voip.xml \ + frameworks/native/data/etc/android.hardware.usb.accessory.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.accessory.xml \ + frameworks/native/data/etc/android.hardware.usb.host.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.host.xml \ + frameworks/native/data/etc/android.hardware.opengles.aep.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.opengles.aep.xml \ + frameworks/native/data/etc/android.hardware.nfc.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.nfc.xml \ + frameworks/native/data/etc/android.hardware.nfc.hce.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.nfc.hce.xml \ + frameworks/native/data/etc/android.hardware.nfc.hcef.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.nfc.hcef.xml \ + frameworks/native/data/etc/android.hardware.vr.headtracking-0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vr.headtracking.xml \ + frameworks/native/data/etc/android.hardware.vr.high_performance.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vr.high_performance.xml \ + frameworks/native/data/etc/android.hardware.vulkan.level-0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.level.xml \ + frameworks/native/data/etc/android.hardware.vulkan.version-1_0_3.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.version.xml \ + frameworks/native/data/etc/android.hardware.telephony.carrierlock.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.telephony.carrierlock.xml \ + +# power HAL +PRODUCT_PACKAGES += \ + android.hardware.power@1.1-service.wahoo + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/powerhint.xml:$(TARGET_COPY_OUT_VENDOR)/etc/powerhint.xml + +# Audio fluence, ns, aec property, voice and media volume steps +PRODUCT_PROPERTY_OVERRIDES += \ + ro.qc.sdk.audio.fluencetype=fluencepro \ + persist.audio.fluence.voicecall=true \ + persist.audio.fluence.speaker=true \ + persist.audio.fluence.voicecomm=true \ + persist.audio.fluence.voicerec=false \ + ro.config.vc_call_vol_steps=7 \ + ro.config.media_vol_steps=25 + +# graphics +PRODUCT_PROPERTY_OVERRIDES += \ + ro.opengles.version=196610 + +# Enable camera EIS3.0 +PRODUCT_PROPERTY_OVERRIDES += \ + persist.camera.is_type=5 \ + persist.camera.gzoom.at=0 \ + persist.camera.llv.fuse=2 + +# OEM Unlock reporting +PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \ + ro.oem_unlock_supported=1 + +PRODUCT_PROPERTY_OVERRIDES += \ + persist.cne.feature=1 \ + persist.data.iwlan.enable=true \ + persist.radio.RATE_ADAPT_ENABLE=1 \ + persist.radio.ROTATION_ENABLE=1 \ + persist.radio.VT_ENABLE=1 \ + persist.radio.VT_HYBRID_ENABLE=1 \ + persist.radio.apm_sim_not_pwdn=1 \ + persist.radio.custom_ecc=1 \ + persist.radio.data_ltd_sys_ind=1 \ + persist.radio.is_wps_enabled=true \ + persist.radio.videopause.mode=1 \ + persist.radio.sib16_support=1 \ + persist.radio.data_con_rprt=true \ + persist.radio.always_send_plmn=true \ + persist.rcs.supported=1 \ + rild.libpath=/vendor/lib64/libril-qc-qmi-1.so + +# Disable snapshot timer +PRODUCT_PROPERTY_OVERRIDES += \ + persist.radio.snapshot_enabled=0 \ + persist.radio.snapshot_timer=0 + +PRODUCT_PROPERTY_OVERRIDES += \ + ro.vendor.extension_library=libqti-perfd-client.so + +# camera gyro and laser sensor +PRODUCT_PROPERTY_OVERRIDES += \ + persist.camera.gyro.android=20 \ + persist.camera.tof.direct=1 \ + persist.camera.max.previewfps=60 \ + persist.camera.sensor.hdr=2 + +# camera TNR controls +PRODUCT_PROPERTY_OVERRIDES += \ + persist.camera.tnr.video=1 \ + +# WLAN driver configuration files +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/wpa_supplicant_overlay.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/wpa_supplicant_overlay.conf \ + $(LOCAL_PATH)/p2p_supplicant_overlay.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/p2p_supplicant_overlay.conf \ + $(LOCAL_PATH)/wifi_concurrency_cfg.txt:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/wifi_concurrency_cfg.txt + +#ipacm configuration files +PRODUCT_COPY_FILES += \ + hardware/qcom/data/ipacfg-mgr/msm8998/ipacm/src/IPACM_cfg.xml:$(TARGET_COPY_OUT_VENDOR)/etc/IPACM_cfg.xml + +PRODUCT_PACKAGES += \ + hwcomposer.msm8998 \ + android.hardware.graphics.composer@2.1-impl \ + android.hardware.graphics.composer@2.1-service \ + gralloc.msm8998 \ + android.hardware.graphics.allocator@2.0-impl \ + android.hardware.graphics.allocator@2.0-service \ + android.hardware.graphics.mapper@2.0-impl \ + libbt-vendor + +# RenderScript HAL +PRODUCT_PACKAGES += \ + android.hardware.renderscript@1.0-impl + +# Light HAL +PRODUCT_PACKAGES += \ + lights.$(PRODUCT_HARDWARE) \ + android.hardware.light@2.0-impl \ + android.hardware.light@2.0-service + +# eSE applet HALs +PRODUCT_PACKAGES += \ + esed + +# Memtrack HAL +PRODUCT_PACKAGES += \ + memtrack.msm8998 \ + android.hardware.memtrack@1.0-impl \ + android.hardware.memtrack@1.0-service + +# Bluetooth HAL +PRODUCT_PACKAGES += \ + libbt-vendor \ + android.hardware.bluetooth@1.0-impl \ + android.hardware.bluetooth@1.0-service + +# DRM HAL +PRODUCT_PACKAGES += \ + android.hardware.drm@1.0-impl \ + android.hardware.drm@1.0-service \ + android.hardware.drm@1.0-service.widevine + +# NFC packages +PRODUCT_PACKAGES += \ + nfc_nci.$(PRODUCT_HARDWARE) \ + NfcNci \ + Tag \ + android.hardware.nfc@1.0-impl \ + android.hardware.nfc@1.0-service + +PRODUCT_COPY_FILES += \ + device/google/wahoo/nfc/libnfc-brcm.conf:$(TARGET_COPY_OUT_VENDOR)/etc/libnfc-brcm.conf \ + +PRODUCT_PACKAGES += \ + android.hardware.usb@1.1-service.wahoo + +PRODUCT_PACKAGES += \ + libmm-omxcore \ + libOmxCore \ + libstagefrighthw \ + libOmxVdec \ + libOmxVdecHevc \ + libOmxVenc \ + libc2dcolorconvert + +PRODUCT_PACKAGES += \ + android.hardware.camera.provider@2.4-impl \ + android.hardware.camera.provider@2.4-service \ + camera.device@3.2-impl \ + camera.msm8998 \ + libqomx_core \ + libmmjpeg_interface \ + libmmcamera_interface + +PRODUCT_PACKAGES += \ + sensors.$(PRODUCT_HARDWARE) \ + android.hardware.sensors@1.0-impl \ + android.hardware.sensors@1.0-service + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/sensors/hals.conf:vendor/etc/sensors/hals.conf + +# Default permission grant exceptions +PRODUCT_COPY_FILES += \ + device/google/wahoo/default-permissions.xml:$(TARGET_COPY_OUT_VENDOR)/etc/default-permissions/default-permissions.xml + +PRODUCT_PACKAGES += \ + fs_config_dirs \ + fs_config_files + +# Context hub HAL +PRODUCT_PACKAGES += \ + android.hardware.contexthub@1.0-impl.generic \ + android.hardware.contexthub@1.0-service + +# Boot control HAL +PRODUCT_PACKAGES += \ + android.hardware.boot@1.0-impl \ + android.hardware.boot@1.0-service \ + +# Vibrator HAL +PRODUCT_PACKAGES += \ + android.hardware.vibrator@1.1-service.wahoo + +# Thermal packages +PRODUCT_PACKAGES += \ + android.hardware.thermal@1.0-service.wahoo + +#GNSS HAL +PRODUCT_PACKAGES += \ + gps.conf \ + libgps.utils \ + libgnss \ + liblocation_api \ + android.hardware.gnss@1.0-impl-qti \ + android.hardware.gnss@1.0-service-qti + +# VR HAL +PRODUCT_PACKAGES += \ + android.hardware.vr@1.0-service.wahoo \ + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/sec_config:$(TARGET_COPY_OUT_VENDOR)/etc/sec_config + + +HOSTAPD := hostapd +HOSTAPD += hostapd_cli +PRODUCT_PACKAGES += $(HOSTAPD) + +WPA := wpa_supplicant.conf +WPA += wpa_supplicant_wcn.conf +WPA += wpa_supplicant +PRODUCT_PACKAGES += $(WPA) + +# Wifi +PRODUCT_PACKAGES += \ + android.hardware.wifi@1.0-service \ + android.hardware.wifi.offload@1.0-service \ + wificond \ + wifilogd \ + libwpa_client + +LIB_NL := libnl_2 +PRODUCT_PACKAGES += $(LIB_NL) + +# Audio effects +PRODUCT_PACKAGES += \ + libvolumelistener \ + libqcomvisualizer \ + libqcomvoiceprocessing \ + libqcomvoiceprocessingdescriptors \ + libqcompostprocbundle + +PRODUCT_PACKAGES += \ + audio.primary.msm8998 \ + audio.a2dp.default \ + audio.usb.default \ + audio.r_submix.default \ + libaudio-resampler + +PRODUCT_PACKAGES += \ + android.hardware.audio@2.0-impl \ + android.hardware.audio.effect@2.0-impl \ + android.hardware.soundtrigger@2.0-impl \ + android.hardware.audio@2.0-service + +# stereo speakers: orientation changes swap L/R channels +PRODUCT_PROPERTY_OVERRIDES += \ + ro.audio.monitorRotation=true + +# Bug 62375603 +# PRODUCT_PROPERTY_OVERRIDES += audio.adm.buffering.ms=4 + +# MIDI feature +PRODUCT_COPY_FILES += \ + frameworks/native/data/etc/android.software.midi.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.midi.xml + +# Audio low latency feature +PRODUCT_COPY_FILES += \ + frameworks/native/data/etc/android.hardware.audio.low_latency.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.low_latency.xml + +# Pro audio feature +# PRODUCT_COPY_FILES += \ +# frameworks/native/data/etc/android.hardware.audio.pro.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.pro.xml + +# Thermal packages +PRODUCT_PACKAGES += \ + thermal.default + +ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) +PRODUCT_PACKAGES += \ + tinyplay \ + tinycap \ + tinymix \ + tinypcminfo \ + cplay +endif + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml \ + frameworks/av/services/audiopolicy/config/a2dp_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_audio_policy_configuration.xml \ + frameworks/av/services/audiopolicy/config/usb_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/usb_audio_policy_configuration.xml \ + frameworks/av/services/audiopolicy/config/r_submix_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/r_submix_audio_policy_configuration.xml \ + frameworks/av/services/audiopolicy/config/audio_policy_volumes.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_volumes.xml \ + frameworks/av/services/audiopolicy/config/default_volume_tables.xml:$(TARGET_COPY_OUT_VENDOR)/etc/default_volume_tables.xml \ + +# audio hal tables +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/sound_trigger_platform_info.xml:$(TARGET_COPY_OUT_VENDOR)/etc/sound_trigger_platform_info.xml \ + $(LOCAL_PATH)/sound_trigger_mixer_paths_wcd9340.xml:$(TARGET_COPY_OUT_VENDOR)/etc/sound_trigger_mixer_paths_wcd9340.xml \ + $(LOCAL_PATH)/graphite_ipc_platform_info.xml:$(TARGET_COPY_OUT_VENDOR)/etc/graphite_ipc_platform_info.xml \ + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/media_codecs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs.xml \ + $(LOCAL_PATH)/media_codecs_performance.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_performance.xml \ + frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_audio.xml \ + frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_telephony.xml \ + frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_video.xml \ + $(LOCAL_PATH)/media_profiles_V1_0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_profiles_V1_0.xml \ + +PRODUCT_PROPERTY_OVERRIDES += \ + audio.snd_card.open.retries=50 + +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/lowi.conf:$(TARGET_COPY_OUT_VENDOR)/etc/lowi.conf + +# Fingerprint HIDL implementation +PRODUCT_PACKAGES += \ + android.hardware.biometrics.fingerprint@2.1-service.wahoo + +PRODUCT_COPY_FILES += \ + frameworks/native/data/etc/android.hardware.fingerprint.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.fingerprint.xml + +# GPS configuration file +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/gps.conf:$(TARGET_COPY_OUT_VENDOR)/etc/gps.conf + +# GPS debug file +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/gps_debug.conf:system/etc/gps_debug.conf + +# Vendor seccomp policy files for media components: +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/seccomp_policy/mediacodec.policy:$(TARGET_COPY_OUT_VENDOR)/etc/seccomp_policy/mediacodec.policy + +ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) +# Subsystem ramdump +PRODUCT_PROPERTY_OVERRIDES += \ + persist.sys.ssr.enable_ramdumps=1 +endif + +# Subsystem silent restart +PRODUCT_PROPERTY_OVERRIDES += \ + persist.sys.ssr.restart_level=modem,slpi,adsp + +# setup dalvik vm configs +$(call inherit-product, frameworks/native/build/phone-xhdpi-2048-dalvik-heap.mk) + +PRODUCT_COPY_FILES += \ + device/google/wahoo/fstab.hardware:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.$(PRODUCT_HARDWARE) + +# For SPN display +PRODUCT_COPY_FILES += \ + device/google/wahoo/spn-conf.xml:system/etc/spn-conf.xml + +# Provide meaningful APN configuration +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/apns-full-conf.xml:system/etc/apns-conf.xml + +# Use the default charger mode images +PRODUCT_PACKAGES += \ + charger_res_images + +# b/36703476 +# Set default log size on userdebug/eng build to 1M +ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) +PRODUCT_PROPERTY_OVERRIDES += ro.logd.size=1M +endif + +# Dumpstate HAL +PRODUCT_PACKAGES += \ + android.hardware.dumpstate@1.0-service.wahoo + +# Use daemon to detect folio open/close +PRODUCT_PACKAGES += \ + folio_daemon + +# Storage: for factory reset protection feature +PRODUCT_PROPERTY_OVERRIDES += \ + ro.frp.pst=/dev/block/platform/soc/1da4000.ufshc/by-name/frp + +PRODUCT_PROPERTY_OVERRIDES += \ + ro.vendor.vndk.version=26.1.0 \ + +PRODUCT_PACKAGES += \ + android.hardware.renderscript@1.0.vndk-sp\ + android.hardware.graphics.allocator@2.0.vndk-sp\ + android.hardware.graphics.mapper@2.0.vndk-sp\ + android.hardware.graphics.common@1.0.vndk-sp\ + libhwbinder.vndk-sp\ + libbase.vndk-sp\ + libcutils.vndk-sp\ + libhardware.vndk-sp\ + libhidlbase.vndk-sp\ + libhidltransport.vndk-sp\ + libutils.vndk-sp\ + libc++.vndk-sp\ + libRS_internal.vndk-sp\ + libRSDriver.vndk-sp\ + libRSCpuRef.vndk-sp\ + libbcinfo.vndk-sp\ + libblas.vndk-sp\ + libft2.vndk-sp\ + libpng.vndk-sp\ + libcompiler_rt.vndk-sp\ + libbacktrace.vndk-sp\ + libunwind.vndk-sp\ + liblzma.vndk-sp\ + libz.vndk-sp\ + +PRODUCT_ENFORCE_RRO_TARGETS := framework-res + +# Override heap growth limit due to high display density on device +PRODUCT_PROPERTY_OVERRIDES += \ + dalvik.vm.heapgrowthlimit=256m + +PRODUCT_PROPERTY_OVERRIDES += \ + qcom.bluetooth.soc=cherokee + +PRODUCT_COPY_FILES += \ + device/google/wahoo/tango_permissions.xml:system/etc/permissions/tango_permissions.xml \ + device/google/wahoo/libtango_device2.jar:system/framework/libtango_device2.jar + +PRODUCT_PACKAGES += \ + ipacm + +#Set default CDMA subscription to RUIM +PRODUCT_PROPERTY_OVERRIDES += \ + ro.telephony.default_cdma_sub=0 + +# Add an extra 10% saturation to display colors +PRODUCT_PROPERTY_OVERRIDES += \ + persist.sys.sf.color_saturation=1.1 + +# Add minidebug info to the system server to support diagnosing native crashes. +ifneq (,$(filter user userdebug, $(TARGET_BUILD_VARIANT))) + # System server and some of its services. + # Note: we cannot use PRODUCT_SYSTEM_SERVER_JARS, as it has not been expanded at this point. + $(call add-product-dex-preopt-module-config,services,--generate-mini-debug-info) + $(call add-product-dex-preopt-module-config,wifi-service,--generate-mini-debug-info) +endif + +# QC time-daemon to use persist +PRODUCT_PROPERTY_OVERRIDES += \ + persist.delta_time.enable=true + +# Do not drop packets based upon enqueue sequence +# to avoid freeze +PRODUCT_PROPERTY_OVERRIDES += \ + persist.vendor.ims.dropset_feature=0 + +# Enable CameraHAL perfd usage +PRODUCT_PROPERTY_OVERRIDES += \ + persist.camera.perfd.enable=true + +# Preopt SystemUI +PRODUCT_DEXPREOPT_SPEED_APPS += \ + SystemUIGoogle diff --git a/dumpstate/Android.mk b/dumpstate/Android.mk new file mode 100644 index 00000000..6607bf85 --- /dev/null +++ b/dumpstate/Android.mk @@ -0,0 +1,43 @@ +# +# Copyright 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) +LOCAL_MODULE := android.hardware.dumpstate@1.0-service.wahoo +LOCAL_INIT_RC := android.hardware.dumpstate@1.0-service.wahoo.rc +LOCAL_MODULE_RELATIVE_PATH := hw + +LOCAL_SRC_FILES := \ + DumpstateDevice.cpp \ + service.cpp + +LOCAL_SHARED_LIBRARIES := \ + android.hardware.dumpstate@1.0 \ + libbase \ + libcutils \ + libdumpstateutil \ + libhidlbase \ + libhidltransport \ + libhwbinder \ + liblog \ + libutils + +LOCAL_CFLAGS := -Werror -Wall + +LOCAL_MODULE_TAGS := optional +LOCAL_PROPRIETARY_MODULE := true + +include $(BUILD_EXECUTABLE) diff --git a/dumpstate/DumpstateDevice.cpp b/dumpstate/DumpstateDevice.cpp new file mode 100755 index 00000000..cfe9e76a --- /dev/null +++ b/dumpstate/DumpstateDevice.cpp @@ -0,0 +1,220 @@ +/* + * Copyright 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "dumpstate" + +#include "DumpstateDevice.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "DumpstateUtil.h" + +#define MODEM_LOG_PREFIX_PROPERTY "ro.radio.log_prefix" +#define MODEM_LOG_LOC_PROPERTY "ro.radio.log_loc" +#define MODEM_LOGGING_SWITCH "persist.radio.smlog_switch" + +#define DIAG_MDLOG_PROPERTY "sys.modem.diag.mdlog" +#define DIAG_MDLOG_STATUS_PROPERTY "sys.modem.diag.mdlog_on" + +using android::os::dumpstate::CommandOptions; +using android::os::dumpstate::DumpFileToFd; +using android::os::dumpstate::PropertiesHelper; +using android::os::dumpstate::RunCommandToFd; + +namespace android { +namespace hardware { +namespace dumpstate { +namespace V1_0 { +namespace implementation { + +void DumpstateDevice::dumpModem(int fd, int fdModem) +{ + std::string modemLogDir = android::base::GetProperty(MODEM_LOG_LOC_PROPERTY, ""); + if (modemLogDir.empty()) { + ALOGD("No modem log place is set\n"); + return; + } + + if (!PropertiesHelper::IsUserBuild()) { + bool smlogEnabled = android::base::GetBoolProperty(MODEM_LOGGING_SWITCH, false) && + !access("/vendor/bin/smlog_dump", X_OK); + + bool diagLogEnabled = android::base::GetBoolProperty(DIAG_MDLOG_PROPERTY, false); + + CommandOptions options = CommandOptions::WithTimeout(120).Build(); + std::string modemLogAllDir = modemLogDir + "/modem_log"; + std::string diagLogDir = "/data/vendor/radio/diag_logs/logs"; + std::vector rilAndNetmgrLogs + { + "/data/vendor/radio/ril_log", + "/data/vendor/radio/ril_log_old", + "/data/vendor/netmgr/netmgr_log", + "/data/vendor/netmgr/netmgr_log_old" + }; + + std::string modemLogMkDirCmd= "/vendor/bin/mkdir -p " + modemLogAllDir; + RunCommandToFd(fd, "MKDIR MODEM LOG", { "/vendor/bin/sh", "-c", modemLogMkDirCmd.c_str()}, options); + + if (smlogEnabled) { + RunCommandToFd(fd, "SMLOG DUMP", { "smlog_dump", "-d", "-o", modemLogAllDir.c_str() }, options); + } else if (diagLogEnabled) { + std::string copyCmd= "/vendor/bin/cp -rf " + diagLogDir + " " + modemLogAllDir; + + android::base::SetProperty(DIAG_MDLOG_PROPERTY, "false"); + + ALOGD("Waiting for diag log to exit\n"); + for (int i = 0; i < 30; i++) { + if (!android::base::GetBoolProperty(DIAG_MDLOG_STATUS_PROPERTY, false)) { + ALOGD("diag log exited\n"); + sleep(1); + break; + } + + sleep(1); + } + + RunCommandToFd(fd, "CP DIAG LOGS", { "/vendor/bin/sh", "-c", copyCmd.c_str()}, options); + + android::base::SetProperty(DIAG_MDLOG_PROPERTY, "true"); + } + + for (const auto& logFile : rilAndNetmgrLogs) + { + std::string copyCmd= "/vendor/bin/cp " + logFile + " " + modemLogAllDir; + RunCommandToFd(fd, "CP MODEM LOG", { "/vendor/bin/sh", "-c", copyCmd.c_str()}, options); + } + + std::string filePrefix = android::base::GetProperty(MODEM_LOG_PREFIX_PROPERTY, ""); + + if (!filePrefix.empty()) { + std::string modemLogCombined = modemLogDir + "/" + filePrefix + "all.tar"; + std::string modemLogTarCmd= "/vendor/bin/tar cvf " + modemLogCombined + " -C " + modemLogAllDir + " ."; + RunCommandToFd(fd, "TAR LOG", { "/vendor/bin/sh", "-c", modemLogTarCmd.c_str()}, options); + + std::string modemLogPermCmd= "/vendor/bin/chmod a+rw " + modemLogCombined; + RunCommandToFd(fd, "CHG PERM", { "/vendor/bin/sh", "-c", modemLogPermCmd.c_str()}, options); + + std::vector buffer(65536); + android::base::unique_fd fdLog(TEMP_FAILURE_RETRY(open(modemLogCombined.c_str(), O_RDONLY | O_CLOEXEC | O_NONBLOCK))); + + if (fdLog >= 0) { + while (1) { + ssize_t bytes_read = TEMP_FAILURE_RETRY(read(fdLog, buffer.data(), buffer.size())); + + if (bytes_read == 0) { + break; + } else if (bytes_read < 0) { + ALOGD("read(%s): %s\n", modemLogCombined.c_str(), strerror(errno)); + break; + } + + ssize_t result = TEMP_FAILURE_RETRY(write(fdModem, buffer.data(), bytes_read)); + + if (result != bytes_read) { + ALOGD("Failed to write %ld bytes, actually written: %ld", bytes_read, result); + break; + } + } + } + + std::string modemLogClearCmd= "/vendor/bin/rm -r " + modemLogAllDir; + RunCommandToFd(fd, "RM MODEM DIR", { "/vendor/bin/sh", "-c", modemLogClearCmd.c_str()}, options); + RunCommandToFd(fd, "RM LOG", { "/vendor/bin/rm", modemLogCombined.c_str()}, options); + } + } +} + +static void DumpTouch(int fd) { + if (!access("/sys/android_touch", R_OK)) { + DumpFileToFd(fd, "Synaptics touch firmware version", + "/sys/android_touch/vendor"); + DumpFileToFd(fd, "Synaptics touch firmware config", + "/sys/android_touch/config"); + } + if (!access("/sys/class/input/ftm4_touch", R_OK)) { + DumpFileToFd(fd, "STM touch firmware config", + "/sys/class/input/ftm4_touch/version"); + DumpFileToFd(fd, "STM touch VR Mode", + "/sys/class/input/ftm4_touch/vrmode"); + } +} + +// Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow. +Return DumpstateDevice::dumpstateBoard(const hidl_handle& handle) { + if (handle == nullptr || handle->numFds < 1) { + ALOGE("no FDs\n"); + return Void(); + } + + int fd = handle->data[0]; + if (fd < 0) { + ALOGE("invalid FD: %d\n", handle->data[0]); + return Void(); + } + + if (handle->numFds < 2) { + ALOGE("no FD for modem\n"); + } + else { + int fdModem = handle->data[1]; + dumpModem(fd, fdModem); + } + + DumpFileToFd(fd, "SoC serial number", "/sys/devices/soc0/serial_number"); + DumpFileToFd(fd, "CPU present", "/sys/devices/system/cpu/present"); + DumpFileToFd(fd, "CPU online", "/sys/devices/system/cpu/online"); + DumpFileToFd(fd, "INTERRUPTS", "/proc/interrupts"); + DumpFileToFd(fd, "RPM Stats", "/d/rpm_stats"); + DumpFileToFd(fd, "Power Management Stats", "/d/rpm_master_stats"); + DumpFileToFd(fd, "WLAN Power Stats", "/d/wlan0/power_stats"); + DumpFileToFd(fd, "LL-Stats", "/d/wlan0/ll_stats"); + DumpFileToFd(fd, "ICNSS Stats", "/d/icnss/stats"); + DumpFileToFd(fd, "SMD Log", "/d/ipc_logging/smd/log"); + RunCommandToFd(fd, "ION HEAPS", {"/vendor/bin/sh", "-c", "for d in $(ls -d /d/ion/*); do for f in $(ls $d); do echo --- $d/$f; cat $d/$f; done; done"}); + DumpFileToFd(fd, "dmabuf info", "/d/dma_buf/bufinfo"); + RunCommandToFd(fd, "Temperatures", {"/vendor/bin/sh", "-c", "for f in `ls /sys/class/thermal` ; do type=`cat /sys/class/thermal/$f/type` ; temp=`cat /sys/class/thermal/$f/temp` ; echo \"$type: $temp\" ; done"}); + DumpFileToFd(fd, "cpu0-1 time-in-state", "/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state"); + RunCommandToFd(fd, "cpu0-1 cpuidle", {"/vendor/bin/sh", "-c", "for d in $(ls -d /sys/devices/system/cpu/cpu0/cpuidle/state*); do echo \"$d: `cat $d/name` `cat $d/desc` `cat $d/time` `cat $d/usage`\"; done"}); + DumpFileToFd(fd, "cpu2-3 time-in-state", "/sys/devices/system/cpu/cpu2/cpufreq/stats/time_in_state"); + RunCommandToFd(fd, "cpu2-3 cpuidle", {"/vendor/bin/sh", "-c", "for d in $(ls -d /sys/devices/system/cpu/cpu2/cpuidle/state*); do echo \"$d: `cat $d/name` `cat $d/desc` `cat $d/time` `cat $d/usage`\"; done"}); + DumpFileToFd(fd, "MDP xlogs", "/data/vendor/display/mdp_xlog"); + DumpFileToFd(fd, "TCPM logs", "/d/tcpm/usbpd0"); + DumpFileToFd(fd, "PD Engine", "/d/pd_engine/usbpd0"); + DumpFileToFd(fd, "smblib-usb logs", "/d/ipc_logging/smblib/log"); + DumpFileToFd(fd, "ipc-local-ports", "/d/msm_ipc_router/dump_local_ports"); + DumpTouch(fd); + RunCommandToFd(fd, "USB Device Descriptors", {"/vendor/bin/sh", "-c", "cd /sys/bus/usb/devices/1-1 && cat product && cat bcdDevice; cat descriptors | od -t x1 -w16 -N96"}); + + /* Check if qsee_logger tool exists */ + if (!access("/vendor/bin/qsee_logger", X_OK)) { + RunCommandToFd(fd, "FP LOGS", {"qsee_logger", "-d"}); + } + + RunCommandToFd(fd, "Battery cycle count", {"/vendor/bin/sh", "-c", "for f in 1 2 3 4 5 6 7 8 ; do echo $f > /sys/class/power_supply/bms/cycle_count_id; count=`cat /sys/class/power_supply/bms/cycle_count`; echo \"$f: $count\"; done"}); + return Void(); +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace dumpstate +} // namespace hardware +} // namespace android diff --git a/dumpstate/DumpstateDevice.h b/dumpstate/DumpstateDevice.h new file mode 100644 index 00000000..650c0cd0 --- /dev/null +++ b/dumpstate/DumpstateDevice.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H +#define ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H + +#include +#include +#include + +namespace android { +namespace hardware { +namespace dumpstate { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::dumpstate::V1_0::IDumpstateDevice; +using ::android::hardware::hidl_array; +using ::android::hardware::hidl_handle; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +struct DumpstateDevice : public IDumpstateDevice { + // Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow. + Return dumpstateBoard(const hidl_handle& h) override; + + void dumpModem(int fd, int fdModem); +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace dumpstate +} // namespace hardware +} // namespace android + +#endif // ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H diff --git a/dumpstate/android.hardware.dumpstate@1.0-service.wahoo.rc b/dumpstate/android.hardware.dumpstate@1.0-service.wahoo.rc new file mode 100644 index 00000000..924782f0 --- /dev/null +++ b/dumpstate/android.hardware.dumpstate@1.0-service.wahoo.rc @@ -0,0 +1,4 @@ +service dumpstate-1-0 /vendor/bin/hw/android.hardware.dumpstate@1.0-service.wahoo + class hal + user system + group system diff --git a/dumpstate/service.cpp b/dumpstate/service.cpp new file mode 100644 index 00000000..e5091660 --- /dev/null +++ b/dumpstate/service.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#define LOG_TAG "android.hardware.dumpstate@1.0-service.wahoo" + +#include +#include + +#include "DumpstateDevice.h" + +using ::android::hardware::configureRpcThreadpool; +using ::android::hardware::dumpstate::V1_0::IDumpstateDevice; +using ::android::hardware::dumpstate::V1_0::implementation::DumpstateDevice; +using ::android::hardware::joinRpcThreadpool; +using ::android::sp; + + +int main(int /* argc */, char* /* argv */ []) { + sp dumpstate = new DumpstateDevice; + configureRpcThreadpool(1, true); + + android::status_t status = dumpstate->registerAsService(); + + if (status != android::OK) + { + ALOGE("Could not register DumpstateDevice service (%d).", status); + return -1; + } + + joinRpcThreadpool(); +} diff --git a/folio_daemon/Android.mk b/folio_daemon/Android.mk new file mode 100755 index 00000000..d62bd741 --- /dev/null +++ b/folio_daemon/Android.mk @@ -0,0 +1,21 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SHARED_LIBRARIES := \ + libandroid \ + libcutils \ + liblog + +LOCAL_SRC_FILES := \ + main.cpp + +LOCAL_C_INCLUDES := + +LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"folio_daemon\" -DLOG_NDEBUG=0 + +LOCAL_CLANG := true +LOCAL_MODULE := folio_daemon +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_OWNER := google + +include $(BUILD_EXECUTABLE) diff --git a/folio_daemon/main.cpp b/folio_daemon/main.cpp new file mode 100644 index 00000000..1cda1ce5 --- /dev/null +++ b/folio_daemon/main.cpp @@ -0,0 +1,182 @@ +/* + * Copyright 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Hall-effect sensor type +#define SENSOR_TYPE 33171016 + +#define RETRY_LIMIT 120 +#define RETRY_PERIOD 30 // 30 seconds +#define WARN_PERIOD (time_t)300 // 5 minutes + +/* + * This simple daemon listens for events from the Hall-effect sensor and writes + * the appropriate SW_LID event to a uinput node. This allows the screen to be + * locked with a magnetic folio case. + */ +int main(void) { + int uinputFd; + int err; + struct uinput_user_dev uidev; + ASensorManager *sensorManager = nullptr; + ASensorRef hallSensor; + ALooper *looper; + ASensorEventQueue *eventQueue = nullptr; + time_t lastWarn = 0; + int attemptCount = 0; + + ALOGI("Started"); + + uinputFd = TEMP_FAILURE_RETRY(open("/dev/uinput", O_WRONLY | O_NONBLOCK)); + if (uinputFd < 0) { + ALOGE("Unable to open uinput node: %s", strerror(errno)); + goto out; + } + + err = TEMP_FAILURE_RETRY(ioctl(uinputFd, UI_SET_EVBIT, EV_SW)) + | TEMP_FAILURE_RETRY(ioctl(uinputFd, UI_SET_EVBIT, EV_SYN)) + | TEMP_FAILURE_RETRY(ioctl(uinputFd, UI_SET_SWBIT, SW_LID)); + if (err != 0) { + ALOGE("Unable to enable SW_LID events: %s", strerror(errno)); + goto out; + } + + memset(&uidev, 0, sizeof (uidev)); + snprintf(uidev.name, UINPUT_MAX_NAME_SIZE, "uinput-folio"); + uidev.id.bustype = BUS_VIRTUAL; + uidev.id.vendor = 0; + uidev.id.product = 0; + uidev.id.version = 0; + + err = TEMP_FAILURE_RETRY(write(uinputFd, &uidev, sizeof (uidev))); + if (err < 0) { + ALOGE("Write user device to uinput node failed: %s", strerror(errno)); + goto out; + } + + err = TEMP_FAILURE_RETRY(ioctl(uinputFd, UI_DEV_CREATE)); + if (err < 0) { + ALOGE("Unable to create uinput device: %s", strerror(errno)); + goto out; + } + + ALOGI("Successfully registered uinput-folio for SW_LID events"); + + // Get Hall-effect sensor events from the NDK + sensorManager = ASensorManager_getInstanceForPackage(nullptr); + /* + * As long as we are unable to get the sensor handle, periodically retry + * and emit an error message at a low frequency to prevent high CPU usage + * and log spam. If we simply exited with an error here, we would be + * immediately restarted and fail in the same way indefinitely. + */ + while (true) { + time_t now = time(NULL); + hallSensor = ASensorManager_getDefaultSensor(sensorManager, + SENSOR_TYPE); + if (hallSensor != nullptr) { + break; + } + + if (++attemptCount >= RETRY_LIMIT) { + ALOGE("Retries exhausted; exiting"); + goto out; + } else if (now > lastWarn + WARN_PERIOD) { + ALOGE("Unable to get Hall-effect sensor"); + lastWarn = now; + } + + sleep(RETRY_PERIOD); + } + + looper = ALooper_forThread(); + if (looper == nullptr) { + looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS); + } + + eventQueue = ASensorManager_createEventQueue(sensorManager, looper, 0, NULL, + NULL); + err = ASensorEventQueue_registerSensor(eventQueue, hallSensor, + ASensor_getMinDelay(hallSensor), + 10000); + if (err < 0) { + ALOGE("Unable to register for Hall-effect sensor events"); + goto out; + } + + ALOGI("Starting polling loop"); + + // Polling loop + while (ALooper_pollAll(-1, NULL, NULL, NULL) == 0) { + int eventCount = 0; + ASensorEvent sensorEvent; + while (ASensorEventQueue_getEvents(eventQueue, &sensorEvent, 1) > 0) { + // 1 means closed; 0 means open + int isClosed = sensorEvent.data[0] > 0.0f ? 1 : 0; + struct input_event event; + event.type = EV_SW; + event.code = SW_LID; + event.value = isClosed; + err = TEMP_FAILURE_RETRY(write(uinputFd, &event, sizeof (event))); + if (err < 0) { + ALOGE("Write EV_SW to uinput node failed: %s", strerror(errno)); + goto out; + } + + // Force a flush with an EV_SYN + event.type = EV_SYN; + event.code = SYN_REPORT; + event.value = 0; + err = TEMP_FAILURE_RETRY(write(uinputFd, &event, sizeof (event))); + if (err < 0) { + ALOGE("Write EV_SYN to uinput node failed: %s", + strerror(errno)); + goto out; + } + + ALOGI("Sent lid %s event", isClosed ? "closed" : "open"); + eventCount++; + } + + if (eventCount == 0) { + ALOGE("Poll returned with zero events: %s", strerror(errno)); + break; + } + } + +out: + // Clean up + if (sensorManager != nullptr && eventQueue != nullptr) { + ASensorManager_destroyEventQueue(sensorManager, eventQueue); + } + + if (uinputFd >= 0) { + close(uinputFd); + } + + // The loop can only be exited via failure or signal + return 1; +} diff --git a/fstab.hardware b/fstab.hardware new file mode 100644 index 00000000..7d1e9ac0 --- /dev/null +++ b/fstab.hardware @@ -0,0 +1,9 @@ +# Android fstab file. + +# +/dev/block/platform/soc/1da4000.ufshc/by-name/system / ext4 ro,barrier=1 wait,slotselect,avb +/dev/block/platform/soc/1da4000.ufshc/by-name/userdata /data ext4 errors=panic,noatime,nosuid,nodev,barrier=1,noauto_da_alloc latemount,wait,check,formattable,fileencryption=ice:aes-256-heh,eraseblk=16777216,logicalblk=4096,quota +/dev/block/platform/soc/1da4000.ufshc/by-name/misc /misc emmc defaults defaults +/dev/block/platform/soc/1da4000.ufshc/by-name/modem /firmware vfat ro,shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337,context=u:object_r:firmware_file:s0 wait,slotselect +/devices/soc/a800000.ssusb/a800000.dwc3* auto vfat defaults voldmanaged=usb:auto +/dev/block/zram0 none swap defaults zramsize=536870912,max_comp_streams=8 diff --git a/gps.conf b/gps.conf new file mode 100644 index 00000000..1653bcc8 --- /dev/null +++ b/gps.conf @@ -0,0 +1,128 @@ +#Version check for XTRA +#DISABLE = 0 +#AUTO = 1 +#XTRA2 = 2 +#XTRA3 = 3 +XTRA_VERSION_CHECK=1 + +# Error Estimate +# _SET = 1 +# _CLEAR = 0 +ERR_ESTIMATE=0 + +# NTP Server +# NTP_SERVER=time.gpsonextra.net +# Asia +# NTP_SERVER=asia.pool.ntp.org +# Europe +# NTP_SERVER=europe.pool.ntp.org +# North America +NTP_SERVER=north-america.pool.ntp.org +# If NTP_SERVER is commented NTP_SERVER=time.izatcloud.net is used + +# DEBUG LEVELS: 0 - none, 1 - Error, 2 - Warning, 3 - Info +# 4 - Debug, 5 - Verbose +# If DEBUG_LEVEL is commented, Android's logging levels will be used +DEBUG_LEVEL = 2 + +# Intermediate position report, 1=enable, 0=disable +INTERMEDIATE_POS=0 + +# GPS Capabilities bit mask +# SCHEDULING = 0x01 +# MSB = 0x02 +# MSA = 0x04 +# ON_DEMAND_TIME = 0x10 +# GEOFENCE = 0x20 +# default = ON_DEMAND_TIME | MSA | MSB | SCHEDULING | GEOFENCE +CAPABILITIES=0x37 + +# Accuracy threshold for intermediate positions +# less accurate positions are ignored, 0 for passing all positions +# ACCURACY_THRES=5000 + +################################ +##### AGPS server settings ##### +################################ +# Bitmask of slots that are available +# for write/install to, where 1s indicate writable, +# and the default value is 0 where no slots +# are writable. For example, AGPS_CERT_WRITABLE_MASK +# of b1000001010 makes 3 slots available +# and the remaining 7 slots unwritable. +# AGPS_CERT_WRITABLE_MASK=0 + +################################ +# EXTRA SETTINGS +################################ +# NMEA provider (1=Modem Processor, 0=Application Processor) +NMEA_PROVIDER=0 + +# Mark if it is a SGLTE target (1=SGLTE, 0=nonSGLTE) +SGLTE_TARGET=0 + +################################################## +# Select technology for LPPe Control Plane +################################################## +# 0x1: DBH for LPPe CP +# 0x2: WLAN AP Measurements for LPPe CP +LPPE_CP_TECHNOLOGY = 0 + +################################################## +# Select technology for LPPe User Plane +################################################## +# 0x1: DBH for LPPe UP +# 0x2: WLAN AP Measurements for LPPe UP +LPPE_UP_TECHNOLOGY = 0 + +################################################## +# AGPS_CONFIG_INJECT +################################################## +# enable/disable injection of AGPS configurations: +# SUPL_VER +# SUPL_HOST +# SUPL_PORT +# SUPL_MODE +# SUPL_ES +# C2K_HOST +# C2K_PORT +# LPP_PROFILE +# A_GLONASS_POS_PROTOCOL_SELECT +# USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL +# GPS_LOCK +# 0: disable +# 1: enable +AGPS_CONFIG_INJECT = 1 + +# AP Coarse Timestamp Uncertainty +################################################## +# default : 10 +# or as per clock uncertainty of product +AP_TIMESTAMP_UNCERTAINTY = 10 + +##################################### +#DR_SYNC Pulse Availability +##################################### +# 0 : DR_SYNC pulse not available (default) +# 1 : DR_SYNC pulse available +DR_SYNC_ENABLED = 0 + +##################################### +#PPS Device name +##################################### +PPS_DEVICENAME = /dev/pps0 + +##################################### +#AP Clock Accuracy +##################################### +AP_CLOCK_PPM = 100 + +##################################### +#MAX ms difference to detect missing pulse +##################################### +MISSING_PULSE_TIME_DELTA = 900 + +##################################### +#Propagation time uncertainty +##################################### +PROPAGATION_TIME_UNCERTAINTY = 1 \ No newline at end of file diff --git a/gps_debug.conf b/gps_debug.conf new file mode 100644 index 00000000..34ce96f3 --- /dev/null +++ b/gps_debug.conf @@ -0,0 +1,52 @@ +# Sample file for use for on device debug override only +# Prefer frameworks/base/core/res/res/values/config.xml and +# frameworks/base/core/res/res/values-mcc*-mnc*/config.xml + +################################ +##### AGPS server settings ##### +################################ +# FOR SUPL SUPPORT, set the following +# SUPL_HOST=supl.google.com or IP +# SUPL_PORT=7275 + +# supl version 2.0 +# SUPL_VER=0x20000 + +#SUPL_MODE is a bit mask set in config.xml per carrier by default. +#If it is uncommented here, this value will overwrite the value from +#config.xml. +#MSA=0X2 +#MSB=0X1 +#SUPL_MODE=1 + +# Emergency SUPL, 1=enable, 0=disable +#SUPL_ES=0 + +#Choose PDN for Emergency SUPL +#1 - Use emergency PDN +#0 - Use regular SUPL PDN for Emergency SUPL +#USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL=0 + +#################################### +# LTE Positioning Profile Settings +#################################### +# 0: Enable RRLP on LTE(Default) +# 1: Enable LPP_User_Plane on LTE +# 2: Enable LPP_Control_Plane +# 3: Enable both LPP_User_Plane and LPP_Control_Plane +#LPP_PROFILE = 2 + +################################################## +# Select Positioning Protocol on A-GLONASS system +################################################## +# 0x1: RRC CPlane +# 0x2: RRLP UPlane +# 0x4: LLP Uplane +#A_GLONASS_POS_PROTOCOL_SELECT = 0 + +# Below bit mask configures how GPS functionalities +# should be locked when user turns off GPS on Settings +# Set bit 0x1 if MO GPS functionalities are to be locked +# Set bit 0x2 if NI GPS functionalities are to be locked +# default - non is locked for backward compatibility +#GPS_LOCK = 0 diff --git a/graphite_ipc_platform_info.xml b/graphite_ipc_platform_info.xml new file mode 100644 index 00000000..f6775bed --- /dev/null +++ b/graphite_ipc_platform_info.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/init.elabel.sh b/init.elabel.sh new file mode 100644 index 00000000..52e402c5 --- /dev/null +++ b/init.elabel.sh @@ -0,0 +1,10 @@ +#! /system/bin/sh + +if [ -d /persist/elabel ]; then + if [ ! -f /data/misc/elabel/elabels_copied ]; then + cp /persist/elabel/* /data/misc/elabel/ + echo 1 > /data/misc/elabel/elabels_copied + chown system.system /data/misc/elabel/* + chmod 400 /data/misc/elabel/* + fi +fi diff --git a/init.hardware.diag.rc.user b/init.hardware.diag.rc.user new file mode 100644 index 00000000..1fc0b0c9 --- /dev/null +++ b/init.hardware.diag.rc.user @@ -0,0 +1,18 @@ +# +# Copyright (C) 2016 The Android Open-Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +on property:ro.boot.mode=normal + rm /dev/diag diff --git a/init.hardware.diag.rc.userdebug b/init.hardware.diag.rc.userdebug new file mode 100644 index 00000000..16d7e834 --- /dev/null +++ b/init.hardware.diag.rc.userdebug @@ -0,0 +1,386 @@ +# +# Copyright (C) 2016 The Android Open-Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +on init + chmod 666 /dev/diag + +on post-fs-data + # Modem logging collection + mkdir /data/vendor/radio 0777 radio radio + mkdir /data/vendor/radio/diag_logs 0777 system system + # WLAN logging collection + mkdir /data/vendor/wifi 0777 system system + mkdir /data/vendor/wifi/cnss_diag 0777 system system + +on property:sys.usb.ffs.ready=1 && property:sys.usb.config=diag && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "diag" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x900E + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f1 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=diag,adb && property:sys.usb.configfs=1 + start adbd + + +on property:sys.usb.ffs.ready=1 && property:sys.usb.config=diag,adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "diag_adb" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x901D + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f2 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=diag,serial_cdev,rmnet_gsi,adb && property:sys.usb.configfs=1 + start adbd + start port-bridge + +on property:sys.usb.ffs.ready=1 && property:sys.usb.config=diag,serial_cdev,rmnet_gsi,adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "Default composition" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x9091 + write /config/usb_gadget/g1/os_desc/use 1 + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/cser.dun.0 /config/usb_gadget/g1/configs/b.1/f2 + symlink /config/usb_gadget/g1/functions/gsi.rmnet /config/usb_gadget/g1/configs/b.1/f3 + symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f4 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=diag,serial_cdev,rmnet_gsi && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "Default comp without ADB" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x9092 + write /config/usb_gadget/g1/os_desc/use 1 + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/cser.dun.0 /config/usb_gadget/g1/configs/b.1/f2 + symlink /config/usb_gadget/g1/functions/gsi.rmnet /config/usb_gadget/g1/configs/b.1/f3 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + start port-bridge + +on property:sys.usb.config=rndis,diag && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "rndis_diag" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x902C + symlink /config/usb_gadget/g1/functions/gsi.rndis /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f2 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=rndis,diag,adb && property:sys.usb.configfs=1 + start adbd + +on property:sys.usb.ffs.ready=1 && property:sys.usb.config=rndis,diag,adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "rndis_diag_adb" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x902D + symlink /config/usb_gadget/g1/functions/gsi.rndis /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f2 + symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f3 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=rndis,serial_cdev,diag && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "rndis_dun_diag" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x90B5 + symlink /config/usb_gadget/g1/functions/gsi.rndis /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/cser.dun.0 /config/usb_gadget/g1/configs/b.1/f2 + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f3 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + start port-bridge + +on property:sys.usb.config=rndis,serial_cdev,diag,adb && property:sys.usb.configfs=1 + start adbd + start port-bridge + +on property:sys.usb.ffs.ready=1 && property:sys.usb.config=rndis,serial_cdev,diag,adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "rndis_dun_diag" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x90B6 + symlink /config/usb_gadget/g1/functions/gsi.rndis /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/cser.dun.0 /config/usb_gadget/g1/configs/b.1/f2 + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f3 + symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f4 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=mtp,diag && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "mtp_diag" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x901B + symlink /config/usb_gadget/g1/functions/mtp.gs0 /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f2 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=mtp,diag,adb && property:sys.usb.configfs=1 + start adbd + +on property:sys.usb.ffs.ready=1 && property:sys.usb.config=mtp,diag,adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "mtp_diag_adb" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x903A + symlink /config/usb_gadget/g1/functions/mtp.gs0 /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f2 + symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f3 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=diag,qdss && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "diag_qdss" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x904A + write /config/usb_gadget/g1/functions/qdss.qdss/enable_debug_inface 1 + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/qdss.qdss /config/usb_gadget/g1/configs/b.1/f2 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=diag,qdss,adb && property:sys.usb.configfs=1 + start adbd + +on property:sys.usb.ffs.ready=1 && property:sys.usb.config=diag,qdss,adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "diag_qdss_adb" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x9060 + write /config/usb_gadget/g1/functions/qdss.qdss/enable_debug_inface 1 + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/qdss.qdss /config/usb_gadget/g1/configs/b.1/f2 + symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f3 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=diag,qdss,rmnet_gsi && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "diag_qdss_rmnet" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x9083 + write /config/usb_gadget/g1/functions/qdss.qdss/enable_debug_inface 1 + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/qdss.qdss /config/usb_gadget/g1/configs/b.1/f2 + symlink /config/usb_gadget/g1/functions/gsi.rmnet /config/usb_gadget/g1/configs/b.1/f3 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=diag,qdss,rmnet_gsi,adb && property:sys.usb.configfs=1 + start adbd + +on property:sys.usb.ffs.ready=1 && property:sys.usb.config=diag,qdss,rmnet_gsi,adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "diag_qdss_rmnet_adb" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x9084 + write /config/usb_gadget/g1/functions/qdss.qdss/enable_debug_inface 1 + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/qdss.qdss /config/usb_gadget/g1/configs/b.1/f2 + symlink /config/usb_gadget/g1/functions/gsi.rmnet /config/usb_gadget/g1/configs/b.1/f3 + symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f4 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=rndis,diag,qdss && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "rndis_diag_qdss" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x9081 + write /config/usb_gadget/g1/functions/qdss.qdss/enable_debug_inface 1 + symlink /config/usb_gadget/g1/functions/gsi.rndis /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f2 + symlink /config/usb_gadget/g1/functions/qdss.qdss /config/usb_gadget/g1/configs/b.1/f3 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=rndis,diag,qdss,adb && property:sys.usb.configfs=1 + start adbd + +on property:sys.usb.ffs.ready=1 && property:sys.usb.config=rndis,diag,qdss,adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "rndis_diag_qdss_adb" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x9082 + write /config/usb_gadget/g1/functions/qdss.qdss/enable_debug_inface 1 + symlink /config/usb_gadget/g1/functions/gsi.rndis /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f2 + symlink /config/usb_gadget/g1/functions/qdss.qdss /config/usb_gadget/g1/configs/b.1/f3 + symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f4 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=diag,serial_cdev && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "diag_dun" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x9004 + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/cser.dun.0 /config/usb_gadget/g1/configs/b.1/f2 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + start port-bridge + +on property:sys.usb.config=diag,adb,serial_cdev && property:sys.usb.configfs=1 + start adbd + start port-bridge + +on property:sys.usb.ffs.ready=1 && property:sys.usb.config=diag,adb,serial_cdev && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "diag_adb_dun" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + rm /config/usb_gadget/g1/configs/b.1/f4 + rm /config/usb_gadget/g1/configs/b.1/f5 + write /config/usb_gadget/g1/idVendor 0x05C6 + write /config/usb_gadget/g1/idProduct 0x901f + symlink /config/usb_gadget/g1/functions/diag.diag /config/usb_gadget/g1/configs/b.1/f1 + symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f2 + symlink /config/usb_gadget/g1/functions/cser.dun.0 /config/usb_gadget/g1/configs/b.1/f3 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +service diag_mdlog_start /vendor/bin/diag_mdlog + class late_start + user shell + group system diag media_rw + disabled + oneshot + +service diag_mdlog_stop /vendor/bin/diag_mdlog -k + class late_start + user shell + group system diag media_rw + disabled + oneshot + +on boot && property:persist.sys.modem.diag.mdlog=* + setprop sys.modem.diag.mdlog ${persist.sys.modem.diag.mdlog} + +on property:sys.modem.diag.mdlog=true + start diag_mdlog_start + +on property:sys.modem.diag.mdlog=false + start diag_mdlog_stop + +on property:persist.sys.cnss.diag_qxdm=true + start cnss_diag + +on property:persist.sys.cnss.diag_qxdm=false + stop cnss_diag + +on property:persist.sys.cnss.diag_txt=true + start cnss_diag_txt + +on property:persist.sys.cnss.diag_txt=false + stop cnss_diag_txt + +service cnss_diag /vendor/bin/cnss_diag -q -u -w + class late_start + user system + group system + oneshot + +service cnss_diag_txt /vendor/bin/cnss_diag -s -f -m /data/vendor/wifi/cnss_diag/cnss_diag.conf + class late_start + user system + group system + disabled + oneshot + +on property:debug.htc.ramdump.crash=true + write /proc/sysrq-trigger "c" diff --git a/init.hardware.rc b/init.hardware.rc new file mode 100644 index 00000000..7f9184f5 --- /dev/null +++ b/init.hardware.rc @@ -0,0 +1,814 @@ +# +# Copyright (C) 2016 The Android Open-Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import /vendor/etc/init/hw/init.${ro.hardware}.usb.rc + +on charger + write /sys/devices/system/cpu/cpu2/online 0 + write /sys/devices/system/cpu/cpu3/online 0 + write /sys/devices/system/cpu/cpu4/online 0 + write /sys/devices/system/cpu/cpu5/online 0 + write /sys/devices/system/cpu/cpu6/online 0 + write /sys/devices/system/cpu/cpu7/online 0 + wait /dev/block/platform/soc/${ro.boot.bootdevice} + # Enable UFS powersaving + write /sys/devices/soc/${ro.boot.bootdevice}/clkscale_enable 1 + write /sys/devices/soc/${ro.boot.bootdevice}/clkgate_enable 1 + write /sys/devices/soc/${ro.boot.bootdevice}/hibern8_on_idle_enable 1 + write /sys/class/typec/port0/port_type sink + write /sys/module/lpm_levels/parameters/sleep_disabled N + +service charger /charger + class charger + seclabel u:r:charger:s0 + +on early-init + mount debugfs debugfs /sys/kernel/debug + chmod 0755 /sys/kernel/debug + +on init + # Disable UFS powersaving + write /sys/devices/soc/${ro.boot.bootdevice}/clkscale_enable 0 + write /sys/devices/soc/${ro.boot.bootdevice}/clkgate_enable 0 + write /sys/devices/soc/${ro.boot.bootdevice}/hibern8_on_idle_enable 0 + write /sys/module/lpm_levels/parameters/sleep_disabled Y + + # Loading kernel modules in background + start insmod_sh + + # Support legacy paths + symlink /sdcard /mnt/sdcard + symlink /sdcard /storage/sdcard0 + + # disable thermal hotplug for thermal + write /sys/module/msm_thermal/core_control/enabled 0 + + # bring back all cores + write /sys/devices/system/cpu/cpu0/online 1 + write /sys/devices/system/cpu/cpu1/online 1 + write /sys/devices/system/cpu/cpu2/online 1 + write /sys/devices/system/cpu/cpu3/online 1 + write /sys/devices/system/cpu/cpu4/online 1 + write /sys/devices/system/cpu/cpu5/online 1 + write /sys/devices/system/cpu/cpu6/online 1 + write /sys/devices/system/cpu/cpu7/online 1 + # configure governor settings for little cluster + write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "schedutil" + write /sys/devices/system/cpu/cpufreq/policy0/schedutil/up_rate_limit_us 500 + write /sys/devices/system/cpu/cpufreq/policy0/schedutil/down_rate_limit_us 20000 + + # configure governor settings for big cluster + write /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor "schedutil" + write /sys/devices/system/cpu/cpufreq/policy4/schedutil/up_rate_limit_us 500 + write /sys/devices/system/cpu/cpufreq/policy4/schedutil/down_rate_limit_us 20000 + + # set default schedTune value for foreground/top-app + write /dev/stune/foreground/schedtune.prefer_idle 1 + write /dev/stune/top-app/schedtune.boost 10 + write /dev/stune/top-app/schedtune.prefer_idle 1 + + # Setup cpusets used by the VR services. + mkdir /dev/cpuset/kernel 0750 root system + write /dev/cpuset/kernel/cpus 0 + write /dev/cpuset/kernel/mems 0 + chown system system /dev/cpuset/kernel/tasks + chmod 0660 /dev/cpuset/kernel/tasks + + mkdir /dev/cpuset/system 0750 root system + write /dev/cpuset/system/cpus 0 + write /dev/cpuset/system/mems 0 + chown system system /dev/cpuset/system/tasks + chmod 0660 /dev/cpuset/system/tasks + + mkdir /dev/cpuset/system/performance 0750 root system + write /dev/cpuset/system/performance/cpus 0 + write /dev/cpuset/system/performance/mems 0 + chown system system /dev/cpuset/system/performance/tasks + chmod 0660 /dev/cpuset/system/performance/tasks + + mkdir /dev/cpuset/system/background 0750 root system + write /dev/cpuset/system/background/cpus 0 + write /dev/cpuset/system/background/mems 0 + chown system system /dev/cpuset/system/background/tasks + chmod 0660 /dev/cpuset/system/background/tasks + + mkdir /dev/cpuset/application 0750 root system + write /dev/cpuset/application/cpus 0 + write /dev/cpuset/application/mems 0 + chown system system /dev/cpuset/application/tasks + chmod 0660 /dev/cpuset/application/tasks + + mkdir /dev/cpuset/application/performance 0750 root system + write /dev/cpuset/application/performance/cpus 0 + write /dev/cpuset/application/performance/mems 0 + chown system system /dev/cpuset/application/performance/tasks + chmod 0660 /dev/cpuset/application/performance/tasks + + mkdir /dev/cpuset/application/background 0750 root system + write /dev/cpuset/application/background/cpus 0 + write /dev/cpuset/application/background/mems 0 + chown system system /dev/cpuset/application/background/tasks + chmod 0660 /dev/cpuset/application/background/tasks + + # Create UDS structure for base VR services. + mkdir /dev/socket/pdx 0775 system system + mkdir /dev/socket/pdx/system 0775 system system + mkdir /dev/socket/pdx/system/buffer_hub 0775 system system + mkdir /dev/socket/pdx/system/performance 0775 system system + mkdir /dev/socket/pdx/system/vr 0775 system system + mkdir /dev/socket/pdx/system/vr/display 0775 system system + mkdir /dev/socket/pdx/system/vr/pose 0775 system system + mkdir /dev/socket/pdx/system/vr/sensors 0775 system system + + # Disable retention + write /sys/module/lpm_levels/system/pwr/cpu0/ret/idle_enabled N + write /sys/module/lpm_levels/system/pwr/cpu1/ret/idle_enabled N + write /sys/module/lpm_levels/system/pwr/cpu2/ret/idle_enabled N + write /sys/module/lpm_levels/system/pwr/cpu3/ret/idle_enabled N + write /sys/module/lpm_levels/system/perf/cpu4/ret/idle_enabled N + write /sys/module/lpm_levels/system/perf/cpu5/ret/idle_enabled N + write /sys/module/lpm_levels/system/perf/cpu6/ret/idle_enabled N + write /sys/module/lpm_levels/system/perf/cpu7/ret/idle_enabled N + write /sys/module/lpm_levels/system/pwr/pwr-l2-dynret/idle_enabled N + write /sys/module/lpm_levels/system/pwr/pwr-l2-ret/idle_enabled N + write /sys/module/lpm_levels/system/perf/perf-l2-dynret/idle_enabled N + write /sys/module/lpm_levels/system/perf/perf-l2-ret/idle_enabled N + + # b/37682684 Enable suspend clock reporting + write /sys/kernel/debug/clk/debug_suspend 1 + + # ZRAM setup + write /sys/block/zram0/comp_algorithm lz4 + write /proc/sys/vm/page-cluster 0 + +on fs + wait /dev/block/platform/soc/${ro.boot.bootdevice} + symlink /dev/block/platform/soc/${ro.boot.bootdevice} /dev/block/bootdevice + + mount_all /vendor/etc/fstab.${ro.hardware} --early + + mkdir /persist/data 0700 system system + mkdir /persist/display 0770 system graphics + mkdir /persist/rfs 0770 root system + mkdir /persist/hlos_rfs 0770 root system + mkdir /persist/elabel 0700 system system + chmod 0770 /persist/rfs + chmod 0770 /persist/rfs/shared + chmod 0770 /persist/rfs/msm + chmod 0770 /persist/rfs/msm/adsp + chown system system /persist/rfs/msm/adsp + chmod 0770 /persist/rfs/msm/mpss + chown system system /persist/rfs/msm/mpss + mkdir /persist/rfs/msm/slpi 0770 system system + chmod 0770 /persist/rfs/mdm + chmod 0770 /persist/rfs/mdm/adsp + chown system system /persist/rfs/mdm/adsp + chmod 0770 /persist/rfs/mdm/mpss + chown system system /persist/rfs/mdm/mpss + mkdir /persist/rfs/mdm/slpi 0770 system system + chmod 0770 /persist/rfs/mdm/sparrow + chown system system /persist/rfs/mdm/sparrow + mkdir /persist/rfs/mdm/tn 0770 system system + chmod 0770 /persist/rfs/apq + chmod 0770 /persist/rfs/apq/gnss + chmod 0770 /persist/hlos_rfs + restorecon_recursive /persist + + # Start HW service manager early + start hwservicemanager + + # qseecomd needs /dev/block/bootdevice + # vold needs keymaster that needs qseecomd + start qseecomd + +on late-fs + # Start devices by sysfs trigger + start devstart_sh + # Start services for bootanim + start surfaceflinger + start bootanim + start hwcomposer-2-1 + start configstore-hal + start gralloc-2-0 + + # Mount RW partitions which need run fsck + mount_all /vendor/etc/fstab.${ro.hardware} --late + + # Required for time_daemon + mkdir /persist/time 0770 system system + + # Start time daemon early so that the system time can be set early + start time_daemon + +on post-fs + # set RLIMIT_MEMLOCK to 64MB + setrlimit 8 67108864 67108864 + + chmod 0664 /sys/devices/virtual/graphics/fb0/idle_time + chown system graphics /sys/devices/virtual/graphics/fb0/idle_time + write /sys/devices/virtual/graphics/fb0/idle_time 100 + + # Wait qseecomd started + wait_for_prop sys.listeners.registered true + +on property:sys.user.0.ce_available=true + mkdir /data/misc_ce/0/ramoops + start ramoops_sh + +on property:sys.ramoops.decrypted=true + mount pstore pstore /sys/fs/pstore + chown system log /sys/fs/pstore/console-ramoops + chmod 0440 /sys/fs/pstore/console-ramoops + chown system log /sys/fs/pstore/console-ramoops-0 + chmod 0440 /sys/fs/pstore/console-ramoops-0 + chown system log /sys/fs/pstore/pmsg-ramoops-0 + chmod 0440 /sys/fs/pstore/pmsg-ramoops-0 + +on property:sys.listeners.registered=true + # load IPA FWs + start ipastart_sh + +on post-fs-data + # We can start netd here before in is launched in common init.rc on zygote-start + start netd + + # b/38048356 Setup debug folders for camera + mkdir /data/vendor/camera 0770 camera camera + + # b/38496103 Setup debug folders for display + mkdir /data/vendor/display 0770 system graphics + + # keep that at the end of on post-fs-data + # Set indication (checked by vold) that we have finished this action + setprop vold.post_fs_data_done 1 + + # Wait until the system time is set + wait_for_prop sys.time.set true + +# zygote need to be started after otapreopt which will be done on post-fs-data +on zygote-start + # zygote is started in common init.rc + # and now we can continue to initialize /data/ + mkdir /data/tombstones 0771 system system + mkdir /tombstones/modem 0771 system system + mkdir /tombstones/lpass 0771 system system + mkdir /tombstones/wcnss 0771 system system + mkdir /tombstones/dsps 0771 system system + mkdir /data/misc/qvop 0660 system system + mkdir /data/misc/hbtp 0750 system system + mkdir /data/misc/seemp 0700 system system + + # Create directory for TZ Apps + mkdir /data/misc/qsee 0770 system system + + mkdir /data/media 0770 media_rw media_rw + chown media_rw media_rw /data/media + + mkdir /data/vendor/ipa 0770 radio radio + chown radio radio /data/vendor/ipa + + # Create the directories used by the Wireless subsystem + mkdir /data/misc/wifi 0770 wifi wifi + mkdir /data/misc/wifi/sockets 0770 wifi wifi + mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi + mkdir /data/misc/dhcp 0770 dhcp dhcp + chown dhcp dhcp /data/misc/dhcp + + # Mounting of persist is moved to 'on emmc-fs' and 'on fs' sections + # We chown/chmod /persist again so because mount is run as root + defaults + chown root system /persist + chmod 0771 /persist + chown system system /persist/WCNSS_qcom_wlan_nv.bin + + # Create directory for hostapd + mkdir /data/hostapd 0770 system wifi + + # Trigger WLAN driver load + write /sys/kernel/boot_wlan/boot_wlan 1 + + #create port-bridge log dir + mkdir /data/misc/port_bridge 0770 radio radio + chmod 0770 /data/misc/port_bridge + + #create netmgr log dir + mkdir /data/vendor/netmgr 0771 radio radio + chmod 0771 /data/vendor/netmgr + + # Create the directories used by CnE subsystem + mkdir /data/connectivity 0771 system system + chown system system /data/connectivity + + # Create the directories used by DPM subsystem + mkdir /data/dpm 0771 system system + chown system system /data/dpm + + mkdir /data/dpm/nsrm 0771 system system + chown system system /data/dpm/nsrm + + # Create directory used by audio subsystem + mkdir /data/misc/audio 0770 audio audio + + # Create directory for audio delta files + mkdir /data/misc/audio/acdbdata 0770 media audio + mkdir /data/misc/audio/acdbdata/delta 0770 media audio + + # Create directory used by the DASH client + mkdir /data/misc/dash 0770 media audio + + # Create directory for radio + mkdir /data/vendor/radio 0771 system radio + + # Create directory used by display clients + mkdir /data/misc/display 0770 system graphics + + # Create perfd related dirs + mkdir /data/system/perfd 0770 root system + chmod 2770 /data/system/perfd + + # Setup sensors-related directories and permissions + mkdir /persist/sensors 0775 + chown root system /persist/sensors + write /persist/sensors/sensors_settings 1 + chown root system /persist/sensors/sensors_settings + chmod 664 /persist/sensors/sensors_settings + chown root system /persist/sensors/sns.reg + chmod 664 /persist/sensors/sns.reg + + mkdir /data/vendor/sensors 0770 + chown system system /data/vendor/sensors + + # These files might have been created by root from a prior build - make sure + # they are accessible to the sensors daemon + chown system system /data/vendor/sensors/cal.bin + chown system system /data/vendor/sensors/cal.txt + + # /dev/sensors only supports an ioctl to get the current SLPI timestamp; + # allow the sensors daemon to perform this as non-root + chown root system /dev/sensors + chmod 660 /dev/sensors + + # Mark the copy complete flag to not completed + write /data/vendor/radio/copy_complete 0 + chown radio radio /data/vendor/radio/copy_complete + chmod 0660 /data/vendor/radio/copy_complete + + # File flags for prebuilt ril db file + write /data/vendor/radio/prebuilt_db_support 1 + chown radio radio /data/vendor/radio/prebuilt_db_support + chmod 0400 /data/vendor/radio/prebuilt_db_support + write /data/vendor/radio/db_check_done 0 + chown radio radio /data/vendor/radio/db_check_done + chmod 0660 /data/vendor/radio/db_check_done + + # Create directories for Location services + mkdir /data/vendor/location 0770 gps gps + mkdir /data/vendor/location/mq 0770 gps gps + mkdir /data/vendor/location/xtwifi 0770 gps gps + + # NFC local data and nfcee xml storage + mkdir /data/nfc 0770 nfc nfc + mkdir /data/nfc/param 0770 nfc nfc + mkdir /data/vendor/nfc 0770 nfc nfc + + # b/62837579 elabel directory + mkdir /data/misc/elabel 0700 system system + + +on early-boot + # wait for devices + wait_for_prop sys.qcom.devup 1 + # wait for insmod_sh to finish all modules + wait_for_prop sys.all.modules.ready 1 + # Update dm-verity state and set partition.*.verified properties + verity_update_state + + # Permission for laser sensor driver + chown camera camera /sys/class/wahoo_laser/laser/enable_ps_sensor + + # Permission for Vibrator + chown system system /sys/class/leds/vibrator/device/mode + chown system system /sys/class/leds/vibrator/device/od_clamp + chown system system /sys/class/leds/vibrator/device/rtp_input + chown system system /sys/class/leds/vibrator/device/scale + chown system system /sys/class/leds/vibrator/device/set_sequencer + chown system system /sys/class/leds/vibrator/device/autocal_result + chown system system /sys/class/leds/vibrator/device/ctrl_loop + chown system system /sys/class/leds/vibrator/device/ol_lra_period + chown system system /sys/class/leds/vibrator/device/autocal + chown system system /sys/class/leds/vibrator/device/lp_trigger_effect + + # Permission for LED driver + chown system system /sys/class/leds/red/on_off_ms + chown system system /sys/class/leds/green/on_off_ms + chown system system /sys/class/leds/blue/on_off_ms + chown system system /sys/class/leds/red/rgb_start + chown system system /sys/class/leds/green/rgb_start + chown system system /sys/class/leds/blue/rgb_start + chown system system /sys/class/graphics/fb0/msm_fb_persist_mode + +on boot + mkdir /dev/socket/qmux_radio 0770 radio radio + chmod 2770 /dev/socket/qmux_radio + mkdir /dev/socket/qmux_audio 0770 media audio + chmod 2770 /dev/socket/qmux_audio + mkdir /dev/socket/qmux_bluetooth 0770 bluetooth bluetooth + chmod 2770 /dev/socket/qmux_bluetooth + mkdir /dev/socket/qmux_gps 0770 gps gps + chmod 2770 /dev/socket/qmux_gps + + # Create NETMGR daemon socket area + mkdir /dev/socket/netmgr 0750 radio radio + + setprop wifi.interface wlan0 + + # Define TCP buffer sizes for various networks + # ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax, + setprop net.tcp.buffersize.wifi 524288,2097152,4194304,262144,524288,1048576 + + # Assign TCP buffer thresholds to be ceiling value of technology maximums + # Increased technology maximums should be reflected here. + write /proc/sys/net/core/rmem_max 8388608 + write /proc/sys/net/core/wmem_max 8388608 + + # Update DVR cpusets to boot-time values. + write /dev/cpuset/kernel/cpus 0-7 + write /dev/cpuset/system/cpus 0-7 + write /dev/cpuset/system/performance/cpus 0-7 + write /dev/cpuset/system/background/cpus 0-7 + write /dev/cpuset/system/cpus 0-7 + write /dev/cpuset/application/cpus 0-7 + write /dev/cpuset/application/performance/cpus 0-7 + write /dev/cpuset/application/background/cpus 0-7 + write /dev/cpuset/application/cpus 0-7 + + # Bluetooth + chown bluetooth net_bt /sys/class/rfkill/rfkill0/type + chown bluetooth net_bt /sys/class/rfkill/rfkill0/state + chmod 0660 /sys/class/rfkill/rfkill0/state + chown bluetooth net_bt /sys/class/rfkill/rfkill0/device/extldo + chmod 0660 /sys/class/rfkill/rfkill0/device/extldo + + # Wifi firmware reload path + chown wifi wifi /sys/module/wlan/parameters/fwpath + + # Allow system to write to cycle_count_id to iterate and get stats + chown system system /sys/class/power_supply/bms/cycle_count_id + chmod 0666 /sys/class/power_supply/bms/cycle_count_id + + # default country code + setprop ro.boot.wificountrycode 00 + + # Encrypted ramoops + umount /sys/fs/pstore + chmod 770 /dev/access-ramoops + chown system system /dev/access-ramoops + chmod 770 /dev/access-metadata + chown system system /dev/access-metadata + + # Make the ftm4 command node writeable from dumpstate + chown system system /sys/devices/virtual/input/ftm4_touch/cmd + + # ftm4 VR mode + chown system system /sys/devices/virtual/input/ftm4_touch/vrmode + +service init-elabel-sh /system/bin/init.elabel.sh + class late_start + user system + group system + oneshot + +service init-radio-sh /vendor/bin/init.radio.sh + class late_start + user radio + group root radio + oneshot + +service folio_daemon /system/bin/folio_daemon + class late_start + user system + group system + +service perfd /vendor/bin/perfd + class main + user root + group root readproc system + socket perfd seqpacket 0666 root system + disabled + +service thermal-engine /vendor/bin/thermal-engine -c ${sys.qcom.thermalcfg:-/vendor/etc/thermal-engine.conf} + class main + user root + group root system + socket thermal-send-client stream 0666 system system + socket thermal-recv-client stream 0660 system system + socket thermal-recv-passive-client stream 0666 system system + +service msm_irqbalance /vendor/bin/msm_irqbalance -f /vendor/etc/msm_irqbalance.conf + socket msm_irqbalance seqpacket 660 root system + class core + user root + group root + writepid /dev/cpuset/system-background/tasks + +on property:persist.sys.ssr.restart_level=* + start ssr_setup + +service ssr_setup /vendor/bin/ssr_setup + oneshot + disabled + +service ssr_diag /vendor/bin/ssr_diag + class late_start + user system + group system + disabled + +service per_mgr /vendor/bin/pm-service + class core + user system + group system + ioprio rt 4 + shutdown critical + +service per_proxy /vendor/bin/pm-proxy + class core + user system + group system + disabled + +on property:sys.post_boot.parsed=1 + start perfd + +on property:sys.boot_completed=1 + # Enable power setting and set sys.post_boot.parsed to 1 + # to start perfd + start power_sh + + # Enable UFS powersaving + write /sys/devices/soc/${ro.boot.bootdevice}/clkscale_enable 1 + write /sys/devices/soc/${ro.boot.bootdevice}/clkgate_enable 1 + write /sys/devices/soc/${ro.boot.bootdevice}/hibern8_on_idle_enable 1 + write /sys/module/lpm_levels/parameters/sleep_disabled N + + # Enable ZRAM on boot_complete + swapon_all /vendor/etc/fstab.${ro.hardware} + + # Setup final cpuset + write /dev/cpuset/top-app/cpus 0-7 + write /dev/cpuset/foreground/boost/cpus 0-3,6-7 + write /dev/cpuset/foreground/cpus 0-3,6-7 + write /dev/cpuset/background/cpus 0-1 + write /dev/cpuset/system-background/cpus 0-3 + + # Update DVR cpusets to runtime values. + write /dev/cpuset/kernel/cpus 2,3 + write /dev/cpuset/system/performance/cpus 6-7 + write /dev/cpuset/system/background/cpus 0-1 + write /dev/cpuset/system/cpus 0-1,6-7 + write /dev/cpuset/application/performance/cpus 4-5 + write /dev/cpuset/application/background/cpus 0-1 + write /dev/cpuset/application/cpus 0-1,4-5 + +on property:init.svc.per_mgr=running + start per_proxy + +on shutdown + stop per_proxy + # Disable subsystem restart + write /sys/module/subsystem_restart/parameters/disable_restart_work 0x9889deed + +service qseecomd /vendor/bin/qseecomd + class core + user root + group root + shutdown critical + +service time_daemon /vendor/bin/time_daemon + class core + user root + group root + +service ss_ramdump /vendor/bin/subsystem_ramdump + class main + user root + group root system + disabled + +on property:persist.sys.ssr.enable_ramdumps=1 + write /sys/module/subsystem_restart/parameters/enable_ramdumps 1 + mkdir /data/vendor/ssrdump 761 root system + mkdir /data/vendor/ramdump 771 root system + mkdir /data/vendor/ramdump/bluetooth 771 root system + start ss_ramdump + +on property:persist.sys.ssr.enable_ramdumps=0 + write /sys/module/subsystem_restart/parameters/enable_ramdumps 0 + +service sensors /vendor/bin/sensors.qcom + class core + user system + group system + # Grants the ability for this daemon to bind IPC router ports so it can + # register QMI services + capabilities NET_BIND_SERVICE + +service adsprpcd /vendor/bin/adsprpcd + class main + user media + group media + +service irsc_util /vendor/bin/irsc_util "/vendor/etc/sec_config" + class core + user root + oneshot + +service rmt_storage /vendor/bin/rmt_storage + class core + user root + ioprio rt 0 + shutdown critical + +service tftp_server /vendor/bin/tftp_server + class core + user root + group root system + +service wpa_supplicant /vendor/bin/hw/wpa_supplicant \ + -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \ + -I/vendor/etc/wifi/p2p_supplicant_overlay.conf -N \ + -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \ + -I/vendor/etc/wifi/wpa_supplicant_overlay.conf \ + -O/data/misc/wifi/sockets -puse_p2p_group_interface=1 -dd \ + -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0 + # we will start as root and wpa_supplicant will switch to user wifi + # after setting up the capabilities required for WEXT + # user wifi + # group wifi inet keystore + class main + socket wpa_wlan0 dgram 660 wifi wifi + disabled + oneshot + +service cnss-daemon /vendor/bin/cnss-daemon -n -l + class late_start + user system + group system inet wifi + +service imsqmidaemon /vendor/bin/imsqmidaemon + class main + user system + socket ims_qmid stream 0660 system radio + group radio log diag + +service imsdatadaemon /vendor/bin/imsdatadaemon + class main + user system + socket ims_datad stream 0660 system radio + group system wifi radio inet log + disabled + +on property:vendor.ims.QMI_DAEMON_STATUS=1 + start imsdatadaemon + +service ims_rtp_daemon /vendor/bin/ims_rtp_daemon + class main + user system + group radio diag inet log + disabled + +service imsrcsservice /vendor/bin/imsrcsd + class hal + user system + group radio diag inet log + disabled + +on property:vendor.ims.DATA_DAEMON_STATUS=1 + start ims_rtp_daemon + start imsrcsservice + +service qmuxd /vendor/bin/qmuxd + class main + user root + group radio audio bluetooth gps nfc qcom_diag + +#TODO evaluate group system once b/62571088 is resolved +service cnd /vendor/bin/cnd + class main + user system + group inet system wifi radio wakelock + +service netmgrd /vendor/bin/netmgrd + class main + user root + group root wifi wakelock radio inet + +service port-bridge /vendor/bin/port-bridge + class main + user radio + group radio system inet + oneshot + +service ipacm /vendor/bin/ipacm + class main + user radio + group radio inet + +service qti /vendor/bin/qti + class main + user radio + group radio net_raw diag usb net_admin + +on property:wc_transport.start_hci=true + start hci_filter + +on property:wc_transport.start_hci=false + stop hci_filter + +service hci_filter /vendor/bin/wcnss_filter + class late_start + user bluetooth + group bluetooth diag system wakelock + disabled + +service loc_launcher /vendor/bin/loc_launcher + class late_start + group gps inet diag wifi + +service pd_mapper /vendor/bin/pd-mapper + class core + +service atfwd /vendor/bin/ATFWD-daemon + class late_start + user system + group system radio + disabled + +on property:persist.radio.atfwd.start=true + start atfwd + +on property:persist.radio.atfwd.start=false + stop atfwd + +# bugreport is triggered by holding down volume down, volume up and power +service bugreport /system/bin/dumpstate -d -p -B -z \ + -o /data/user_de/0/com.android.shell/files/bugreports/bugreport + class main + disabled + oneshot + keycodes 114 115 116 + +service chre /vendor/bin/chre + class late_start + user system + group system + socket chre seqpacket 0660 root system + shutdown critical + +service power_sh /vendor/bin/init.power.sh + class main + user root + group root system + disabled + oneshot + +service devstart_sh /vendor/bin/init.qcom.devstart.sh + class main + user root + group root system + disabled + oneshot + +service ipastart_sh /vendor/bin/init.qcom.ipastart.sh + class main + user system + group net_admin + disabled + oneshot + +service insmod_sh /vendor/bin/init.insmod.sh + class main + user root + group root system + disabled + oneshot + +service ramoops_sh /system/bin/init.ramoops.sh + class main + user root + group root system + disabled + oneshot + diff --git a/init.hardware.usb.rc b/init.hardware.usb.rc new file mode 100644 index 00000000..7b8b6924 --- /dev/null +++ b/init.hardware.usb.rc @@ -0,0 +1,118 @@ +# +# Copyright (C) 2016 The Android Open-Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +on boot + mount configfs none /config + mkdir /config/usb_gadget/g1 0770 shell shell + mkdir /config/usb_gadget/g1/strings/0x409 0770 shell shell + write /config/usb_gadget/g1/bcdUSB 0x0200 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/bcdDevice 0x0440 + write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno} + write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer} + write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model} + mkdir /config/usb_gadget/g1/functions/mass_storage.0 + mkdir /config/usb_gadget/g1/functions/accessory.gs2 + mkdir /config/usb_gadget/g1/functions/audio_source.gs3 + mkdir /config/usb_gadget/g1/functions/midi.gs5 + mkdir /config/usb_gadget/g1/functions/ffs.adb + mkdir /config/usb_gadget/g1/functions/ffs.mtp + mkdir /config/usb_gadget/g1/functions/diag.diag + mkdir /config/usb_gadget/g1/functions/cser.dun.0 + mkdir /config/usb_gadget/g1/functions/cser.nmea.1 + mkdir /config/usb_gadget/g1/functions/gsi.rmnet + mkdir /config/usb_gadget/g1/functions/gsi.rndis + mkdir /config/usb_gadget/g1/functions/qdss.qdss + mkdir /config/usb_gadget/g1/configs/b.1 0770 shell shell + mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell + write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1 + mkdir /dev/usb-ffs 0775 shell shell + mkdir /dev/usb-ffs/adb 0770 shell shell + mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000 + mkdir /dev/usb-ffs/mtp 0770 mtp mtp + mount functionfs mtp /dev/usb-ffs/mtp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1 + setprop sys.usb.ffs.max_write 524288 + setprop sys.usb.ffs.max_read 524288 + setprop sys.usb.mtp.device_type 3 + setprop sys.usb.configfs 1 + setprop sys.usb.controller "a800000.dwc3" + write /sys/module/libcomposite/parameters/disable_l1_for_hs "y" + +on property:sys.usb.ffs.mtp.ready=1 && property:sys.usb.config=mtp && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x4ee1 + symlink /config/usb_gadget/g1/functions/ffs.mtp /config/usb_gadget/g1/configs/b.1/f1 + +on property:sys.usb.ffs.ready=1 && property:sys.usb.ffs.mtp.ready=1 && property:sys.usb.config=mtp,adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x4ee2 + symlink /config/usb_gadget/g1/functions/ffs.mtp /config/usb_gadget/g1/configs/b.1/f1 + +on property:sys.usb.config=rndis && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x4ee3 + symlink /config/usb_gadget/g1/functions/gsi.rndis /config/usb_gadget/g1/configs/b.1/f1 + +on property:sys.usb.ffs.ready=1 && property:sys.usb.config=rndis,adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x4ee4 + symlink /config/usb_gadget/g1/functions/gsi.rndis /config/usb_gadget/g1/configs/b.1/f1 + +on property:sys.usb.ffs.mtp.ready=1 && property:sys.usb.config=ptp && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x4ee5 + symlink /config/usb_gadget/g1/functions/ffs.mtp /config/usb_gadget/g1/configs/b.1/f1 + +on property:sys.usb.ffs.ready=1 && property:sys.usb.ffs.mtp.ready=1 && property:sys.usb.config=ptp,adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x4ee6 + symlink /config/usb_gadget/g1/functions/ffs.mtp /config/usb_gadget/g1/configs/b.1/f1 + +on property:sys.usb.config=adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x4ee7 + +on property:sys.usb.config=midi && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x4ee8 + +on property:sys.usb.config=midi,adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x4ee9 + +on property:sys.usb.config=accessory && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x2d00 + +on property:sys.usb.config=accessory,adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x2d01 + +on property:sys.usb.config=audio_source && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x2d02 + +on property:sys.usb.config=audio_source,adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x2d03 + +on property:sys.usb.config=accessory,audio_source && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x2d04 + +on property:sys.usb.config=accessory,audio_source,adb && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0x2d05 diff --git a/init.insmod.sh b/init.insmod.sh new file mode 100755 index 00000000..d98037cf --- /dev/null +++ b/init.insmod.sh @@ -0,0 +1,24 @@ +#! /vendor/bin/sh + +######################################### +### init.insmod.cfg format: ### +### --------------------------------- ### +### [insmod|setprop] [path|prop name] ### +### ... ### +######################################### + +cfg_file="/vendor/etc/init.insmod.cfg" + +if [ -f $cfg_file ]; then + while IFS=" " read -r action name + do + case $action in + "insmod") insmod $name ;; + "setprop") setprop $name 1 ;; + esac + done < $cfg_file +fi + +# set property even if there is no insmod config +# as property value "1" is expected in early-boot trigger +setprop sys.all.modules.ready 1 diff --git a/init.power.sh b/init.power.sh new file mode 100755 index 00000000..3dc650d0 --- /dev/null +++ b/init.power.sh @@ -0,0 +1,53 @@ +#! /vendor/bin/sh + +################################################################################ +# helper functions to allow Android init like script + +function write() { + echo -n $2 > $1 +} + +function copy() { + cat $1 > $2 +} + +################################################################################ + +# Enable bus-dcvs +for cpubw in /sys/class/devfreq/*qcom,cpubw* +do + write $cpubw/governor "bw_hwmon" + write $cpubw/polling_interval 50 + write $cpubw/min_freq 1525 + write $cpubw/bw_hwmon/mbps_zones "3143 5859 11863 13763" + write $cpubw/bw_hwmon/sample_ms 4 + write $cpubw/bw_hwmon/io_percent 34 + write $cpubw/bw_hwmon/hist_memory 20 + write $cpubw/bw_hwmon/hyst_length 10 + write $cpubw/bw_hwmon/low_power_ceil_mbps 0 + write $cpubw/bw_hwmon/low_power_io_percent 34 + write $cpubw/bw_hwmon/low_power_delay 20 + write $cpubw/bw_hwmon/guard_band_mbps 0 + write $cpubw/bw_hwmon/up_scale 250 + write $cpubw/bw_hwmon/idle_mbps 1600 +done + +write /sys/class/devfreq/soc:qcom,mincpubw/governor "cpufreq" + +# Enable memlat governor +for memlat in /sys/class/devfreq/*qcom,memlat-cpu* +do + write $memlat/governor "mem_latency" + write $memlat/polling_interval 10 + write $memlat/mem_latency/ratio_ceil 400 +done + +# Signal perfd that boot has completed +setprop sys.post_boot.parsed 1 + +# On debuggable builds, enable console_suspend if uart is enabled to save power +# Otherwise, disable console_suspend to get better logging for kernel crashes +if [[ $(getprop ro.debuggable) == "1" && ! -e /sys/class/tty/ttyMSM0 ]] +then + write /sys/module/printk/parameters/console_suspend N +fi diff --git a/init.qcom.devstart.sh b/init.qcom.devstart.sh new file mode 100644 index 00000000..3589ac22 --- /dev/null +++ b/init.qcom.devstart.sh @@ -0,0 +1,10 @@ +#! /vendor/bin/sh + +echo 1 > /sys/kernel/boot_adsp/boot +echo 1 > /sys/kernel/boot_slpi/boot +setprop sys.qcom.devup 1 + +version=`grep -ao "OEM_IMAGE_VERSION_STRING[ -~]*" \ + /vendor/firmware/slpi_v2.b04 | \ + sed -e s/OEM_IMAGE_VERSION_STRING=SLPI.version.// -e s/\(.*\).//` +setprop sys.slpi.firmware.version "$version" diff --git a/init.qcom.ipastart.sh b/init.qcom.ipastart.sh new file mode 100644 index 00000000..48b96d09 --- /dev/null +++ b/init.qcom.ipastart.sh @@ -0,0 +1,3 @@ +#! /vendor/bin/sh + +echo 1 > /dev/ipa diff --git a/init.radio.sh b/init.radio.sh new file mode 100644 index 00000000..55104ccc --- /dev/null +++ b/init.radio.sh @@ -0,0 +1,33 @@ +#! /vendor/bin/sh + +# +# Copy qcril.db if needed for RIL +# +if [ -f /vendor/radio/qcril_database/qcril.db -a ! -f /data/vendor/radio/qcril.db ]; then + cp /vendor/radio/qcril_database/qcril.db /data/vendor/radio/qcril.db + chown -h radio.radio /data/vendor/radio/qcril.db +fi +echo 1 > /data/vendor/radio/db_check_done + +# +# Make modem config folder and copy firmware config to that folder for RIL +# +if [ -f /data/vendor/radio/ver_info.txt ]; then + prev_version_info=`cat /data/vendor/radio/ver_info.txt` +else + prev_version_info="" +fi + +cur_version_info=`cat /firmware/verinfo/ver_info.txt` +if [ ! -f /firmware/verinfo/ver_info.txt -o "$prev_version_info" != "$cur_version_info" ]; then + rm -rf /data/vendor/radio/modem_config + mkdir /data/vendor/radio/modem_config + chmod 770 /data/vendor/radio/modem_config + cp -r /firmware/image/modem_pr/mcfg/configs/* /data/vendor/radio/modem_config + chown -hR radio.radio /data/vendor/radio/modem_config + cp /firmware/verinfo/ver_info.txt /data/vendor/radio/ver_info.txt + chown radio.radio /data/vendor/radio/ver_info.txt +fi +cp /firmware/image/modem_pr/mbn_ota.txt /data/vendor/radio/modem_config +chown radio.radio /data/vendor/radio/modem_config/mbn_ota.txt +echo 1 > /data/vendor/radio/copy_complete diff --git a/init.ramoops.sh b/init.ramoops.sh new file mode 100644 index 00000000..4c57a1a1 --- /dev/null +++ b/init.ramoops.sh @@ -0,0 +1,22 @@ +#!/system/bin/sh + +# Decrypt the keys and write them to the kernel +ramoops -D + +if [ $? -eq 0 ]; then + # Pivot (and decrypt) + echo 1 > /sys/devices/virtual/ramoops/pstore/use_alt +else + setprop sys.ramoops.decryption.error $? +fi + +# Trigger remount of pstore regardless of decryption state +setprop sys.ramoops.decrypted true + +# Generate keys (if none exist), and load the keys to carveout +if [[ $(getprop ro.hardware) == "walleye" ]]; then + ramoops -g -l -c +else + ramoops -g -l +fi + diff --git a/init.recovery.hardware.rc b/init.recovery.hardware.rc new file mode 100644 index 00000000..b40464ee --- /dev/null +++ b/init.recovery.hardware.rc @@ -0,0 +1,24 @@ +on fs + wait /dev/block/platform/soc/${ro.boot.bootdevice} + symlink /dev/block/platform/soc/${ro.boot.bootdevice} /dev/block/bootdevice + +on init + mount configfs none /config + mkdir /config/usb_gadget/g1 0770 shell shell + write /config/usb_gadget/g1/idVendor 0x18d1 + write /config/usb_gadget/g1/idProduct 0xd001 + mkdir /config/usb_gadget/g1/strings/0x409 0770 + write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno} + write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer} + write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model} + mkdir /config/usb_gadget/g1/functions/ffs.adb + write /config/usb_gadget/g1/os_desc/use 1 + setprop sys.usb.configfs 1 + +on property:sys.usb.ffs.ready=1 + mkdir /config/usb_gadget/g1/configs/b.1 0777 shell shell + symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1 + mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb" + symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1 + write /config/usb_gadget/g1/UDC "a800000.dwc3" diff --git a/liblight/Android.mk b/liblight/Android.mk new file mode 100644 index 00000000..ef0c71a7 --- /dev/null +++ b/liblight/Android.mk @@ -0,0 +1,30 @@ +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := lights.c +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_PROPRIETARY_MODULE := true +LOCAL_SHARED_LIBRARIES := libc libcutils liblog +LOCAL_CFLAGS := $(common_flags) \ + -DLOG_TAG=\"qdlights\" \ + -DDEFAULT_LOW_PERSISTENCE_MODE_BRIGHTNESS=$(DEFAULT_LOW_PERSISTENCE_MODE_BRIGHTNESS) +LOCAL_CLANG := true +LOCAL_MODULE := lights.$(TARGET_DEVICE) +LOCAL_MODULE_TAGS := optional + +include $(BUILD_SHARED_LIBRARY) diff --git a/liblight/NOTICE b/liblight/NOTICE new file mode 100644 index 00000000..7340b9e3 --- /dev/null +++ b/liblight/NOTICE @@ -0,0 +1,190 @@ + + Copyright (c) 2008, The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + diff --git a/liblight/lights.c b/liblight/lights.c new file mode 100644 index 00000000..ae22ddb5 --- /dev/null +++ b/liblight/lights.c @@ -0,0 +1,388 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2014 The Linux Foundation. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include + +/* + * Change this to 1 to support battery notifications via BatteryService + */ +#define LIGHTS_SUPPORT_BATTERY 0 +#define CG_COLOR_ID_PROPERTY "ro.boot.hardware.color" + +#define LP_MODE_BRIGHTNESS_PROPERTY "sys.display.low_persistence_mode_brightness" + +static pthread_once_t g_init = PTHREAD_ONCE_INIT; +static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER; +static struct light_state_t g_notification; +static struct light_state_t g_battery; +static int g_last_backlight_mode = BRIGHTNESS_MODE_USER; +static int g_attention = 0; +static int rgb_brightness_ratio = 255; + +char const*const RED_LED_FILE + = "/sys/class/leds/red/brightness"; + +char const*const GREEN_LED_FILE + = "/sys/class/leds/green/brightness"; + +char const*const BLUE_LED_FILE + = "/sys/class/leds/blue/brightness"; + +char const*const LCD_FILE + = "/sys/class/leds/lcd-backlight/brightness"; + +char const*const PERSISTENCE_FILE + = "/sys/class/graphics/fb0/msm_fb_persist_mode"; + +char const*const RED_BLINK_FILE + = "/sys/class/leds/red/blink"; + +char const*const GREEN_BLINK_FILE + = "/sys/class/leds/green/blink"; + +char const*const BLUE_BLINK_FILE + = "/sys/class/leds/blue/blink"; + +char const*const RED_ON_OFF_MS_FILE + = "/sys/class/leds/red/on_off_ms"; + +char const*const GREEN_ON_OFF_MS_FILE + = "/sys/class/leds/green/on_off_ms"; + +char const*const BLUE_ON_OFF_MS_FILE + = "/sys/class/leds/blue/on_off_ms"; + +char const*const RED_RGB_START_FILE + = "/sys/class/leds/red/rgb_start"; + +char const*const GREEN_RGB_START_FILE + = "/sys/class/leds/green/rgb_start"; + +char const*const BLUE_RGB_START_FILE + = "/sys/class/leds/blue/rgb_start"; + +/** + * device methods + */ + +void init_globals(void) +{ + char color_id_prop[PROPERTY_VALUE_MAX] = {""}; + + // init the mutex + pthread_mutex_init(&g_lock, NULL); + + // check CG color + property_get(CG_COLOR_ID_PROPERTY, color_id_prop, "DEF00"); + if (strcmp(color_id_prop, "GRA00") == 0) { + rgb_brightness_ratio = 25; + } else if (strcmp(color_id_prop, "SLV00") == 0) { + rgb_brightness_ratio = 15; + } else if (strcmp(color_id_prop, "BLU00") == 0) { + rgb_brightness_ratio = 15; + } else { + rgb_brightness_ratio = 20; + } +} + +static int +write_int(char const* path, int value) +{ + int fd; + static int already_warned = 0; + + fd = open(path, O_WRONLY); + if (fd >= 0) { + char buffer[20]; + size_t bytes = snprintf(buffer, sizeof(buffer), "%d\n", value); + if(bytes >= sizeof(buffer)) return -EINVAL; + ssize_t amt = write(fd, buffer, bytes); + close(fd); + return amt == -1 ? -errno : 0; + } else { + if (already_warned == 0) { + ALOGE("write_int failed to open %s\n", path); + already_warned = 1; + } + return -errno; + } +} + +static int +write_double_int(char const* path, int value1, int value2) +{ + int fd; + static int already_warned = 0; + + fd = open(path, O_WRONLY); + if (fd >= 0) { + char buffer[20]; + size_t bytes = snprintf(buffer, sizeof(buffer), "%d %d\n", value1, value2); + if(bytes >= sizeof(buffer)) return -EINVAL; + ssize_t amt = write(fd, buffer, bytes); + close(fd); + return amt == -1 ? -errno : 0; + } else { + if (already_warned == 0) { + ALOGE("write_int failed to open %s\n", path); + already_warned = 1; + } + return -errno; + } +} + +static int +is_lit(struct light_state_t const* state) +{ + return state->color & 0x00ffffff; +} + +static int +rgb_to_brightness(struct light_state_t const* state) +{ + int color = state->color & 0x00ffffff; + return ((77*((color>>16)&0x00ff)) + + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8; +} + +static int +set_light_backlight(struct light_device_t* dev, + struct light_state_t const* state) +{ + int err = 0; + int brightness = rgb_to_brightness(state); + unsigned int lpEnabled = state->brightnessMode == BRIGHTNESS_MODE_LOW_PERSISTENCE; + if(!dev) { + return -1; + } + + pthread_mutex_lock(&g_lock); + + // If we're not in lp mode and it has been enabled or if we are in lp mode + // and it has been disabled send an ioctl to the display with the update + if ((g_last_backlight_mode != state->brightnessMode && lpEnabled) || + (!lpEnabled && g_last_backlight_mode == BRIGHTNESS_MODE_LOW_PERSISTENCE)) { + if ((err = write_int(PERSISTENCE_FILE, lpEnabled)) != 0) { + ALOGE("%s: Failed to write to %s: %s\n", __FUNCTION__, PERSISTENCE_FILE, + strerror(errno)); + } + if (lpEnabled != 0) { + // Try to get the brigntess though property, otherwise it will + // set the default brightness, which is defined in BoardConfig.mk. + brightness = property_get_int32(LP_MODE_BRIGHTNESS_PROPERTY, + DEFAULT_LOW_PERSISTENCE_MODE_BRIGHTNESS); + } + } + + g_last_backlight_mode = state->brightnessMode; + + if (!err) { + err = write_int(LCD_FILE, brightness); + } + + pthread_mutex_unlock(&g_lock); + return err; +} + +static int +set_speaker_light_locked(struct light_device_t* dev, + struct light_state_t const* state) +{ + int red, green, blue; + int blink; + int onMS, offMS; + unsigned int colorRGB; + + if(!dev) { + return -1; + } + + switch (state->flashMode) { + case LIGHT_FLASH_TIMED: + onMS = state->flashOnMS; + offMS = state->flashOffMS; + break; + case LIGHT_FLASH_NONE: + default: + onMS = 0; + offMS = 0; + break; + } + + colorRGB = state->color; + +#if 0 + ALOGD("set_speaker_light_locked mode %d, colorRGB=%08X, onMS=%d, offMS=%d\n", + state->flashMode, colorRGB, onMS, offMS); +#endif + + red = ((colorRGB >> 16) & 0xFF) * rgb_brightness_ratio / 255; + green = ((colorRGB >> 8) & 0xFF) * rgb_brightness_ratio / 255; + blue = (colorRGB & 0xFF) * rgb_brightness_ratio / 255; + + write_double_int(RED_ON_OFF_MS_FILE, onMS, offMS); + write_int(RED_LED_FILE, red); + write_double_int(GREEN_ON_OFF_MS_FILE, onMS, offMS); + write_int(GREEN_LED_FILE, green); + write_double_int(BLUE_ON_OFF_MS_FILE, onMS, offMS); + write_int(BLUE_LED_FILE, blue); + + if(!write_int(RED_RGB_START_FILE, 1)) + if(!write_int(GREEN_RGB_START_FILE, 1)) + if(!write_int(BLUE_RGB_START_FILE, 1)) + return -1; + + return 0; +} + +static void +handle_speaker_battery_locked(struct light_device_t* dev) +{ + if (is_lit(&g_battery)) { + set_speaker_light_locked(dev, &g_battery); + } else { + set_speaker_light_locked(dev, &g_notification); + } +} + +#if LIGHTS_SUPPORT_BATTERY +static int +set_light_battery(struct light_device_t* dev, + struct light_state_t const* state) +{ + pthread_mutex_lock(&g_lock); + g_battery = *state; + handle_speaker_battery_locked(dev); + pthread_mutex_unlock(&g_lock); + return 0; +} +#endif + +static int +set_light_notifications(struct light_device_t* dev, + struct light_state_t const* state) +{ + pthread_mutex_lock(&g_lock); + g_notification = *state; + handle_speaker_battery_locked(dev); + pthread_mutex_unlock(&g_lock); + return 0; +} + +static int +set_light_attention(struct light_device_t* dev, + struct light_state_t const* state) +{ + pthread_mutex_lock(&g_lock); + if (state->flashMode == LIGHT_FLASH_HARDWARE) { + g_attention = state->flashOnMS; + } else if (state->flashMode == LIGHT_FLASH_NONE) { + g_attention = 0; + } + handle_speaker_battery_locked(dev); + pthread_mutex_unlock(&g_lock); + return 0; +} + +/** Close the lights device */ +static int +close_lights(struct light_device_t *dev) +{ + if (dev) { + free(dev); + } + return 0; +} + + +/******************************************************************************/ + +/** + * module methods + */ + +/** Open a new instance of a lights device using name */ +static int open_lights(const struct hw_module_t* module, char const* name, + struct hw_device_t** device) +{ + int (*set_light)(struct light_device_t* dev, + struct light_state_t const* state); + + if (0 == strcmp(LIGHT_ID_BACKLIGHT, name)) + set_light = set_light_backlight; +#if LIGHTS_SUPPORT_BATTERY + else if (0 == strcmp(LIGHT_ID_BATTERY, name)) + set_light = set_light_battery; +#endif + else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name)) + set_light = set_light_notifications; + else if (0 == strcmp(LIGHT_ID_ATTENTION, name)) + set_light = set_light_attention; + else + return -EINVAL; + + pthread_once(&g_init, init_globals); + + struct light_device_t *dev = malloc(sizeof(struct light_device_t)); + + if(!dev) + return -ENOMEM; + + memset(dev, 0, sizeof(*dev)); + + dev->common.tag = HARDWARE_DEVICE_TAG; + dev->common.version = LIGHTS_DEVICE_API_VERSION_2_0; + dev->common.module = (struct hw_module_t*)module; + dev->common.close = (int (*)(struct hw_device_t*))close_lights; + dev->set_light = set_light; + + *device = (struct hw_device_t*)dev; + return 0; +} + +static struct hw_module_methods_t lights_module_methods = { + .open = open_lights, +}; + +/* + * The lights Module + */ +struct hw_module_t HAL_MODULE_INFO_SYM = { + .tag = HARDWARE_MODULE_TAG, + .version_major = 1, + .version_minor = 0, + .id = LIGHTS_HARDWARE_MODULE_ID, + .name = "lights Module", + .author = "Google, Inc.", + .methods = &lights_module_methods, +}; diff --git a/libtango_device2.jar b/libtango_device2.jar new file mode 100644 index 00000000..36d86087 Binary files /dev/null and b/libtango_device2.jar differ diff --git a/lisa/targetdev/__init__.py b/lisa/targetdev/__init__.py new file mode 100644 index 00000000..130911e1 --- /dev/null +++ b/lisa/targetdev/__init__.py @@ -0,0 +1,2 @@ + +print 'Welcome to wahoo LISA environment' diff --git a/lisa/targetdev/powerhint.py b/lisa/targetdev/powerhint.py new file mode 100644 index 00000000..2254f715 --- /dev/null +++ b/lisa/targetdev/powerhint.py @@ -0,0 +1,83 @@ +import xml.etree.ElementTree as ET +import tempfile + +DEVICE_PATH = '/vendor/etc/powerhint.xml' + + +def restart_power_hal(target): + """Kill power HAL service so it can pick up new values in powerhint.xml.""" + target.execute('pkill -f android\.hardware\.power') + + +def set_touch_param(target, opcode, new_val): + """Set a new value for the touch hint parameter with the specified opcode.""" + hinttype = '0x1A00' + + # Get current powerhint.xml file + with tempfile.NamedTemporaryFile() as tmp: + target.pull(DEVICE_PATH, tmp.name) + + # Replace current parameter value + tree = ET.parse(tmp.name) + xpath = './Hint[@type="{}"]/Resource[@opcode="{}"]'.format(hinttype, opcode) + tree.findall(xpath)[0].set('value', '{:#x}'.format(new_val)) + + # Write new powerhint.xml file to device + tree.write(tmp.name) + target.push(tmp.name, DEVICE_PATH) + + # Restart power HAL to pick up new value + restart_power_hal(target) + + +def set_touch_boost(target, boost=50): + """Change the top-app schedtune.boost value to use after touch events.""" + opcode = '0x42C18000' + if boost < 0: + boost = 100-boost + set_touch_param(target, opcode, boost) + + +def set_touch_min_freq(target, cluster, freq=1100): + """Change the CPU cluster min frequency (in Mhz) to use after touch events.""" + opcode = '0x40800000' if cluster == 'big' else '0x40800100' + set_touch_param(target, opcode, freq) + + +def set_touch_cpubw_hysteresis(target, enable=False): + """Set whether to leave CPUBW hysteresis enabled after touch events.""" + opcode = '0x4180C000' + enable_num = 1 if enable else 0 + set_touch_param(target, opcode, enable_num) + + +def set_touch_cpubw_min_freq(target, freq=51): + """Set CPUBW min freq used after touch events. See mapping in msm8998.dtsi.""" + opcode = '0x41800000' + set_touch_param(target, opcode, freq) + + +def restore_defaults(target, powerhint_host_path): + """Restore default power hint settings using a powerhint.xml file from the host.""" + target.push(powerhint_host_path, DEVICE_PATH) + + restart_power_hal(target) + + +def disable_launch_hint(target): + """Turn off all launch hint tweaks.""" + hinttype = '0x1B00' + + with tempfile.NamedTemporaryFile() as tmp: + target.pull(DEVICE_PATH, tmp.name) + + tree = ET.parse(tmp.name) + xpath = './Hint[@type="{}"]'.format(hinttype) + launch_hints = tree.findall(xpath)[0] + for child in launch_hints.findall('./Resource'): + launch_hints.remove(child) + + tree.write(tmp.name) + target.push(tmp.name, DEVICE_PATH) + + restart_power_hal(target) diff --git a/lowi.conf b/lowi.conf new file mode 100644 index 00000000..cfadcb21 --- /dev/null +++ b/lowi.conf @@ -0,0 +1,51 @@ +#*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* +# +# LOWI Config file +# +# GENERAL DESCRIPTION +# This file contains the config params for LOWI +# +# Copyright (c) 2012-2013 Qualcomm Atheros, Inc. +# All Rights Reserved. +# Qualcomm Atheros Confidential and Proprietary. +# +# Export of this technology or software is regulated by the U.S. Government. +# Diversion contrary to U.S. law prohibited. +#=============================================================================*/ + +# X86 ONLY - UBUNTU: +# Copy this file in the same directory where the executable is + +# The RSSI threshold used in the RTT outlier detection in half decibels. Default value recommended by the +# system team currently is -140 (corresponding to -70 dB). +LOWI_RSSI_THRESHOLD_FOR_RTT = -140 + +# Number of measurment per AP for RTS/CTS +LOWI_RTS_CTS_NUM_MEAS = 5 + +# Maximum Number of Outstanding Requests supported +LOWI_MAX_OUTSTANDING_REQUEST = 255 + +# Maximum number of records in Cache +LOWI_MAX_NUM_CACHE_RECORDS = 200 + +# Default threshold before issuing another fresh scan (ms) +LOWI_FRESH_SCAN_THRESHOLD = 500 + +# Timeout in case no result is reported by the driver (seconds) +LOWI_NO_RESULT_WAIT_TOLERANCE = 10 + +# Use Fake Wifi driver. Only valid for engineering builds +LOWI_USE_FAKE_WIFI_DRIVER = 0 + +# Use ROME Wifi driver. Only valid for engineering builds +# Will be removed later only for development support +LOWI_USE_ROME_WIFI_DRIVER = 0 + +# Use LOWI LP. +# When enabled the Discovery Request will be routed to LOWI-LP +LOWI_USE_LOWI_LP = 1 + +# Log level +# EL_LOG_OFF = 0, EL_ERROR = 1, EL_WARNING = 2, EL_INFO = 3, EL_DEBUG = 4, EL_VERBOSE = 5, EL_LOG_ALL = 100 +LOWI_LOG_LEVEL = 2 diff --git a/manifest.xml b/manifest.xml new file mode 100644 index 00000000..5efabfa3 --- /dev/null +++ b/manifest.xml @@ -0,0 +1,424 @@ + + + android.hardware.audio + hwbinder + 2.0 + + IDevicesFactory + default + + + + android.hardware.audio.effect + hwbinder + 2.0 + + IEffectsFactory + default + + + + android.hardware.biometrics.fingerprint + hwbinder + 2.1 + + IBiometricsFingerprint + default + + + + android.hardware.bluetooth + hwbinder + 1.0 + + IBluetoothHci + default + + + + android.hardware.boot + hwbinder + 1.0 + + IBootControl + default + + + + android.hardware.camera.provider + hwbinder + 2.4 + + ICameraProvider + legacy/0 + + + + android.hardware.configstore + hwbinder + 1.1 + + ISurfaceFlingerConfigs + default + + + + android.hardware.contexthub + hwbinder + 1.0 + + IContexthub + default + + + + android.hardware.drm + hwbinder + 1.0 + + ICryptoFactory + default + widevine + + + IDrmFactory + default + widevine + + + + android.hardware.dumpstate + hwbinder + 1.0 + + IDumpstateDevice + default + + + + android.hardware.gatekeeper + hwbinder + 1.0 + + IGatekeeper + default + + + + android.hardware.gnss + hwbinder + 1.0 + + IGnss + default + + + + android.hardware.graphics.allocator + hwbinder + 2.0 + + IAllocator + default + + + + android.hardware.graphics.composer + hwbinder + 2.1 + + IComposer + default + + + + android.hardware.graphics.mapper + passthrough + 2.0 + + IMapper + default + + + + android.hardware.keymaster + hwbinder + 3.0 + + IKeymasterDevice + default + + + + android.hardware.light + hwbinder + 2.0 + + ILight + default + + + + android.hardware.media.omx + hwbinder + 1.0 + + IOmx + default + + + IOmxStore + default + + + + android.hardware.memtrack + hwbinder + 1.0 + + IMemtrack + default + + + + android.hardware.nfc + hwbinder + 1.0 + + INfc + default + + + + android.hardware.oemlock + hwbinder + 1.0 + + IOemLock + default + + + + android.hardware.power + hwbinder + 1.1 + + IPower + default + + + + android.hardware.radio.deprecated + hwbinder + 1.0 + + IOemHook + slot1 + + + + android.hardware.radio + hwbinder + 1.1 + + IRadio + slot1 + + + ISap + slot1 + + + + android.hardware.renderscript + passthrough + 1.0 + + IDevice + default + + + + android.hardware.sensors + hwbinder + 1.0 + + ISensors + default + + + + android.hardware.soundtrigger + hwbinder + 2.0 + + ISoundTriggerHw + default + + + + android.hardware.tetheroffload.config + hwbinder + 1.0 + + IOffloadConfig + default + + + + android.hardware.tetheroffload.control + hwbinder + 1.0 + + IOffloadControl + default + + + + android.hardware.thermal + hwbinder + 1.0 + + IThermal + default + + + + android.hardware.usb + hwbinder + 1.1 + + IUsb + default + + + + android.hardware.vibrator + hwbinder + 1.1 + + IVibrator + default + + + + android.hardware.vr + hwbinder + 1.0 + + IVr + default + + + + android.hardware.weaver + hwbinder + 1.0 + + IWeaver + default + + + + android.hardware.wifi + hwbinder + 1.1 + + IWifi + default + + + + android.hardware.wifi.supplicant + hwbinder + 1.0 + + ISupplicant + default + + + + android.hardware.wifi.offload + hwbinder + 1.0 + + IOffload + default + + + + com.qualcomm.qti.ims.radio + hwbinder + 1.0 + + IImsRadio + imsradio0 + + + + com.qualcomm.qti.qcril.qcrilhook + hwbinder + 1.0 + + IQtiOemHook + oemhook0 + + + + com.qualcomm.qti.imsrtpservice + hwbinder + 1.0 + + IRTPService + imsrtpservice + + + + com.qualcomm.qti.uceservice + hwbinder + 1.0 + + IUceService + com.qualcomm.qti.uceservice + + + + vendor.qti.qcril.am + hwbinder + 1.0 + + IQcRilAudio + slot1 + slot2 + + + + com.quicinc.cne.server + hwbinder + + 1.0 + + IServer + cnd + + + + com.quicinc.cne.api + hwbinder + + 1.0 + + IApiService + cnd + + + + vendor.qti.atcmdfwd + hwbinder + 1.0 + + IAtCmdFwd + AtCmdFwdService + + + diff --git a/media_codecs.xml b/media_codecs.xml new file mode 100644 index 00000000..68b75621 --- /dev/null +++ b/media_codecs.xml @@ -0,0 +1,294 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media_codecs_performance.xml b/media_codecs_performance.xml new file mode 100644 index 00000000..23494064 --- /dev/null +++ b/media_codecs_performance.xml @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/media_profiles_V1_0.xml b/media_profiles_V1_0.xml new file mode 100644 index 00000000..db790d05 --- /dev/null +++ b/media_profiles_V1_0.xml @@ -0,0 +1,497 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nfc/libnfc-brcm.conf b/nfc/libnfc-brcm.conf new file mode 100644 index 00000000..05cb160b --- /dev/null +++ b/nfc/libnfc-brcm.conf @@ -0,0 +1,407 @@ +###################### Start of libnfc-brcm.conf ####################### + +############################################################################### +# Application options +APPL_TRACE_LEVEL=0x01 +PROTOCOL_TRACE_LEVEL=0x00000000 + +############################################################################### +# performance measurement +# Change this setting to control how often USERIAL log the performance (throughput) +# data on read/write/poll +# defailt is to log performance dara for every 100 read or write +#REPORT_PERFORMANCE_MEASURE=100 + +############################################################################### +# File used for NFA storage +NFA_STORAGE="/data/nfc" + +############################################################################### +# Snooze Mode Settings +# +# By default snooze mode is enabled. Set SNOOZE_MODE_CFG byte[0] to 0 +# to disable. +# +# If SNOOZE_MODE_CFG is not provided, the default settings are used: +# They are as follows: +# 8 Sleep Mode (0=Disabled 1=UART 8=SPI/I2C) +# 0 Idle Threshold Host +# 0 Idle Threshold HC +# 0 NFC Wake active mode (0=ActiveLow 1=ActiveHigh) +# 1 Host Wake active mode (0=ActiveLow 1=ActiveHigh) +# +#SNOOZE_MODE_CFG={08:00:00:00:01} + +############################################################################### +# Insert a delay in milliseconds after NFC_WAKE and before write to NFCC +#NFC_WAKE_DELAY=20 + +############################################################################### +# Various Delay settings (in ms) used in USERIAL +# POWER_ON_DELAY +# Delay after turning on chip, before writing to transport (default 300) +# PRE_POWER_OFF_DELAY +# Delay after deasserting NFC-Wake before turn off chip (default 0) +# POST_POWER_OFF_DELAY +# Delay after turning off chip, before USERIAL_close returns (default 0) +# +#POWER_ON_DELAY=300 +#PRE_POWER_OFF_DELAY=0 +#POST_POWER_OFF_DELAY=0 + +############################################################################### +# Maximum time (ms) to wait for RESET NTF after setting REG_PU to high +# The default is 1000. +#NFCC_ENABLE_TIMEOUT=0 + +############################################################################### +# LPTD mode configuration +# byte[0] is the length of the remaining bytes in this value +# if set to 0, LPTD params will NOT be sent to NFCC (i.e. disabled). +# byte[1] is the param id it should be set to B9. +# byte[2] is the length of the LPTD parameters +# byte[3] indicates if LPTD is enabled +# if set to 0, LPTD will be disabled (parameters will still be sent). +# byte[4-n] are the LPTD parameters. +# By default, LPTD is enabled and default settings are used. +# See nfc_hal_dm_cfg.c for defaults +#LPTD_CFG={23:B9:21:01:02:FF:FF:04:A0:0F:40:00:80:02:02:10:00:00:00:31:0C:30:00:00:00:00:00:00:00:00:00:00:00:00:00:00} + +############################################################################### +# Startup Configuration (100 bytes maximum) +# +# For the 0xCA parameter, byte[9] (marked by 'AA') is for UICC0, and byte[10] (marked by BB) is +# for UICC1. The values are defined as: +# 0 : UICCx only supports ISO_DEP in low power mode. +# 2 : UICCx only supports Mifare in low power mode. +# 3 : UICCx supports both ISO_DEP and Mifare in low power mode. +# +# AA BB +#NFA_DM_START_UP_CFG={1F:CB:01:01:A5:01:01:CA:14:00:00:00:00:06:E8:03:00:00:00:00:00:00:00:00:00:00:00:00:00:80:01:01} + +############################################################################### +# Startup Vendor Specific Configuration (100 bytes maximum); +# byte[0] TLV total len = 0x5 +# byte[1] NCI_MTS_CMD|NCI_GID_PROP = 0x2f +# byte[2] NCI_MSG_FRAME_LOG = 0x9 +# byte[3] 2 +# byte[4] 0=turn off RF frame logging; 1=turn on +# byte[5] 0=turn off SWP frame logging; 1=turn on +# NFA_DM_START_UP_VSC_CFG={05:2F:09:02:01:01} + +############################################################################### +# Antenna Configuration - This data is used when setting 0xC8 config item +# at startup (before discovery is started). If not used, no value is sent. +# +# The settings for this value are documented here: +# http://wcgbu.broadcom.com/wpan/PM/Project%20Document%20Library/bcm20791B0/ +# Design/Doc/PHY%20register%20settings/BCM20791-B2-1027-02_PHY_Recommended_Reg_Settings.xlsx +# This document is maintained by Paul Forshaw. +# +# The values marked as ?? should be tweaked per antenna or customer/app: +# {20:C8:1E:06:??:00:??:??:??:00:??:24:00:1C:00:75:00:77:00:76:00:1C:00:03:00:0A:00:??:01:00:00:40:04} +# array[0] = 0x20 is length of the payload from array[1] to the end +# array[1] = 0xC8 is PREINIT_DSP_CFG +#PREINIT_DSP_CFG={20:C8:1E:06:1F:00:0F:03:3C:00:04:24:00:1C:00:75:00:77:00:76:00:1C:00:03:00:0A:00:48:01:00:00:40:04} + +############################################################################### +# Configure crystal frequency when internal LPO can't detect the frequency. +#XTAL_FREQUENCY=0 +############################################################################### +# Configure the default Destination Gate used by HCI (the default is 4, which +# is the ETSI loopback gate. +NFA_HCI_DEFAULT_DEST_GATE=0xF0 + +############################################################################### +# Configure the single default SE to use. The default is to use the first +# SE that is detected by the stack. This value might be used when the phone +# supports multiple SE (e.g. 0xF3 and 0xF4) but you want to force it to use +# one of them (e.g. 0xF4). +#ACTIVE_SE=0xF3 + +############################################################################### +# Configure the default NfcA/IsoDep techology and protocol route. Can be +# either a secure element (e.g. 0xF4) or the host (0x00) +#DEFAULT_ISODEP_ROUTE=0x00 + +############################################################################### +# Configure the NFC Extras to open and use a static pipe. If the value is +# not set or set to 0, then the default is use a dynamic pipe based on a +# destination gate (see NFA_HCI_DEFAULT_DEST_GATE). Note there is a value +# for each UICC (where F3="UICC0" and F4="UICC1") +#NFA_HCI_STATIC_PIPE_ID_F3=0x70 +#NFA_HCI_STATIC_PIPE_ID_01=0x19 +NFA_HCI_STATIC_PIPE_ID_C0=0x19 +############################################################################### +# When disconnecting from Oberthur secure element, perform a warm-reset of +# the secure element to deselect the applet. +# The default hex value of the command is 0x3. If this variable is undefined, +# then this feature is not used. +#OBERTHUR_WARM_RESET_COMMAND=0x03 + +############################################################################### +# Force UICC to only listen to the following technology(s). +# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h. +# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_B | NFA_TECHNOLOGY_MASK_F +UICC_LISTEN_TECH_MASK=0x07 + +############################################################################### +# Force HOST listen feature enable or disable. +# 0: Disable +# 1: Enable +HOST_LISTEN_ENABLE=0x01 + +############################################################################### +# Enabling/Disabling Forward functionality +# Disable 0x00 +# Enable 0x01 +NXP_FWD_FUNCTIONALITY_ENABLE=0x01 + +############################################################################### +# Allow UICC to be powered off if there is no traffic. +# Timeout is in ms. If set to 0, then UICC will not be powered off. +#UICC_IDLE_TIMEOUT=30000 +UICC_IDLE_TIMEOUT=0 + +############################################################################### +# AID for Empty Select command +# If specified, this AID will be substituted when an Empty SELECT command is +# detected. The first byte is the length of the AID. Maximum length is 16. +AID_FOR_EMPTY_SELECT={08:A0:00:00:01:51:00:00:00} +############################################################################### +# Maximum Number of Credits to be allowed by the NFCC +# This value overrides what the NFCC specifices allowing the host to have +# the control to work-around transport limitations. If this value does +# not exist or is set to 0, the NFCC will provide the number of credits. +MAX_RF_DATA_CREDITS=1 + +############################################################################### +# This setting allows you to disable registering the T4t Virtual SE that causes +# the NFCC to send PPSE requests to the DH. +# The default setting is enabled (i.e. T4t Virtual SE is registered). +#REGISTER_VIRTUAL_SE=1 + +############################################################################### +# When screen is turned off, specify the desired power state of the controller. +# 0: power-off-sleep state; DEFAULT +# 1: full-power state +# 2: screen-off card-emulation (CE4/CE3/CE1 modes are used) +SCREEN_OFF_POWER_STATE=1 + +############################################################################### +# Firmware patch file +# If the value is not set then patch download is disabled. +#FW_PATCH="/vendor/firmware/bcm2079x_firmware.ncd" + +############################################################################### +# Firmware pre-patch file (sent before the above patch file) +# If the value is not set then pre-patch is not used. +#FW_PRE_PATCH="/vendor/firmware/bcm2079x_pre_firmware.ncd" + +############################################################################### +# Firmware patch format +# 1 = HCD +# 2 = NCD (default) +#NFA_CONFIG_FORMAT=2 + +############################################################################### +# SPD Debug mode +# If set to 1, any failure of downloading a patch will trigger a hard-stop +#SPD_DEBUG=0 + +############################################################################### +# SPD Max Retry Count +# The number of attempts to download a patch before giving up (defualt is 3). +# Note, this resets after a power-cycle. +#SPD_MAX_RETRY_COUNT=3 + +############################################################################### +# transport driver +# +# TRANSPORT_DRIVER= +# +# where can be, for example: +# "/dev/ttyS" (UART) +# "/dev/bcmi2cnfc" (I2C) +# "hwtun" (HW Tunnel) +# "/dev/bcmspinfc" (SPI) +# "/dev/btusb0" (BT USB) +#TRANSPORT_DRIVER="/dev/bcm2079x-i2c" + +############################################################################### +# power control driver +# Specify a kernel driver that support ioctl commands to control NFC_EN and +# NFC_WAKE gpio signals. +# +# POWER_CONTRL_DRIVER= +# where can be, for example: +# "/dev/nfcpower" +# "/dev/bcmi2cnfc" (I2C) +# "/dev/bcmspinfc" (SPI) +# i2c and spi driver may be used to control NFC_EN and NFC_WAKE signal +#POWER_CONTROL_DRIVER="/dev/bcm2079x-i2c" + +############################################################################### +# I2C transport driver options +# Mako does not support 10-bit I2C addresses +# Revert to 7-bit address +#BCMI2CNFC_ADDRESS=0x77 + +############################################################################### +# I2C transport driver try to read multiple packets in read() if data is available +# remove the comment below to enable this feature +#READ_MULTIPLE_PACKETS=1 + +############################################################################### +# SPI transport driver options +#SPI_NEGOTIATION={0A:F0:00:01:00:00:00:FF:FF:00:00} + +############################################################################### +# UART transport driver options +# +# PORT=1,2,3,... +# BAUD=115200, 19200, 9600, 4800, +# DATABITS=8, 7, 6, 5 +# PARITY="even" | "odd" | "none" +# STOPBITS="0" | "1" | "1.5" | "2" + +#UART_PORT=2 +#UART_BAUD=115200 +#UART_DATABITS=8 +#UART_PARITY="none" +#UART_STOPBITS="1" + +############################################################################### +# Insert a delay in microseconds per byte after a write to NFCC. +# after writing a block of data to the NFCC, delay this an amopunt of time before +# writing next block of data. the delay is calculated as below +# NFC_WRITE_DELAY * (number of byte written) / 1000 milliseconds +# e.g. after 259 bytes is written, delay (259 * 20 / 1000) 5 ms before next write +#NFC_WRITE_DELAY=20 + +############################################################################### +# Maximum Number of Credits to be allowed by the NFCC +# This value overrides what the NFCC specifices allowing the host to have +# the control to work-around transport limitations. If this value does +# not exist or is set to 0, the NFCC will provide the number of credits. +MAX_RF_DATA_CREDITS=1 + +############################################################################### +# Default poll duration (in ms) +# The defualt is 500ms if not set (see nfc_target.h) +#NFA_DM_DISC_DURATION_POLL=333 +############################################################################### +# Antenna Configuration - This data is used when setting 0xC8 config item +# at startup (before discovery is started). If not used, no value is sent. +# +# The settings for this value are documented here: +# http://wcgbu.broadcom.com/wpan/PM/Project%20Document%20Library/bcm20791B0/ +# Design/Doc/PHY%20register%20settings/BCM20791-B2-1027-02_PHY_Recommended_Reg_Settings.xlsx +# This document is maintained by Paul Forshaw. +# +# The values marked as ?? should be tweaked per antenna or customer/app: +# {20:C8:1E:06:??:00:??:??:??:00:??:24:00:1C:00:75:00:77:00:76:00:1C:00:03:00:0A:00:??:01:00:00:40:04} +# array[0] = 0x20 is length of the payload from array[1] to the end +# array[1] = 0xC8 is PREINIT_DSP_CFG +#PREINIT_DSP_CFG={20:C8:1E:06:1F:00:0F:03:3C:00:04:24:00:1C:00:75:00:77:00:76:00:1C:00:03:00:0A:00:48:01:00:00:40:04} + +############################################################################### +# Choose the presence-check algorithm for type-4 tag. If not defined, the default value is 1. +# 0 NFA_RW_PRES_CHK_DEFAULT; Let stack selects an algorithm +# 1 NFA_RW_PRES_CHK_I_BLOCK; ISO-DEP protocol's empty I-block +# 2 NFA_RW_PRES_CHK_RESET; Deactivate to Sleep, then re-activate +# 3 NFA_RW_PRES_CHK_RB_CH0; Type-4 tag protocol's ReadBinary command on channel 0 +# 4 NFA_RW_PRES_CHK_RB_CH3; Type-4 tag protocol's ReadBinary command on channel 3 +# 5 NFA_RW_PRES_CHK_ISO_DEP_NAK; Type - 4 tag protocol iso-dep nak presence check +# command is sent waiting for rsp and ntf. +PRESENCE_CHECK_ALGORITHM=5 + +############################################################################### +# Force tag polling for the following technology(s). +# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h. +# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_B | +# NFA_TECHNOLOGY_MASK_F | NFA_TECHNOLOGY_MASK_ISO15693 | +# NFA_TECHNOLOGY_MASK_B_PRIME | NFA_TECHNOLOGY_MASK_KOVIO | +# NFA_TECHNOLOGY_MASK_ACTIVE +# +# Notable bits: +# NFA_TECHNOLOGY_MASK_A 0x01 /* NFC Technology A */ +# NFA_TECHNOLOGY_MASK_B 0x02 /* NFC Technology B */ +# NFA_TECHNOLOGY_MASK_F 0x04 /* NFC Technology F */ +# NFA_TECHNOLOGY_MASK_ISO15693 0x08 /* Proprietary Technology */ +# NFA_TECHNOLOGY_MASK_KOVIO 0x20 /* Proprietary Technology */ +# NFA_TECHNOLOGY_MASK_ACTIVE 0x40 /* NFC Technology Active */ +POLLING_TECH_MASK=0x6F + +############################################################################### +# Force P2P to only listen for the following technology(s). +# The bits are defined as tNFA_TECHNOLOGY_MASK in nfa_api.h. +# Default is NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_F | +# NFA_TECHNOLOGY_MASK_ACTIVE +# +# Notable bits: +# NFA_TECHNOLOGY_MASK_A 0x01 /* NFC Technology A */ +# NFA_TECHNOLOGY_MASK_F 0x04 /* NFC Technology F */ +# NFA_TECHNOLOGY_MASK_ACTIVE 0x40 /* NFC Technology Active */ +P2P_LISTEN_TECH_MASK=0x45 + +PRESERVE_STORAGE=0x01 + +############################################################################### +# Override the stack default for NFA_EE_MAX_EE_SUPPORTED set in nfc_target.h. +# The value is set to 3 by default as it assumes we will discover 0xF2, +# 0xF3, and 0xF4. If a platform will exclude and SE, this value can be reduced +# so that the stack will not wait any longer than necessary. + +# Maximum EE supported number +# NXP PN547C2 0x02 +# NXP PN65T 0x03 +# NXP PN548C2 0x02 +# NXP PN66T 0x03 +NFA_MAX_EE_SUPPORTED=0x02 + +############################################################################### +# NCI Hal Module name +NCI_HAL_MODULE="nfc_nci" + +############################################################################## +# Deactivate notification wait time out in seconds used in ETSI Reader mode +# 0 - Infinite wait +#NFA_DM_DISC_NTF_TIMEOUT=0 + +############################################################################### +# AID_MATCHING constants +# AID_MATCHING_EXACT_ONLY 0x00 +# AID_MATCHING_EXACT_OR_PREFIX 0x01 +# AID_MATCHING_PREFIX_ONLY 0x02 +# AID_MATCHING_EXACT_OR_SUBSET_OR_PREFIX 0x03 +AID_MATCHING_MODE=0x03 + +############################################################################### +# Default Secure Element route id +DEFAULT_OFFHOST_ROUTE=0x02 + +############################################################################### +# Vendor Specific Proprietary Protocol & Discovery Configuration +# Set to 0xFF if unsupported +# byte[0] NCI_PROTOCOL_18092_ACTIVE +# byte[1] NCI_PROTOCOL_B_PRIME +# byte[2] NCI_PROTOCOL_DUAL +# byte[3] NCI_PROTOCOL_15693 +# byte[4] NCI_PROTOCOL_KOVIO +# byte[5] NCI_PROTOCOL_MIFARE +# byte[6] NCI_DISCOVERY_TYPE_POLL_KOVIO +# byte[7] NCI_DISCOVERY_TYPE_POLL_B_PRIME +# byte[8] NCI_DISCOVERY_TYPE_LISTEN_B_PRIME +NFA_PROPRIETARY_CFG={05:FF:FF:06:81:80:70:FF:FF} + +############################################################################### +# Bail out mode +# If set to 1, NFCC is using bail out mode for either Type A or Type B poll. +NFA_POLL_BAIL_OUT_MODE=0x01 +############################################################################### +# Enable/Disable Block Route feature. +# Block Route will restrict routing to first matched rule +# Block Route enable 0x01 +# Block Route disable 0x00 +NFA_BLOCK_ROUTE=0x00 diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml new file mode 100755 index 00000000..92eda687 --- /dev/null +++ b/overlay/frameworks/base/core/res/res/values/config.xml @@ -0,0 +1,349 @@ + + + + + + + false + + + true + + + true + + + true + + + true + + + true + + + 2000 + 4000 + + + 180 + + + 60 + + + true + + + true + + + true + + + + true + + + true + + + true + + + #ffffffff + + + 1000 + + + 9000 + + + 4 + + + true + + + 4 + + + + "usb\\d" + "rndis\\d" + + + + + "wlan0" + "softap.*" + + + + + "bt-pan" + + + + 1 + + + 4 + + + 3300 + + + true + + + + + 1 + 7 + 0 + 5 + + + + + + + + "wifi,1,1,1,-1,true" + "mobile,0,0,0,-1,true" + "mobile_mms,2,0,2,60000,true" + "mobile_supl,3,0,2,60000,true" + "mobile_dun,4,0,2,60000,true" + "mobile_hipri,5,0,3,60000,true" + "mobile_fota,10,0,2,60000,true" + "mobile_ims,11,0,2,60000,true" + "mobile_cbs,12,0,2,60000,true" + "mobile_ia,14,0,2,-1,true" + "bluetooth,7,7,2,-1,true" + "ethernet,9,9,9,-1,true" + "mobile_emergency,15,0,2,-1,true + + + + + + "1,1" + "0,1" + "7,1" + "9,1" + + + + 0x80000000 + + + 0x80000000 + + + true + + + true + + + true + + + -77 + -80 + + + + + 8 + + + + false + + + true + + + true + + + true + + + com.android.systemui/com.android.systemui.doze.DozeService + + + true + + + true + + + com.google.sensor.double_touch + + + com.google.sensor.long_press + + + true + + + true + + + true + + + org.codeaurora.ims + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + + umts:131072,262144,1452032,4096,16384,399360 + hspa:131072,262144,2441216,4096,16384,399360 + hsupa:131072,262144,2441216,4096,16384,399360 + hsdpa:131072,262144,2441216,4096,16384,399360 + hspap:131072,262144,2441216,4096,16384,399360 + edge:16384,32768,131072,4096,16384,65536 + gprs:4096,8192,24576,4096,8192,24576 + 1xrtt:16384,32768,131070,4096,16384,102400 + evdo:131072,262144,1048576,4096,16384,524288 + lte:524288,1048576,8388608,262144,524288,4194304 + + + + 524288,2097152,8388608,262144,524288,4194304 + + + 1 + + + 100 + + + 250 + + + 3800 + + + 6 + + + false + + + + false + + + + "/system/framework/arm64/boot-framework.oat" + "/system/framework/arm64/boot-framework.vdex" + "/system/framework/oat/arm64/services.odex" + "/system/framework/oat/arm64/services.vdex" + "/system/framework/arm64/boot.oat" + "/system/framework/arm64/boot.vdex" + "/system/framework/arm64/boot-core-libart.oat" + "/system/framework/arm64/boot-core-libart.vdex" + + + + true + + + true + + + true + + + true + + + com.google.android.GoogleCamera:com.google.intelligence.sense:com.google.android.apps.location.context.activity.zen + diff --git a/overlay/frameworks/base/core/res/res/values/strings.xml b/overlay/frameworks/base/core/res/res/values/strings.xml new file mode 100644 index 00000000..e1daaadc --- /dev/null +++ b/overlay/frameworks/base/core/res/res/values/strings.xml @@ -0,0 +1,25 @@ + + + + + + + Pixel + diff --git a/overlay/frameworks/base/packages/SystemUI/res/values/config.xml b/overlay/frameworks/base/packages/SystemUI/res/values/config.xml new file mode 100644 index 00000000..fb7e8cbf --- /dev/null +++ b/overlay/frameworks/base/packages/SystemUI/res/values/config.xml @@ -0,0 +1,39 @@ + + + + + + + true + + + false + + + com.google.sensor.binned_brightness + + + true + + + true + diff --git a/overlay/packages/apps/Bluetooth/res/values/config.xml b/overlay/packages/apps/Bluetooth/res/values/config.xml new file mode 100644 index 00000000..6db14c05 --- /dev/null +++ b/overlay/packages/apps/Bluetooth/res/values/config.xml @@ -0,0 +1,32 @@ + + + + true + diff --git a/overlay/packages/apps/Settings/res/values-mcc262-mnc01/strings.xml b/overlay/packages/apps/Settings/res/values-mcc262-mnc01/strings.xml new file mode 100644 index 00000000..cff4d804 --- /dev/null +++ b/overlay/packages/apps/Settings/res/values-mcc262-mnc01/strings.xml @@ -0,0 +1,22 @@ + + + + + WLAN Call + diff --git a/overlay/packages/apps/Settings/res/values/bools.xml b/overlay/packages/apps/Settings/res/values/bools.xml new file mode 100755 index 00000000..bb937893 --- /dev/null +++ b/overlay/packages/apps/Settings/res/values/bools.xml @@ -0,0 +1,20 @@ + + + + + + false + diff --git a/overlay/packages/services/Telephony/res/values/config.xml b/overlay/packages/services/Telephony/res/values/config.xml new file mode 100644 index 00000000..4a10e11c --- /dev/null +++ b/overlay/packages/services/Telephony/res/values/config.xml @@ -0,0 +1,22 @@ + + + + + + + true + diff --git a/p2p_supplicant_overlay.conf b/p2p_supplicant_overlay.conf new file mode 100644 index 00000000..acbace22 --- /dev/null +++ b/p2p_supplicant_overlay.conf @@ -0,0 +1 @@ +disable_scan_offload=1 diff --git a/power/Android.mk b/power/Android.mk new file mode 100644 index 00000000..f2e29188 --- /dev/null +++ b/power/Android.mk @@ -0,0 +1,58 @@ +# Copyright (C) 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_PROPRIETARY_MODULE := true +LOCAL_MODULE_OWNER := qcom +LOCAL_MODULE_TAGS := optional + +LOCAL_MODULE := android.hardware.power@1.1-service.wahoo +LOCAL_INIT_RC := android.hardware.power@1.1-service.wahoo.rc +LOCAL_SRC_FILES := service.cpp \ + Power.cpp \ + InteractionHandler.cpp \ + power-helper.c \ + metadata-parser.c \ + utils.c \ + list.c \ + hint-data.c \ + powerhintparser.c + +LOCAL_C_INCLUDES := external/libxml2/include \ + external/icu/icu4c/source/common + +# Include target-specific files. +LOCAL_SRC_FILES += power-8998.c + + +# Enable interaction boost all the time +LOCAL_CFLAGS += -DINTERACTION_BOOST -Werror + +LOCAL_SHARED_LIBRARIES := \ + libbase \ + liblog \ + libcutils \ + libdl \ + libxml2 \ + libhidlbase \ + libhidltransport \ + libhardware \ + libutils \ + android.hardware.power@1.1 \ + +include $(BUILD_EXECUTABLE) diff --git a/power/InteractionHandler.cpp b/power/InteractionHandler.cpp new file mode 100644 index 00000000..ac00514f --- /dev/null +++ b/power/InteractionHandler.cpp @@ -0,0 +1,258 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +//#define LOG_NDEBUG 0 + +#define LOG_TAG "PowerInteractionHandler" +#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL) + +#include +#include +#include +#include +#include +#include +#include + +#include "InteractionHandler.h" +#include "power-common.h" +#include "power-helper.h" +#include "powerhintparser.h" +#include "hint-data.h" +#include "utils.h" + +#define FB_IDLE_PATH "/sys/class/graphics/fb0/idle_state" +#define MAX_LENGTH 64 + +#define MSINSEC 1000L +#define USINMS 1000000L + +InteractionHandler::InteractionHandler() + : mState(INTERACTION_STATE_UNINITIALIZED), + mWaitMs(100), + mMinDurationMs(1400), + mMaxDurationMs(5650), + mDurationMs(0) { +} + +InteractionHandler::~InteractionHandler() { + Exit(); +} + +bool InteractionHandler::Init() { + std::lock_guard lk(mLock); + + if (mState != INTERACTION_STATE_UNINITIALIZED) + return true; + + mIdleFd = open(FB_IDLE_PATH, O_RDONLY); + if (mIdleFd < 0) { + ALOGE("Unable to open idle state path (%d)", errno); + return false; + } + + mEventFd = eventfd(0, EFD_NONBLOCK); + if (mEventFd < 0) { + ALOGE("Unable to create event fd (%d)", errno); + close(mIdleFd); + return false; + } + + mState = INTERACTION_STATE_IDLE; + mThread = std::unique_ptr( + new std::thread(&InteractionHandler::Routine, this)); + + return true; +} + +void InteractionHandler::Exit() { + std::unique_lock lk(mLock); + if (mState == INTERACTION_STATE_UNINITIALIZED) + return; + + AbortWaitLocked(); + mState = INTERACTION_STATE_UNINITIALIZED; + lk.unlock(); + + mCond.notify_all(); + mThread->join(); + + close(mEventFd); + close(mIdleFd); +} + +void InteractionHandler::PerfLock() { + int *resource_values; + int num_resources; + + resource_values = getPowerhint(INTERACTION_HINT_ID, &num_resources); + if (resource_values != NULL) { + ALOGV("%s: acquiring perf lock", __func__); + perform_hint_action(INTERACTION_HINT_ID, + resource_values, num_resources); + + ATRACE_INT("interaction_lock", 1); + } +} + +void InteractionHandler::PerfRel() { + ALOGV("%s: releasing perf lock", __func__); + undo_hint_action(INTERACTION_HINT_ID); + ATRACE_INT("interaction_lock", 0); +} + +long long InteractionHandler::CalcTimespecDiffMs(struct timespec start, + struct timespec end) { + long long diff_in_us = 0; + diff_in_us += (end.tv_sec - start.tv_sec) * MSINSEC; + diff_in_us += (end.tv_nsec - start.tv_nsec) / USINMS; + return diff_in_us; +} + +void InteractionHandler::Acquire(int32_t duration) { + if (is_perf_hint_active(SUSTAINED_PERF_HINT_ID) || + is_perf_hint_active(VR_MODE_HINT_ID)) { + ALOGV("%s: ignoring due to other active perf hints", __func__); + return; + } + + ATRACE_CALL(); + + std::lock_guard lk(mLock); + if (mState == INTERACTION_STATE_UNINITIALIZED) { + ALOGW("%s: called while uninitialized", __func__); + return; + } + + int inputDuration = duration + 650; + int finalDuration; + if (inputDuration > mMaxDurationMs) + finalDuration = mMaxDurationMs; + else if (inputDuration > mMinDurationMs) + finalDuration = inputDuration; + else + finalDuration = mMinDurationMs; + + struct timespec cur_timespec; + clock_gettime(CLOCK_MONOTONIC, &cur_timespec); + if (mState != INTERACTION_STATE_IDLE && finalDuration <= mDurationMs) { + long long elapsed_time = CalcTimespecDiffMs(mLastTimespec, cur_timespec); + // don't hint if previous hint's duration covers this hint's duration + if (elapsed_time <= (mDurationMs - finalDuration)) { + ALOGV("%s: Previous duration (%d) cover this (%d) elapsed: %lld", + __func__, mDurationMs, finalDuration, elapsed_time); + return; + } + } + mLastTimespec = cur_timespec; + mDurationMs = finalDuration; + + ALOGV("%s: input: %d final duration: %d", __func__, + duration, finalDuration); + + if (mState == INTERACTION_STATE_WAITING) + AbortWaitLocked(); + else if (mState == INTERACTION_STATE_IDLE) + PerfLock(); + + mState = INTERACTION_STATE_INTERACTION; + mCond.notify_one(); +} + +void InteractionHandler::Release() { + std::lock_guard lk(mLock); + if (mState == INTERACTION_STATE_WAITING) { + ATRACE_CALL(); + PerfRel(); + mState = INTERACTION_STATE_IDLE; + } else { + // clear any wait aborts pending in event fd + uint64_t val; + ssize_t ret = read(mEventFd, &val, sizeof(val)); + + ALOGW_IF(ret < 0, "%s: failed to clear eventfd (%zd, %d)", + __func__, ret, errno); + } +} + +// should be called while locked +void InteractionHandler::AbortWaitLocked() { + uint64_t val = 1; + ssize_t ret = write(mEventFd, &val, sizeof(val)); + if (ret != sizeof(val)) + ALOGW("Unable to write to event fd (%zd)", ret); +} + +void InteractionHandler::WaitForIdle(int32_t wait_ms, int32_t timeout_ms) { + char data[MAX_LENGTH]; + ssize_t ret; + struct pollfd pfd[2]; + + ATRACE_CALL(); + + ALOGV("%s: wait:%d timeout:%d", __func__, wait_ms, timeout_ms); + + pfd[0].fd = mEventFd; + pfd[0].events = POLLIN; + pfd[1].fd = mIdleFd; + pfd[1].events = POLLPRI | POLLERR; + + ret = poll(pfd, 1, wait_ms); + if (ret > 0) { + ALOGV("%s: wait aborted", __func__); + return; + } else if (ret < 0) { + ALOGE("%s: error in poll while waiting", __func__); + return; + } + + ret = pread(mIdleFd, data, sizeof(data), 0); + if (!ret) { + ALOGE("%s: Unexpected EOF!", __func__); + return; + } + + if (!strncmp(data, "idle", 4)) { + ALOGV("%s: already idle", __func__); + return; + } + + ret = poll(pfd, 2, timeout_ms); + if (ret < 0) + ALOGE("%s: Error on waiting for idle (%zd)", __func__, ret); + else if (ret == 0) + ALOGV("%s: timed out waiting for idle", __func__); + else if (pfd[0].revents) + ALOGV("%s: wait for idle aborted", __func__); + else if (pfd[1].revents) + ALOGV("%s: idle detected", __func__); +} + +void InteractionHandler::Routine() { + std::unique_lock lk(mLock, std::defer_lock); + + while (true) { + lk.lock(); + mCond.wait(lk, [&] { return mState != INTERACTION_STATE_IDLE; }); + if (mState == INTERACTION_STATE_UNINITIALIZED) + return; + mState = INTERACTION_STATE_WAITING; + lk.unlock(); + + WaitForIdle(mWaitMs, mDurationMs); + Release(); + } +} diff --git a/power/InteractionHandler.h b/power/InteractionHandler.h new file mode 100644 index 00000000..8b5aebc9 --- /dev/null +++ b/power/InteractionHandler.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef INTERACTIONHANDLER_H +#define INTERACTIONHANDLER_H + +#include +#include +#include + +enum interaction_state { + INTERACTION_STATE_UNINITIALIZED, + INTERACTION_STATE_IDLE, + INTERACTION_STATE_INTERACTION, + INTERACTION_STATE_WAITING, +}; + +struct InteractionHandler { + InteractionHandler(); + ~InteractionHandler(); + bool Init(); + void Exit(); + void Acquire(int32_t duration); + + private: + void Release(); + void WaitForIdle(int32_t wait_ms, int32_t timeout_ms); + void AbortWaitLocked(); + void Routine(); + + void PerfLock(); + void PerfRel(); + + long long CalcTimespecDiffMs(struct timespec start, struct timespec end); + + enum interaction_state mState; + + int mIdleFd; + int mEventFd; + + int32_t mWaitMs; + int32_t mMinDurationMs; + int32_t mMaxDurationMs; + int32_t mDurationMs; + + struct timespec mLastTimespec; + + std::unique_ptr mThread; + std::mutex mLock; + std::condition_variable mCond; +}; + +#endif //INTERACTIONHANDLER_H + diff --git a/power/Power.cpp b/power/Power.cpp new file mode 100644 index 00000000..c74cb573 --- /dev/null +++ b/power/Power.cpp @@ -0,0 +1,209 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "android.hardware.power@1.1-service.wahoo" + +#include +#include +#include +#include +#include +#include "Power.h" +#include "power-common.h" +#include "power-helper.h" + +/* RPM runs at 19.2Mhz. Divide by 19200 for msec */ +#define RPM_CLK 19200 + +extern struct stat_pair rpm_stat_map[]; + +namespace android { +namespace hardware { +namespace power { +namespace V1_1 { +namespace implementation { + +using ::android::hardware::power::V1_0::Feature; +using ::android::hardware::power::V1_0::PowerHint; +using ::android::hardware::power::V1_0::PowerStatePlatformSleepState; +using ::android::hardware::power::V1_0::Status; +using ::android::hardware::power::V1_1::PowerStateSubsystem; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; + +Power::Power() { + power_init(); + mInteractionHandler.Init(); +} + +// Methods from ::android::hardware::power::V1_0::IPower follow. +Return Power::setInteractive(bool interactive) { + if (!isSupportedGovernor()) { + return Void(); + } + power_set_interactive(interactive ? 1 : 0); + return Void(); +} + +Return Power::powerHint(PowerHint hint, int32_t data) { + if (android::base::GetProperty("init.svc.perfd", "") != "running") { + ALOGW("perfd is not started"); + return Void(); + } + + power_hint_t h = static_cast(hint); + if (!isSupportedGovernor()) { + return Void(); + } + if (h == POWER_HINT_INTERACTION) { + mInteractionHandler.Acquire(data); + return Void(); + } + power_hint(h, data ? &data : NULL); + return Void(); +} + +Return Power::setFeature(Feature /*feature*/, bool /*activate*/) { + //Nothing to do + return Void(); +} + +Return Power::getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) { + + hidl_vec states; + uint64_t stats[MAX_PLATFORM_STATS * MAX_RPM_PARAMS] = {0}; + uint64_t *values; + struct PowerStatePlatformSleepState *state; + int ret; + + states.resize(PLATFORM_SLEEP_MODES_COUNT); + + ret = extract_platform_stats(stats); + if (ret != 0) { + states.resize(0); + goto done; + } + + /* Update statistics for XO_shutdown */ + state = &states[RPM_MODE_XO]; + state->name = "XO_shutdown"; + values = stats + (RPM_MODE_XO * MAX_RPM_PARAMS); + + state->residencyInMsecSinceBoot = values[1]; + state->totalTransitions = values[0]; + state->supportedOnlyInSuspend = false; + state->voters.resize(XO_VOTERS); + for(size_t i = 0; i < XO_VOTERS; i++) { + int voter = static_cast(i + XO_VOTERS_START); + state->voters[i].name = rpm_stat_map[voter].label; + values = stats + (voter * MAX_RPM_PARAMS); + state->voters[i].totalTimeInMsecVotedForSinceBoot = values[0] / RPM_CLK; + state->voters[i].totalNumberOfTimesVotedSinceBoot = values[1]; + } + + /* Update statistics for VMIN state */ + state = &states[RPM_MODE_VMIN]; + state->name = "VMIN"; + values = stats + (RPM_MODE_VMIN * MAX_RPM_PARAMS); + + state->residencyInMsecSinceBoot = values[1]; + state->totalTransitions = values[0]; + state->supportedOnlyInSuspend = false; + state->voters.resize(VMIN_VOTERS); + //Note: No filling of state voters since VMIN_VOTERS = 0 + +done: + _hidl_cb(states, Status::SUCCESS); + return Void(); +} + +static int get_wlan_low_power_stats(struct PowerStateSubsystem &subsystem) { + + uint64_t stats[WLAN_POWER_PARAMS_COUNT] = {0}; + struct PowerStateSubsystemSleepState *state; + int ret; + + ret = extract_wlan_stats(stats); + if (ret) + return ret; + + subsystem.name = "wlan"; + subsystem.states.resize(WLAN_STATES_COUNT); + + /* Update statistics for Active State */ + state = &subsystem.states[WLAN_STATE_ACTIVE]; + state->name = "Active"; + state->residencyInMsecSinceBoot = stats[CUMULATIVE_TOTAL_ON_TIME_MS]; + state->totalTransitions = stats[DEEP_SLEEP_ENTER_COUNTER]; + state->lastEntryTimestampMs = 0; //FIXME need a new value from Qcom + state->supportedOnlyInSuspend = false; + + /* Update statistics for Deep-Sleep state */ + state = &subsystem.states[WLAN_STATE_DEEP_SLEEP]; + state->name = "Deep-Sleep"; + state->residencyInMsecSinceBoot = stats[CUMULATIVE_SLEEP_TIME_MS]; + state->totalTransitions = stats[DEEP_SLEEP_ENTER_COUNTER]; + state->lastEntryTimestampMs = stats[LAST_DEEP_SLEEP_ENTER_TSTAMP_MS]; + state->supportedOnlyInSuspend = false; + + return 0; +} + +// Methods from ::android::hardware::power::V1_1::IPower follow. +Return Power::getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) { + + hidl_vec subsystems; + int ret; + + subsystems.resize(SUBSYSTEM_COUNT); + + //We currently have only one Subsystem for WLAN + ret = get_wlan_low_power_stats(subsystems[SUBSYSTEM_WLAN]); + if (ret != 0) + goto done; + + //Add query for other subsystems here + +done: + _hidl_cb(subsystems, Status::SUCCESS); + return Void(); +} + +bool Power::isSupportedGovernor() { + std::string buf; + if (android::base::ReadFileToString(SCALING_GOVERNOR_PATH, &buf)) { + buf = android::base::Trim(buf); + } + // Only support EAS 1.2, legacy EAS and HMP + if (buf == SCHEDUTIL_GOVERNOR || buf == SCHED_GOVERNOR || buf == INTERACTIVE_GOVERNOR) { + return true; + } else { + ALOGE("Governor not supported by powerHAL, skipping"); + return false; + } +} + +Return Power::powerHintAsync(PowerHint hint, int32_t data) { + // just call the normal power hint in this oneway function + return powerHint(hint, data); +} + +} // namespace implementation +} // namespace V1_1 +} // namespace power +} // namespace hardware +} // namespace android diff --git a/power/Power.h b/power/Power.h new file mode 100644 index 00000000..9d4f79fd --- /dev/null +++ b/power/Power.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_HARDWARE_POWER_V1_1_POWER_H +#define ANDROID_HARDWARE_POWER_V1_1_POWER_H + +#include +#include +#include +#include + +#include "InteractionHandler.h" + +namespace android { +namespace hardware { +namespace power { +namespace V1_1 { +namespace implementation { + +using ::android::hardware::power::V1_0::Feature; +using ::android::hardware::power::V1_0::PowerHint; +using ::android::hardware::power::V1_1::IPower; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::InteractionHandler; + +struct Power : public IPower { + // Methods from ::android::hardware::power::V1_0::IPower follow. + + Power(); + + Return setInteractive(bool interactive) override; + Return powerHint(PowerHint hint, int32_t data) override; + Return setFeature(Feature feature, bool activate) override; + Return getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) override; + + // Methods from ::android::hardware::power::V1_1::IPower follow. + Return getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) override; + Return powerHintAsync(PowerHint hint, int32_t data) override; + + // Methods from ::android::hidl::base::V1_0::IBase follow. + + private: + InteractionHandler mInteractionHandler; + static bool isSupportedGovernor(); +}; + +} // namespace implementation +} // namespace V1_1 +} // namespace power +} // namespace hardware +} // namespace android + +#endif // ANDROID_HARDWARE_POWER_V1_1_POWER_H diff --git a/power/android.hardware.power@1.1-service.wahoo.rc b/power/android.hardware.power@1.1-service.wahoo.rc new file mode 100644 index 00000000..064cf35a --- /dev/null +++ b/power/android.hardware.power@1.1-service.wahoo.rc @@ -0,0 +1,4 @@ +service power-hal-1-1 /vendor/bin/hw/android.hardware.power@1.1-service.wahoo + class hal + user system + group system diff --git a/power/hint-data.c b/power/hint-data.c new file mode 100644 index 00000000..f3403b7c --- /dev/null +++ b/power/hint-data.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include "hint-data.h" + +int hint_compare(struct hint_data *first_hint, + struct hint_data *other_hint) { + if (first_hint == other_hint) { + return 0; + } else if ((first_hint && other_hint) && + (first_hint->hint_id == other_hint->hint_id)) { + return 0; + } else { + return 1; + } +} + +void hint_dump(struct hint_data *hint) +{ + ALOGV("hint_id: %lu", hint->hint_id); +} diff --git a/power/hint-data.h b/power/hint-data.h new file mode 100644 index 00000000..7be3b3b2 --- /dev/null +++ b/power/hint-data.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Default use-case hint IDs */ +#define DEFAULT_VIDEO_ENCODE_HINT_ID (0x0A00) +#define DEFAULT_VIDEO_DECODE_HINT_ID (0x0B00) +#define DISPLAY_STATE_HINT_ID (0x0C00) +#define DISPLAY_STATE_HINT_ID_2 (0x0D00) +#define CAM_PREVIEW_HINT_ID (0x0E00) +#define SUSTAINED_PERF_HINT_ID (0x0F00) +#define VR_MODE_HINT_ID (0x1000) +#define VR_MODE_SUSTAINED_PERF_HINT_ID (0x1001) +#define INTERACTION_HINT_ID (0x1A00) +#define BOOST_HINT_ID (0x1B00) + +struct hint_data { + unsigned long hint_id; /* This is our key. */ + unsigned long perflock_handle; +}; + +int hint_compare(struct hint_data *first_hint, + struct hint_data *other_hint); +void hint_dump(struct hint_data *hint); diff --git a/power/list.c b/power/list.c new file mode 100644 index 00000000..30a16943 --- /dev/null +++ b/power/list.c @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +#include "list.h" +#include + +int init_list_head(struct list_node *head) +{ + if (head == NULL) + return -1; + + memset(head, 0, sizeof(*head)); + + return 0; +} + +struct list_node *add_list_node(struct list_node *head, void *data) +{ + /* Create a new list_node. And put 'data' into it. */ + struct list_node *new_node; + + if (head == NULL) { + return NULL; + } + + if (!(new_node = malloc(sizeof(struct list_node)))) { + return NULL; + } + + new_node->data = data; + new_node->next = head->next; + new_node->compare = head->compare; + new_node->dump = head->dump; + head->next = new_node; + + return new_node; +} + +int is_list_empty(struct list_node *head) +{ + return (head == NULL || head->next == NULL); +} + +/* + * Delink and de-allocate 'node'. + */ +int remove_list_node(struct list_node *head, struct list_node *del_node) +{ + struct list_node *current_node; + struct list_node *saved_node; + + if (head == NULL || head->next == NULL) { + return -1; + } + + current_node = head->next; + saved_node = head; + + while (current_node && current_node != del_node) { + saved_node = current_node; + current_node = current_node->next; + } + + if (saved_node) { + if (current_node) { + saved_node->next = current_node->next; + } else { + /* Node not found. */ + return -1; + } + } + + if (del_node) { + free(del_node); + } + + return 0; +} + +void dump_list(struct list_node *head) +{ + struct list_node *current_node = head; + + if (head == NULL) + return; + + ALOGV("List:\n"); + + while ((current_node = current_node->next)) { + if (current_node->dump) { + current_node->dump(current_node->data); + } + } +} + +struct list_node *find_node(struct list_node *head, void *comparison_data) +{ + struct list_node *current_node = head; + + if (head == NULL) + return NULL; + + while ((current_node = current_node->next)) { + if (current_node->compare) { + if (current_node->compare(current_node->data, + comparison_data) == 0) { + /* Match found. Return current_node. */ + return current_node; + } + } + } + + /* No match found. */ + return NULL; +} diff --git a/power/list.h b/power/list.h new file mode 100644 index 00000000..d68c3df1 --- /dev/null +++ b/power/list.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2012, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +struct list_node { + struct list_node *next; + void *data; + int (*compare)(void *data1, void *data2); + void (*dump)(void *data); +}; + +int init_list_head(struct list_node *head); +struct list_node * add_list_node(struct list_node *head, void *data); +int remove_list_node(struct list_node *head, struct list_node *del_node); +void dump_list(struct list_node *head); +struct list_node *find_node(struct list_node *head, void *comparison_data); diff --git a/power/metadata-defs.h b/power/metadata-defs.h new file mode 100644 index 00000000..e3ce944d --- /dev/null +++ b/power/metadata-defs.h @@ -0,0 +1,54 @@ +/* Copyright (c) 2012, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#define ATTRIBUTE_VALUE_DELIM ('=') +#define ATTRIBUTE_STRING_DELIM (";") + +#define METADATA_PARSING_ERR (-1) +#define METADATA_PARSING_CONTINUE (0) +#define METADATA_PARSING_DONE (1) + +#define MIN(x,y) (((x)>(y))?(y):(x)) + +struct video_encode_metadata_t { + int hint_id; + int state; +}; + +struct video_decode_metadata_t { + int hint_id; + int state; +}; + +int parse_metadata(char *metadata, char **metadata_saveptr, + char *attribute, unsigned int attribute_size, char *value, unsigned int value_size); +int parse_video_encode_metadata(char *metadata, + struct video_encode_metadata_t *video_encode_metadata); +int parse_video_decode_metadata(char *metadata, + struct video_decode_metadata_t *video_decode_metadata); diff --git a/power/metadata-parser.c b/power/metadata-parser.c new file mode 100644 index 00000000..ffe092b5 --- /dev/null +++ b/power/metadata-parser.c @@ -0,0 +1,126 @@ +/* Copyright (c) 2012, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include + +#include "metadata-defs.h" + +int parse_metadata(char *metadata, char **metadata_saveptr, + char *attribute, unsigned int attribute_size, char *value, unsigned int value_size) +{ + char *attribute_string; + char *attribute_value_delim; + unsigned int bytes_to_copy; + + attribute_string = strtok_r(metadata, ATTRIBUTE_STRING_DELIM, + metadata_saveptr); + + if (attribute_string == NULL) + return METADATA_PARSING_DONE; + + attribute[0] = value[0] = '\0'; + + if ((attribute_value_delim = strchr(attribute_string, + ATTRIBUTE_VALUE_DELIM)) != NULL) { + unsigned int attribute_len = (unsigned int) (attribute_value_delim - attribute_string); + /* copy only attribute len + NUL character, or as much as can be fit */ + bytes_to_copy = MIN(attribute_len + 1, attribute_size); + + strlcpy(attribute, attribute_string, bytes_to_copy); + strlcpy(value, attribute_value_delim + 1, value_size); + } + + return METADATA_PARSING_CONTINUE; +} + +int parse_video_encode_metadata(char *metadata, + struct video_encode_metadata_t *video_encode_metadata) +{ + char attribute[1024], value[1024], *saveptr; + char *temp_metadata = metadata; + int parsing_status; + + while ((parsing_status = parse_metadata(temp_metadata, &saveptr, + attribute, sizeof(attribute), value, sizeof(value))) == METADATA_PARSING_CONTINUE) { + if (strlen(attribute) == strlen("hint_id") && + (strncmp(attribute, "hint_id", strlen("hint_id")) == 0)) { + if (strlen(value) > 0) { + video_encode_metadata->hint_id = atoi(value); + } + } + + if (strlen(attribute) == strlen("state") && + (strncmp(attribute, "state", strlen("state")) == 0)) { + if (strlen(value) > 0) { + video_encode_metadata->state = atoi(value); + } + } + + temp_metadata = NULL; + } + + if (parsing_status == METADATA_PARSING_ERR) + return -1; + + return 0; +} + +int parse_video_decode_metadata(char *metadata, + struct video_decode_metadata_t *video_decode_metadata) +{ + char attribute[1024], value[1024], *saveptr; + char *temp_metadata = metadata; + int parsing_status; + + while ((parsing_status = parse_metadata(temp_metadata, &saveptr, + attribute, sizeof(attribute), value, sizeof(value))) == METADATA_PARSING_CONTINUE) { + if (strlen(attribute) == strlen("hint_id") && + (strncmp(attribute, "hint_id", strlen("hint_id")) == 0)) { + if (strlen(value) > 0) { + video_decode_metadata->hint_id = atoi(value); + } + } + + if (strlen(attribute) == strlen("state") && + (strncmp(attribute, "state", strlen("state")) == 0)) { + if (strlen(value) > 0) { + video_decode_metadata->state = atoi(value); + } + } + + temp_metadata = NULL; + } + + if (parsing_status == METADATA_PARSING_ERR) + return -1; + + return 0; +} diff --git a/power/performance.h b/power/performance.h new file mode 100755 index 00000000..85a611d3 --- /dev/null +++ b/power/performance.h @@ -0,0 +1,264 @@ +/* Copyright (c) 2012, 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define FAILED -1 +#define SUCCESS 0 +#define INDEFINITE_DURATION 0 + +enum SCREEN_DISPLAY_TYPE { + DISPLAY_OFF = 0x00FF, +}; + +enum PWR_CLSP_TYPE { + ALL_CPUS_PWR_CLPS_DIS = 0x101, +}; + +/* For CPUx min freq, the leftmost byte + * represents the CPU and the + * rightmost byte represents the frequency + * All intermediate frequencies on the + * device are supported. The hex value + * passed into PerfLock will be multiplied + * by 10^5. This frequency or the next + * highest frequency available will be set + * + * For example, if 1.4 Ghz is required on + * CPU0, use 0x20E + * + * If the highest available frequency + * on the device is required, use + * CPUx_MIN_FREQ_TURBO_MAX + * where x represents the CPU + */ +enum CPU0_MIN_FREQ_LVL { + CPU0_MIN_FREQ_NONTURBO_MAX = 0x20A, + CPU0_MIN_FREQ_TURBO_MAX = 0x2FE, +}; + +enum CPU1_MIN_FREQ_LVL { + CPU1_MIN_FREQ_NONTURBO_MAX = 0x30A, + CPU1_MIN_FREQ_TURBO_MAX = 0x3FE, +}; + +enum CPU2_MIN_FREQ_LVL { + CPU2_MIN_FREQ_NONTURBO_MAX = 0x40A, + CPU2_MIN_FREQ_TURBO_MAX = 0x4FE, +}; + +enum CPU3_MIN_FREQ_LVL { + CPU3_MIN_FREQ_NONTURBO_MAX = 0x50A, + CPU3_MIN_FREQ_TURBO_MAX = 0x5FE, +}; + +enum CPU0_MAX_FREQ_LVL { + CPU0_MAX_FREQ_NONTURBO_MAX = 0x150A, +}; + +enum CPU1_MAX_FREQ_LVL { + CPU1_MAX_FREQ_NONTURBO_MAX = 0x160A, +}; + +enum CPU2_MAX_FREQ_LVL { + CPU2_MAX_FREQ_NONTURBO_MAX = 0x170A, +}; + +enum CPU3_MAX_FREQ_LVL { + CPU3_MAX_FREQ_NONTURBO_MAX = 0x180A, +}; + +enum MIN_CPUS_ONLINE_LVL { + CPUS_ONLINE_MIN_2 = 0x702, + CPUS_ONLINE_MIN_3 = 0x703, + CPUS_ONLINE_MIN_4 = 0x704, + CPUS_ONLINE_MPD_OVERRIDE = 0x777, + CPUS_ONLINE_MAX = 0x7FF, +}; + +enum MAX_CPUS_ONLINE_LVL { + CPUS_ONLINE_MAX_LIMIT_1 = 0x8FE, + CPUS_ONLINE_MAX_LIMIT_2 = 0x8FD, + CPUS_ONLINE_MAX_LIMIT_3 = 0x8FC, + CPUS_ONLINE_MAX_LIMIT_4 = 0x8FB, + CPUS_ONLINE_MAX_LIMIT_MAX = 0x8FB, +}; + +enum SAMPLING_RATE_LVL { + MS_500 = 0xBCD, + MS_50 = 0xBFA, + MS_20 = 0xBFD, +}; + +enum ONDEMAND_IO_BUSY_LVL { + IO_BUSY_OFF = 0xC00, + IO_BUSY_ON = 0xC01, +}; + +enum ONDEMAND_SAMPLING_DOWN_FACTOR_LVL { + SAMPLING_DOWN_FACTOR_1 = 0xD01, + SAMPLING_DOWN_FACTOR_4 = 0xD04, +}; + +enum INTERACTIVE_TIMER_RATE_LVL { + TR_MS_500 = 0xECD, + TR_MS_100 = 0xEF5, + TR_MS_50 = 0xEFA, + TR_MS_30 = 0xEFC, + TR_MS_20 = 0xEFD, +}; + +/* This timer rate applicable to cpu0 + across 8939 series chipset */ +enum INTERACTIVE_TIMER_RATE_LVL_CPU0_8939 { + TR_MS_CPU0_500 = 0x30CD, + TR_MS_CPU0_100 = 0x30F5, + TR_MS_CPU0_50 = 0x30FA, + TR_MS_CPU0_30 = 0x30FC, + TR_MS_CPU0_20 = 0x30FD, +}; + +/* This timer rate applicable to cpu4 + across 8939 series chipset */ +enum INTERACTIVE_TIMER_RATE_LVL_CPU4_8939 { + TR_MS_CPU4_500 = 0x3BCD, + TR_MS_CPU4_100 = 0x3BF5, + TR_MS_CPU4_50 = 0x3BFA, + TR_MS_CPU4_30 = 0x3BFC, + TR_MS_CPU4_20 = 0x3BFD, +}; + +/* This timer rate applicable to big.little arch */ +enum INTERACTIVE_TIMER_RATE_LVL_BIG_LITTLE { + BIG_LITTLE_TR_MS_100 = 0x64, + BIG_LITTLE_TR_MS_50 = 0x32, + BIG_LITTLE_TR_MS_40 = 0x28, + BIG_LITTLE_TR_MS_30 = 0x1E, + BIG_LITTLE_TR_MS_20 = 0x14, +}; + +/* INTERACTIVE opcodes */ +enum INTERACTIVE_OPCODES { + INT_OP_CLUSTER0_TIMER_RATE = 0x41424000, + INT_OP_CLUSTER1_TIMER_RATE = 0x41424100, + INT_OP_CLUSTER0_USE_SCHED_LOAD = 0x41430000, + INT_OP_CLUSTER1_USE_SCHED_LOAD = 0x41430100, + INT_OP_CLUSTER0_USE_MIGRATION_NOTIF = 0x41434000, + INT_OP_CLUSTER1_USE_MIGRATION_NOTIF = 0x41434100, + INT_OP_NOTIFY_ON_MIGRATE = 0x4241C000 +}; + +enum INTERACTIVE_HISPEED_FREQ_LVL { + HS_FREQ_1026 = 0xF0A, +}; + +enum INTERACTIVE_HISPEED_LOAD_LVL { + HISPEED_LOAD_90 = 0x105A, +}; + +enum SYNC_FREQ_LVL { + SYNC_FREQ_300 = 0x1103, + SYNC_FREQ_600 = 0X1106, + SYNC_FREQ_384 = 0x1103, + SYNC_FREQ_NONTURBO_MAX = 0x110A, + SYNC_FREQ_TURBO = 0x110F, +}; + +enum OPTIMAL_FREQ_LVL { + OPTIMAL_FREQ_300 = 0x1203, + OPTIMAL_FREQ_600 = 0x1206, + OPTIMAL_FREQ_384 = 0x1203, + OPTIMAL_FREQ_NONTURBO_MAX = 0x120A, + OPTIMAL_FREQ_TURBO = 0x120F, +}; + +enum SCREEN_PWR_CLPS_LVL { + PWR_CLPS_DIS = 0x1300, + PWR_CLPS_ENA = 0x1301, +}; + +enum THREAD_MIGRATION_LVL { + THREAD_MIGRATION_SYNC_OFF = 0x1400, +}; + +enum SCHED_GUIDED_LVL { + INTERACTIVE_USE_SCHED_LOAD_OFF = 0x5201, + INTERACTIVE_USE_MIGRATION_NOTIF_OFF = 0x5301 +}; + +enum INTERACTIVE_IO_BUSY_LVL { + INTERACTIVE_IO_BUSY_OFF = 0x1B00, + INTERACTIVE_IO_BUSY_ON = 0x1B01, +}; + +enum SCHED_BOOST_LVL { + SCHED_BOOST_ON = 0x1E01, +}; + +enum CPU4_MIN_FREQ_LVL { + CPU4_MIN_FREQ_NONTURBO_MAX = 0x1F0A, + CPU4_MIN_FREQ_TURBO_MAX = 0x1FFE, +}; + +enum CPU5_MIN_FREQ_LVL { + CPU5_MIN_FREQ_NONTURBO_MAX = 0x200A, + CPU5_MIN_FREQ_TURBO_MAX = 0x20FE, +}; + +enum CPU6_MIN_FREQ_LVL { + CPU6_MIN_FREQ_NONTURBO_MAX = 0x210A, + CPU6_MIN_FREQ_TURBO_MAX = 0x21FE, +}; + +enum CPU7_MIN_FREQ_LVL { + CPU7_MIN_FREQ_NONTURBO_MAX = 0x220A, + CPU7_MIN_FREQ_TURBO_MAX = 0x22FE, +}; + +enum CPU4_MAX_FREQ_LVL { + CPU4_MAX_FREQ_NONTURBO_MAX = 0x230A, +}; + +enum CPU5_MAX_FREQ_LVL { + CPU5_MAX_FREQ_NONTURBO_MAX = 0x240A, +}; + +enum CPU6_MAX_FREQ_LVL { + CPU6_MAX_FREQ_NONTURBO_MAX = 0x250A, +}; + +enum CPU7_MAX_FREQ_LVL { + CPU7_MAX_FREQ_NONTURBO_MAX = 0x260A, +}; + +#ifdef __cplusplus +} +#endif diff --git a/power/power-8998.c b/power/power-8998.c new file mode 100644 index 00000000..dbc6542f --- /dev/null +++ b/power/power-8998.c @@ -0,0 +1,288 @@ +/* + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define LOG_NIDEBUG 0 + +#include +#include +#include +#include +#include +#include +#include + +#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL) +#define LOG_TAG "QCOM PowerHAL" +#include +#include +#include +#include + +#include "utils.h" +#include "metadata-defs.h" +#include "hint-data.h" +#include "performance.h" +#include "power-common.h" +#include "powerhintparser.h" + +static int sustained_mode_handle = 0; +static int vr_mode_handle = 0; +static int launch_handle = 0; +static int sustained_performance_mode = 0; +static int vr_mode = 0; +static int launch_mode = 0; +#define CHECK_HANDLE(x) (((x)>0) && ((x)!=-1)) + +int is_perf_hint_active(int hint) +{ + switch (hint) { + case SUSTAINED_PERF_HINT_ID: + return sustained_performance_mode != 0; + case VR_MODE_HINT_ID: + return vr_mode != 0; + case VR_MODE_SUSTAINED_PERF_HINT_ID: + return vr_mode != 0 && sustained_performance_mode != 0; + } + return 0; +} + +static int process_sustained_perf_hint(void *data) +{ + int duration = 0; + int *resource_values = NULL; + int resources = 0; + + if (data && sustained_performance_mode == 0) { + if (vr_mode == 0) { // Sustained mode only. + resource_values = getPowerhint(SUSTAINED_PERF_HINT_ID, &resources); + if (!resource_values) { + ALOGE("Can't get sustained perf hints from xml "); + return HINT_NONE; + } + sustained_mode_handle = interaction_with_handle( + sustained_mode_handle, duration, resources, resource_values); + if (!CHECK_HANDLE(sustained_mode_handle)) { + ALOGE("Failed interaction_with_handle for sustained_mode_handle"); + return HINT_NONE; + } + } else if (vr_mode == 1) { // Sustained + VR mode. + release_request(vr_mode_handle); + resource_values = getPowerhint(VR_MODE_SUSTAINED_PERF_HINT_ID, &resources); + if (!resource_values) { + ALOGE("Can't get VR mode sustained perf hints from xml "); + return HINT_NONE; + } + sustained_mode_handle = interaction_with_handle( + sustained_mode_handle, duration, resources, resource_values); + if (!CHECK_HANDLE(sustained_mode_handle)) { + ALOGE("Failed interaction_with_handle for sustained_mode_handle"); + return HINT_NONE; + } + } + sustained_performance_mode = 1; + } else if (sustained_performance_mode == 1) { + release_request(sustained_mode_handle); + if (vr_mode == 1) { // Switch back to VR Mode. + resource_values = getPowerhint(VR_MODE_HINT_ID, &resources); + if (!resource_values) { + ALOGE("Can't get VR mode perf hints from xml "); + return HINT_NONE; + } + vr_mode_handle = interaction_with_handle( + vr_mode_handle, duration, resources, resource_values); + if (!CHECK_HANDLE(vr_mode_handle)) { + ALOGE("Failed interaction_with_handle for vr_mode_handle"); + return HINT_NONE; + } + } + sustained_performance_mode = 0; + } + return HINT_HANDLED; +} + +static int process_vr_mode_hint(void *data) +{ + int duration = 0; + int *resource_values = NULL; + int resources = 0; + + if (data && vr_mode == 0) { + if (sustained_performance_mode == 0) { // VR mode only. + resource_values = getPowerhint(VR_MODE_HINT_ID, &resources); + if (!resource_values) { + ALOGE("Can't get VR mode perf hints from xml "); + return HINT_NONE; + } + vr_mode_handle = interaction_with_handle( + vr_mode_handle, duration, resources, resource_values); + if (!CHECK_HANDLE(vr_mode_handle)) { + ALOGE("Failed interaction_with_handle for vr_mode_handle"); + return HINT_NONE; + } + } else if (sustained_performance_mode == 1) { // Sustained + VR mode. + release_request(sustained_mode_handle); + resource_values = getPowerhint(VR_MODE_SUSTAINED_PERF_HINT_ID, &resources); + if (!resource_values) { + ALOGE("Can't get VR mode sustained perf hints from xml "); + return HINT_NONE; + } + vr_mode_handle = interaction_with_handle( + vr_mode_handle, duration, resources, resource_values); + if (!CHECK_HANDLE(vr_mode_handle)) { + ALOGE("Failed interaction_with_handle for vr_mode_handle"); + return HINT_NONE; + } + } + vr_mode = 1; + } else if (vr_mode == 1) { + release_request(vr_mode_handle); + if (sustained_performance_mode == 1) { // Switch back to sustained Mode. + resource_values = getPowerhint(SUSTAINED_PERF_HINT_ID, &resources); + if (!resource_values) { + ALOGE("Can't get sustained perf hints from xml "); + return HINT_NONE; + } + sustained_mode_handle = interaction_with_handle( + sustained_mode_handle, duration, resources, resource_values); + if (!CHECK_HANDLE(sustained_mode_handle)) { + ALOGE("Failed interaction_with_handle for sustained_mode_handle"); + return HINT_NONE; + } + } + vr_mode = 0; + } + + return HINT_HANDLED; +} + +static int process_boost(int boost_handle, int duration) +{ + int *resource_values; + int resources; + + resource_values = getPowerhint(BOOST_HINT_ID, &resources); + + if (resource_values != NULL) { + boost_handle = interaction_with_handle( + boost_handle, duration, resources, resource_values); + if (!CHECK_HANDLE(boost_handle)) { + ALOGE("Failed interaction_with_handle for boost_handle"); + } + } + + return boost_handle; +} + +static int process_video_encode_hint(void *data) +{ + static int boost_handle = -1; + + if (data) { + // TODO: remove the launch boost based on camera launch time + int duration = 2000; // boosts 2s for starting encoding + boost_handle = process_boost(boost_handle, duration); + ALOGD("LAUNCH ENCODER-ON: %d MS", duration); + int *resource_values = NULL; + int resources = 0; + resource_values = getPowerhint(DEFAULT_VIDEO_ENCODE_HINT_ID, &resources); + if (resource_values != NULL) + perform_hint_action(DEFAULT_VIDEO_ENCODE_HINT_ID, resource_values, resources); + ALOGD("Video Encode hint start"); + return HINT_HANDLED; + } else { + undo_hint_action(DEFAULT_VIDEO_ENCODE_HINT_ID); + ALOGD("Video Encode hint stop"); + return HINT_HANDLED; + } + return HINT_NONE; +} + +static int process_activity_launch_hint(void *data) +{ + // boost will timeout in 1.25s + int duration = 1250; + ATRACE_BEGIN("launch"); + if (sustained_performance_mode || vr_mode) { + ATRACE_END(); + return HINT_HANDLED; + } + + ALOGD("LAUNCH HINT: %s", data ? "ON" : "OFF"); + // restart the launch hint if the framework has not yet released + // this shouldn't happen, but we've seen bugs where it could + if (data) { + launch_handle = process_boost(launch_handle, duration); + if (launch_handle > 0) { + launch_mode = 1; + ALOGD("Activity launch hint handled"); + ATRACE_INT("launch_lock", 1); + ATRACE_END(); + return HINT_HANDLED; + } else { + ATRACE_END(); + return HINT_NONE; + } + } else if (data == NULL && launch_mode == 1) { + // framework release hints aren't necessarily reliable + // always wait the full duration + // release_request(launch_handle); + ATRACE_INT("launch_lock", 0); + launch_mode = 0; + ATRACE_END(); + return HINT_HANDLED; + } + ATRACE_END(); + return HINT_NONE; +} + +int power_hint_override(power_hint_t hint, void *data) +{ + int ret_val = HINT_NONE; + switch(hint) { + case POWER_HINT_VIDEO_ENCODE: + ret_val = process_video_encode_hint(data); + break; + case POWER_HINT_SUSTAINED_PERFORMANCE: + ret_val = process_sustained_perf_hint(data); + break; + case POWER_HINT_VR_MODE: + ret_val = process_vr_mode_hint(data); + break; + case POWER_HINT_LAUNCH: + ret_val = process_activity_launch_hint(data); + break; + default: + break; + } + return ret_val; +} + +int set_interactive_override(int UNUSED(on)) +{ + return HINT_HANDLED; /* Don't excecute this code path, not in use */ +} diff --git a/power/power-common.h b/power/power-common.h new file mode 100644 index 00000000..aff3cd24 --- /dev/null +++ b/power/power-common.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define NODE_MAX (64) + +#define SCALING_GOVERNOR_PATH "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" +#define DCVS_CPU0_SLACK_MAX_NODE "/sys/module/msm_dcvs/cores/cpu0/slack_time_max_us" +#define DCVS_CPU0_SLACK_MIN_NODE "/sys/module/msm_dcvs/cores/cpu0/slack_time_min_us" +#define MPDECISION_SLACK_MAX_NODE "/sys/module/msm_mpdecision/slack_time_max_us" +#define MPDECISION_SLACK_MIN_NODE "/sys/module/msm_mpdecision/slack_time_min_us" +#define SCALING_MIN_FREQ "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq" +#define ONDEMAND_GOVERNOR "ondemand" +#define INTERACTIVE_GOVERNOR "interactive" +#define SCHEDUTIL_GOVERNOR "schedutil" +#define SCHED_GOVERNOR "sched" + +#define MSMDCVS_GOVERNOR "msm-dcvs" +#define SCHED_GOVERNOR "sched" + +#define HINT_HANDLED (0) +#define HINT_NONE (-1) + +enum CPU_GOV_CHECK { + CPU0 = 0, + CPU1 = 1, + CPU2 = 2, + CPU3 = 3 +}; + +#define UNUSED(x) UNUSED_ ## x __attribute__((__unused__)) diff --git a/power/power-helper.c b/power/power-helper.c new file mode 100644 index 00000000..e449ac1f --- /dev/null +++ b/power/power-helper.c @@ -0,0 +1,450 @@ +/* + * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define LOG_NIDEBUG 0 + +#include +#include +#include +#include +#include +#include +#include +#include + +#define LOG_TAG "QCOM PowerHAL" +#include +#include + +#include "utils.h" +#include "metadata-defs.h" +#include "hint-data.h" +#include "performance.h" +#include "power-common.h" +#include "power-helper.h" + +#ifndef RPM_SYSTEM_STAT +#define RPM_SYSTEM_STAT "/d/system_stats" +#endif + +#ifndef WLAN_POWER_STAT +#define WLAN_POWER_STAT "/d/wlan0/power_stats" +#endif + +#define ARRAY_SIZE(x) (sizeof((x))/sizeof((x)[0])) +#define LINE_SIZE 128 + +const char *rpm_stat_params[MAX_RPM_PARAMS] = { + "count", + "actual last sleep(msec)", +}; + +const char *master_stat_params[MAX_RPM_PARAMS] = { + "Accumulated XO duration", + "XO Count", +}; + +struct stat_pair rpm_stat_map[] = { + { RPM_MODE_XO, "RPM Mode:vlow", rpm_stat_params, ARRAY_SIZE(rpm_stat_params) }, + { RPM_MODE_VMIN, "RPM Mode:vmin", rpm_stat_params, ARRAY_SIZE(rpm_stat_params) }, + { VOTER_APSS, "APSS", master_stat_params, ARRAY_SIZE(master_stat_params) }, + { VOTER_MPSS, "MPSS", master_stat_params, ARRAY_SIZE(master_stat_params) }, + { VOTER_ADSP, "ADSP", master_stat_params, ARRAY_SIZE(master_stat_params) }, + { VOTER_SLPI, "SLPI", master_stat_params, ARRAY_SIZE(master_stat_params) }, +}; + + +const char *wlan_power_stat_params[] = { + "cumulative_sleep_time_ms", + "cumulative_total_on_time_ms", + "deep_sleep_enter_counter", + "last_deep_sleep_enter_tstamp_ms" +}; + +struct stat_pair wlan_stat_map[] = { + { WLAN_POWER_DEBUG_STATS, "POWER DEBUG STATS", wlan_power_stat_params, ARRAY_SIZE(wlan_power_stat_params) }, +}; + +static int saved_dcvs_cpu0_slack_max = -1; +static int saved_dcvs_cpu0_slack_min = -1; +static int saved_mpdecision_slack_max = -1; +static int saved_mpdecision_slack_min = -1; +static int saved_interactive_mode = -1; +static int slack_node_rw_failed = 0; +static int display_hint_sent; + +void power_init(void) +{ + ALOGI("QCOM power HAL initing."); +} + +int __attribute__ ((weak)) power_hint_override(power_hint_t UNUSED(hint), + void *UNUSED(data)) +{ + return HINT_NONE; +} + +/* Declare function before use */ +void interaction(int duration, int num_args, int opt_list[]); + +void power_hint(power_hint_t hint, void *data) +{ + /* Check if this hint has been overridden. */ + if (power_hint_override(hint, data) == HINT_HANDLED) { + /* The power_hint has been handled. We can skip the rest. */ + return; + } + + switch(hint) { + case POWER_HINT_VSYNC: + break; + case POWER_HINT_SUSTAINED_PERFORMANCE: + ALOGD("Sustained perf power hint not handled in power_hint_override"); + break; + case POWER_HINT_VR_MODE: + ALOGD("VR mode power hint not handled in power_hint_override"); + break; + case POWER_HINT_INTERACTION: + { + int resources[] = {0x702, 0x20F, 0x30F}; + int duration = 3000; + + interaction(duration, sizeof(resources)/sizeof(resources[0]), resources); + } + break; + default: + break; + } +} + +int __attribute__ ((weak)) is_perf_hint_active(int UNUSED(hint)) +{ + return 0; +} + +int __attribute__ ((weak)) set_interactive_override(int UNUSED(on)) +{ + return HINT_NONE; +} + +void power_set_interactive(int on) +{ + char governor[80]; + char tmp_str[NODE_MAX]; + struct video_encode_metadata_t video_encode_metadata; + int rc = 0; + + if (set_interactive_override(on) == HINT_HANDLED) { + return; + } + + ALOGD("Got set_interactive hint"); + + if (get_scaling_governor(governor, sizeof(governor)) == -1) { + ALOGE("Can't obtain scaling governor."); + + return; + } + + if (!on) { + /* Display off. */ + if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) && + (strlen(governor) == strlen(ONDEMAND_GOVERNOR))) { + int resource_values[] = {DISPLAY_OFF, MS_500, THREAD_MIGRATION_SYNC_OFF}; + + if (!display_hint_sent) { + perform_hint_action(DISPLAY_STATE_HINT_ID, + resource_values, sizeof(resource_values)/sizeof(resource_values[0])); + display_hint_sent = 1; + } + } else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) && + (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) { + int resource_values[] = {TR_MS_50, THREAD_MIGRATION_SYNC_OFF}; + + if (!display_hint_sent) { + perform_hint_action(DISPLAY_STATE_HINT_ID, + resource_values, sizeof(resource_values)/sizeof(resource_values[0])); + display_hint_sent = 1; + } + } else if ((strncmp(governor, MSMDCVS_GOVERNOR, strlen(MSMDCVS_GOVERNOR)) == 0) && + (strlen(governor) == strlen(MSMDCVS_GOVERNOR))) { + if (saved_interactive_mode == 1){ + /* Display turned off. */ + if (sysfs_read(DCVS_CPU0_SLACK_MAX_NODE, tmp_str, NODE_MAX - 1)) { + if (!slack_node_rw_failed) { + ALOGE("Failed to read from %s", DCVS_CPU0_SLACK_MAX_NODE); + } + + rc = 1; + } else { + saved_dcvs_cpu0_slack_max = atoi(tmp_str); + } + + if (sysfs_read(DCVS_CPU0_SLACK_MIN_NODE, tmp_str, NODE_MAX - 1)) { + if (!slack_node_rw_failed) { + ALOGE("Failed to read from %s", DCVS_CPU0_SLACK_MIN_NODE); + } + + rc = 1; + } else { + saved_dcvs_cpu0_slack_min = atoi(tmp_str); + } + + if (sysfs_read(MPDECISION_SLACK_MAX_NODE, tmp_str, NODE_MAX - 1)) { + if (!slack_node_rw_failed) { + ALOGE("Failed to read from %s", MPDECISION_SLACK_MAX_NODE); + } + + rc = 1; + } else { + saved_mpdecision_slack_max = atoi(tmp_str); + } + + if (sysfs_read(MPDECISION_SLACK_MIN_NODE, tmp_str, NODE_MAX - 1)) { + if(!slack_node_rw_failed) { + ALOGE("Failed to read from %s", MPDECISION_SLACK_MIN_NODE); + } + + rc = 1; + } else { + saved_mpdecision_slack_min = atoi(tmp_str); + } + + /* Write new values. */ + if (saved_dcvs_cpu0_slack_max != -1) { + snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_dcvs_cpu0_slack_max); + + if (sysfs_write(DCVS_CPU0_SLACK_MAX_NODE, tmp_str) != 0) { + if (!slack_node_rw_failed) { + ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MAX_NODE); + } + + rc = 1; + } + } + + if (saved_dcvs_cpu0_slack_min != -1) { + snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_dcvs_cpu0_slack_min); + + if (sysfs_write(DCVS_CPU0_SLACK_MIN_NODE, tmp_str) != 0) { + if(!slack_node_rw_failed) { + ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MIN_NODE); + } + + rc = 1; + } + } + + if (saved_mpdecision_slack_max != -1) { + snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_mpdecision_slack_max); + + if (sysfs_write(MPDECISION_SLACK_MAX_NODE, tmp_str) != 0) { + if(!slack_node_rw_failed) { + ALOGE("Failed to write to %s", MPDECISION_SLACK_MAX_NODE); + } + + rc = 1; + } + } + + if (saved_mpdecision_slack_min != -1) { + snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_mpdecision_slack_min); + + if (sysfs_write(MPDECISION_SLACK_MIN_NODE, tmp_str) != 0) { + if(!slack_node_rw_failed) { + ALOGE("Failed to write to %s", MPDECISION_SLACK_MIN_NODE); + } + + rc = 1; + } + } + } + + slack_node_rw_failed = rc; + } + } else { + /* Display on. */ + if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) && + (strlen(governor) == strlen(ONDEMAND_GOVERNOR))) { + undo_hint_action(DISPLAY_STATE_HINT_ID); + display_hint_sent = 0; + } else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) && + (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) { + undo_hint_action(DISPLAY_STATE_HINT_ID); + display_hint_sent = 0; + } else if ((strncmp(governor, MSMDCVS_GOVERNOR, strlen(MSMDCVS_GOVERNOR)) == 0) && + (strlen(governor) == strlen(MSMDCVS_GOVERNOR))) { + if (saved_interactive_mode == -1 || saved_interactive_mode == 0) { + /* Display turned on. Restore if possible. */ + if (saved_dcvs_cpu0_slack_max != -1) { + snprintf(tmp_str, NODE_MAX, "%d", saved_dcvs_cpu0_slack_max); + + if (sysfs_write(DCVS_CPU0_SLACK_MAX_NODE, tmp_str) != 0) { + if (!slack_node_rw_failed) { + ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MAX_NODE); + } + + rc = 1; + } + } + + if (saved_dcvs_cpu0_slack_min != -1) { + snprintf(tmp_str, NODE_MAX, "%d", saved_dcvs_cpu0_slack_min); + + if (sysfs_write(DCVS_CPU0_SLACK_MIN_NODE, tmp_str) != 0) { + if (!slack_node_rw_failed) { + ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MIN_NODE); + } + + rc = 1; + } + } + + if (saved_mpdecision_slack_max != -1) { + snprintf(tmp_str, NODE_MAX, "%d", saved_mpdecision_slack_max); + + if (sysfs_write(MPDECISION_SLACK_MAX_NODE, tmp_str) != 0) { + if (!slack_node_rw_failed) { + ALOGE("Failed to write to %s", MPDECISION_SLACK_MAX_NODE); + } + + rc = 1; + } + } + + if (saved_mpdecision_slack_min != -1) { + snprintf(tmp_str, NODE_MAX, "%d", saved_mpdecision_slack_min); + + if (sysfs_write(MPDECISION_SLACK_MIN_NODE, tmp_str) != 0) { + if (!slack_node_rw_failed) { + ALOGE("Failed to write to %s", MPDECISION_SLACK_MIN_NODE); + } + + rc = 1; + } + } + } + + slack_node_rw_failed = rc; + } + } + + saved_interactive_mode = !!on; +} + + +static int parse_stats(const char **params, size_t params_size, + uint64_t *list, FILE *fp) { + ssize_t nread; + size_t len = LINE_SIZE; + char *line; + size_t params_read = 0; + size_t i; + + line = malloc(len); + if (!line) { + ALOGE("%s: no memory to hold line", __func__); + return -ENOMEM; + } + + while ((params_read < params_size) && + (nread = getline(&line, &len, fp) > 0)) { + char *key = line + strspn(line, " \t"); + char *value = strchr(key, ':'); + if (!value || (value > (line + len))) + continue; + *value++ = '\0'; + + for (i = 0; i < params_size; i++) { + if (!strcmp(key, params[i])) { + list[i] = strtoull(value, NULL, 0); + params_read++; + break; + } + } + } + free(line); + + return 0; +} + + +static int extract_stats(uint64_t *list, char *file, + struct stat_pair *map, size_t map_size) { + FILE *fp; + ssize_t read; + size_t len = LINE_SIZE; + char *line; + size_t i, stats_read = 0; + int ret = 0; + + fp = fopen(file, "re"); + if (fp == NULL) { + ALOGE("%s: failed to open: %s Error = %s", __func__, file, strerror(errno)); + return -errno; + } + + line = malloc(len); + if (!line) { + ALOGE("%s: no memory to hold line", __func__); + fclose(fp); + return -ENOMEM; + } + + while ((stats_read < map_size) && (read = getline(&line, &len, fp) != -1)) { + size_t begin = strspn(line, " \t"); + + for (i = 0; i < map_size; i++) { + if (!strncmp(line + begin, map[i].label, strlen(map[i].label))) { + stats_read++; + break; + } + } + + if (i == map_size) + continue; + + ret = parse_stats(map[i].parameters, map[i].num_parameters, + &list[map[i].stat * MAX_RPM_PARAMS], fp); + if (ret < 0) + break; + } + free(line); + fclose(fp); + + return ret; +} + +int extract_platform_stats(uint64_t *list) { + return extract_stats(list, RPM_SYSTEM_STAT, rpm_stat_map, ARRAY_SIZE(rpm_stat_map)); +} + +int extract_wlan_stats(uint64_t *list) { + return extract_stats(list, WLAN_POWER_STAT, wlan_stat_map, ARRAY_SIZE(wlan_stat_map)); +} diff --git a/power/power-helper.h b/power/power-helper.h new file mode 100644 index 00000000..b2ef147a --- /dev/null +++ b/power/power-helper.h @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2017, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __POWER_HELPER_H__ +#define __POWER_HELPER_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "hardware/power.h" + + +enum stats_type { + //Platform Stats + RPM_MODE_XO = 0, + RPM_MODE_VMIN, + RPM_MODE_MAX, + XO_VOTERS_START = RPM_MODE_MAX, + VOTER_APSS = XO_VOTERS_START, + VOTER_MPSS, + VOTER_ADSP, + VOTER_SLPI, + MAX_PLATFORM_STATS, + + //WLAN Stats + WLAN_POWER_DEBUG_STATS = 0, + MAX_WLAN_STATS, +}; + +enum subsystem_type { + SUBSYSTEM_WLAN = 0, + + //Don't add any lines after this line + SUBSYSTEM_COUNT +}; + +enum wlan_sleep_states { + WLAN_STATE_ACTIVE = 0, + WLAN_STATE_DEEP_SLEEP, + + //Don't add any lines after this line + WLAN_STATES_COUNT +}; + +enum wlan_power_params { + CUMULATIVE_SLEEP_TIME_MS = 0, + CUMULATIVE_TOTAL_ON_TIME_MS, + DEEP_SLEEP_ENTER_COUNTER, + LAST_DEEP_SLEEP_ENTER_TSTAMP_MS, + + //Don't add any lines after this line + WLAN_POWER_PARAMS_COUNT +}; + + +#define PLATFORM_SLEEP_MODES_COUNT RPM_MODE_MAX + +#define MAX_RPM_PARAMS 2 +#define XO_VOTERS (MAX_PLATFORM_STATS - XO_VOTERS_START) +#define VMIN_VOTERS 0 + +struct stat_pair { + enum stats_type stat; + const char *label; + const char **parameters; + size_t num_parameters; +}; + + +void power_init(void); +void power_hint(power_hint_t hint, void *data); +void power_set_interactive(int on); +int extract_platform_stats(uint64_t *list); +int extract_wlan_stats(uint64_t *list); + +int is_perf_hint_active(int hint); + +#ifdef __cplusplus +} +#endif + +#endif //__POWER_HELPER_H__ diff --git a/power/powerhintparser.c b/power/powerhintparser.c new file mode 100644 index 00000000..5f880dfb --- /dev/null +++ b/power/powerhintparser.c @@ -0,0 +1,173 @@ +/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#define LOG_TAG "QCOM PowerHAL" + +#include +#include +#include "powerhintparser.h" + +int parsePowerhintXML() { + + xmlDocPtr doc; + xmlNodePtr currNode; + const char *opcode_str, *value_str, *type_str; + int opcode = 0, value = 0, type = 0; + int numParams = 0; + static int hintCount; + + if(access(POWERHINT_XML, F_OK) < 0) { + return -1; + } + + doc = xmlReadFile(POWERHINT_XML, "UTF-8", XML_PARSE_RECOVER); + if(!doc) { + ALOGE("Document not parsed successfully"); + return -1; + } + + currNode = xmlDocGetRootElement(doc); + if(!currNode) { + ALOGE("Empty document"); + xmlFreeDoc(doc); + xmlCleanupParser(); + return -1; + } + + // Confirm the root-element of the tree + if(xmlStrcmp(currNode->name, BAD_CAST "Powerhint")) { + ALOGE("document of the wrong type, root node != root"); + xmlFreeDoc(doc); + xmlCleanupParser(); + return -1; + } + + currNode = currNode->xmlChildrenNode; + + for(; currNode != NULL; currNode=currNode->next) { + + if(currNode->type != XML_ELEMENT_NODE) + continue; + + xmlNodePtr node = currNode; + + if(hintCount == MAX_HINT) { + ALOGE("Number of hints exceeded the max count of %d\n",MAX_HINT); + break; + } + + if(!xmlStrcmp(node->name, BAD_CAST "Hint")) { + if(xmlHasProp(node, BAD_CAST "type")) { + type_str = (const char*)xmlGetProp(node, BAD_CAST "type"); + if (type_str == NULL) + { + ALOGE("xmlGetProp failed on type"); + xmlFreeDoc(doc); + xmlCleanupParser(); + return -1; + } + type = strtol(type_str, NULL, 16); + } + + node = node->children; + while(node != NULL) { + if(!xmlStrcmp(node->name, BAD_CAST "Resource")) { + + if(xmlHasProp(node, BAD_CAST "opcode")) { + opcode_str = (const char*)xmlGetProp(node, BAD_CAST "opcode"); + if (opcode_str == NULL) + { + ALOGE("xmlGetProp failed on opcode"); + xmlFreeDoc(doc); + xmlCleanupParser(); + return -1; + } + opcode = strtol(opcode_str, NULL, 16); + } + if(xmlHasProp(node, BAD_CAST "value")) { + value_str = (const char*)xmlGetProp(node, BAD_CAST "value"); + if (value_str == NULL) + { + ALOGE("xmlGetProp failed on value"); + xmlFreeDoc(doc); + xmlCleanupParser(); + return -1; + } + value = strtol(value_str, NULL, 16); + } + if(opcode > 0) { + if(numParams < (MAX_PARAM-1)) { + powerhint[hintCount].paramList[numParams++] = opcode; + powerhint[hintCount].paramList[numParams++] = value; + } else { + ALOGE("Maximum parameters exceeded for Hint ID %x\n",type); + opcode = value = 0; + break; + } + } + + opcode = value = 0; + } + node = node->next; + } + powerhint[hintCount].type = type; + powerhint[hintCount].numParams = numParams; + numParams = 0; + } + hintCount++; + } + + xmlFreeDoc(doc); + xmlCleanupParser(); + return 0; +} + +int* getPowerhint(int hint_id, int *params) { + + int *result = NULL; + + if(!hint_id) + return result; + + ALOGV("Powerhal hint received=%x\n",hint_id); + + if(!powerhint[0].numParams) { + parsePowerhintXML(); + } + + for(int i = 0; i < MAX_HINT; i++) { + if(hint_id == powerhint[i].type) { + *params = powerhint[i].numParams; + result = powerhint[i].paramList; + break; + } + } + + return result; +} diff --git a/power/powerhintparser.h b/power/powerhintparser.h new file mode 100644 index 00000000..c1da1de1 --- /dev/null +++ b/power/powerhintparser.h @@ -0,0 +1,57 @@ +/* Copyright (c) 2016, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __POWERHINTPARSER__ +#define __POWERHINTPARSER__ + +#define POWERHINT_XML "/vendor/etc/powerhint.xml" +#define MAX_HINT 8 +#define MAX_PARAM 30 + +typedef struct perflock_param_t { + int type; + int numParams; + int paramList[MAX_PARAM];//static limit on number of hints - 15 +}perflock_param_t; + +static perflock_param_t powerhint[MAX_HINT]; + +int parsePowerhintXML(); + +#ifdef __cplusplus +extern "C" { +#endif + +int *getPowerhint(int, int *); + +#ifdef __cplusplus +} +#endif + +#endif /* __POWERHINTPARSER__ */ diff --git a/power/service.cpp b/power/service.cpp new file mode 100644 index 00000000..5b3a47d6 --- /dev/null +++ b/power/service.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "android.hardware.power@1.1-service.wahoo" + +#include +#include +#include +#include "Power.h" + +using android::sp; +using android::status_t; +using android::OK; + +// libhwbinder: +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; + +// Generated HIDL files +using android::hardware::power::V1_1::IPower; +using android::hardware::power::V1_1::implementation::Power; + +int main() { + + status_t status; + android::sp service = nullptr; + + ALOGI("Power HAL Service 1.1 for Wahoo is starting."); + + service = new Power(); + if (service == nullptr) { + ALOGE("Can not create an instance of Power HAL Iface, exiting."); + + goto shutdown; + } + + configureRpcThreadpool(1, true /*callerWillJoin*/); + + status = service->registerAsService(); + if (status != OK) { + ALOGE("Could not register service for Power HAL Iface (%d).", status); + goto shutdown; + } + + ALOGI("Power Service is ready"); + joinRpcThreadpool(); + //Should not pass this line + +shutdown: + // In normal operation, we don't expect the thread pool to exit + + ALOGE("Power Service is shutting down"); + return 1; +} diff --git a/power/utils.c b/power/utils.c new file mode 100644 index 00000000..ef7e366e --- /dev/null +++ b/power/utils.c @@ -0,0 +1,326 @@ +/* + * Copyright (c) 2012-2013,2015-2016, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define LOG_NIDEBUG 0 + +#include +#include +#include +#include +#include + +#include "utils.h" +#include "list.h" +#include "hint-data.h" +#include "power-common.h" + +#define LOG_TAG "QCOM PowerHAL" +#include + +static void *qcopt_handle; +static int (*perf_lock_acq)(unsigned long handle, int duration, + int list[], int numArgs); +static int (*perf_lock_rel)(unsigned long handle); +static struct list_node active_hint_list_head; + +static void *get_qcopt_handle() +{ + char qcopt_lib_path[PATH_MAX] = {0}; + void *handle = NULL; + + dlerror(); + + if (property_get("ro.vendor.extension_library", qcopt_lib_path, + NULL)) { + handle = dlopen(qcopt_lib_path, RTLD_NOW); + if (!handle) { + ALOGE("Unable to open %s: %s\n", qcopt_lib_path, + dlerror()); + } + } + + return handle; +} + +static void __attribute__ ((constructor)) initialize(void) +{ + qcopt_handle = get_qcopt_handle(); + + if (!qcopt_handle) { + ALOGE("Failed to get qcopt handle.\n"); + } else { + /* + * qc-opt handle obtained. Get the perflock acquire/release + * function pointers. + */ + perf_lock_acq = dlsym(qcopt_handle, "perf_lock_acq"); + + if (!perf_lock_acq) { + ALOGE("Unable to get perf_lock_acq function handle.\n"); + } + + perf_lock_rel = dlsym(qcopt_handle, "perf_lock_rel"); + + if (!perf_lock_rel) { + ALOGE("Unable to get perf_lock_rel function handle.\n"); + } + } +} + +static void __attribute__ ((destructor)) cleanup(void) +{ + if (qcopt_handle) { + if (dlclose(qcopt_handle)) + ALOGE("Error occurred while closing qc-opt library."); + } +} + +int sysfs_read(char *path, char *s, int num_bytes) +{ + char buf[80]; + int count; + int ret = 0; + int fd = open(path, O_RDONLY); + + if (fd < 0) { + strerror_r(errno, buf, sizeof(buf)); + ALOGE("Error opening %s: %s\n", path, buf); + + return -1; + } + + if ((count = read(fd, s, num_bytes - 1)) < 0) { + strerror_r(errno, buf, sizeof(buf)); + ALOGE("Error writing to %s: %s\n", path, buf); + + ret = -1; + } else { + s[count] = '\0'; + } + + close(fd); + + return ret; +} + +int sysfs_write(char *path, char *s) +{ + char buf[80]; + int len; + int ret = 0; + int fd = open(path, O_WRONLY); + + if (fd < 0) { + strerror_r(errno, buf, sizeof(buf)); + ALOGE("Error opening %s: %s\n", path, buf); + return -1 ; + } + + len = write(fd, s, strlen(s)); + if (len < 0) { + strerror_r(errno, buf, sizeof(buf)); + ALOGE("Error writing to %s: %s\n", path, buf); + + ret = -1; + } + + close(fd); + + return ret; +} + +int get_scaling_governor(char governor[], int size) +{ + if (sysfs_read(SCALING_GOVERNOR_PATH, governor, + size) == -1) { + // Can't obtain the scaling governor. Return. + return -1; + } else { + // Strip newline at the end. + int len = strlen(governor); + + len--; + + while (len >= 0 && (governor[len] == '\n' || governor[len] == '\r')) + governor[len--] = '\0'; + } + + return 0; +} + +int is_interactive_governor(char* governor) { + if (strncmp(governor, INTERACTIVE_GOVERNOR, (strlen(INTERACTIVE_GOVERNOR)+1)) == 0) + return 1; + return 0; +} + +void interaction(int duration, int num_args, int opt_list[]) +{ +#ifdef INTERACTION_BOOST + static int lock_handle = 0; + + if (duration < 0 || num_args < 1 || opt_list[0] == 0) + return; + + if (qcopt_handle) { + if (perf_lock_acq) { + lock_handle = perf_lock_acq(lock_handle, duration, opt_list, num_args); + if (lock_handle == -1) + ALOGE("Failed to acquire lock."); + } + } +#endif +} + +int interaction_with_handle(int lock_handle, int duration, int num_args, int opt_list[]) +{ +#ifdef INTERACTION_BOOST + if (duration < 0 || num_args < 1 || opt_list[0] == 0) + return 0; + + if (qcopt_handle) { + if (perf_lock_acq) { + lock_handle = perf_lock_acq(lock_handle, duration, opt_list, num_args); + if (lock_handle == -1) + ALOGE("Failed to acquire lock."); + } + } + return lock_handle; +#else + return 0; +#endif +} + +void release_request(int lock_handle) { + if (qcopt_handle && perf_lock_rel) + perf_lock_rel(lock_handle); +} + +void perform_hint_action(int hint_id, int resource_values[], int num_resources) +{ + if (qcopt_handle) { + struct hint_data temp_hint_data = { + .hint_id = hint_id + }; + struct list_node *found_node = find_node(&active_hint_list_head, + &temp_hint_data); + if (found_node) { + ALOGE("hint ID %d already active", hint_id); + return; + } + if (perf_lock_acq) { + /* Acquire an indefinite lock for the requested resources. */ + int lock_handle = perf_lock_acq(0, 0, resource_values, + num_resources); + + if (lock_handle == -1) { + ALOGE("%s: Failed to acquire lock.", __func__); + } else { + /* Add this handle to our internal hint-list. */ + struct hint_data *new_hint = + (struct hint_data *)malloc(sizeof(struct hint_data)); + + if (new_hint) { + if (!active_hint_list_head.compare) { + active_hint_list_head.compare = + (int (*)(void *, void *))hint_compare; + active_hint_list_head.dump = (void (*)(void *))hint_dump; + } + + new_hint->hint_id = hint_id; + new_hint->perflock_handle = lock_handle; + + if (add_list_node(&active_hint_list_head, new_hint) == NULL) { + free(new_hint); + /* Can't keep track of this lock. Release it. */ + if (perf_lock_rel) + perf_lock_rel(lock_handle); + + ALOGE("Failed to process hint."); + } + } else { + /* Can't keep track of this lock. Release it. */ + if (perf_lock_rel) + perf_lock_rel(lock_handle); + + ALOGE("Failed to process hint."); + } + } + } + } +} + +void undo_hint_action(int hint_id) +{ + if (qcopt_handle) { + if (perf_lock_rel) { + /* Get hint-data associated with this hint-id */ + struct list_node *found_node; + struct hint_data temp_hint_data = { + .hint_id = hint_id + }; + + found_node = find_node(&active_hint_list_head, + &temp_hint_data); + + if (found_node) { + /* Release this lock. */ + struct hint_data *found_hint_data = + (struct hint_data *)(found_node->data); + + if (found_hint_data) { + if (perf_lock_rel(found_hint_data->perflock_handle) == -1) + ALOGE("Perflock release failed: %d", hint_id); + } + + if (found_node->data) { + /* We can free the hint-data for this node. */ + free(found_node->data); + } + + remove_list_node(&active_hint_list_head, found_node); + ALOGV("Undo of hint ID %d succeeded", hint_id); + } else { + ALOGE("Invalid hint ID: %d", hint_id); + } + } + } +} + +/* + * Used to release initial lock holding + * two cores online when the display is on + */ +void undo_initial_hint_action() +{ + if (qcopt_handle) { + if (perf_lock_rel) { + perf_lock_rel(1); + } + } +} diff --git a/power/utils.h b/power/utils.h new file mode 100644 index 00000000..fb7aa113 --- /dev/null +++ b/power/utils.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2012-2013,2015-2016, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#ifndef UTILS_H +#define UTILS_H +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int sysfs_read(char *path, char *s, int num_bytes); +int sysfs_write(char *path, char *s); +int get_scaling_governor(char governor[], int size); +int get_scaling_governor_check_cores(char governor[], int size, int core_num); +int is_interactive_governor(char *); + +void vote_ondemand_io_busy_off(); +void unvote_ondemand_io_busy_off(); +void vote_ondemand_sdf_low(); +void unvote_ondemand_sdf_low(); +void perform_hint_action(int hint_id, int resource_values[], + int num_resources); +void undo_hint_action(int hint_id); +void release_request(int lock_handle); +int interaction_with_handle(int lock_handle, + int duration, + int num_args, + int opt_list[]); + +#ifdef __cplusplus +} +#endif + +#endif //UTILS_H \ No newline at end of file diff --git a/powerhint.xml b/powerhint.xml new file mode 100755 index 00000000..19373d49 --- /dev/null +++ b/powerhint.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/recovery.wipe b/recovery.wipe new file mode 100644 index 00000000..03e5e18b --- /dev/null +++ b/recovery.wipe @@ -0,0 +1,10 @@ +# All the partitions to be wiped (in order) under recovery. +/dev/block/bootdevice/by-name/system_a +/dev/block/bootdevice/by-name/system_b +/dev/block/bootdevice/by-name/vendor_a +/dev/block/bootdevice/by-name/vendor_b +/dev/block/bootdevice/by-name/userdata +# Wipe the boot partitions last so that all partitions will be wiped +# correctly even if the wiping process gets interrupted by a force boot. +/dev/block/bootdevice/by-name/boot_a +/dev/block/bootdevice/by-name/boot_b diff --git a/sec_config b/sec_config new file mode 100644 index 00000000..23716aac --- /dev/null +++ b/sec_config @@ -0,0 +1,323 @@ +/* IPC Security Config */ +/* :: */ +16:4294967295:1000:1021 +/* :: */ +56:4294967295:1021 +/* Allow SS CTL service to be used by system and net_raw processes */ +43:4294967295:1000:3004 +/* :: */ +71:4294967295:1001 +/* :: */ +50:4294967295:1001 +/* QMI-SLIM service permitted to gps and net_raw */ +55:4294967295:1021 +/* Allow Sensor services to be used by sensor process */ +256:4294967295:1000:1006:1013:1021:1047:3011 +257:4294967295:1000:1006:1013:1021:1047:3011 +258:4294967295:1000:1006:1013:1021:1047:3011 +259:4294967295:1000:1006:1013:1021:1047:3011 +260:4294967295:1000:1006:1013:1021:1047:3011 +261:4294967295:1000:1006:1013:1021:1047:3011 +262:4294967295:1000:1006:1013:1021:1047:3011 +263:4294967295:1000:1006:1013:1021:1047:3011 +264:4294967295:1000:1006:1013:1021:1047:3011 +265:4294967295:1000:1006:1013:1021:1047:3011 +266:4294967295:1000:1006:1013:1021:1047:3011 +267:4294967295:1000:1006:1013:1021:1047:3011 +268:4294967295:1000:1006:1013:1021:1047:3011 +269:4294967295:1000:1006:1013:1021:1047:3011 +270:4294967295:1000:1006:1013:1021:1047:3011 +271:4294967295:1000:1006:1013:1021:1047:3011 +272:4294967295:1000:1006:1013:1021:1047:3011 +273:4294967295:1000:1006:1013:1021:1047:3011 +274:4294967295:1000:1006:1013:1021:1047:3011 +275:4294967295:1000:1006:1013:1021:1047:3011 +276:4294967295:1000:1006:1013:1021:1047:3011 +277:4294967295:1000:1006:1013:1021:1047:3011 +278:4294967295:1000:1006:1013:1021:1047:3011 +279:4294967295:1000:1006:1013:1021:1047:3011 +280:4294967295:1000:1006:1013:1021:1047:3011 +281:4294967295:1000:1006:1013:1021:1047:3011 +282:4294967295:1000:1006:1013:1021:1047:3011 +283:4294967295:1000:1006:1013:1021:1047:3011 +284:4294967295:1000:1006:1013:1021:1047:3011 +285:4294967295:1000:1006:1013:1021:1047:3011 +286:4294967295:1000:1006:1013:1021:1047:3011 +287:4294967295:1000:1006:1013:1021:1047:3011 +288:4294967295:1000:1006:1013:1021:1047:3011 +289:4294967295:1000:1006:1013:1021:1047:3011 +290:4294967295:1000:1006:1013:1021:1047:3011 +291:4294967295:1000:1006:1013:1021:1047:3011 +292:4294967295:1000:1006:1013:1021:1047:3011 +293:4294967295:1000:1006:1013:1021:1047:3011 +294:4294967295:1000:1006:1013:1021:1047:3011 +295:4294967295:1000:1006:1013:1021:1047:3011 +296:4294967295:1000:1006:1013:1021:1047:3011 +297:4294967295:1000:1006:1013:1021:1047:3011 +298:4294967295:1000:1006:1013:1021:1047:3011 +299:4294967295:1000:1006:1013:1021:1047:3011 +300:4294967295:1000:1006:1013:1021:1047:3011 +301:4294967295:1000:1006:1013:1021:1047:3011 +302:4294967295:1000:1006:1013:1021:1047:3011 +303:4294967295:1000:1006:1013:1021:1047:3011 +304:4294967295:1000:1006:1013:1021:1047:3011 +305:4294967295:1000:1006:1013:1021:1047:3011 +306:4294967295:1000:1006:1013:1021:1047:3011 +307:4294967295:1000:1006:1013:1021:1047:3011 +308:4294967295:1000:1006:1013:1021:1047:3011 +309:4294967295:1000:1006:1013:1021:1047:3011 +310:4294967295:1000:1006:1013:1021:1047:3011 +311:4294967295:1000:1006:1013:1021:1047:3011 +312:4294967295:1000:1006:1013:1021:1047:3011 +313:4294967295:1000:1006:1013:1021:1047:3011 +314:4294967295:1000:1006:1013:1021:1047:3011 +315:4294967295:1000:1006:1013:1021:1047:3011 +316:4294967295:1000:1006:1013:1021:1047:3011 +317:4294967295:1000:1006:1013:1021:1047:3011 +318:4294967295:1000:1006:1013:1021:1047:3011 +319:4294967295:1000:1006:1013:1021:1047:3011 +320:4294967295:1000:1006:1013:1021:1047:3011 +321:4294967295:1000:1006:1013:1021:1047:3011 +322:4294967295:1000:1006:1013:1021:1047:3011 +323:4294967295:1000:1006:1013:1021:1047:3011 +324:4294967295:1000:1006:1013:1021:1047:3011 +325:4294967295:1000:1006:1013:1021:1047:3011 +326:4294967295:1000:1006:1013:1021:1047:3011 +327:4294967295:1000:1006:1013:1021:1047:3011 +328:4294967295:1000:1006:1013:1021:1047:3011 +329:4294967295:1000:1006:1013:1021:1047:3011 +330:4294967295:1000:1006:1013:1021:1047:3011 +331:4294967295:1000:1006:1013:1021:1047:3011 +332:4294967295:1000:1006:1013:1021:1047:3011 +333:4294967295:1000:1006:1013:1021:1047:3011 +334:4294967295:1000:1006:1013:1021:1047:3011 +335:4294967295:1000:1006:1013:1021:1047:3011 +336:4294967295:1000:1006:1013:1021:1047:3011 +337:4294967295:1000:1006:1013:1021:1047:3011 +338:4294967295:1000:1006:1013:1021:1047:3011 +339:4294967295:1000:1006:1013:1021:1047:3011 +340:4294967295:1000:1006:1013:1021:1047:3011 +341:4294967295:1000:1006:1013:1021:1047:3011 +342:4294967295:1000:1006:1013:1021:1047:3011 +343:4294967295:1000:1006:1013:1021:1047:3011 +344:4294967295:1000:1006:1013:1021:1047:3011 +345:4294967295:1000:1006:1013:1021:1047:3011 +346:4294967295:1000:1006:1013:1021:1047:3011 +347:4294967295:1000:1006:1013:1021:1047:3011 +348:4294967295:1000:1006:1013:1021:1047:3011 +349:4294967295:1000:1006:1013:1021:1047:3011 +350:4294967295:1000:1006:1013:1021:1047:3011 +351:4294967295:1000:1006:1013:1021:1047:3011 +352:4294967295:1000:1006:1013:1021:1047:3011 +353:4294967295:1000:1006:1013:1021:1047:3011 +354:4294967295:1000:1006:1013:1021:1047:3011 +355:4294967295:1000:1006:1013:1021:1047:3011 +356:4294967295:1000:1006:1013:1021:1047:3011 +357:4294967295:1000:1006:1013:1021:1047:3011 +358:4294967295:1000:1006:1013:1021:1047:3011 +359:4294967295:1000:1006:1013:1021:1047:3011 +360:4294967295:1000:1006:1013:1021:1047:3011 +361:4294967295:1000:1006:1013:1021:1047:3011 +362:4294967295:1000:1006:1013:1021:1047:3011 +363:4294967295:1000:1006:1013:1021:1047:3011 +364:4294967295:1000:1006:1013:1021:1047:3011 +365:4294967295:1000:1006:1013:1021:1047:3011 +366:4294967295:1000:1006:1013:1021:1047:3011 +367:4294967295:1000:1006:1013:1021:1047:3011 +368:4294967295:1000:1006:1013:1021:1047:3011 +369:4294967295:1000:1006:1013:1021:1047:3011 +370:4294967295:1000:1006:1013:1021:1047:3011 +371:4294967295:1000:1006:1013:1021:1047:3011 +372:4294967295:1000:1006:1013:1021:1047:3011 +373:4294967295:1000:1006:1013:1021:1047:3011 +374:4294967295:1000:1006:1013:1021:1047:3011 +375:4294967295:1000:1006:1013:1021:1047:3011 +376:4294967295:1000:1006:1013:1021:1047:3011 +377:4294967295:1000:1006:1013:1021:1047:3011 +378:4294967295:1000:1006:1013:1021:1047:3011 +379:4294967295:1000:1006:1013:1021:1047:3011 +380:4294967295:1000:1006:1013:1021:1047:3011 +381:4294967295:1000:1006:1013:1021:1047:3011 +382:4294967295:1000:1006:1013:1021:1047:3011 +383:4294967295:1000:1006:1013:1021:1047:3011 +384:4294967295:1000:1006:1013:1021:1047:3011 +385:4294967295:1000:1006:1013:1021:1047:3011 +386:4294967295:1000:1006:1013:1021:1047:3011 +387:4294967295:1000:1006:1013:1021:1047:3011 +388:4294967295:1000:1006:1013:1021:1047:3011 +389:4294967295:1000:1006:1013:1021:1047:3011 +390:4294967295:1000:1006:1013:1021:1047:3011 +391:4294967295:1000:1006:1013:1021:1047:3011 +392:4294967295:1000:1006:1013:1021:1047:3011 +393:4294967295:1000:1006:1013:1021:1047:3011 +394:4294967295:1000:1006:1013:1021:1047:3011 +395:4294967295:1000:1006:1013:1021:1047:3011 +396:4294967295:1000:1006:1013:1021:1047:3011 +397:4294967295:1000:1006:1013:1021:1047:3011 +398:4294967295:1000:1006:1013:1021:1047:3011 +399:4294967295:1000:1006:1013:1021:1047:3011 +400:4294967295:1000:1006:1013:1021:1047:3011 +401:4294967295:1000:1006:1013:1021:1047:3011 +402:4294967295:1000:1006:1013:1021:1047:3011 +403:4294967295:1000:1006:1013:1021:1047:3011 +404:4294967295:1000:1006:1013:1021:1047:3011 +405:4294967295:1000:1006:1013:1021:1047:3011 +406:4294967295:1000:1006:1013:1021:1047:3011 +407:4294967295:1000:1006:1013:1021:1047:3011 +408:4294967295:1000:1006:1013:1021:1047:3011 +409:4294967295:1000:1006:1013:1021:1047:3011 +410:4294967295:1000:1006:1013:1021:1047:3011 +411:4294967295:1000:1006:1013:1021:1047:3011 +412:4294967295:1000:1006:1013:1021:1047:3011 +413:4294967295:1000:1006:1013:1021:1047:3011 +414:4294967295:1000:1006:1013:1021:1047:3011 +415:4294967295:1000:1006:1013:1021:1047:3011 +416:4294967295:1000:1006:1013:1021:1047:3011 +417:4294967295:1000:1006:1013:1021:1047:3011 +418:4294967295:1000:1006:1013:1021:1047:3011 +419:4294967295:1000:1006:1013:1021:1047:3011 +420:4294967295:1000:1006:1013:1021:1047:3011 +421:4294967295:1000:1006:1013:1021:1047:3011 +422:4294967295:1000:1006:1013:1021:1047:3011 +423:4294967295:1000:1006:1013:1021:1047:3011 +424:4294967295:1000:1006:1013:1021:1047:3011 +425:4294967295:1000:1006:1013:1021:1047:3011 +426:4294967295:1000:1006:1013:1021:1047:3011 +427:4294967295:1000:1006:1013:1021:1047:3011 +428:4294967295:1000:1006:1013:1021:1047:3011 +429:4294967295:1000:1006:1013:1021:1047:3011 +430:4294967295:1000:1006:1013:1021:1047:3011 +431:4294967295:1000:1006:1013:1021:1047:3011 +432:4294967295:1000:1006:1013:1021:1047:3011 +433:4294967295:1000:1006:1013:1021:1047:3011 +434:4294967295:1000:1006:1013:1021:1047:3011 +435:4294967295:1000:1006:1013:1021:1047:3011 +436:4294967295:1000:1006:1013:1021:1047:3011 +437:4294967295:1000:1006:1013:1021:1047:3011 +438:4294967295:1000:1006:1013:1021:1047:3011 +439:4294967295:1000:1006:1013:1021:1047:3011 +440:4294967295:1000:1006:1013:1021:1047:3011 +441:4294967295:1000:1006:1013:1021:1047:3011 +442:4294967295:1000:1006:1013:1021:1047:3011 +443:4294967295:1000:1006:1013:1021:1047:3011 +444:4294967295:1000:1006:1013:1021:1047:3011 +445:4294967295:1000:1006:1013:1021:1047:3011 +446:4294967295:1000:1006:1013:1021:1047:3011 +447:4294967295:1000:1006:1013:1021:1047:3011 +448:4294967295:1000:1006:1013:1021:1047:3011 +449:4294967295:1000:1006:1013:1021:1047:3011 +450:4294967295:1000:1006:1013:1021:1047:3011 +451:4294967295:1000:1006:1013:1021:1047:3011 +452:4294967295:1000:1006:1013:1021:1047:3011 +453:4294967295:1000:1006:1013:1021:1047:3011 +454:4294967295:1000:1006:1013:1021:1047:3011 +455:4294967295:1000:1006:1013:1021:1047:3011 +456:4294967295:1000:1006:1013:1021:1047:3011 +457:4294967295:1000:1006:1013:1021:1047:3011 +458:4294967295:1000:1006:1013:1021:1047:3011 +459:4294967295:1000:1006:1013:1021:1047:3011 +460:4294967295:1000:1006:1013:1021:1047:3011 +461:4294967295:1000:1006:1013:1021:1047:3011 +462:4294967295:1000:1006:1013:1021:1047:3011 +463:4294967295:1000:1006:1013:1021:1047:3011 +464:4294967295:1000:1006:1013:1021:1047:3011 +465:4294967295:1000:1006:1013:1021:1047:3011 +466:4294967295:1000:1006:1013:1021:1047:3011 +467:4294967295:1000:1006:1013:1021:1047:3011 +468:4294967295:1000:1006:1013:1021:1047:3011 +469:4294967295:1000:1006:1013:1021:1047:3011 +470:4294967295:1000:1006:1013:1021:1047:3011 +471:4294967295:1000:1006:1013:1021:1047:3011 +472:4294967295:1000:1006:1013:1021:1047:3011 +473:4294967295:1000:1006:1013:1021:1047:3011 +474:4294967295:1000:1006:1013:1021:1047:3011 +475:4294967295:1000:1006:1013:1021:1047:3011 +476:4294967295:1000:1006:1013:1021:1047:3011 +477:4294967295:1000:1006:1013:1021:1047:3011 +478:4294967295:1000:1006:1013:1021:1047:3011 +479:4294967295:1000:1006:1013:1021:1047:3011 +480:4294967295:1000:1006:1013:1021:1047:3011 +481:4294967295:1000:1006:1013:1021:1047:3011 +482:4294967295:1000:1006:1013:1021:1047:3011 +483:4294967295:1000:1006:1013:1021:1047:3011 +484:4294967295:1000:1006:1013:1021:1047:3011 +485:4294967295:1000:1006:1013:1021:1047:3011 +486:4294967295:1000:1006:1013:1021:1047:3011 +487:4294967295:1000:1006:1013:1021:1047:3011 +488:4294967295:1000:1006:1013:1021:1047:3011 +489:4294967295:1000:1006:1013:1021:1047:3011 +490:4294967295:1000:1006:1013:1021:1047:3011 +491:4294967295:1000:1006:1013:1021:1047:3011 +492:4294967295:1000:1006:1013:1021:1047:3011 +493:4294967295:1000:1006:1013:1021:1047:3011 +494:4294967295:1000:1006:1013:1021:1047:3011 +495:4294967295:1000:1006:1013:1021:1047:3011 +496:4294967295:1000:1006:1013:1021:1047:3011 +497:4294967295:1000:1006:1013:1021:1047:3011 +498:4294967295:1000:1006:1013:1021:1047:3011 +499:4294967295:1000:1006:1013:1021:1047:3011 +500:4294967295:1000:1006:1013:1021:1047:3011 +501:4294967295:1000:1006:1013:1021:1047:3011 +502:4294967295:1000:1006:1013:1021:1047:3011 +503:4294967295:1000:1006:1013:1021:1047:3011 +504:4294967295:1000:1006:1013:1021:1047:3011 +505:4294967295:1000:1006:1013:1021:1047:3011 +506:4294967295:1000:1006:1013:1021:1047:3011 +507:4294967295:1000:1006:1013:1021:1047:3011 +508:4294967295:1000:1006:1013:1021:1047:3011 +509:4294967295:1000:1006:1013:1021:1047:3011 +510:4294967295:1000:1006:1013:1021:1047:3011 +511:4294967295:1000:1006:1013:1021:1047:3011 +/* Allow RCS service to aquire net_raw permission */ +18:4294967295:1001:3004 +/* Allow QMID service to aquire net_raw permission */ +3:4294967295:1001:3004 +2:4294967295:1001:3004 +42:4294967295:1001:3004 +18:4294967295:1001:3004 +9:4294967295:1001:3004 +1:4294967295:1001:3004:1000 +4:4294967295:1001:3004 +7:4294967295:1001:3004 +8:4294967295:1001:3004:1000 +68:4294967295:1001:3004 +/* DPM */ +47:4294967295:1001:3004 +/* Allow communication to some QMI services with radio privilages */ +/* Format is :: */ +/* PBM */ +12:4294967295:1001 +/* WMS */ +5:4294967295:1001 +/* IMS VT */ +32:4294967295:1001 +/* IMSP */ +31:4294967295:1001 +/* PDC */ +36:4294967295:1001 +/* SAR */ +17:4294967295:1001 +/* RFRPE */ +41:4294967295:1001 +/*UIM*/ +11:4294967295:1001 +/*CAT*/ +10:4294967295:1001 +/*IMSA*/ +33:4294967295:1001 +/* CSVT */ +29:4294967295:1001 +/*LTE*/ +70:4294967295:1001 +/* Allow Data dpmd to access QMI DFS */ +48:4294967295:1000:3004 +/* hTC Extended QMI service from modem team. more protocol related */ +229:4294967295:1001 +/* hTC Extended QMI service from modem BSP team */ +230:4294967295:1001 +/* DIAG */ +4097:4294967295:2002:2950:3009 +/* :: */ +69:4294967295:1000 +/* :: */ +57:4294967295:1000 \ No newline at end of file diff --git a/seccomp_policy/mediacodec.policy b/seccomp_policy/mediacodec.policy new file mode 100644 index 00000000..07b7bf70 --- /dev/null +++ b/seccomp_policy/mediacodec.policy @@ -0,0 +1,9 @@ +# device specific syscalls +pselect6: 1 +eventfd2: 1 +sendto: 1 +recvfrom: 1 +_llseek: 1 +sysinfo: 1 +getcwd: 1 +getdents64: 1 diff --git a/sensors/hals.conf b/sensors/hals.conf new file mode 100644 index 00000000..ace979a9 --- /dev/null +++ b/sensors/hals.conf @@ -0,0 +1 @@ +sensors.msm8998.so diff --git a/sepolicy/private/dataservice_app.te b/sepolicy/private/dataservice_app.te new file mode 100644 index 00000000..cb3d0693 --- /dev/null +++ b/sepolicy/private/dataservice_app.te @@ -0,0 +1,21 @@ +typeattribute dataservice_app coredomain; +app_domain(dataservice_app) +net_domain(dataservice_app) + +add_service(dataservice_app, cne_service) +add_service(dataservice_app, uce_service) +allow dataservice_app { + app_api_service + system_api_service + audioserver_service + radio_service +}:service_manager find; + +allow dataservice_app hal_imsrcsd_hwservice:hwservice_manager find; +allow dataservice_app hal_cne_hwservice:hwservice_manager find; + +allow dataservice_app system_app_data_file:dir create_dir_perms; +allow dataservice_app system_app_data_file:{ file lnk_file } create_file_perms; + +hwbinder_use(dataservice_app) + diff --git a/sepolicy/private/device.te b/sepolicy/private/device.te new file mode 100644 index 00000000..ae7cadd7 --- /dev/null +++ b/sepolicy/private/device.te @@ -0,0 +1 @@ +type ramoops_device, dev_type; diff --git a/sepolicy/private/file_contexts b/sepolicy/private/file_contexts new file mode 100644 index 00000000..88cdca05 --- /dev/null +++ b/sepolicy/private/file_contexts @@ -0,0 +1,8 @@ +/system/bin/folio_daemon u:object_r:folio_daemon_exec:s0 +/data/misc/elabel(/.*)? u:object_r:elabel_data_file:s0 +/system/bin/init\.elabel\.sh u:object_r:init_elabel_exec:s0 +/system/bin/ramoops u:object_r:ramoops_exec:s0 +/system/bin/init\.ramoops\.sh u:object_r:ramoops_exec:s0 +/dev/access-metadata u:object_r:ramoops_device:s0 +/dev/access-ramoops u:object_r:ramoops_device:s0 +/data/misc_ce/[0-9]+/ramoops(/.*)? u:object_r:ramoops_data_file:s0 diff --git a/sepolicy/private/folio_daemon.te b/sepolicy/private/folio_daemon.te new file mode 100644 index 00000000..0c4d2d3e --- /dev/null +++ b/sepolicy/private/folio_daemon.te @@ -0,0 +1,15 @@ +type folio_daemon, domain, coredomain; +type folio_daemon_exec, exec_type, file_type; + +init_daemon_domain(folio_daemon) + +allow folio_daemon binder_device:chr_file rw_file_perms; +allow folio_daemon uhid_device:chr_file rw_file_perms; + +allow folio_daemon system_server:unix_stream_socket rw_socket_perms_no_ioctl; + +binder_use(folio_daemon) +binder_call(folio_daemon, system_server) + +allow folio_daemon sensorservice_service:service_manager find; +allow folio_daemon permission_service:service_manager find; diff --git a/sepolicy/private/genfs_contexts b/sepolicy/private/genfs_contexts new file mode 100644 index 00000000..9c5764a5 --- /dev/null +++ b/sepolicy/private/genfs_contexts @@ -0,0 +1,4 @@ +genfscon sysfs /devices/virtual/ramoops/pstore/aes_key u:object_r:sysfs_pstore:s0 +genfscon sysfs /devices/virtual/ramoops/pstore/aes_key_iv u:object_r:sysfs_pstore:s0 +genfscon sysfs /devices/virtual/ramoops/pstore/aes_key_tag u:object_r:sysfs_pstore:s0 +genfscon sysfs /devices/virtual/ramoops/pstore/use_alt u:object_r:sysfs_pstore:s0 diff --git a/sepolicy/private/init_elabel.te b/sepolicy/private/init_elabel.te new file mode 100644 index 00000000..4934d241 --- /dev/null +++ b/sepolicy/private/init_elabel.te @@ -0,0 +1,12 @@ +# /system/bin/init.elabel.sh +# +# write data from /persist/elabel to /data/misc/elabel for use by +# settings app +# +init_daemon_domain(init_elabel) + +allow init_elabel shell_exec:file rx_file_perms; +allow init_elabel toolbox_exec:file rx_file_perms; + +allow init_elabel elabel_data_file:dir rw_dir_perms; +allow init_elabel elabel_data_file:file create_file_perms; diff --git a/sepolicy/private/priv_app.te b/sepolicy/private/priv_app.te new file mode 100644 index 00000000..43f9fd43 --- /dev/null +++ b/sepolicy/private/priv_app.te @@ -0,0 +1,3 @@ +dontaudit priv_app device:dir read; +dontaudit priv_app proc_interrupts:file read; +dontaudit priv_app proc_modules:file read; diff --git a/sepolicy/private/property.te b/sepolicy/private/property.te new file mode 100644 index 00000000..cc8bd9c5 --- /dev/null +++ b/sepolicy/private/property.te @@ -0,0 +1 @@ +type ramoops_prop, property_type; diff --git a/sepolicy/private/property_contexts b/sepolicy/private/property_contexts new file mode 100644 index 00000000..8453a6c0 --- /dev/null +++ b/sepolicy/private/property_contexts @@ -0,0 +1 @@ +sys.ramoops. u:object_r:ramoops_prop:s0 diff --git a/sepolicy/private/radio.te b/sepolicy/private/radio.te new file mode 100644 index 00000000..9e505223 --- /dev/null +++ b/sepolicy/private/radio.te @@ -0,0 +1 @@ +allow radio uce_service:service_manager find; diff --git a/sepolicy/private/ramoops.te b/sepolicy/private/ramoops.te new file mode 100644 index 00000000..57161d95 --- /dev/null +++ b/sepolicy/private/ramoops.te @@ -0,0 +1,20 @@ +type ramoops, domain, coredomain; +type ramoops_data_file, file_type, data_file_type; +type ramoops_exec, exec_type, file_type; + +init_daemon_domain(ramoops); + +# kmod=crypto-gcm(aes) +dontaudit ramoops kernel:system module_request; + +allow ramoops ramoops_exec:file rx_file_perms; +allow ramoops shell_exec:file rx_file_perms; +allow ramoops toolbox_exec:file rx_file_perms; + +# Set the sys.ramoops.decrypted property +set_prop(ramoops, ramoops_prop); + +allow ramoops sysfs_pstore:file rw_file_perms; +allow ramoops ramoops_device:chr_file rw_file_perms; +allow ramoops ramoops_data_file:file create_file_perms; +allow ramoops ramoops_data_file:dir rw_dir_perms; diff --git a/sepolicy/private/service.te b/sepolicy/private/service.te new file mode 100644 index 00000000..d6581237 --- /dev/null +++ b/sepolicy/private/service.te @@ -0,0 +1,2 @@ +type cne_service, service_manager_type; +type uce_service, service_manager_type; diff --git a/sepolicy/private/service_contexts b/sepolicy/private/service_contexts new file mode 100644 index 00000000..20fa4e6e --- /dev/null +++ b/sepolicy/private/service_contexts @@ -0,0 +1,4 @@ +qti.ims.ext u:object_r:radio_service:s0 +cneservice u:object_r:cne_service:s0 +uce u:object_r:uce_service:s0 +rcs u:object_r:radio_service:s0 diff --git a/sepolicy/private/system_server.te b/sepolicy/private/system_server.te new file mode 100644 index 00000000..389fee02 --- /dev/null +++ b/sepolicy/private/system_server.te @@ -0,0 +1 @@ +binder_call(system_server, folio_daemon) diff --git a/sepolicy/private/untrusted_app_all.te b/sepolicy/private/untrusted_app_all.te new file mode 100644 index 00000000..99bb3001 --- /dev/null +++ b/sepolicy/private/untrusted_app_all.te @@ -0,0 +1,2 @@ +# suppress spurious denials +dontaudit untrusted_app_all sysfs_zram:dir search; diff --git a/sepolicy/public/dataservice_app.te b/sepolicy/public/dataservice_app.te new file mode 100644 index 00000000..8c8d82fa --- /dev/null +++ b/sepolicy/public/dataservice_app.te @@ -0,0 +1 @@ +type dataservice_app, domain; \ No newline at end of file diff --git a/sepolicy/public/file.te b/sepolicy/public/file.te new file mode 100644 index 00000000..ad98df70 --- /dev/null +++ b/sepolicy/public/file.te @@ -0,0 +1,2 @@ +type elabel_data_file, file_type, data_file_type; +type sysfs_pstore, sysfs_type, fs_type; diff --git a/sepolicy/public/hwservice.te b/sepolicy/public/hwservice.te new file mode 100644 index 00000000..73653011 --- /dev/null +++ b/sepolicy/public/hwservice.te @@ -0,0 +1,2 @@ +type hal_cne_hwservice, hwservice_manager_type; +type hal_imsrcsd_hwservice, hwservice_manager_type; diff --git a/sepolicy/public/init_elabel.te b/sepolicy/public/init_elabel.te new file mode 100644 index 00000000..c6985f09 --- /dev/null +++ b/sepolicy/public/init_elabel.te @@ -0,0 +1,7 @@ +# /system/bin/init.elabel.sh +# +# write data from /persist/elabel to /data/misc/elabel for use by +# settings app +# +type init_elabel, domain, coredomain; +type init_elabel_exec, exec_type, file_type; diff --git a/sepolicy/vendor/adsprpcd.te b/sepolicy/vendor/adsprpcd.te new file mode 100644 index 00000000..e76179da --- /dev/null +++ b/sepolicy/vendor/adsprpcd.te @@ -0,0 +1,9 @@ +type adsprpcd, domain; +type adsprpcd_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(adsprpcd) + +allow adsprpcd ion_device:chr_file r_file_perms; +allow adsprpcd qdsp_device:chr_file r_file_perms; + +allow adsprpcd system_file:dir r_dir_perms; diff --git a/sepolicy/vendor/app.te b/sepolicy/vendor/app.te new file mode 100644 index 00000000..036cccd7 --- /dev/null +++ b/sepolicy/vendor/app.te @@ -0,0 +1,2 @@ +# For the camera app +get_prop(appdomain, camera_prop) diff --git a/sepolicy/vendor/atfwd.te b/sepolicy/vendor/atfwd.te new file mode 100644 index 00000000..ad96a120 --- /dev/null +++ b/sepolicy/vendor/atfwd.te @@ -0,0 +1,16 @@ +type atfwd, domain; +type atfwd_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(atfwd) + +hwbinder_use(atfwd) +get_prop(atfwd, hwservicemanager_prop) +allow atfwd vnd_atcmdfwd_hwservice:hwservice_manager find; +binder_call(atfwd, qtelephony); + +allow atfwd self:socket create_socket_perms; +allowxperm atfwd self:socket ioctl msm_sock_ipc_ioctls; + +r_dir_file(atfwd, sysfs_type) + +set_prop(atfwd, radio_prop) diff --git a/sepolicy/vendor/audioserver.te b/sepolicy/vendor/audioserver.te new file mode 100644 index 00000000..02c801ca --- /dev/null +++ b/sepolicy/vendor/audioserver.te @@ -0,0 +1,6 @@ +binder_call(audioserver, bootanim) + +allow audioserver perfd_socket:sock_file write; + +allow audioserver sysfs_soc:file r_file_perms; +allow audioserver sysfs_soc:dir search; diff --git a/sepolicy/vendor/bluetooth.te b/sepolicy/vendor/bluetooth.te new file mode 100644 index 00000000..5a8371dd --- /dev/null +++ b/sepolicy/vendor/bluetooth.te @@ -0,0 +1,4 @@ +set_prop(bluetooth, wc_prop) + +# Allow access to net_admin ioctls +allowxperm bluetooth self:udp_socket ioctl priv_sock_ioctls; diff --git a/sepolicy/vendor/bootanim.te b/sepolicy/vendor/bootanim.te new file mode 100644 index 00000000..838b4fa9 --- /dev/null +++ b/sepolicy/vendor/bootanim.te @@ -0,0 +1,7 @@ +allow bootanim hwservicemanager:binder call; + +# TODO(b/62954877). On Android Wear, bootanim reads the time +# during boot to display. It currently gets that time from a file +# in /data/system. This should be moved. In the meantime, suppress +# this denial on wahoo since this functionality is not used. +dontaudit bootanim system_data_file:dir read; diff --git a/sepolicy/vendor/cameraserver.te b/sepolicy/vendor/cameraserver.te new file mode 100644 index 00000000..d29d473d --- /dev/null +++ b/sepolicy/vendor/cameraserver.te @@ -0,0 +1,11 @@ +allow cameraserver gpu_device:chr_file rw_file_perms; + +set_prop(cameraserver, camera_prop) + +allow cameraserver sysfs_camera:file r_file_perms; +allow cameraserver sysfs_camera:dir search; + +allow cameraserver system_server:unix_stream_socket { read write }; + +# TODO (b/37688918) Verify that this is actually needed and not a violation of treble +binder_call(cameraserver, mediacodec) diff --git a/sepolicy/vendor/certs/app.x509.pem b/sepolicy/vendor/certs/app.x509.pem new file mode 100644 index 00000000..8e3e6273 --- /dev/null +++ b/sepolicy/vendor/certs/app.x509.pem @@ -0,0 +1,27 @@ +-----BEGIN CERTIFICATE----- +MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYD +VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4g +VmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UE +AxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe +Fw0wODA0MTUyMzM2NTZaFw0zNTA5MDEyMzM2NTZaMIGUMQswCQYDVQQGEwJVUzET +MBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4G +A1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9p +ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZI +hvcNAQEBBQADggENADCCAQgCggEBANbOLggKv+IxTdGNs8/TGFy0PTP6DHThvbbR +24kT9ixcOd9W+EaBPWW+wPPKQmsHxajtWjmQwWfna8mZuSeJS48LIgAZlKkpFeVy +xW0qMBujb8X8ETrWy550NaFtI6t9+u7hZeTfHwqNvacKhp1RbE6dBRGWynwMVX8X +W8N1+UjFaq6GCJukT4qmpN2afb8sCjUigq0GuMwYXrFVee74bQgLHWGJwPmvmLHC +69EH6kWr22ijx4OKXlSIx2xT1AsSHee70w5iDBiK4aph27yH3TxkXy9V89TDdexA +cKk/cVHYNnDBapcavl7y0RiQ4biu8ymM8Ga/nmzhRKya6G0cGw8CAQOjgfwwgfkw +HQYDVR0OBBYEFI0cxb6VTEM8YYY6FbBMvAPyT+CyMIHJBgNVHSMEgcEwgb6AFI0c +xb6VTEM8YYY6FbBMvAPyT+CyoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UE +CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMH +QW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAG +CSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJANWFuGx90071MAwGA1Ud +EwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADggEBABnTDPEF+3iSP0wNfdIjIz1AlnrP +zgAIHVvXxunW7SBrDhEglQZBbKJEk5kT0mtKoOD1JMrSu1xuTKEBahWRbqHsXcla +XjoBADb0kkjVEJu/Lh5hgYZnOjvlba8Ld7HCKePCVePoTJBdI4fvugnL8TsgK05a +IskyY0hKI9L8KfqfGTl1lzOv2KoWD0KWwtAWPoGChZxmQ+nBli+gwYMzM1vAkP+a +ayLe0a1EQimlOalO762r0GXO0ks+UeXde2Z4e+8S/pf7pITEI/tP+MxJTALw9QUW +Ev9lKTk+jkbqxbsh8nfBUapfKqYn0eidpwq2AzVp3juYl7//fKnaPhJD9gs= +-----END CERTIFICATE----- diff --git a/sepolicy/vendor/certs/arcore.x509.pem b/sepolicy/vendor/certs/arcore.x509.pem new file mode 100644 index 00000000..df83d5e9 --- /dev/null +++ b/sepolicy/vendor/certs/arcore.x509.pem @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- +MIIDvzCCAqegAwIBAgIJAMl7uSdzNfUbMA0GCSqGSIb3DQEBCwUAMHYxCzAJBgNV +BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBW +aWV3MRQwEgYDVQQKDAtHb29nbGUgSW5jLjEQMA4GA1UECwwHQW5kcm9pZDESMBAG +A1UEAwwJdnJfYXJjb3JlMB4XDTE3MDgwNDE2NTQ1OFoXDTQ0MTIyMDE2NTQ1OFow +djELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1v +dW50YWluIFZpZXcxFDASBgNVBAoMC0dvb2dsZSBJbmMuMRAwDgYDVQQLDAdBbmRy +b2lkMRIwEAYDVQQDDAl2cl9hcmNvcmUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw +ggEKAoIBAQC95hqS8Gj3DVcufC0jbwtlB7wyY2eBf1s3Ftj3ZpUCbD+ra1MZIMU8 +Y/sV3xzuyGbbx3r0W/ZqK1c8xO0xDR/03QJ2XKpaEHzRHZnWSyLSYsmq5Qe4XEuE +s7Q6v7OorTxbfBTLpWm83Gq2z0a2DDN6y9FMeIY7UxSw0ty1hZDDGRKbqsEyfhYq +/CDOSsBTdmYzMrNY57ANxm2Ap7F7xZAMrF8Fs6VRi/jHhaL8fgHC3sT5Ql3vhy+Z +vOihZi7Al8mcV0jyzIzV5TtafSBFu5fMxb5dbMKG4EfgsIh7aobFmRhF1gi1jsJT +NL1bwsPzl+TGZDRR5vSONY5aMUiBrbx1AgMBAAGjUDBOMB0GA1UdDgQWBBST4+Xw +yTxGQMN8QvNf7f2Ew/5euTAfBgNVHSMEGDAWgBST4+XwyTxGQMN8QvNf7f2Ew/5e +uTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBBcjzoaU9GDOYpDQI2 +mD1/C5kdD9Y8UXP+jKUGPvBgFXBzdaNxyclClI30EiabwMOYQW06Ckn+QvRmESAt +WJqt9PxsRRNKWmJ+A/irGAjJyQsiVVzfryeUg44Q+yRErL8wAV/kfHjVF44ZiUoq +FCpErxjSNNLjtBGbaZid+gsBARnrUWrol6Zcuj1DWKUoCZHW6gTu86/GfgTJKHwV +ABe+D89U4pI8RoykmWOTIcpWZZhrDFjJrIXnOqG/T9O3DK+sDigBPv1UhKJI6ucd +dCDLQK3lmP+vvj/sXnxUU7zqrUSj6dyKJwCz4i8rXx9XijsX13J+JMtk23iJFeOo +XjFY +-----END CERTIFICATE----- diff --git a/sepolicy/vendor/certs/arcore_release.x509.pem b/sepolicy/vendor/certs/arcore_release.x509.pem new file mode 100644 index 00000000..de39c3d7 --- /dev/null +++ b/sepolicy/vendor/certs/arcore_release.x509.pem @@ -0,0 +1,24 @@ +-----BEGIN CERTIFICATE----- +MIIDxzCCAq+gAwIBAgIVANwoa0O06hIDmVigCmZV64RyDkbJMA0GCSqGSIb3DQEB +CwUAMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQH +Ew1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMH +QW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0xNzA4MDQxNjUzMzdaFw00NzA4 +MDQxNjUzMzdaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYw +FAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4G +A1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASIwDQYJKoZIhvcNAQEB +BQADggEPADCCAQoCggEBAImYZG9H/DM9sJZEwwMQTtGD6QTjURUqpmpgO3f2M4nU +XW/P+uPJT63x8oA44mXWl/6jRzJ/kIGn8LkHTVsUjbW/NXxhGnf4f4RKFQaIGL3N +WyHRh+k/olUWdhcO7c4EoVDDXsCnke71B/qbQGVzw29vIHdkhC5Wd+NaKBpCJlnp +HibrT+z7BTtck20JdsN/h1ettXo3lT2lhE6jUGlYVNNDphrTQbY6HEJdIoVa9+v+ +4Bjhc2zumFNr5bmUfyiOKib5nrn5G13pP+zFEwGdLpDxKzhhDR8C6qgd7KTOkcGc +vONtbDAlziQys9F4YWvq+vQ3wIRRvEaca8b0UXpxSlsCAwEAAaNQME4wDAYDVR0T +BAUwAwEB/zAdBgNVHQ4EFgQUGahkwPJhjGfIA6I9qQm8cFIfJpswHwYDVR0jBBgw +FoAUGahkwPJhjGfIA6I9qQm8cFIfJpswDQYJKoZIhvcNAQELBQADggEBAFQD/Fb9 +78RAN2oDN4FQArlqFb/8L+Qt5sWPUvrk2AZS43BEVbiFQJ7vgf+7TETboQS2uOJM +ni4OegQzjuc7qltxv7RIj44EvvPQ6vfUOqQrA7J4wzzB8N04AlcWJLqhYdhR+rN9 +tLySuQlLaIXf9itADs2B8GnVahvh20bYGYxQyWKM2244aG72QP04Z3X1A3b5V+JO +pF7RlClo8gyC8Ylgf9si8Rz9/Qdgp3pgzrNBbPs/SPE/n4Pzg0oBABdQp8eLwf2B +8LU6fEHcup9aARglnQg8Mrueu4TWRdb2ucMZI9ircOfwollA7Mn0lFFEQZ+G6MQh +07mXdPS489CSYuc= +-----END CERTIFICATE----- + diff --git a/sepolicy/vendor/certs/arcore_userdev.x509.pem b/sepolicy/vendor/certs/arcore_userdev.x509.pem new file mode 100644 index 00000000..8128ed29 --- /dev/null +++ b/sepolicy/vendor/certs/arcore_userdev.x509.pem @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- +MIIDmTCCAoGgAwIBAgIEXT5J7jANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJV +UzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEU +MBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxGTAXBgNVBAMM +EGFyY29yZV91c2VyYnVpbGQwHhcNMTcwODA4MjIyMzUzWhcNNDQxMjI0MjIyMzUz +WjB9MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMN +TW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0Fu +ZHJvaWQxGTAXBgNVBAMMEGFyY29yZV91c2VyYnVpbGQwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQDI+9aEC0Zg3Bjid1Pa/PWmC1tmyKx57QJIN/8kPq9b +p3qH1fOVkCsNQq7lzmd4jT4m3weZPtwNCYWFQDnTzeywm6/1+kFg52ilPkKQiLc/ +Ew3YcJ5aSfACECP7GMwr3WpL/jsuVR11X2I98tvUJ0aOjwS1u25Z8AMscpZNOvE6 +MRcfmE/mcFKMqwFo5hGiAwirQznAykOcHZIwANAGiQMQkiidSvTMq/fDF6iP9giH +xGvJqaLs55aNSTweMGLWGPjiNERxhA9bBo3vwMyMR6zM6PSPnYHhy/Xm7NwGVLBU +gkHomhpQpGioaAnQes6mTvdR8SA+MpYQDNEoXbHx2eOpAgMBAAGjITAfMB0GA1Ud +DgQWBBSdLVDMs0DfeLCiHxL07bCyNub7wzANBgkqhkiG9w0BAQUFAAOCAQEAggrm +iZBZ8hpbN4IUaSy6HEiLuiQZoLXE8cegAGJGXg4Y95dtk+8tUQu3fSXY+RNbc0JZ +FaYJN2deD3zRFC7nLjIMiHdo6+JE7W9s4omrLvm7rEs7tXszP2/JR3dvS+5III62 +9CrPf4DdAHYffeZJWXsGUmP+wBKb4TsVSO+8pcqM69178A9IvQ3EnLYRCZ0YDnwz +IBDSBANEkAqTxDUMSi909ziusiAmHINcKelxAB8DhE6PuU0tcAfpqFOeZdh0T7hF +fEwhLK6lklnP6DyEPgJiBYHsIP4jycc26Pa5OKDSv7kho/MvWLhCzDeTyOIg7LVu +MgY5FIrpuaqIowB/4A== +-----END CERTIFICATE----- + diff --git a/sepolicy/vendor/certs/easel.x509.pem b/sepolicy/vendor/certs/easel.x509.pem new file mode 100644 index 00000000..695ecf3b --- /dev/null +++ b/sepolicy/vendor/certs/easel.x509.pem @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- +MIID1zCCAr+gAwIBAgIJAKOIETaYwmxkMA0GCSqGSIb3DQEBCwUAMIGBMQswCQYD +VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4g +VmlldzEUMBIGA1UECgwLR29vZ2xlIEluYy4xEDAOBgNVBAsMB0FuZHJvaWQxHTAb +BgNVBAMMFGVhc2Vsc2VydmljZS1hbmRyb2lkMB4XDTE3MDYwMTE4MjUxM1oXDTQ0 +MTAxNzE4MjUxM1owgYExCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlh +MRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKDAtHb29nbGUgSW5jLjEQ +MA4GA1UECwwHQW5kcm9pZDEdMBsGA1UEAwwUZWFzZWxzZXJ2aWNlLWFuZHJvaWQw +ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDdqipNwS7MFSdJV0Y51Tc1 +UU55YkVlwKBjSmYfKpmURR/OqqkP4AswI7byxbapLSZiJAS6TdJmL0QC9ycMOfQL +7RFSKdiY72Ze0abYxpaimj0iVprHVTmaakVg/0o7Dx4hOEqWE6U1TUCK3tAWzyJq +gfH8sJQbFygGpSrEG+XvgN4VAzUEzC6WvV4gAg+5QWYB/Jqh3PJM0iI7WHsjp7oY +j1w2E/R9YHjEOlXa8vB8Mbh1zAghtzWoMry73Xyo8h3Ji3jSGqM+YP+JGCKMEHBm +TE7ywZdi1btKfGEB6WAoZ9IxnX6ezlFmCt3H+LtHS1iiaZf+hl8vnWkX5oddkpUj +AgMBAAGjUDBOMB0GA1UdDgQWBBQ6dUV+uzBrL91ibZm6y4hU49lXXDAfBgNVHSME +GDAWgBQ6dUV+uzBrL91ibZm6y4hU49lXXDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3 +DQEBCwUAA4IBAQBjGGh2oj/c8L9oCsImdSdlDtxMsUT26LKr3UaqhY4xsYp32pcF +ICSjkufog6l7+oOfYISV2r7pN6e9nHoxky9lns9a7jP6Mrh+oL9kTTcWKMo1F88I +jppWvo0hc8WuGef1Sh3DpYi4jSmdUa8HESLeB9LskCxBAS5iwE4x6VAOxfVGOfWw +o3LQ1Y8QL256NPkgQfS+V4hFW+7l2corVYHCRbmXfsHyCk9yesbMsjE1TgdZH9Ys +SyamPaLSZ/Heelqrha0DqdWO1KDQcKC8oISichTJ++EphsdTUsEz6rzCYziPf7A6 +MNmY9YdjnvD5f2IBusSPGC0Bzqn9JdpBnAPL +-----END CERTIFICATE----- diff --git a/sepolicy/vendor/certs/tango.x509.pem b/sepolicy/vendor/certs/tango.x509.pem new file mode 100644 index 00000000..431c1a5c --- /dev/null +++ b/sepolicy/vendor/certs/tango.x509.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDWjCCAkKgAwIBAgIEUlNYsDANBgkqhkiG9w0BAQUFADBvMRAwDgYDVQQGEwdV +bmtub3duMRAwDgYDVQQIEwdVbmtub3duMRAwDgYDVQQHEwdVbmtub3duMREwDwYD +VQQKEwhNb3Rvcm9sYTERMA8GA1UECxMIVHJhaWxtaXgxETAPBgNVBAMTCFRyYWls +bWl4MB4XDTEzMTAwODAwNTgyNFoXDTQxMDIyMzAwNTgyNFowbzEQMA4GA1UEBhMH +VW5rbm93bjEQMA4GA1UECBMHVW5rbm93bjEQMA4GA1UEBxMHVW5rbm93bjERMA8G +A1UEChMITW90b3JvbGExETAPBgNVBAsTCFRyYWlsbWl4MREwDwYDVQQDEwhUcmFp +bG1peDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKQBftL+C3I6JiLF +utgzqfQ5YHNpL8Vjov8RbKTeYbyNSDMB+knby2wuiGgcSWMYokD7uhR2ysPtyv52 +CM9O8MWXelgJ3mdxLh4WzcWzELXW529J08FKpgcM5579/EpSdQQlh1WHlnTAoNdm +xsgWJQMM0CR+/0puIkc1W6GM3cOfS9KNeL/08wfjxRVeFMpyM6DhHMbDxVuNYq57 +mm3xTAMSmsxEveYsZDjNnZgYZDVJoCnWlpT+1KivzYFxp+1pstk7I76WlwqIqCoz +nT3NTVj9h9kvQcd4IgDe+UEygdPa1cAMO4wYdFlGDQKqZjIYvnAy1Qi1JqoeyEr+ +8ggpr2UCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAjpKzuYGq3tICtYZSXbuUmJbj +dIsFRivWxCP25TQ/Csv+tiOijHsU3HNbNXvn8EamkyRi/LoQy7ThoDYhFaQJFaYb +wU4mgdoGxj5rH6URlH/qPmWP6nuM2NQBt0VLwh/MWaXm8u0WY5Tzfd/mRwwc+UMM +9TJhuQxaf42gjnyQO+d/eBves7lL23vDPFCP8okQ3aAzsg5lDFQ6nT+91TXvMpCx +zIurNhce+i2M8tX0IkHmqkEKGBfTdoeUkOVH7Lnac30D5P6daGJrt6PBpWUa8OMC +5VdKhy+DE9cQFE8qG+lDZxg56PqZdWG1pyUotFViUAYkA16Ct5363yLWWYid6g== +-----END CERTIFICATE----- diff --git a/sepolicy/vendor/certs/tango_release.x509.pem b/sepolicy/vendor/certs/tango_release.x509.pem new file mode 100644 index 00000000..07ac5afa --- /dev/null +++ b/sepolicy/vendor/certs/tango_release.x509.pem @@ -0,0 +1,24 @@ +-----BEGIN CERTIFICATE----- +MIIDwTCCAqmgAwIBAgIJAO+A5DYVLfprMA0GCSqGSIb3DQEBBQUAMHcxCzAJBgNV +BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBW +aWV3MRQwEgYDVQQKDAtHb29nbGUgSW5jLjEQMA4GA1UECwwHQW5kcm9pZDETMBEG +A1UEAwwKdGFuZ29fY29yZTAeFw0xNjA0MjYxOTQ2MzdaFw00MzA5MTIxOTQ2Mzda +MHcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1N +b3VudGFpbiBWaWV3MRQwEgYDVQQKDAtHb29nbGUgSW5jLjEQMA4GA1UECwwHQW5k +cm9pZDETMBEGA1UEAwwKdGFuZ29fY29yZTCCASIwDQYJKoZIhvcNAQEBBQADggEP +ADCCAQoCggEBAPJYCbynrmMeP8ZtqzBMoNhMOUGuq9p77j6gM3B90jQ6f2LRVL09 +l3UM+wu+SxTV2T6PXR9LXB0FiJ1waqMQ5yPBZzptQqckUw2ov5uhpx9yE8KqeTGQ +W03xoXoo5S38OztAME8rGMcUtuofEySAWm4Qxm6iq8aZ+NlJAViVztffC9Wx0Kqs +pJ7kgvFSv11ZFPP6EADdihSjH3ApQgU4dlIc4Nevh5fGE7gEY5fxU/NBEDMawhox +pI9UEWSG4QNB4sE9Wwh0AM9GJ5+5S6xG55bsY/SHEbzMv2NsYVjayQiNb2D4nK+r +NdgjTBq508d9m8ybpNjxZRFEs/SagYLV23cCAwEAAaNQME4wHQYDVR0OBBYEFE/G +b+OBEdIfHSDmF/1bl6Q98nXlMB8GA1UdIwQYMBaAFE/Gb+OBEdIfHSDmF/1bl6Q9 +8nXlMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBACpBNrrt/50EwS2A +/8jQG/2W20OawIkSjGAyICQ2TiOwu9nOw2LcZh6GNE1tCjCPCAzXGMC+5UTS09aA +ElfG/9WiUK2PjuqeOe8l57XHaHxvL+oVQUbmjiU8RIR9bgiN/BqVklN1LIrXAMNd +CtcVkXYcnhQE3vlhCxfjwqn+2GMghDTftiQZDL/mxflckAY7hJxVV7dexewNoXQ0 +bVNBuvAnFTl6fG5HAZGRG6y89GLcugzbxVKbRzcuxEVPFDiLQJJcW2e9C/u1cP0+ +91aoz+/Ick0DCSMrEVJPo2w3saPSDUONOS6Tu9JPm2rRwdlM2I/ipmlU3ziwwM6K +0+4WtYc= +-----END CERTIFICATE----- + diff --git a/sepolicy/vendor/certs/tango_userdev.x509.pem b/sepolicy/vendor/certs/tango_userdev.x509.pem new file mode 100644 index 00000000..e86c7209 --- /dev/null +++ b/sepolicy/vendor/certs/tango_userdev.x509.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDjzCCAnegAwIBAgIEaRjVZzANBgkqhkiG9w0BAQsFADB3MQ4wDAYDVQQGEwU5 +NTExNzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxDzANBgNV +BAoTBkdvb2dsZTEWMBQGA1UECxMNUHJvamVjdCBUYW5nbzEXMBUGA1UEAxMOQ2hh +cmxlcyBMIENoZW4wIBcNMTQxMDE1MjIzNjE3WhgPMzAxMzAyMTUyMjM2MTdaMHcx +DjAMBgNVBAYTBTk1MTE3MQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4g +VmlldzEPMA0GA1UEChMGR29vZ2xlMRYwFAYDVQQLEw1Qcm9qZWN0IFRhbmdvMRcw +FQYDVQQDEw5DaGFybGVzIEwgQ2hlbjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAI1d+E9l4ndaDNqzMzJuXf2jslm3/y1oIumQo3dwCa6rF77kxxmI9lM7 +52+tR06dLwnT7uEcO2mQgZ7TWY2tgrXwVYSCzu+WSuc1KgtlLIvcoBodUKSR4vGI +gsvG9eJwVZAVOLOBpF96OJoTOIwLaN1DokkKoBXDkONlYP0hU4/Yo7qxTbM64a+Y +DeAdZ9hirq8p11VZC0o930Ejc47+RZoNt5YMVtpeVBzSrrMLuwZAvD1wrzK9gP9j +xwS/knQSsCb9UZ3OpFogCUeiyFO/lDE9BJHbmDiJch0X52rOm5SKvr4kwduGcENy +oWjmmQR1jjIzxQuO2G8CGJkEmA57vp8CAwEAAaMhMB8wHQYDVR0OBBYEFMvhYFl2 +LMBcFi1vcDPkyz4g0Q4cMA0GCSqGSIb3DQEBCwUAA4IBAQAW9YM5ATbSO5T1sULQ +MhJ2IvqQcPTpP4KUfnHSXLSucyotmsCSVNhuTX+KYHTOmS3srEjv63qojYz8QpeJ +GLlIMbrRPI4MSoZgzMWBX71Ld27rMXbVeKiFa44L3+5XBC15WxoqPJSOxAFsv1Lt +mI5CwqtywwhEUqMR9jBeHn8AhZyOB8gP592BCLs8YVKl0aYQruaNcUuc5PRPiKgH +iCPkaPoyUMCVsfZjOI6IAuu8PGeiXn4QJgcc8YQcEgpSqYea/TqgeLdV+mAER5BK +qg1kX528kWm+K+0PJScVaZk9jZHYo5qMFFWAc9DreNTLWETQEMPi3E6BVY0EI/56 +GsqT +-----END CERTIFICATE----- diff --git a/sepolicy/vendor/chre.te b/sepolicy/vendor/chre.te new file mode 100644 index 00000000..167f8db3 --- /dev/null +++ b/sepolicy/vendor/chre.te @@ -0,0 +1,12 @@ +# This daemon loads the Context Hub Runtime Environment (CHRE) dynamic modules +# onto the SLPI using FastRPC, and exposes a sockets interface for clients on +# the applications processor to interact CHRE +type chre, domain; +type chre_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(chre) + +allow chre ion_device:chr_file { open read }; +allow chre qdsp_device:chr_file { ioctl open read }; + +allow chre system_file:dir read; diff --git a/sepolicy/vendor/cnd.te b/sepolicy/vendor/cnd.te new file mode 100644 index 00000000..ca562c9a --- /dev/null +++ b/sepolicy/vendor/cnd.te @@ -0,0 +1,31 @@ +type cnd, domain; +type cnd_exec, exec_type, vendor_file_type, file_type; +file_type_auto_trans(cnd, socket_device, cnd_socket); + +# cnd is started by init, type transit from init domain to cnd domain +init_daemon_domain(cnd) + +allow cnd self:capability { net_bind_service }; +wakelock_use(cnd) + +allow cnd self:udp_socket create_socket_perms; +allowxperm cnd self:udp_socket ioctl SIOCGIFMTU; + +allow cnd sysfs_timestamp_switch:file r_file_perms; +r_dir_file(cnd, sysfs_msm_subsys) +r_dir_file(cnd, sysfs_diag) +r_dir_file(cnd, sysfs_soc) + +allow cnd proc_meminfo:file r_file_perms; + +set_prop(cnd, cnd_prop) + +allow cnd self:socket create_socket_perms; +allowxperm cnd self:socket ioctl msm_sock_ipc_ioctls; + +# To register cnd to hwbinder +add_hwservice(cnd, hal_cne_hwservice) +hwbinder_use(cnd) +get_prop(cnd, hwservicemanager_prop) +binder_call(cnd, dataservice_app) +binder_call(cnd, ims) diff --git a/sepolicy/vendor/dataservice_app.te b/sepolicy/vendor/dataservice_app.te new file mode 100644 index 00000000..1cb94e3c --- /dev/null +++ b/sepolicy/vendor/dataservice_app.te @@ -0,0 +1,8 @@ +get_prop(dataservice_app, cnd_prop) + +r_dir_file(dataservice_app, sysfs_msm_subsys) + +binder_call(dataservice_app, cnd) + +# imsrcsd to bind with UceShimService.apk +binder_call(dataservice_app, hal_rcsservice) diff --git a/sepolicy/vendor/device.te b/sepolicy/vendor/device.te new file mode 100644 index 00000000..97fc839b --- /dev/null +++ b/sepolicy/vendor/device.te @@ -0,0 +1,27 @@ +type ab_block_device, dev_type; +type at_device, dev_type; +type avtimer_device, dev_type; +type bt_device, dev_type; +type diag_device, dev_type, mlstrustedobject; +type dsp_device, dev_type; +type easel_device, dev_type; +type hbtp_device, dev_type; +type ipa_dev, dev_type; +type latency_device, dev_type; +type modem_block_device, dev_type; +type persist_block_device, dev_type; +type pn81a_device, dev_type; +type qsee_ipc_irq_spss_device, dev_type; +type qdsp_device, dev_type, mlstrustedobject; +type ramdump_device, dev_type; +type rmnet_device, dev_type; +type gpt_block_device, dev_type; +type ramdump_block_device, dev_type; +type seemplog_device, dev_type; +type sg_device, dev_type; +type smd_device, dev_type; +type spcom_device, dev_type; +type ssd_block_device, dev_type; +type ssr_device, dev_type; +type wlan_device, dev_type; +type xbl_block_device, dev_type; diff --git a/sepolicy/vendor/domain.te b/sepolicy/vendor/domain.te new file mode 100644 index 00000000..fdbac32c --- /dev/null +++ b/sepolicy/vendor/domain.te @@ -0,0 +1,11 @@ +userdebug_or_eng(` + allow domain diag_device:chr_file rw_file_perms; +') + +# In order for /sys/kernel/debug/kgsl/proc//mem +# to be created for memory tracking, the domain of +# the tracked process must have permission to search +# in /sys/kernel/debug/kgsl +allow domain debugfs_kgsl:dir search; + +allow domain debugfs_ion:dir search; diff --git a/sepolicy/vendor/dumpstate.te b/sepolicy/vendor/dumpstate.te new file mode 100644 index 00000000..ce328ce8 --- /dev/null +++ b/sepolicy/vendor/dumpstate.te @@ -0,0 +1,13 @@ +userdebug_or_eng(` + allow dumpstate modem_dump_file:dir create_dir_perms; + allow dumpstate modem_dump_file:file create_file_perms; + allow dumpstate proc_modules:file r_file_perms; + allow dumpstate proc_stat:file r_file_perms; + allow dumpstate persist_file:dir r_dir_perms; + allow dumpstate sysfs_leds:dir search; + allow dumpstate system_block_device:blk_file r_file_perms; + + dontaudit dumpstate self:netlink_xfrm_socket create_socket_perms_no_ioctl; + + binder_call(dumpstate, per_mgr) +') diff --git a/sepolicy/vendor/easelservice_app.te b/sepolicy/vendor/easelservice_app.te new file mode 100644 index 00000000..9cf8b784 --- /dev/null +++ b/sepolicy/vendor/easelservice_app.te @@ -0,0 +1,8 @@ +type easelservice_app, domain; + +app_domain(easelservice_app) + +allow easelservice_app app_api_service:service_manager find; +allow easelservice_app surfaceflinger_service:service_manager find; +# Access to mnh_sm driver +allow easelservice_app easel_device:chr_file { read write ioctl open }; diff --git a/sepolicy/vendor/esed.te b/sepolicy/vendor/esed.te new file mode 100644 index 00000000..0443de50 --- /dev/null +++ b/sepolicy/vendor/esed.te @@ -0,0 +1,12 @@ +# android.hardware.weaver HAL implementation +# Clean up naming after via b/38447431 +type esed, domain; +type esed_exec, exec_type, vendor_file_type, file_type; + +hal_server_domain(esed, hal_weaver) + +allow esed pn81a_device:chr_file rw_file_perms; +allow esed ese_vendor_data_file:dir create_dir_perms; +allow esed ese_vendor_data_file:file create_file_perms; + +init_daemon_domain(esed) diff --git a/sepolicy/vendor/file.te b/sepolicy/vendor/file.te new file mode 100644 index 00000000..2e9a984b --- /dev/null +++ b/sepolicy/vendor/file.te @@ -0,0 +1,93 @@ +type sysfs_camera, sysfs_type, fs_type; +type sysfs_clkscale, sysfs_type, fs_type; +type sysfs_console_suspend, sysfs_type, fs_type; +type sysfs_easel, sysfs_type, fs_type; +type sysfs_fingerprint, sysfs_type, fs_type; +type sysfs_graphics, sysfs_type, fs_type; +type sysfs_laser, sysfs_type, fs_type; +type sysfs_mdss_mdp_caps, sysfs_type, fs_type; +type sysfs_msm_subsys, sysfs_type, fs_type; +type sysfs_msm_subsys_restart, sysfs_type, fs_type; +type sysfs_rmtfs, sysfs_type, fs_type; +type sysfs_soc, sysfs_type, fs_type; +type sysfs_scsi_devices_0000, sysfs_type, fs_type; +type sysfs_timestamp_switch, sysfs_type, fs_type; +type sysfs_touch, sysfs_type, fs_type; +type sysfs_usb_c, sysfs_type, fs_type; +type sysfs_usb_device, sysfs_type, fs_type; + +type debugfs_clk, debugfs_type, fs_type; +type debugfs_ion, debugfs_type, fs_type; +type debugfs_ipc, debugfs_type, fs_type; +type debugfs_kgsl, debugfs_type, fs_type; +type debugfs_rpm, debugfs_type, fs_type; +type debugfs_rmt_storage, debugfs_type, fs_type; +type debugfs_usb, debugfs_type, fs_type; +type debugfs_wlan, debugfs_type, fs_type; +type debugfs_mdp, debugfs_type, fs_type; +type debugfs_icnss, debugfs_type, fs_type; + +# /proc +type proc_wifi_dbg, fs_type; + +type qmuxd_socket, file_type; +type netmgrd_socket, file_type; +type thermal_socket, file_type; +type perfd_socket, file_type; + +type ims_socket, file_type; +type ipacm_socket, file_type; +type cnd_socket, file_type; +type chre_socket, file_type; +type hal_bootctl_socket, file_type; + +type firmware_file, fs_type, contextmount_type; + +type location_data_file, file_type, data_file_type; + +type persist_file, file_type; +type persist_data_file, file_type; +type persist_display_file, file_type; +type persist_drm_file, file_type; +type persist_elabel_file, file_type; +type persist_haptics_file, file_type; +type persist_rfs_file, file_type; +type persist_sensors_file, file_type; +type persist_time_file, file_type; + +type netmgr_data_file, file_type, data_file_type; +type ipa_vendor_data_file, file_type, data_file_type; + +type camera_vendor_data_file, file_type, data_file_type; +type display_vendor_data_file, file_type, data_file_type; +type nfc_vendor_data_file, file_type, data_file_type; +type radio_vendor_data_file, file_type, data_file_type, mlstrustedobject; +type cnss_vendor_data_file, file_type, data_file_type, mlstrustedobject; +type ramdump_vendor_data_file, file_type, data_file_type, mlstrustedobject; +type modem_dump_file, file_type, data_file_type; +type ese_vendor_data_file, file_type, data_file_type; +type sensors_vendor_data_file, file_type, data_file_type; + +type vendor_firmware_file, vendor_file_type, file_type; + +type ramdump_data_file, file_type, data_file_type, mlstrustedobject; + +#data sysfs files +type sysfs_data, fs_type, sysfs_type; + +#diag sysfs files +type sysfs_diag, fs_type, sysfs_type; + +type hexagon_halide_file, vendor_file_type, file_type; + +# input files +type idc_file, file_type, vendor_file_type; +type keylayout_file, file_type, vendor_file_type; + +# Battery Stats file +typeattribute sysfs_batteryinfo mlstrustedobject; + +# msm_irqbalance +type proc_irq, fs_type; +type sysfs_irq, fs_type; +type irqbalance_socket, file_type; diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts new file mode 100644 index 00000000..d604beda --- /dev/null +++ b/sepolicy/vendor/file_contexts @@ -0,0 +1,275 @@ +# dev nodes +/dev/btpower u:object_r:bt_device:s0 +/dev/diag u:object_r:diag_device:s0 +/dev/kgsl-3d0 u:object_r:gpu_device:s0 +/dev/rtc0 u:object_r:rtc_device:s0 +/dev/smd.* u:object_r:smd_device:s0 +# TODO: does ttyMSM0 need to be more specific +/dev/ttyMSM0 u:object_r:tty_device:s0 +/dev/ipa u:object_r:ipa_dev:s0 +/dev/wwan_ioctl u:object_r:ipa_dev:s0 +/dev/ipaNatTable u:object_r:ipa_dev:s0 +/dev/cpu_dma_latency u:object_r:latency_device:s0 +/dev/rmnet_ctrl.* u:object_r:rmnet_device:s0 +/dev/at_.* u:object_r:at_device:s0 +/dev/video([0-9])+ u:object_r:video_device:s0 +/dev/media([0-9])+ u:object_r:video_device:s0 +/dev/v4l-subdev.* u:object_r:video_device:s0 +/dev/qseecom u:object_r:tee_device:s0 +/dev/qsee_ipc_irq_spss u:object_r:qsee_ipc_irq_spss_device:s0 +/dev/seemplog u:object_r:seemplog_device:s0 +/dev/spcom u:object_r:spcom_device:s0 +/dev/jpeg[0-9]* u:object_r:video_device:s0 +/dev/adsprpc-smd u:object_r:qdsp_device:s0 +/dev/sdsprpc-smd u:object_r:dsp_device:s0 +/dev/wcd-dsp-glink u:object_r:audio_device:s0 +/dev/wcd_dsp0_control u:object_r:audio_device:s0 +/dev/msm_.* u:object_r:audio_device:s0 +/dev/avtimer u:object_r:avtimer_device:s0 +/dev/subsys_.* u:object_r:ssr_device:s0 +/dev/ramdump_.* u:object_r:ramdump_device:s0 +/dev/hbtp_input u:object_r:hbtp_device:s0 +/dev/hbtp_vm u:object_r:hbtp_device:s0 +/dev/sg[0-9]+ u:object_r:sg_device:s0 +/dev/sensors u:object_r:sensors_device:s0 +/dev/mnh_sm u:object_r:easel_device:s0 +/dev/easelcomm-client u:object_r:easel_device:s0 +/dev/pn81a u:object_r:pn81a_device:s0 + +# dev socket nodes +/dev/socket/chre u:object_r:chre_socket:s0 +/dev/socket/oemlock u:object_r:hal_bootctl_socket:s0 +/dev/socket/qmux_audio(/.*)? u:object_r:qmuxd_socket:s0 +/dev/socket/qmux_bluetooth(/.*)? u:object_r:qmuxd_socket:s0 +/dev/socket/qmux_gps(/.*)? u:object_r:qmuxd_socket:s0 +/dev/socket/qmux_nfc(/.*)? u:object_r:qmuxd_socket:s0 +/dev/socket/qmux_radio(/.*)? u:object_r:qmuxd_socket:s0 +/dev/socket/ims_qmid u:object_r:ims_socket:s0 +/dev/socket/ims_datad u:object_r:ims_socket:s0 +/dev/socket/ipacm_log_file u:object_r:ipacm_socket:s0 +/dev/socket/cnd u:object_r:cnd_socket:s0 +/dev/socket/msm_irqbalance u:object_r:irqbalance_socket:s0 +/dev/socket/thermal-send-client u:object_r:thermal_socket:s0 +/dev/socket/thermal-recv-client u:object_r:thermal_socket:s0 +/dev/socket/thermal-recv-passive-client u:object_r:thermal_socket:s0 +/dev/socket/perfd u:object_r:perfd_socket:s0 +/dev/socket/netmgr(/.*)? u:object_r:netmgrd_socket:s0 +/dev/nq-nci u:object_r:nfc_device:s0 +/dev/ttyHS0 u:object_r:hci_attach_dev:s0 +/dev/wlan u:object_r:wlan_device:s0 + +# dev block nodes +/dev/block/platform/soc/1da4000\.ufshc/by-name/abl_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/aes_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/apdp_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/cmnlib64_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/cmnlib_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/dtbo_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/devcfg_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/hosd_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/hyp_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/keymaster_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/lockbooter_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/laf_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/msadp_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/pmic_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/rpm_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/storsec_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/trusty_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/tz_[ab] u:object_r:ab_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/vbmeta_[ab] u:object_r:ab_block_device:s0 + +/dev/block/platform/soc/1da4000\.ufshc/by-name/boot_[ab] u:object_r:boot_block_device:s0 + +/dev/block/platform/soc/1da4000\.ufshc/by-name/metadata u:object_r:metadata_block_device:s0 + +/dev/block/platform/soc/1da4000\.ufshc/by-name/misc u:object_r:misc_block_device:s0 + +/dev/block/platform/soc/1da4000\.ufshc/by-name/frp u:object_r:frp_block_device:s0 + +/dev/block/platform/soc/1da4000\.ufshc/by-name/fsc u:object_r:modem_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/fsg u:object_r:modem_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/modem_[ab] u:object_r:modem_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/modemst[12] u:object_r:modem_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/persist u:object_r:persist_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/ramdump u:object_r:ramdump_block_device:s0 + +/dev/block/platform/soc/1da4000\.ufshc/by-name/ssd u:object_r:ssd_block_device:s0 + +/dev/block/platform/soc/1da4000\.ufshc/by-name/system_[ab] u:object_r:system_block_device:s0 +/dev/block/platform/soc/1da4000\.ufshc/by-name/vendor_[ab] u:object_r:system_block_device:s0 + +/dev/block/platform/soc/1da4000\.ufshc/by-name/userdata u:object_r:userdata_block_device:s0 + +/dev/block/platform/soc/1da4000\.ufshc/by-name/xbl_[ab] u:object_r:xbl_block_device:s0 + +# Block device holding the GPT, where the A/B attributes are stored. +/dev/block/sda u:object_r:gpt_block_device:s0 + +# Block devices for the drive that holds the xbl_a and xbl_b partitions. +/dev/block/sd[bc]1? u:object_r:xbl_block_device:s0 + +# Block device for hal_bootctl +/dev/block/sde u:object_r:boot_block_device:s0 + +# Block device for ZRAM +/dev/block/zram0 u:object_r:swap_block_device:s0 + +# files in /vendor +/vendor/firmware(/.*)? u:object_r:vendor_firmware_file:s0 +/vendor/bin/hw/android\.hardware\.dumpstate@1\.0-service.wahoo u:object_r:hal_dumpstate_impl_exec:s0 +/vendor/bin/hw/android\.hardware\.vr@1\.0-service.wahoo u:object_r:hal_vr_default_exec:s0 +/vendor/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.1-service.wahoo u:object_r:hal_fingerprint_default_exec:s0 +/vendor/bin/msm_irqbalance u:object_r:irqbalance_exec:s0 +/vendor/bin/perfd u:object_r:perfd_exec:s0 +/vendor/bin/thermal-engine u:object_r:thermal-engine_exec:s0 +/vendor/bin/sensors.qcom u:object_r:sensors_exec:s0 +/vendor/bin/ssr_setup u:object_r:ssr_setup_exec:s0 +/vendor/bin/ssr_diag u:object_r:ssr_diag_exec:s0 +/vendor/bin/pm-service u:object_r:per_mgr_exec:s0 +/vendor/bin/pm-proxy u:object_r:per_proxy_exec:s0 +/vendor/bin/qseecomd u:object_r:tee_exec:s0 +/vendor/bin/subsystem_ramdump u:object_r:subsystem_ramdump_exec:s0 +/vendor/bin/adsprpcd u:object_r:adsprpcd_exec:s0 +/vendor/bin/irsc_util u:object_r:irsc_util_exec:s0 +/vendor/bin/rmt_storage u:object_r:rmt_storage_exec:s0 +/vendor/bin/tftp_server u:object_r:rfs_access_exec:s0 +/vendor/bin/cnss-daemon u:object_r:wcnss_service_exec:s0 +/vendor/bin/cnss_diag u:object_r:wcnss_service_exec:s0 +/vendor/bin/diag_mdlog u:object_r:qlogd_exec:s0 +/vendor/bin/netmgrd u:object_r:netmgrd_exec:s0 +/vendor/bin/port-bridge u:object_r:port-bridge_exec:s0 +/vendor/bin/qti u:object_r:qti_exec:s0 +/vendor/bin/ramdump u:object_r:ramdump_exec:s0 +/vendor/bin/smlog_dump u:object_r:smlog_dump_exec:s0 +/vendor/bin/wcnss_filter u:object_r:wcnss_filter_exec:s0 +/vendor/bin/loc_launcher u:object_r:location_exec:s0 +/vendor/bin/lowi-server u:object_r:location_exec:s0 +/vendor/bin/xtra-daemon u:object_r:location_exec:s0 +/vendor/bin/pd-mapper u:object_r:pd_mapper_exec:s0 +/vendor/bin/imsqmidaemon u:object_r:ims_exec:s0 +/vendor/bin/imsdatadaemon u:object_r:ims_exec:s0 +/vendor/bin/ims_rtp_daemon u:object_r:hal_imsrtp_exec:s0 +/vendor/bin/ipacm u:object_r:hal_tetheroffload_default_exec:s0 +/vendor/bin/ipacm-diag u:object_r:hal_tetheroffload_default_exec:s0 +/vendor/bin/qmuxd u:object_r:qmuxd_exec:s0 +/vendor/bin/cnd u:object_r:cnd_exec:s0 +/vendor/bin/ATFWD-daemon u:object_r:atfwd_exec:s0 +# Remove after b/38447389 +/vendor/bin/esed u:object_r:esed_exec:s0 +# Rename to android.hardware.[XXX] after b/38447431 +/vendor/bin/hw/esed u:object_r:esed_exec:s0 +/vendor/bin/ese_load u:object_r:init_ese_exec:s0 +/vendor/bin/ese-replay u:object_r:esed_exec:s0 +/vendor/bin/ese-ls-provision u:object_r:esed_exec:s0 +/vendor/bin/hw/android\.hardware\.oemlock@1\.0-service u:object_r:hal_oemlock_default_exec:s0 +/vendor/bin/oemlock_provision u:object_r:hal_bootctl_default_exec:s0 +/vendor/bin/oemlock-bridge u:object_r:hal_bootctl_default_exec:s0 +/vendor/bin/hw/android\.hardware\.usb@1\.1-service.wahoo u:object_r:hal_usb_default_exec:s0 +/vendor/bin/hw/android\.hardware\.power@1\.1-service.wahoo u:object_r:hal_power_default_exec:s0 +/vendor/bin/hw/android\.hardware\.thermal@1\.0-service.wahoo u:object_r:hal_thermal_default_exec:s0 +/vendor/bin/chre u:object_r:chre_exec:s0 +/vendor/bin/time_daemon u:object_r:time_daemon_exec:s0 +/vendor/bin/imsrcsd u:object_r:hal_rcsservice_exec:s0 +/vendor/bin/init\.qcom\.devstart\.sh u:object_r:init-qcom-devstart-sh_exec:s0 +/vendor/bin/init\.qcom\.ipastart\.sh u:object_r:init-qcom-ipastart-sh_exec:s0 +/vendor/bin/init\.insmod\.sh u:object_r:init-insmod-sh_exec:s0 +/vendor/etc/init\.insmod\.cfg u:object_r:init-insmod-sh_exec:s0 +/vendor/bin/init\.power\.sh u:object_r:init_power_exec:s0 +/vendor/bin/init\.radio\.sh u:object_r:init_radio_exec:s0 + +/vendor/bin/hw/android\.hardware\.drm@1\.0-service.widevine u:object_r:hal_drm_widevine_exec:s0 +/vendor/bin/hw/android\.hardware\.vibrator@1\.1-service.wahoo u:object_r:hal_vibrator_default_exec:s0 +/vendor/bin/hw/android\.hardware\.keymaster@3\.0-service-qti u:object_r:hal_keymaster_qti_exec:s0 +/vendor/bin/hw/android\.hardware\.gatekeeper@1\.0-service-qti u:object_r:hal_gatekeeper_qti_exec:s0 +/vendor/bin/hw/android\.hardware\.gnss@1\.0-service-qti u:object_r:hal_gnss_qti_exec:s0 + +############################################### +# same-process HAL files and their dependencies +# +/vendor/lib(64)?/hw/gralloc\.msm8998\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/libqdMetaData\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/libqservice\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/libqdutils\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/libadreno_utils\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/libgsl\.so u:object_r:same_process_hal_file:s0 + +/vendor/lib(64)?/hw/vulkan\.msm8998\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/libEGL_adreno\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/libGLESv1_CM_adreno\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/libGLESv2_adreno\.so u:object_r:same_process_hal_file:s0 + +/vendor/lib(64)?/libdrmutils\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/libdrm\.so u:object_r:same_process_hal_file:s0 + +# /vendor/app/TimeService/TimeService.apk +/vendor/lib(64)?/libTimeService\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/libtime_genoff\.so u:object_r:same_process_hal_file:s0 + +# RenderScript dependencies. +# To test: run cts -m CtsRenderscriptTestCases +/vendor/lib(64)?/libRSDriver_adreno\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/libCB\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/libllvm-qgl\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/libbccQTI\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/libllvm-qcom\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/librs_adreno\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/librs_adreno_sha1\.so u:object_r:same_process_hal_file:s0 +/vendor/lib(64)?/libqti-perfd-client\.so u:object_r:same_process_hal_file:s0 + +# TODO(b/36895509): remove the following 2 lines once this bug is resolved +# needed by radio +/vendor/lib(64)?/libimsmedia_jni\.so u:object_r:same_process_hal_file:s0 + +# libGLESv2_adreno depends on this +/vendor/lib(64)?/libllvm-glnext\.so u:object_r:same_process_hal_file:s0 + +# Hexagon DSP host runtime and DSP-side executable needed for Halide operation +/vendor/lib(64)?/libadsprpc\.so u:object_r:same_process_hal_file:s0 +/vendor/lib/dsp/fastrpc_shell_0 u:object_r:hexagon_halide_file:s0 + +# thermal sysfs files +/sys/class/thermal(/.*)? u:object_r:sysfs_thermal:s0 + +# data files +/data/vendor/netmgr(/.*)? u:object_r:netmgr_data_file:s0 +/data/vendor/location(/.*)? u:object_r:location_data_file:s0 +/data/ramdump(/.*)? u:object_r:ramdump_data_file:s0 +/data/nfc(/.*)? u:object_r:nfc_data_file:s0 +/data/vendor/camera(/.*)? u:object_r:camera_vendor_data_file:s0 +/data/vendor/display(/.*)? u:object_r:display_vendor_data_file:s0 +/data/vendor/nfc(/.*)? u:object_r:nfc_vendor_data_file:s0 +/data/vendor/radio(/.*)? u:object_r:radio_vendor_data_file:s0 +/data/vendor/wifi(/.*)? u:object_r:cnss_vendor_data_file:s0 +/data/vendor/ramdump(/.*)? u:object_r:ramdump_vendor_data_file:s0 +/data/vendor/ssrdump(/.*)? u:object_r:ramdump_vendor_data_file:s0 +/data/vendor/modem_dump(/.*)? u:object_r:modem_dump_file:s0 +/data/vendor/ese(/.*)? u:object_r:ese_vendor_data_file:s0 +/data/vendor/ipa(/.*)? u:object_r:ipa_vendor_data_file:s0 +/data/vendor/sensors(/.*)? u:object_r:sensors_vendor_data_file:s0 + +# input files +/vendor/usr/idc(/.*)? u:object_r:idc_file:s0 +/vendor/usr/keylayout(/.*)? u:object_r:keylayout_file:s0 + +# / +/tombstones u:object_r:rootfs:s0 +/dsp u:object_r:rootfs:s0 + +# files in firmware +/firmware(/.*)? u:object_r:firmware_file:s0 + +# /persist +/persist(/.*)? u:object_r:persist_file:s0 +/persist/data(/.*)? u:object_r:persist_data_file:s0 +/persist/display(/.*)? u:object_r:persist_display_file:s0 +/persist/drm(/.*)? u:object_r:persist_drm_file:s0 +/persist/elabel(/.*)? u:object_r:persist_elabel_file:s0 +/persist/haptics(/.*)? u:object_r:persist_haptics_file:s0 +/persist/hlos_rfs(/.*)? u:object_r:persist_rfs_file:s0 +/persist/rfs(/.*)? u:object_r:persist_rfs_file:s0 +/persist/sensors(/.*)? u:object_r:persist_sensors_file:s0 +/persist/time(/.*)? u:object_r:persist_time_file:s0 + +/metadata u:object_r:rootfs:s0 +/metadata/.* u:object_r:vold_data_file:s0 diff --git a/sepolicy/vendor/fsck.te b/sepolicy/vendor/fsck.te new file mode 100644 index 00000000..1500b5f2 --- /dev/null +++ b/sepolicy/vendor/fsck.te @@ -0,0 +1 @@ +allow fsck persist_block_device:blk_file rw_file_perms; diff --git a/sepolicy/vendor/gatekeeperd.te b/sepolicy/vendor/gatekeeperd.te new file mode 100644 index 00000000..647ede2a --- /dev/null +++ b/sepolicy/vendor/gatekeeperd.te @@ -0,0 +1 @@ +set_prop(gatekeeperd, keymaster_prop) diff --git a/sepolicy/vendor/genfs_contexts b/sepolicy/vendor/genfs_contexts new file mode 100644 index 00000000..eac549fe --- /dev/null +++ b/sepolicy/vendor/genfs_contexts @@ -0,0 +1,85 @@ +# TODO: genfs doesn't apply correctly to linked files (b/64270911) +genfscon proc /debug/fwdump u:object_r:proc_wifi_dbg:s0 +genfscon proc /debugdriver/driverdump u:object_r:proc_wifi_dbg:s0 +genfscon proc /ath_pktlog/cld u:object_r:proc_wifi_dbg:s0 +genfscon proc /irq u:object_r:proc_irq:s0 + +genfscon sysfs /devices/soc/soc:qcom,cpubw u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/soc:qcom,mincpubw u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /class/devfreq u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/soc:qcom,memlat-cpu0 u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/soc:qcom,memlat-cpu4 u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /android_touch u:object_r:sysfs_touch:s0 + +genfscon sysfs /devices/soc/1da4000.ufshc/host0/target0:0:0/0:0:0:0 u:object_r:sysfs_scsi_devices_0000:s0 + +genfscon sysfs /class/rfkill/rfkill0/state u:object_r:sysfs_bluetooth_writable:s0 + +genfscon sysfs /class/uio u:object_r:sysfs_uio:s0 +genfscon sysfs /devices/soc/1da4000.ufshc/clkscale_enable u:object_r:sysfs_clkscale:s0 +genfscon sysfs /devices/soc/soc:bt_wcn3990 u:object_r:sysfs_bluetooth_writable:s0 +genfscon sysfs /devices/soc/a1800000.qcom,rmtfs_rtel_sharedmem u:object_r:sysfs_rmtfs:s0 +genfscon sysfs /devices/soc/c17a000.i2c u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/soc:qcom,gpubw u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/800f000.qcom,spmi u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/4080000.qcom,mss u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/17300000.qcom,lpass u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/1d0101c.qcom,spss u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/5c00000.qcom,ssc u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/c900000.qcom,mdss_rotator u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/c900000.qcom,mdss_mdp/caps u:object_r:sysfs_mdss_mdp_caps:s0 +genfscon sysfs /devices/soc/c17a000.i2c/i2c-6/6-005a/leds u:object_r:sysfs_leds:s0 +genfscon sysfs /devices/soc/c1b5000.i2c/i2c-7/7-0030/leds u:object_r:sysfs_leds:s0 +genfscon sysfs /devices/soc/c900000.qcom,mdss_mdp/c900000.qcom,mdss_mdp:qcom,mdss_fb_primary/leds u:object_r:sysfs_leds:s0 +genfscon sysfs /devices/soc/800f000.qcom,spmi/spmi-0/spmi0-03/800f000.qcom,spmi:qcom,pmi8998@3:qcom,leds@d000/leds u:object_r:sysfs_leds:s0 +genfscon sysfs /devices/soc/5000000.qcom,kgsl-3d0 u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/soc:qcom,kgsl-hyp u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/soc:qcom,ipa_fws@1e08000 u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/cce0000.qcom,venus u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/0.qcom,rmtfs_sharedmem u:object_r:sysfs_rmtfs:s0 +genfscon sysfs /devices/soc/soc:fp_fpc1020 u:object_r:sysfs_fingerprint:s0 +genfscon sysfs /devices/virtual/thermal u:object_r:sysfs_thermal:s0 +genfscon sysfs /devices/virtual/wahoo_laser u:object_r:sysfs_laser:s0 +genfscon sysfs /module/msm_thermal u:object_r:sysfs_thermal:s0 +genfscon sysfs /module/printk/parameters/console_suspend u:object_r:sysfs_console_suspend:s0 +genfscon sysfs /module/tcp_cubic/parameters u:object_r:sysfs_net:s0 +genfscon sysfs /module/diagchar/parameters/timestamp_switch u:object_r:sysfs_timestamp_switch:s0 +genfscon sysfs /devices/virtual/graphics/fb0 u:object_r:sysfs_graphics:s0 +genfscon sysfs /devices/virtual/graphics/fb1 u:object_r:sysfs_graphics:s0 +genfscon sysfs /devices/soc/8c0000.qcom,msm-cam u:object_r:sysfs_camera:s0 +genfscon sysfs /devices/soc0 u:object_r:sysfs_soc:s0 +genfscon sysfs /devices/soc/caa0000.qcom,jpeg u:object_r:sysfs_camera:s0 +genfscon sysfs /devices/soc/caa4000.qcom,fd u:object_r:sysfs_camera:s0 +genfscon sysfs /devices/soc/800f000.qcom,spmi/spmi-0/spmi0-02/800f000.qcom,spmi:qcom,pmi8998@2:qpnp,fg/power_supply/bms u:object_r:sysfs_batteryinfo:s0 +genfscon sysfs /devices/soc/800f000.qcom,spmi/spmi-0/spmi0-02/800f000.qcom,spmi:qcom,pmi8998@2:qpnp,fg/power_supply/bms/capacity u:object_r:sysfs_batteryinfo:s0 +genfscon sysfs /devices/soc/800f000.qcom,spmi/spmi-0/spmi0-02/800f000.qcom,spmi:qcom,pmi8998@2:qcom,qpnp-smb2/power_supply/battery/capacity u:object_r:sysfs_batteryinfo:s0 +genfscon sysfs /bus/msm_subsys u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /module/subsystem_restart u:object_r:sysfs_msm_subsys_restart:s0 +genfscon sysfs /kernel/boot_adsp/boot u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /kernel/boot_slpi/boot u:object_r:sysfs_msm_subsys:s0 +genfscon sysfs /devices/soc/c1b7000.i2c/i2c-9/9-0008 u:object_r:sysfs_easel:s0 +genfscon sysfs /class/typec u:object_r:sysfs_usb_c:s0 +genfscon sysfs /class/typec/usbc0 u:object_r:sysfs_usb_c:s0 +genfscon sysfs /devices/soc/a800000.ssusb/a800000.dwc3/xhci-hcd.0.auto/usb1 u:object_r:sysfs_usb_device:s0 +genfscon sysfs /devices/soc/a800000.ssusb/a800000.dwc3/xhci-hcd.0.auto/usb2 u:object_r:sysfs_usb_device:s0 + +genfscon sysfs /devices/soc/800f000.qcom,spmi/spmi-0/spmi0-02/800f000.qcom,spmi:qcom,pmi8998@2:qcom,usb-pdphy@1700/usbpd0/typec u:object_r:sysfs_usb_c:s0 +genfscon sysfs /module/diagchar u:object_r:sysfs_diag:s0 +genfscon sysfs /kernel/irq_helper/irq_blacklist_on u:object_r:sysfs_irq:s0 + +genfscon debugfs /kgsl/proc u:object_r:debugfs_kgsl:s0 +genfscon debugfs /clk/debug_suspend u:object_r:debugfs_clk:s0 +genfscon debugfs /wlan0 u:object_r:debugfs_wlan:s0 + +genfscon debugfs /rpm_stats u:object_r:debugfs_rpm:s0 +genfscon debugfs /rpm_master_stats u:object_r:debugfs_rpm:s0 +genfscon debugfs /ion u:object_r:debugfs_ion:s0 +genfscon debugfs /ipc_logging u:object_r:debugfs_ipc:s0 +genfscon debugfs /system_stats u:object_r:debugfs_rpm:s0 +genfscon debugfs /tcpm/usbpd0 u:object_r:debugfs_usb:s0 +genfscon debugfs /pd_engine/usbpd0 u:object_r:debugfs_usb:s0 +genfscon debugfs /ipc_logging/smblib/log u:object_r:debugfs_usb:s0 +genfscon debugfs /msm_ipc_router u:object_r:debugfs_ipc:s0 +genfscon debugfs /mdp u:object_r:debugfs_mdp:s0 +genfscon debugfs /rmt_storage u:object_r:debugfs_rmt_storage:s0 +genfscon debugfs /icnss u:object_r:debugfs_icnss:s0 diff --git a/sepolicy/vendor/google_camera_app.te b/sepolicy/vendor/google_camera_app.te new file mode 100644 index 00000000..61928827 --- /dev/null +++ b/sepolicy/vendor/google_camera_app.te @@ -0,0 +1,39 @@ +type google_camera_app, domain, coredomain; + +app_domain(google_camera_app) +net_domain(google_camera_app) + +# Access standard system services +allow google_camera_app app_api_service:service_manager find; +allow google_camera_app audioserver_service:service_manager find; +allow google_camera_app cameraserver_service:service_manager find; +allow google_camera_app drmserver_service:service_manager find; +allow google_camera_app mediacodec_service:service_manager find; +allow google_camera_app mediaextractor_service:service_manager find; +allow google_camera_app mediaserver_service:service_manager find; +allow google_camera_app mediametrics_service:service_manager find; +allow google_camera_app nfc_service:service_manager find; +allow google_camera_app surfaceflinger_service:service_manager find; + +allow google_camera_app hidl_token_hwservice:hwservice_manager find; + +# Execute libraries from RenderScript cache +allow google_camera_app app_data_file:file { rx_file_perms }; + +# Read memory info +allow google_camera_app proc_meminfo:file r_file_perms; + +# gdbserver / stack traces +allow google_camera_app self:process ptrace; + +# Access to Hexagon DSP kernel device +allow google_camera_app qdsp_device:chr_file { r_file_perms }; + +# Read and write system app data files passed over Binder. +# Motivating case was /data/data/com.android.settings/cache/*.jpg for +# cropping or taking user photos. +allow google_camera_app system_app_data_file:file { read write getattr }; + +# Allow GoogleCamera access to necessary vendor libraries to execute +# Halide code +allow google_camera_app hexagon_halide_file:file { execute read open getattr }; diff --git a/sepolicy/vendor/hal_audio_default.te b/sepolicy/vendor/hal_audio_default.te new file mode 100644 index 00000000..0b936929 --- /dev/null +++ b/sepolicy/vendor/hal_audio_default.te @@ -0,0 +1,11 @@ +r_dir_file(hal_audio_default, sysfs_soc) + +allow hal_audio_default audio_data_file:dir w_dir_perms; +allow hal_audio_default audio_data_file:file create_file_perms; + +allow hal_audio_default perfd:unix_stream_socket connectto; +allow hal_audio_default perfd_socket:sock_file write; + +userdebug_or_eng(` + allow hal_audio diag_device:chr_file rw_file_perms; +') diff --git a/sepolicy/vendor/hal_bluetooth_default.te b/sepolicy/vendor/hal_bluetooth_default.te new file mode 100644 index 00000000..d345ee72 --- /dev/null +++ b/sepolicy/vendor/hal_bluetooth_default.te @@ -0,0 +1,9 @@ +allow hal_bluetooth_default bt_device:chr_file rw_file_perms; + +allow hal_bluetooth_default wcnss_filter:unix_stream_socket connectto; + +# talk to system_server to set priority +allow hal_bluetooth fwk_scheduler_hwservice:hwservice_manager find; +allow hal_bluetooth system_server:binder call; + +set_prop(hal_bluetooth_default, wc_prop) diff --git a/sepolicy/vendor/hal_bootctl.te b/sepolicy/vendor/hal_bootctl.te new file mode 100644 index 00000000..bdb9e124 --- /dev/null +++ b/sepolicy/vendor/hal_bootctl.te @@ -0,0 +1,31 @@ +# These are the permissions required to use the boot_control HAL implemented +# here: hardware/qcom/bootctrl/boot_control.c + +# Getting and setting GPT attributes for the bootloader iterates over all the +# partition names in the block_device directory /dev/block/.../by-name +allow hal_bootctl block_device:dir r_dir_perms; + +# Edit the attributes stored in the GPT. +allow hal_bootctl gpt_block_device:blk_file rw_file_perms; +allow hal_bootctl ab_block_device:blk_file getattr; +allow hal_bootctl boot_block_device:blk_file rw_file_perms; +allow hal_bootctl modem_block_device:blk_file getattr; +allow hal_bootctl system_block_device:blk_file getattr; +allow hal_bootctl misc_block_device:blk_file rw_file_perms; + +# Access /dev/sgN devices (generic SCSI) to write the +# A/B slot selection for the XBL partition. Allow also to issue a +# UFS_IOCTL_QUERY ioctl. +allow hal_bootctl sg_device:chr_file rw_file_perms; +allow hal_bootctl self:capability sys_admin; +allow hal_bootctl tmpfs:lnk_file r_file_perms; + +# Read the sysfs to lookup what /dev/sgN device +# corresponds to the XBL partitions. +allow hal_bootctl sysfs:dir r_dir_perms; + +# Write to the XBL devices. +allow hal_bootctl xbl_block_device:blk_file rw_file_perms; + +# Expose a socket for brokered boot message access for hal_oemlock. +allow hal_bootctl hal_bootctl_socket:sock_file create_file_perms; diff --git a/sepolicy/vendor/hal_camera.te b/sepolicy/vendor/hal_camera.te new file mode 100644 index 00000000..6e55c979 --- /dev/null +++ b/sepolicy/vendor/hal_camera.te @@ -0,0 +1,52 @@ +# communicate with perfd +allow hal_camera perfd:unix_stream_socket connectto; +allow hal_camera perfd_socket:sock_file write; +allow hal_camera perfd_socket:sock_file w_file_perms; + +allow hal_camera self:capability sys_nice; + +# communicate with camera +#allow hal_camera camera:unix_dgram_socket sendto; +#allow hal_camera camera_data_file:sock_file write; +#allow hal_camera camera_device:chr_file rw_file_perms; + +allow hal_camera gpu_device:chr_file rw_file_perms; + +# access to /dev/input/event{5,10} +allow hal_camera input_device:dir r_dir_perms; +allow hal_camera input_device:chr_file r_file_perms; + +set_prop(hal_camera, camera_prop) + +#allow hal_camera sysfs_enable_ps_sensor:file w_file_perms; +r_dir_file(hal_camera, sysfs_type) +# find libraries +allow hal_camera system_file:dir r_dir_perms; + +allow hal_camera qdisplay_service:service_manager find; + +# talk to system_server + +allow hal_camera system_server:unix_stream_socket { read write }; + +allow hal_camera self:socket { create ioctl read write }; + +# Grant access to Qualcomm MSM Interface (QMI) radio sockets +# qmux_socket(hal_camera) + +# allow hal_camera to call some socket ioctls +allowxperm hal_camera self:socket ioctl { IPC_ROUTER_IOCTL_LOOKUP_SERVER IPC_ROUTER_IOCTL_BIND_CONTROL_PORT }; + +# ignore spurious denial +dontaudit hal_camera graphics_device:dir search; + +userdebug_or_eng(` + allow hal_camera diag_device:chr_file rw_file_perms; +') + +# access easel dev nodes +allow hal_camera easel_device:chr_file { read write ioctl open getattr }; +allow hal_camera sysfs_easel:file rw_file_perms; + +# access hexagon +allow hal_camera qdsp_device:chr_file r_file_perms; diff --git a/sepolicy/vendor/hal_camera_default.te b/sepolicy/vendor/hal_camera_default.te new file mode 100644 index 00000000..27ae92b3 --- /dev/null +++ b/sepolicy/vendor/hal_camera_default.te @@ -0,0 +1,21 @@ +allow hal_camera_default input_device:dir r_dir_perms; + +allow hal_camera_default sysfs_laser:file w_file_perms; +vndbinder_use(hal_camera_default); +allow hal_camera_default qdisplay_service:service_manager { find }; + +allow hal_camera_default hal_graphics_mapper_hwservice:hwservice_manager find; +allow hal_camera_default hal_graphics_allocator_hwservice:hwservice_manager find; + +binder_call(hal_camera_default, hal_graphics_composer) +binder_call(hal_camera_default, system_server) +binder_call(hal_camera_default, hal_graphics_allocator) + +# For interfacing with PowerHAL +hal_client_domain(hal_camera_default, hal_power) + +# For camera team debugging +userdebug_or_eng(` + allow hal_camera_default camera_vendor_data_file:dir create_dir_perms; + allow hal_camera_default camera_vendor_data_file:file create_file_perms; +') diff --git a/sepolicy/vendor/hal_contexthub.te b/sepolicy/vendor/hal_contexthub.te new file mode 100644 index 00000000..10c5d53d --- /dev/null +++ b/sepolicy/vendor/hal_contexthub.te @@ -0,0 +1,3 @@ +# Allow context hub HAL to communicate with daemon via socket +allow hal_contexthub_default chre:unix_stream_socket connectto; +allow hal_contexthub_default chre_socket:sock_file write; diff --git a/sepolicy/vendor/hal_drm_default.te b/sepolicy/vendor/hal_drm_default.te new file mode 100644 index 00000000..3781f126 --- /dev/null +++ b/sepolicy/vendor/hal_drm_default.te @@ -0,0 +1 @@ +allow hal_drm_default vndbinder_device:chr_file rw_file_perms; diff --git a/sepolicy/vendor/hal_drm_widevine.te b/sepolicy/vendor/hal_drm_widevine.te new file mode 100644 index 00000000..faf47b31 --- /dev/null +++ b/sepolicy/vendor/hal_drm_widevine.te @@ -0,0 +1,17 @@ +# policy for /vendor/bin/hw/android.hardware.drm@1.0-service.widevine +type hal_drm_widevine, domain; +type hal_drm_widevine_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(hal_drm_widevine) + +hal_server_domain(hal_drm_widevine, hal_drm) + +vndbinder_use(hal_drm_widevine); + +allow hal_drm mediacodec:fd use; +allow hal_drm { appdomain -isolated_app }:fd use; + +# The Qualcomm DRM-HAL implementation uses a vendor-binder service provided +# by the HWC HAL. +allow hal_drm_widevine qdisplay_service:service_manager { find }; +binder_call(hal_drm_widevine, hal_graphics_composer) diff --git a/sepolicy/vendor/hal_dumpstate_impl.te b/sepolicy/vendor/hal_dumpstate_impl.te new file mode 100644 index 00000000..38461d20 --- /dev/null +++ b/sepolicy/vendor/hal_dumpstate_impl.te @@ -0,0 +1,60 @@ +type hal_dumpstate_impl, domain; +hal_server_domain(hal_dumpstate_impl, hal_dumpstate) + +type hal_dumpstate_impl_exec, exec_type, vendor_file_type, file_type; +init_daemon_domain(hal_dumpstate_impl) + +# Execute dump scripts from vendor partition +allow hal_dumpstate_impl vendor_shell_exec:file rx_file_perms; +allow hal_dumpstate_impl vendor_toolbox_exec:file rx_file_perms; + +userdebug_or_eng(` + # smlog_dump + domain_auto_trans(hal_dumpstate_impl, smlog_dump_exec, smlog_dump) + allow hal_dumpstate_impl modem_dump_file:dir create_dir_perms; + allow hal_dumpstate_impl modem_dump_file:file create_file_perms; + allow hal_dumpstate_impl radio_data_file:dir r_dir_perms; + allow hal_dumpstate_impl radio_vendor_data_file:dir r_dir_perms; + allow hal_dumpstate_impl netmgr_data_file:dir r_dir_perms; + allow hal_dumpstate_impl radio_data_file:file r_file_perms; + allow hal_dumpstate_impl radio_vendor_data_file:file r_file_perms; + allow hal_dumpstate_impl netmgr_data_file:file r_file_perms; + allow hal_dumpstate_impl debugfs_ipc:dir r_dir_perms; + allow hal_dumpstate_impl debugfs_ipc:file r_file_perms; + allow hal_dumpstate_impl sysfs_usb_device:dir r_dir_perms; + allow hal_dumpstate_impl sysfs_usb_device:file r_file_perms; + allow hal_dumpstate_impl sysfs_msm_subsys:file write; + + set_prop(hal_dumpstate_impl, modem_diag_prop) +') + +allow hal_dumpstate_impl uio_device:chr_file rw_file_perms; +r_dir_file(hal_dumpstate_impl, sysfs_uio) +r_dir_file(hal_dumpstate_impl, sysfs_rmtfs) +r_dir_file(hal_dumpstate_impl, sysfs_msm_subsys) +r_dir_file(hal_dumpstate_impl, sysfs_soc) +r_dir_file(hal_dumpstate_impl, sysfs_thermal) + +allow hal_dumpstate_impl debugfs_ion:dir r_dir_perms; +allow hal_dumpstate_impl debugfs_ion:file r_file_perms; +allow hal_dumpstate_impl debugfs_rpm:file r_file_perms; +allow hal_dumpstate_impl debugfs_wlan:dir r_dir_perms; +allow hal_dumpstate_impl debugfs_wlan:file r_file_perms; +allow hal_dumpstate_impl debugfs_icnss:dir r_dir_perms; +allow hal_dumpstate_impl debugfs_icnss:file r_file_perms; +allow hal_dumpstate_impl debugfs_ipc:file r_file_perms; +allow hal_dumpstate_impl proc_stat:file r_file_perms; + +# Access to files for dumping +allow hal_dumpstate_impl sysfs:dir r_dir_perms; +# rpm stat +# usb logs +userdebug_or_eng(`allow hal_dumpstate_impl debugfs_usb:file r_file_perms;') + +#Access display debug data +allow hal_dumpstate_impl display_vendor_data_file:dir r_dir_perms; +allow hal_dumpstate_impl display_vendor_data_file:file r_file_perms; + +# Access to touch firmware info +allow hal_dumpstate_impl sysfs_touch:dir r_dir_perms; +allow hal_dumpstate_impl sysfs_touch:file rw_file_perms; diff --git a/sepolicy/vendor/hal_fingerprint.te b/sepolicy/vendor/hal_fingerprint.te new file mode 100644 index 00000000..3f2e772d --- /dev/null +++ b/sepolicy/vendor/hal_fingerprint.te @@ -0,0 +1,7 @@ +allow hal_fingerprint sysfs_fingerprint:dir r_dir_perms; +allow hal_fingerprint sysfs_fingerprint:file rw_file_perms; +allow hal_fingerprint sysfs_msm_subsys:dir search; +allow hal_fingerprint sysfs_msm_subsys:file r_file_perms; +allow hal_fingerprint tee_device:file rw_file_perms; +allow hal_fingerprint tee_device:chr_file rw_file_perms; +allow hal_fingerprint uhid_device:chr_file rw_file_perms; diff --git a/sepolicy/vendor/hal_gatekeeper.te b/sepolicy/vendor/hal_gatekeeper.te new file mode 100644 index 00000000..fcadc1e9 --- /dev/null +++ b/sepolicy/vendor/hal_gatekeeper.te @@ -0,0 +1 @@ +set_prop(hal_gatekeeper, keymaster_prop) diff --git a/sepolicy/vendor/hal_gatekeeper_qti.te b/sepolicy/vendor/hal_gatekeeper_qti.te new file mode 100644 index 00000000..6c6211bc --- /dev/null +++ b/sepolicy/vendor/hal_gatekeeper_qti.te @@ -0,0 +1,9 @@ +type hal_gatekeeper_qti, domain; +hal_server_domain(hal_gatekeeper_qti, hal_gatekeeper) + +type hal_gatekeeper_qti_exec, exec_type, vendor_file_type, file_type; +init_daemon_domain(hal_gatekeeper_qti) + +dontaudit hal_gatekeeper_qti firmware_file:dir search; + +get_prop(hal_gatekeeper_qti, tee_listener_prop) diff --git a/sepolicy/vendor/hal_gnss_qti.te b/sepolicy/vendor/hal_gnss_qti.te new file mode 100644 index 00000000..74620f8d --- /dev/null +++ b/sepolicy/vendor/hal_gnss_qti.te @@ -0,0 +1,44 @@ +type hal_gnss_qti, domain; +hal_server_domain(hal_gnss_qti, hal_gnss) + +type hal_gnss_qti_exec, exec_type, vendor_file_type, file_type; +init_daemon_domain(hal_gnss_qti) + +r_dir_file(hal_gnss_qti, sysfs_msm_subsys) + +vndbinder_use(hal_gnss_qti) + +allow hal_gnss_qti sysfs_soc:dir r_dir_perms; +allow hal_gnss_qti sysfs_soc:file r_file_perms; + +binder_call(hal_gnss_qti, per_mgr) +allow hal_gnss_qti per_mgr_service:service_manager find; + +# /data/vendor/location +allow hal_gnss_qti location_data_file:fifo_file { open read setattr write }; +allow hal_gnss_qti location_data_file:dir create_dir_perms; +allow hal_gnss_qti location_data_file:sock_file write; + +allow hal_gnss_qti location:unix_stream_socket connectto; + +allow hal_gnss_qti self:socket create_socket_perms; +allowxperm hal_gnss_qti self:socket ioctl msm_sock_ipc_ioctls; + +unix_socket_connect(hal_gnss_qti, netmgrd, netmgrd) +allow hal_gnss_qti netmgrd_socket:dir search; + +allow hal_gnss_qti self:netlink_generic_socket { bind create read }; +allow hal_gnss_qti self:netlink_route_socket { bind create nlmsg_read read write }; + +# Most HALs are not allowed to use network sockets. Qcom library +# libqdi is used across multiple processes which are clients of +# netmgrd including the GNSS HAL. libqdi first attempts to get the network +# interface using an IOCTL on a UDP INET socket, which isn't allowed here. +# If that fails, it falls back to using libc's if_nameindex() which requires +# a netlink route socket, which HALs may use. Due to the initial +# attempt to use a UDP socket, we still see a selinux denial, +# but it is safe to ignore. +# TODO (b/37730994) Remove udp_socket requirement from +# libqdi and have all its clients use netlink route +# sockets. +dontaudit hal_gnss_qti self:udp_socket create; diff --git a/sepolicy/vendor/hal_graphics_composer_default.te b/sepolicy/vendor/hal_graphics_composer_default.te new file mode 100644 index 00000000..7bea2e1b --- /dev/null +++ b/sepolicy/vendor/hal_graphics_composer_default.te @@ -0,0 +1,34 @@ +# Binder access (for display.qservice) +vndbinder_use(hal_graphics_composer_default) +allow hal_graphics_composer_default qdisplay_service:service_manager { add find }; + +allow hal_graphics_composer_default persist_display_file:dir search; +allow hal_graphics_composer_default persist_display_file:file r_file_perms; + +allow hal_graphics_composer_default sysfs_camera:dir search; +allow hal_graphics_composer_default sysfs_camera:file r_file_perms; +allow hal_graphics_composer_default sysfs_msm_subsys:dir search; +allow hal_graphics_composer_default sysfs_msm_subsys:file r_file_perms; +allow hal_graphics_composer_default sysfs_mdss_mdp_caps:file r_file_perms; +allow hal_graphics_composer_default persist_file:dir search; + +allow hal_graphics_composer_default hal_graphics_mapper_hwservice:hwservice_manager find; + +r_dir_file(hal_graphics_composer_default, sysfs_leds) + +# TODO(b/37666508): Remove the following line upon resolution of the bug +allow hal_graphics_composer_default video_device:chr_file rw_file_perms; + +# HWC_UeventThread +allow hal_graphics_composer_default self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl; + +# Access /sys/devices/virtual/graphics/fb0 +r_dir_file(hal_graphics_composer_default, sysfs_type) + +allow hal_graphics_composer_default display_vendor_data_file:dir create_dir_perms; +allow hal_graphics_composer_default display_vendor_data_file:file create_file_perms; + +userdebug_or_eng(` + allow hal_graphics_composer_default debugfs_mdp:dir r_dir_perms; + allow hal_graphics_composer_default debugfs_mdp:file r_file_perms; +') diff --git a/sepolicy/vendor/hal_imsrtp.te b/sepolicy/vendor/hal_imsrtp.te new file mode 100644 index 00000000..a3950190 --- /dev/null +++ b/sepolicy/vendor/hal_imsrtp.te @@ -0,0 +1,32 @@ +#ims rtp service +type hal_imsrtp, domain; +type hal_imsrtp_exec, exec_type, vendor_file_type, file_type; + +# Started by init +init_daemon_domain(hal_imsrtp) +net_domain(hal_imsrtp) + +hwbinder_use(hal_imsrtp) +get_prop(hal_imsrtp, hwservicemanager_prop) +add_hwservice(hal_imsrtp, hal_imsrtp_hwservice) + +allow hal_imsrtp self:socket create_socket_perms; +unix_socket_connect(hal_imsrtp, ims, ims) + +allow hal_imsrtp sysfs_timestamp_switch:file r_file_perms; + +# ioctlcmd=c302 +allowxperm hal_imsrtp self:socket ioctl msm_sock_ipc_ioctls; + +allow hal_imsrtp self:capability net_bind_service; + +allow hal_imsrtp sysfs_timestamp_switch:file r_file_perms; +allow hal_imsrtp ion_device:chr_file r_file_perms; +allow hal_imsrtp sysfs_data:file r_file_perms; +r_dir_file(hal_imsrtp, sysfs_msm_subsys) +r_dir_file(hal_imsrtp, sysfs_diag) +r_dir_file(hal_imsrtp, sysfs_soc) + +allow hal_imsrtp ion_device:chr_file r_file_perms; +get_prop(hal_imsrtp, ims_prop) +binder_call(hal_imsrtp, radio) diff --git a/sepolicy/vendor/hal_keymaster_qti.te b/sepolicy/vendor/hal_keymaster_qti.te new file mode 100644 index 00000000..ea552874 --- /dev/null +++ b/sepolicy/vendor/hal_keymaster_qti.te @@ -0,0 +1,9 @@ +type hal_keymaster_qti, domain; +hal_server_domain(hal_keymaster_qti, hal_keymaster) + +type hal_keymaster_qti_exec, exec_type, vendor_file_type, file_type; +init_daemon_domain(hal_keymaster_qti) + +dontaudit hal_keymaster_qti firmware_file:dir search; + +get_prop(hal_keymaster_qti, tee_listener_prop) diff --git a/sepolicy/vendor/hal_light.te b/sepolicy/vendor/hal_light.te new file mode 100644 index 00000000..458c97ea --- /dev/null +++ b/sepolicy/vendor/hal_light.te @@ -0,0 +1,2 @@ +allow hal_light sysfs_graphics:dir search; +allow hal_light sysfs_graphics:file rw_file_perms; diff --git a/sepolicy/vendor/hal_light_default.te b/sepolicy/vendor/hal_light_default.te new file mode 100644 index 00000000..b7de5302 --- /dev/null +++ b/sepolicy/vendor/hal_light_default.te @@ -0,0 +1 @@ +allow hal_light_default sysfs_msm_subsys:dir search; diff --git a/sepolicy/vendor/hal_memtrack_default.te b/sepolicy/vendor/hal_memtrack_default.te new file mode 100644 index 00000000..4ffa74c2 --- /dev/null +++ b/sepolicy/vendor/hal_memtrack_default.te @@ -0,0 +1 @@ +allow hal_memtrack_default debugfs_kgsl:file { open read getattr }; diff --git a/sepolicy/vendor/hal_nfc_default.te b/sepolicy/vendor/hal_nfc_default.te new file mode 100644 index 00000000..3044f1d5 --- /dev/null +++ b/sepolicy/vendor/hal_nfc_default.te @@ -0,0 +1,3 @@ +# Data file accesses. +allow hal_nfc_default nfc_vendor_data_file:dir create_dir_perms; +allow hal_nfc_default nfc_vendor_data_file:file create_file_perms; diff --git a/sepolicy/vendor/hal_oemlock_default.te b/sepolicy/vendor/hal_oemlock_default.te new file mode 100644 index 00000000..bc8ee58a --- /dev/null +++ b/sepolicy/vendor/hal_oemlock_default.te @@ -0,0 +1,8 @@ +type hal_oemlock_default, domain; +hal_server_domain(hal_oemlock_default, hal_oemlock) + +allow hal_oemlock_default hal_bootctl_socket:sock_file write; +allow hal_oemlock_default hal_bootctl:unix_stream_socket connectto; + +type hal_oemlock_default_exec, exec_type, vendor_file_type, file_type; +init_daemon_domain(hal_oemlock_default) diff --git a/sepolicy/vendor/hal_power_default.te b/sepolicy/vendor/hal_power_default.te new file mode 100644 index 00000000..aa92c358 --- /dev/null +++ b/sepolicy/vendor/hal_power_default.te @@ -0,0 +1,13 @@ +allow hal_power_default perfd:unix_stream_socket connectto; +allow hal_power_default perfd_socket:sock_file write; + +allow hal_power_default sysfs_graphics:dir search; +allow hal_power_default sysfs_graphics:file r_file_perms; + +userdebug_or_eng(` +# debugfs entries are only needed in user-debug or eng builds +allow hal_power_default debugfs_rpm:file r_file_perms; + +allow hal_power_default debugfs_wlan:dir r_dir_perms; +allow hal_power_default debugfs_wlan:file r_file_perms; +') diff --git a/sepolicy/vendor/hal_rcsservice.te b/sepolicy/vendor/hal_rcsservice.te new file mode 100644 index 00000000..7de16c8d --- /dev/null +++ b/sepolicy/vendor/hal_rcsservice.te @@ -0,0 +1,29 @@ +type hal_rcsservice, domain; +type hal_rcsservice_exec, exec_type, vendor_file_type, file_type; + +# Started by init +init_daemon_domain(hal_rcsservice) +net_domain(hal_rcsservice) + +get_prop(hal_rcsservice, hwservicemanager_prop) + +# To register imsrcsd to hwBinder +hwbinder_use(hal_rcsservice) +# add IUceSerive Hidl interface +add_hwservice(hal_rcsservice, hal_imsrcsd_hwservice) + +get_prop(hal_rcsservice, hwservicemanager_prop) + +# allow hal to read sysfs file +r_dir_file(hal_rcsservice, sysfs_msm_subsys) +r_dir_file(hal_rcsservice, sysfs_diag) + +allow hal_rcsservice sysfs_timestamp_switch:file r_file_perms; + +unix_socket_connect(hal_rcsservice, ims, ims) + +# imsrcsd to bind with UceShimService.apk +binder_call(hal_rcsservice, dataservice_app) + +# imsrcsd needs read/write access to devpts +allow hal_rcsservice devpts:chr_file rw_file_perms; diff --git a/sepolicy/vendor/hal_sensors_default.te b/sepolicy/vendor/hal_sensors_default.te new file mode 100644 index 00000000..fa473a87 --- /dev/null +++ b/sepolicy/vendor/hal_sensors_default.te @@ -0,0 +1,15 @@ +# read factory calibration and sensor configuration data +allow hal_sensors_default persist_file:dir search; +r_dir_file(hal_sensors_default, persist_sensors_file) + +# interact with the sensors low power island (SLPI) CPU +allow hal_sensors_default self:socket { create ioctl read write }; +allowxperm hal_sensors_default self:socket ioctl msm_sock_ipc_ioctls; +r_dir_file(hal_sensors_default, sysfs_msm_subsys); + +allow hal_sensors_default qdsp_device:chr_file r_file_perms; + +userdebug_or_eng(` + r_dir_file(hal_sensors_default, sysfs_diag) + allow hal_sensors_default sysfs_timestamp_switch:file r_file_perms; +') diff --git a/sepolicy/vendor/hal_tetheroffload_default.te b/sepolicy/vendor/hal_tetheroffload_default.te new file mode 100644 index 00000000..273f8eca --- /dev/null +++ b/sepolicy/vendor/hal_tetheroffload_default.te @@ -0,0 +1,24 @@ +# associate netdomain to use for accessing internet sockets +net_domain(hal_tetheroffload_default) + +userdebug_or_eng(` + # Allow using the logging file between ipacm and ipacm-diag + unix_socket_send(hal_tetheroffload_default, ipacm, hal_tetheroffload_default) +') +# Allow operations with /dev/ipa, /dev/wwan_ioctl and /dev/ipaNatTable +allow hal_tetheroffload_default ipa_dev:chr_file rw_file_perms; + +# Allow receiving NETLINK messages +allow hal_tetheroffload_default self:{ + netlink_socket + netlink_generic_socket +} create_socket_perms_no_ioctl; + +# Allow creating and modifying the PID file +allow hal_tetheroffload_default ipa_vendor_data_file:dir w_dir_perms; +allow hal_tetheroffload_default ipa_vendor_data_file:file create_file_perms; + +# Register to hwbinder service +add_hwservice(hal_tetheroffload_default, hal_tetheroffload_hwservice) +hwbinder_use(hal_tetheroffload_default) +get_prop(hal_tetheroffload_default, hwservicemanager_prop) diff --git a/sepolicy/vendor/hal_thermal_default.te b/sepolicy/vendor/hal_thermal_default.te new file mode 100644 index 00000000..bafcb555 --- /dev/null +++ b/sepolicy/vendor/hal_thermal_default.te @@ -0,0 +1,4 @@ +allow hal_thermal_default sysfs_thermal:dir { open read search }; +allow hal_thermal_default sysfs_thermal:file { getattr open read }; +allow hal_thermal_default sysfs_thermal:lnk_file read; +allow hal_thermal_default proc_stat:file { getattr open read }; diff --git a/sepolicy/vendor/hal_usb_default.te b/sepolicy/vendor/hal_usb_default.te new file mode 100644 index 00000000..e085b3a5 --- /dev/null +++ b/sepolicy/vendor/hal_usb_default.te @@ -0,0 +1,7 @@ +allow hal_usb_default sysfs_msm_subsys:dir search; +allow hal_usb_default sysfs_msm_subsys:file r_file_perms; +allow hal_usb_default sysfs_usb_c:dir r_dir_perms; +allow hal_usb_default sysfs_usb_c:lnk_file read; +allow hal_usb_default sysfs_usb_c:file rw_file_perms; +allow hal_usb_default sysfs_usb_device:dir r_dir_perms; +allow hal_usb_default sysfs_usb_device:file rw_file_perms; diff --git a/sepolicy/vendor/hal_vibrator_default.te b/sepolicy/vendor/hal_vibrator_default.te new file mode 100644 index 00000000..5cc3a76d --- /dev/null +++ b/sepolicy/vendor/hal_vibrator_default.te @@ -0,0 +1,8 @@ +r_dir_file(hal_vibrator_default, sysfs_leds) +allow hal_vibrator_default sysfs_leds:file w_file_perms; +allow hal_vibrator_default sysfs_msm_subsys:file rw_file_perms; +allow hal_vibrator_default sysfs_msm_subsys:dir search; + +# read-only permission to obtain the calibration data +r_dir_file(hal_vibrator_default, persist_haptics_file) +allow hal_vibrator_default persist_file:dir search; diff --git a/sepolicy/vendor/hal_vr.te b/sepolicy/vendor/hal_vr.te new file mode 100644 index 00000000..a88dcb82 --- /dev/null +++ b/sepolicy/vendor/hal_vr.te @@ -0,0 +1,6 @@ +# interact with thermal_config +set_prop(hal_vr, thermal_prop) + +# Access to touch vrmode node +allow hal_vr sysfs_touch:dir r_dir_perms; +allow hal_vr sysfs_touch:file rw_file_perms; diff --git a/sepolicy/vendor/hal_wifi_default.te b/sepolicy/vendor/hal_wifi_default.te new file mode 100644 index 00000000..ca0e8c58 --- /dev/null +++ b/sepolicy/vendor/hal_wifi_default.te @@ -0,0 +1,19 @@ +# Allow wifi hal access to LOWI +allow hal_wifi_default location:unix_stream_socket connectto; +allow hal_wifi_default location_data_file:sock_file write; + +# write to files owned by location daemon +allow hal_wifi_default location_data_file:dir create_dir_perms; +allow hal_wifi_default location_data_file:{ file fifo_file } create_file_perms; + +allow hal_wifi_default wlan_device:chr_file w_file_perms; + +# Allow wifi hal to read debug info from the driver. +r_dir_file(hal_wifi_default, proc_wifi_dbg) + +userdebug_or_eng(` +# debugfs entries are only needed in user-debug or eng builds + +# Allow wifi hal to access wlan debugfs files and directories +allow hal_wifi_default debugfs_wlan:dir r_dir_perms; +') \ No newline at end of file diff --git a/sepolicy/vendor/hal_wifi_offload_default.te b/sepolicy/vendor/hal_wifi_offload_default.te new file mode 100644 index 00000000..00df6a73 --- /dev/null +++ b/sepolicy/vendor/hal_wifi_offload_default.te @@ -0,0 +1,3 @@ +# Allow Wifi Offload HAL to communicate with daemon via socket +allow hal_wifi_offload_default chre:unix_stream_socket connectto; +allow hal_wifi_offload_default chre_socket:sock_file write; diff --git a/sepolicy/vendor/hardware_info_app.te b/sepolicy/vendor/hardware_info_app.te new file mode 100644 index 00000000..70cb8010 --- /dev/null +++ b/sepolicy/vendor/hardware_info_app.te @@ -0,0 +1,26 @@ +type hardware_info_app, domain; + +app_domain(hardware_info_app) + +# App +allow hardware_info_app app_data_file:file execute; + +# Services +allow hardware_info_app app_api_service:service_manager find; + +# Shell +allow hardware_info_app shell_data_file:dir search; +allow hardware_info_app shell_data_file:file { open read }; + +# SysFS +allow hardware_info_app sysfs_batteryinfo:dir search; +allow hardware_info_app sysfs_batteryinfo:file { getattr open read write }; +allow hardware_info_app sysfs_batteryinfo:file write; +allow hardware_info_app sysfs_camera:dir search; +allow hardware_info_app sysfs_camera:file { getattr open read }; +allow hardware_info_app sysfs_msm_subsys:dir search; +allow hardware_info_app sysfs_scsi_devices_0000:dir search; +allow hardware_info_app sysfs_scsi_devices_0000:file { getattr open read }; +allow hardware_info_app sysfs_soc:dir search; +allow hardware_info_app sysfs_soc:file { getattr open read }; + diff --git a/sepolicy/vendor/hwservice.te b/sepolicy/vendor/hwservice.te new file mode 100644 index 00000000..4e13ddb1 --- /dev/null +++ b/sepolicy/vendor/hwservice.te @@ -0,0 +1,5 @@ +type vnd_ims_radio_hwservice, hwservice_manager_type; +type vnd_qcrilhook_hwservice, hwservice_manager_type; +type vnd_atcmdfwd_hwservice, hwservice_manager_type; +type hal_imsrtp_hwservice, hwservice_manager_type; +type hal_ipacm_hwservice, hwservice_manager_type; diff --git a/sepolicy/vendor/hwservice_contexts b/sepolicy/vendor/hwservice_contexts new file mode 100644 index 00000000..89f75101 --- /dev/null +++ b/sepolicy/vendor/hwservice_contexts @@ -0,0 +1,10 @@ +com.qualcomm.qti.ims.radio::IImsRadio u:object_r:vnd_ims_radio_hwservice:s0 +com.qualcomm.qti.qcril.qcrilhook::IQtiOemHook u:object_r:vnd_qcrilhook_hwservice:s0 +com.qualcomm.qti.uceservice::IUceService u:object_r:hal_imsrcsd_hwservice:s0 +vendor.qti.atcmdfwd::IAtCmdFwd u:object_r:vnd_atcmdfwd_hwservice:s0 +vendor.qti.qcril.am::IQcRilAudio u:object_r:vnd_qcrilhook_hwservice:s0 +com.qualcomm.qti.imsrtpservice::IRTPService u:object_r:hal_imsrtp_hwservice:s0 +android.hardware.tetheroffload.config::IOffloadConfig u:object_r:hal_tetheroffload_hwservice:s0 +android.hardware.tetheroffload.control::IOffloadControl u:object_r:hal_tetheroffload_hwservice:s0 +com.quicinc.cne.api::IApiService u:object_r:hal_cne_hwservice:s0 +com.quicinc.cne.server::IServer u:object_r:hal_cne_hwservice:s0 diff --git a/sepolicy/vendor/ims.te b/sepolicy/vendor/ims.te new file mode 100644 index 00000000..a229417f --- /dev/null +++ b/sepolicy/vendor/ims.te @@ -0,0 +1,35 @@ +type ims, domain; +type ims_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(ims) +net_domain(ims) + +get_prop(ims, hwservicemanager_prop) +set_prop(ims, ims_prop) + +unix_socket_connect(ims, netmgrd, netmgrd) + +allow ims sysfs_soc:dir search; +allow ims sysfs_soc:file r_file_perms; +allow ims sysfs_timestamp_switch:file r_file_perms; + +allow ims self:capability net_bind_service; + +allow ims ion_device:chr_file r_file_perms; + +unix_socket_connect(ims, cnd, cnd) + +allow ims self:socket create_socket_perms; +allow ims ims_socket:sock_file write; +allow ims self:netlink_generic_socket create_socket_perms_no_ioctl; +allow ims netmgrd_socket:dir search; +allow ims netmgrd_socket:sock_file w_file_perms; +allowxperm ims self:socket ioctl msm_sock_ipc_ioctls; +allowxperm ims self:udp_socket ioctl RMNET_IOCTL_EXTENDED; + +r_dir_file(ims, sysfs_msm_subsys) +r_dir_file(ims, sysfs_diag) + +hwbinder_use(ims) +allow ims hal_cne_hwservice:hwservice_manager find; +binder_call(ims, cnd) diff --git a/sepolicy/vendor/init-devstart-sh.te b/sepolicy/vendor/init-devstart-sh.te new file mode 100644 index 00000000..9b762638 --- /dev/null +++ b/sepolicy/vendor/init-devstart-sh.te @@ -0,0 +1,16 @@ +type init-qcom-devstart-sh, domain; +type init-qcom-devstart-sh_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(init-qcom-devstart-sh) + +allow init-qcom-devstart-sh vendor_shell_exec:file rx_file_perms; +allow init-qcom-devstart-sh vendor_toolbox_exec:file rx_file_perms; + +# execute grep +allow init-qcom-devstart-sh vendor_file:file rx_file_perms; + +# Set the sys.qcom.devup property +set_prop(init-qcom-devstart-sh, system_prop) + +# Set boot_adsp and boot_slpi to 1 +allow init-qcom-devstart-sh sysfs_msm_subsys:file w_file_perms; diff --git a/sepolicy/vendor/init-insmod-sh.te b/sepolicy/vendor/init-insmod-sh.te new file mode 100644 index 00000000..024984a5 --- /dev/null +++ b/sepolicy/vendor/init-insmod-sh.te @@ -0,0 +1,16 @@ +type init-insmod-sh, domain; +type init-insmod-sh_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(init-insmod-sh) + +allow init-insmod-sh vendor_shell_exec:file rx_file_perms; +allow init-insmod-sh vendor_toolbox_exec:file rx_file_perms; + +# Set the sys.touch.modules.ready property +set_prop(init-insmod-sh, system_prop) + +# Allow insmod +allow init-insmod-sh self:capability sys_module; +allow init-insmod-sh system_file:system module_load; + +allow init-insmod-sh vendor_file:system module_load; diff --git a/sepolicy/vendor/init-ipastart-sh.te b/sepolicy/vendor/init-ipastart-sh.te new file mode 100644 index 00000000..d2e1754c --- /dev/null +++ b/sepolicy/vendor/init-ipastart-sh.te @@ -0,0 +1,10 @@ +type init-qcom-ipastart-sh, domain; +type init-qcom-ipastart-sh_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(init-qcom-ipastart-sh) + +allow init-qcom-ipastart-sh vendor_shell_exec:file rx_file_perms; +allow init-qcom-ipastart-sh vendor_toolbox_exec:file rx_file_perms; + +# Set /dev/ipa to 1 +allow init-qcom-ipastart-sh ipa_dev:chr_file w_file_perms; diff --git a/sepolicy/vendor/init.te b/sepolicy/vendor/init.te new file mode 100644 index 00000000..fe41cf49 --- /dev/null +++ b/sepolicy/vendor/init.te @@ -0,0 +1,17 @@ +# symlink /sdcard to backing block +allow init tmpfs:lnk_file create; +allow init configfs:lnk_file create; + +allow init firmware_file:dir mounton; +allow init configfs:file w_file_perms; +allow init debugfs_clk:file w_file_perms; + +allow init tty_device:chr_file rw_file_perms; + +allow init persist_file:dir mounton; + +allow init ab_block_device:lnk_file relabelto; +allow init boot_block_device:lnk_file relabelto; +allow init persist_block_device:lnk_file relabelto; + +dontaudit init kernel:system module_request; diff --git a/sepolicy/vendor/init_elabel.te b/sepolicy/vendor/init_elabel.te new file mode 100644 index 00000000..c81ae033 --- /dev/null +++ b/sepolicy/vendor/init_elabel.te @@ -0,0 +1,8 @@ +# /system/bin/init.elabel.sh +# +# write data from /persist/elabel to /data/misc/elabel for use by +# settings app +# +allow init_elabel persist_file:dir {search getattr}; +allow init_elabel persist_elabel_file:dir r_dir_perms; +allow init_elabel persist_elabel_file:file r_file_perms; diff --git a/sepolicy/vendor/init_ese.te b/sepolicy/vendor/init_ese.te new file mode 100644 index 00000000..59ab771e --- /dev/null +++ b/sepolicy/vendor/init_ese.te @@ -0,0 +1,19 @@ +# /vendor/bin/ese_load init called shell script. +type init_ese, domain; +type init_ese_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(init_ese) + +# Shell script exec (toolbox) +allow init_ese vendor_shell_exec:file r_file_perms; +allow init_ese vendor_toolbox_exec:file rx_file_perms; + +# eSE tools +allow init_ese esed_exec:file rx_file_perms; + +# eSE device and data dirs +allow init_ese pn81a_device:chr_file rw_file_perms; +allow init_ese ese_vendor_data_file:dir create_dir_perms; +allow init_ese ese_vendor_data_file:file create_file_perms; + +allow init_ese vendor_file:file execute_no_trans; diff --git a/sepolicy/vendor/init_power.te b/sepolicy/vendor/init_power.te new file mode 100644 index 00000000..6b05522b --- /dev/null +++ b/sepolicy/vendor/init_power.te @@ -0,0 +1,19 @@ +type init_power, domain; +type init_power_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(init_power) + +set_prop(init_power, post_boot_prop) + +allow init_power vendor_shell_exec:file rx_file_perms; +allow init_power vendor_toolbox_exec:file rx_file_perms; + +r_dir_file(init_power, sysfs_msm_subsys) + +allow init_power sysfs_msm_subsys:file write; +allow init_power sysfs_thermal:dir search; +allow init_power sysfs_thermal:file w_file_perms; +allow init_power sysfs_devices_system_cpu:file w_file_perms; +allow init_power sysfs_soc:file r_file_perms; +allow init_power sysfs_soc:dir search; +allow init_power sysfs_console_suspend:file w_file_perms; diff --git a/sepolicy/vendor/init_radio.te b/sepolicy/vendor/init_radio.te new file mode 100644 index 00000000..ff4da345 --- /dev/null +++ b/sepolicy/vendor/init_radio.te @@ -0,0 +1,11 @@ +# /vendor/bin/init.radio.sh +type init_radio, domain; +type init_radio_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(init_radio) + +allow init_radio vendor_shell_exec:file rx_file_perms; +allow init_radio vendor_toolbox_exec:file rx_file_perms; + +allow init_radio radio_vendor_data_file:dir create_dir_perms; +allow init_radio radio_vendor_data_file:file create_file_perms; diff --git a/sepolicy/vendor/ioctl_defines b/sepolicy/vendor/ioctl_defines new file mode 100644 index 00000000..e1c50a7e --- /dev/null +++ b/sepolicy/vendor/ioctl_defines @@ -0,0 +1,10 @@ +# socket ioctls +define(`RMNET_IOCTL_EXTENDED', `0x000089FD') + +# socket ioctls defined in the kernel in include/uapi/linux/msm_ipc.h +define(`IPC_ROUTER_IOCTL_GET_VERSION', `0x0000c300') +define(`IPC_ROUTER_IOCTL_GET_MTU', `0x0000c301') +define(`IPC_ROUTER_IOCTL_LOOKUP_SERVER', `0x0000c302') +define(`IPC_ROUTER_IOCTL_GET_CURR_PKT_SIZE', `0x0000c303') +define(`IPC_ROUTER_IOCTL_BIND_CONTROL_PORT', `0x0000c304') +define(`IPC_ROUTER_IOCTL_CONFIG_SEC_RULES', `0x0000c305') diff --git a/sepolicy/vendor/ioctl_macros b/sepolicy/vendor/ioctl_macros new file mode 100644 index 00000000..dd9a2e86 --- /dev/null +++ b/sepolicy/vendor/ioctl_macros @@ -0,0 +1,8 @@ +define(`msm_sock_ipc_ioctls', `{ +IPC_ROUTER_IOCTL_GET_VERSION +IPC_ROUTER_IOCTL_GET_MTU +IPC_ROUTER_IOCTL_LOOKUP_SERVER +IPC_ROUTER_IOCTL_GET_CURR_PKT_SIZE +IPC_ROUTER_IOCTL_BIND_CONTROL_PORT +IPC_ROUTER_IOCTL_CONFIG_SEC_RULES +}') diff --git a/sepolicy/vendor/irqbalance.te b/sepolicy/vendor/irqbalance.te new file mode 100644 index 00000000..8b54f163 --- /dev/null +++ b/sepolicy/vendor/irqbalance.te @@ -0,0 +1,14 @@ +type irqbalance, domain; +type irqbalance_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(irqbalance); + +allow irqbalance sysfs_devices_system_cpu:file rw_file_perms; +allow irqbalance proc_irq:dir r_dir_perms; +allow irqbalance proc_irq:file rw_file_perms; +allow irqbalance sysfs_irq:file r_file_perms; + +allow irqbalance proc_stat:file r_file_perms; +allow irqbalance proc_interrupts:file r_file_perms; + +r_dir_file(irqbalance, proc) diff --git a/sepolicy/vendor/irsc_util.te b/sepolicy/vendor/irsc_util.te new file mode 100644 index 00000000..79f3c730 --- /dev/null +++ b/sepolicy/vendor/irsc_util.te @@ -0,0 +1,7 @@ +type irsc_util, domain; +type irsc_util_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(irsc_util) + +allow irsc_util self:socket create_socket_perms; +allowxperm irsc_util self:socket ioctl msm_sock_ipc_ioctls; diff --git a/sepolicy/vendor/kernel.te b/sepolicy/vendor/kernel.te new file mode 100644 index 00000000..23686463 --- /dev/null +++ b/sepolicy/vendor/kernel.te @@ -0,0 +1,14 @@ +# for diag over socket +userdebug_or_eng(` + allow kernel self:socket create; + allow kernel debugfs_wlan:dir search; +') + +allow kernel vendor_firmware_file:dir search; +allow kernel vendor_firmware_file:file r_file_perms; +allow kernel vendor_firmware_file:lnk_file read; + +dontaudit kernel kernel:system module_request; + +allow kernel debugfs_ipc:dir search; +allow kernel persist_file:dir search; diff --git a/sepolicy/vendor/keys.conf b/sepolicy/vendor/keys.conf new file mode 100644 index 00000000..2b72a8b4 --- /dev/null +++ b/sepolicy/vendor/keys.conf @@ -0,0 +1,21 @@ +[@TANGO] +ALL : device/google/wahoo/sepolicy/vendor/certs/tango_release.x509.pem + +[@TANGO_DEV] +ENG : device/google/wahoo/sepolicy/vendor/certs/tango.x509.pem +USERDEBUG : device/google/wahoo/sepolicy/vendor/certs/tango.x509.pem +USER : device/google/wahoo/sepolicy/vendor/certs/tango_userdev.x509.pem + +[@GOOGLE] +ALL : device/google/wahoo/sepolicy/vendor/certs/app.x509.pem + +[@EASEL] +ALL : device/google/wahoo/sepolicy/vendor/certs/easel.x509.pem + +[@ARCORE] +ALL : device/google/wahoo/sepolicy/vendor/certs/arcore_release.x509.pem + +[@ARCORE_DEV] +ENG : device/google/wahoo/sepolicy/vendor/certs/arcore.x509.pem +USERDEBUG : device/google/wahoo/sepolicy/vendor/certs/arcore.x509.pem +USER : device/google/wahoo/sepolicy/vendor/certs/arcore_userdev.x509.pem diff --git a/sepolicy/vendor/location.te b/sepolicy/vendor/location.te new file mode 100644 index 00000000..67471df6 --- /dev/null +++ b/sepolicy/vendor/location.te @@ -0,0 +1,49 @@ +# loc_launcher service +# which launches various other services supporting GPS & Wifi-RTT (LOWI) location +type location, domain; +type location_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(location) + +# STOPSHIP b/28340421 +# Temporarily grant this permission (for LOWI) and log its use. +allow location self:capability { net_admin }; +auditallow location self:capability { net_admin }; + +allow location self:capability { setgid setuid }; + +hwbinder_use(location) +get_prop(location, hwservicemanager_prop) +allow location fwk_sensor_hwservice:hwservice_manager find; +binder_call(location, system_server) +allow location hal_wifi:unix_stream_socket { read write }; + +# Enable standard network access (for XTRA download) +net_domain(location) + +# And some additional network access +allow location self:netlink_generic_socket create_socket_perms_no_ioctl; +allow location self:netlink_socket create_socket_perms_no_ioctl; +allowxperm location self:udp_socket ioctl { SIOCGIFINDEX SIOCGIFHWADDR SIOCIWFIRSTPRIV_05 }; + +allow location self:socket create_socket_perms; +# whitelist socket ioctl commands +allowxperm location self:socket ioctl msm_sock_ipc_ioctls; + +# files in /sys +r_dir_file(location, sysfs_type) + +dontaudit location kernel:system module_request; + +allow location proc_net:file r_file_perms; + +# execute /vendor/bin/lowi-server +allow location location_exec:file rx_file_perms; + +# /data/vendor/location +allow location location_data_file:dir create_dir_perms; +allow location location_data_file:{ file sock_file } create_file_perms; + +userdebug_or_eng(` + allow location diag_device:chr_file rw_file_perms; +') \ No newline at end of file diff --git a/sepolicy/vendor/logger_app.te b/sepolicy/vendor/logger_app.te new file mode 100644 index 00000000..941da8b7 --- /dev/null +++ b/sepolicy/vendor/logger_app.te @@ -0,0 +1,21 @@ +type logger_app, domain; + +userdebug_or_eng(` + app_domain(logger_app) + net_domain(logger_app) + + allow logger_app app_api_service:service_manager find; + allow logger_app surfaceflinger_service:service_manager find; + + allow logger_app diag_device:chr_file rw_file_perms; + allow logger_app qlogd_exec:file rx_file_perms; + + allow logger_app radio_vendor_data_file:file create_file_perms; + allow logger_app radio_vendor_data_file:dir create_dir_perms; + + allow logger_app cnss_vendor_data_file:dir create_dir_perms; + allow logger_app cnss_vendor_data_file:file create_file_perms; + + set_prop(logger_app, cnss_diag_prop) + set_prop(logger_app, modem_diag_prop) +') diff --git a/sepolicy/vendor/mac_permissions.xml b/sepolicy/vendor/mac_permissions.xml new file mode 100644 index 00000000..95feba7b --- /dev/null +++ b/sepolicy/vendor/mac_permissions.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sepolicy/vendor/mds_app.te b/sepolicy/vendor/mds_app.te new file mode 100644 index 00000000..e95b423d --- /dev/null +++ b/sepolicy/vendor/mds_app.te @@ -0,0 +1,14 @@ +type mds_app, domain; + +app_domain(mds_app) + +userdebug_or_eng(` + net_domain(mds_app) + + allow mds_app app_api_service:service_manager find; + allow mds_app surfaceflinger_service:service_manager find; + + allow mds_app diag_device:chr_file rw_file_perms; + + set_prop(mds_app, modem_diag_prop) +') diff --git a/sepolicy/vendor/mediacodec.te b/sepolicy/vendor/mediacodec.te new file mode 100644 index 00000000..eb6476fb --- /dev/null +++ b/sepolicy/vendor/mediacodec.te @@ -0,0 +1,11 @@ +allow mediacodec perfd:unix_stream_socket connectto; +allow mediacodec perfd_socket:sock_file write; + +allow mediacodec sysfs_soc:file r_file_perms; +allow mediacodec sysfs_soc:dir search; + +allow mediacodec system_file:dir r_dir_perms; + +userdebug_or_eng(` + allow mediacodec dumpstate:fd use; +') diff --git a/sepolicy/vendor/mediaextractor.te b/sepolicy/vendor/mediaextractor.te new file mode 100644 index 00000000..18abafc0 --- /dev/null +++ b/sepolicy/vendor/mediaextractor.te @@ -0,0 +1,3 @@ +userdebug_or_eng(` + allow mediaextractor dumpstate:fifo_file append; +') diff --git a/sepolicy/vendor/netd.te b/sepolicy/vendor/netd.te new file mode 100644 index 00000000..01c5cc3c --- /dev/null +++ b/sepolicy/vendor/netd.te @@ -0,0 +1,2 @@ +dontaudit netd kernel:system module_request; +dontaudit netd self:capability sys_module; diff --git a/sepolicy/vendor/netmgrd.te b/sepolicy/vendor/netmgrd.te new file mode 100644 index 00000000..adbc4b6d --- /dev/null +++ b/sepolicy/vendor/netmgrd.te @@ -0,0 +1,64 @@ +type netmgrd, domain; +type netmgrd_exec, exec_type, vendor_file_type, file_type; + +net_domain(netmgrd) +init_daemon_domain(netmgrd) + +set_prop(netmgrd, net_radio_prop) +set_prop(netmgrd, net_rmnet_prop) + +# communicate with netd +unix_socket_connect(netmgrd, netd, netd) + +allow netmgrd netmgrd_socket:dir w_dir_perms; +allow netmgrd netmgrd_socket:sock_file create_file_perms; +allow netmgrd self:netlink_xfrm_socket { create_socket_perms_no_ioctl nlmsg_write }; +allow netmgrd self:netlink_generic_socket create_socket_perms_no_ioctl; +allow netmgrd self:netlink_route_socket nlmsg_write; +allow netmgrd self:netlink_socket create_socket_perms_no_ioctl; +allow netmgrd self:socket create_socket_perms; +allowxperm netmgrd self:socket ioctl msm_sock_ipc_ioctls; +allowxperm netmgrd self:udp_socket ioctl priv_sock_ioctls; + +allow netmgrd sysfs_net:dir r_dir_perms; +allow netmgrd sysfs_net:file rw_file_perms; +allow netmgrd sysfs_soc:dir search; +allow netmgrd sysfs_soc:file r_file_perms; +allow netmgrd sysfs_msm_subsys:dir r_dir_perms; +allow netmgrd sysfs_msm_subsys:file r_file_perms; + +allow netmgrd system_file:file lock; + +r_dir_file(netmgrd, sysfs_msm_subsys) + +wakelock_use(netmgrd) + +#Allow netutils usage +domain_auto_trans(netmgrd, netutils_wrapper_exec, netutils_wrapper) + +#Allow diag logging +allow netmgrd sysfs_timestamp_switch:file { read open }; +userdebug_or_eng(` + r_dir_file(netmgrd, sysfs_diag) +') + +#Ignore if device loading for private IOCTL failed +dontaudit netmgrd kernel:system { module_request }; + +allow netmgrd proc_net:file rw_file_perms; +allow netmgrd netmgr_data_file:dir rw_dir_perms; +allow netmgrd netmgr_data_file:file create_file_perms; +allow netmgrd system_file:file execute_no_trans; + +allow netmgrd self:capability { net_admin net_raw setgid setpcap setuid }; + +allow netmgrd vendor_toolbox_exec:file rx_file_perms; + +# Allow netmgrd to use netd HAL +allow netmgrd system_net_netd_hwservice:hwservice_manager find; +get_prop(netmgrd, hwservicemanager_prop) +binder_call(netmgrd, netd) +hwbinder_use(netmgrd) + +dontaudit netmgrd kernel:system module_request; +dontaudit netmgrd self:system module_request; diff --git a/sepolicy/vendor/netutils_wrapper.te b/sepolicy/vendor/netutils_wrapper.te new file mode 100644 index 00000000..ec34fd39 --- /dev/null +++ b/sepolicy/vendor/netutils_wrapper.te @@ -0,0 +1,7 @@ +# For netutils to be able to write their stdout stderr to the pipes opened by netmgrd +allow netutils_wrapper netmgrd:fd use; +allow netutils_wrapper netmgrd:fifo_file { getattr read write append }; + +dontaudit netutils_wrapper netmgrd:netlink_socket { getattr read write append }; +dontaudit netutils_wrapper kernel:system module_request; +dontaudit netutils_wrapper self:capability sys_module; diff --git a/sepolicy/vendor/pd_services.te b/sepolicy/vendor/pd_services.te new file mode 100644 index 00000000..a8d896fc --- /dev/null +++ b/sepolicy/vendor/pd_services.te @@ -0,0 +1,14 @@ +type pd_mapper, domain; + +type pd_mapper_exec, exec_type, vendor_file_type, file_type; +init_daemon_domain(pd_mapper); + +allow pd_mapper self:capability { setgid setpcap setuid net_bind_service }; + +allow pd_mapper firmware_file:dir r_dir_perms; +allow pd_mapper firmware_file:file r_file_perms; + +allow pd_mapper self:socket create_socket_perms; +allowxperm pd_mapper self:socket ioctl IPC_ROUTER_IOCTL_BIND_CONTROL_PORT; + +r_dir_file(pd_mapper, sysfs_msm_subsys) diff --git a/sepolicy/vendor/per_mgr.te b/sepolicy/vendor/per_mgr.te new file mode 100644 index 00000000..cf71f293 --- /dev/null +++ b/sepolicy/vendor/per_mgr.te @@ -0,0 +1,25 @@ +# Policy for pm-service and pm-proxy +type per_mgr, domain; +type per_mgr_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(per_mgr); + +add_service(per_mgr, per_mgr_service) + +vndbinder_use(per_mgr) +binder_call(per_mgr, hal_gnss) +binder_call(per_mgr, per_proxy) +binder_call(per_mgr, wcnss_service) +binder_call(per_mgr, rild) + +allow per_mgr self:capability net_bind_service; + +allow per_mgr firmware_file:file r_file_perms; +allow per_mgr firmware_file:dir search; + +allow per_mgr self:socket create_socket_perms; +allowxperm per_mgr self:socket ioctl msm_sock_ipc_ioctls; +allow per_mgr ssr_device:chr_file { open read }; + +r_dir_file(per_mgr, sysfs_msm_subsys) +r_dir_file(per_mgr, sysfs) diff --git a/sepolicy/vendor/per_proxy.te b/sepolicy/vendor/per_proxy.te new file mode 100644 index 00000000..9c11dc97 --- /dev/null +++ b/sepolicy/vendor/per_proxy.te @@ -0,0 +1,11 @@ +# Policy for /system/bin/pm-proxy +type per_proxy, domain; +type per_proxy_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(per_proxy) + +allow per_proxy per_mgr_service:service_manager find; +r_dir_file(per_proxy, sysfs_type) + +vndbinder_use(per_proxy) +binder_call(per_proxy, per_mgr) diff --git a/sepolicy/vendor/perfd.te b/sepolicy/vendor/perfd.te new file mode 100644 index 00000000..fa99d156 --- /dev/null +++ b/sepolicy/vendor/perfd.te @@ -0,0 +1,32 @@ +type perfd, domain; +type perfd_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(perfd) + +r_dir_file(perfd, sysfs_msm_subsys) + +# perfd uses kill(pid, 0) to determine if a process exists. +# Determining if a process exists does not require the kill capability +# since a permission denied indicates the process exists. +dontaudit perfd self:capability kill; + +allow perfd mediacodec:process signull; +allow perfd hal_power_default:process signull; + +allow perfd cgroup:file r_file_perms; +allow perfd post_boot_prop:file r_file_perms; + +allow perfd proc:file rw_file_perms; +allow perfd sysfs_clkscale:file r_file_perms; +allow perfd sysfs_graphics:dir search; +allow perfd sysfs_graphics:file r_file_perms; +allow perfd sysfs_soc:dir search; +allow perfd sysfs_soc:file r_file_perms; +allow perfd sysfs_graphics:dir search; +allow perfd sysfs_graphics:file r_file_perms; +allow perfd sysfs_msm_subsys:file w_file_perms; +allow perfd sysfs_devices_system_cpu:file w_file_perms; + +allow perfd perfd_socket:sock_file write; + +allow perfd latency_device:chr_file w_file_perms; diff --git a/sepolicy/vendor/platform_app.te b/sepolicy/vendor/platform_app.te new file mode 100644 index 00000000..e69de29b diff --git a/sepolicy/vendor/port-bridge.te b/sepolicy/vendor/port-bridge.te new file mode 100644 index 00000000..e28872ef --- /dev/null +++ b/sepolicy/vendor/port-bridge.te @@ -0,0 +1,11 @@ +type port-bridge, domain; +type port-bridge_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(port-bridge) + +r_dir_file(port-bridge, sysfs_msm_subsys) + +allow port-bridge sysfs_soc:dir search; +allow port-bridge sysfs_soc:file r_file_perms; + +allow port-bridge at_device:chr_file rw_file_perms; diff --git a/sepolicy/vendor/property.te b/sepolicy/vendor/property.te new file mode 100644 index 00000000..b8e8e53f --- /dev/null +++ b/sepolicy/vendor/property.te @@ -0,0 +1,16 @@ +type camera_prop, property_type; +type cnd_prop, property_type; +type ims_prop, property_type; +type keymaster_prop, property_type; +type net_rmnet_prop, property_type; +type ramdump_prop, property_type; +type post_boot_prop, property_type; +type ssr_prop, property_type; +type cnss_diag_prop, property_type; +type tee_listener_prop, property_type; +type wc_prop, property_type; +type thermal_prop, property_type; +type modem_diag_prop, property_type; +type tel_mon_prop, property_type; +type sys_time_prop, property_type; +type atfwd_start_prop, property_type; diff --git a/sepolicy/vendor/property_contexts b/sepolicy/vendor/property_contexts new file mode 100644 index 00000000..b5d5728d --- /dev/null +++ b/sepolicy/vendor/property_contexts @@ -0,0 +1,26 @@ +persist.camera. u:object_r:camera_prop:s0 +htc.camera. u:object_r:camera_prop:s0 +persist.vendor.sys.cnd u:object_r:cnd_prop:s0 +persist.sys.cnd u:object_r:cnd_prop:s0 +sys.ims. u:object_r:ims_prop:s0 +vendor.ims. u:object_r:ims_prop:s0 +sys.keymaster.loaded u:object_r:keymaster_prop:s0 +net.r_rmnet_data0 u:object_r:net_rmnet_prop:s0 +persist.net.doxlat u:object_r:net_radio_prop:s0 +sys.post_boot. u:object_r:post_boot_prop:s0 +radio. u:object_r:radio_prop:s0 +rcs.publish.status u:object_r:radio_prop:s0 +debug.htc.hrdump u:object_r:ramdump_prop:s0 +debug.htc.ramdump u:object_r:ramdump_prop:s0 +persist.sys.crash_rcu u:object_r:ramdump_prop:s0 +debug.ssrdump u:object_r:ssr_prop:s0 +persist.sys.cnss. u:object_r:cnss_diag_prop:s0 +sys.listeners.registered u:object_r:tee_listener_prop:s0 +wc_transport. u:object_r:wc_prop:s0 +sys.qcom.thermalcfg u:object_r:thermal_prop:s0 +ctl.thermal-engine u:object_r:thermal_prop:s0 +persist.sys.modem.diag. u:object_r:modem_diag_prop:s0 +sys.modem.diag. u:object_r:modem_diag_prop:s0 +persist.radio.enable_tel_mon u:object_r:tel_mon_prop:s0 +sys.time.set u:object_r:sys_time_prop:s0 +persist.radio.atfwd.start u:object_r:atfwd_start_prop:s0 diff --git a/sepolicy/vendor/qlogd.te b/sepolicy/vendor/qlogd.te new file mode 100644 index 00000000..f3a8f9bc --- /dev/null +++ b/sepolicy/vendor/qlogd.te @@ -0,0 +1,15 @@ +type qlogd, domain; +type qlogd_exec, exec_type, vendor_file_type, file_type; + +userdebug_or_eng(` + # make transition from init to its domain + init_daemon_domain(qlogd) + + allow qlogd diag_device:chr_file rw_file_perms; + allow qlogd qlogd_exec:file rx_file_perms; + + allow qlogd radio_vendor_data_file:file create_file_perms; + allow qlogd radio_vendor_data_file:dir create_dir_perms; + + set_prop(qlogd, modem_diag_prop) +') \ No newline at end of file diff --git a/sepolicy/vendor/qmuxd.te b/sepolicy/vendor/qmuxd.te new file mode 100644 index 00000000..b8dc015b --- /dev/null +++ b/sepolicy/vendor/qmuxd.te @@ -0,0 +1,5 @@ +type qmuxd, domain; +type qmuxd_exec, exec_type, vendor_file_type, file_type; + +net_domain(qmuxd) +init_daemon_domain(qmuxd) diff --git a/sepolicy/vendor/qtelephony.te b/sepolicy/vendor/qtelephony.te new file mode 100644 index 00000000..0788cdfe --- /dev/null +++ b/sepolicy/vendor/qtelephony.te @@ -0,0 +1,15 @@ +# Qualcomm telephony apps, such as AtFwd and FastDormancy +type qtelephony, domain; + +app_domain(qtelephony) + +hwbinder_use(qtelephony) +add_hwservice(qtelephony, vnd_atcmdfwd_hwservice) + +allow qtelephony { app_api_service }:service_manager find; + +# Read and write /data/data subdirectory. +allow qtelephony system_app_data_file:dir create_dir_perms; +allow qtelephony system_app_data_file:{ file lnk_file } create_file_perms; + +set_prop(qtelephony, atfwd_start_prop) diff --git a/sepolicy/vendor/qti.te b/sepolicy/vendor/qti.te new file mode 100644 index 00000000..a5d1aa84 --- /dev/null +++ b/sepolicy/vendor/qti.te @@ -0,0 +1,16 @@ +type qti, domain; +type qti_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(qti) +net_domain(qti) + +allow qti sysfs_soc:dir search; +allow qti sysfs_soc:file r_file_perms; + +allow qti smd_device:chr_file { read write }; +allow qti rmnet_device:chr_file rw_file_perms; + +allow qti self:socket create_socket_perms; +allowxperm qti self:socket ioctl msm_sock_ipc_ioctls; + +r_dir_file(qti, sysfs_msm_subsys) diff --git a/sepolicy/vendor/radio.te b/sepolicy/vendor/radio.te new file mode 100644 index 00000000..bd704c21 --- /dev/null +++ b/sepolicy/vendor/radio.te @@ -0,0 +1,26 @@ +get_prop(radio, ims_prop) +userdebug_or_eng(`set_prop(radio, tel_mon_prop)') + +allow radio qmuxd_socket:dir search; +allow radio qmuxd_socket:sock_file write; + +allow radio vendor_file:lnk_file r_file_perms; +allow radio vendor_framework_file:file r_file_perms; +allow radio vendor_framework_file:dir search; + +hwbinder_use(radio) +allow radio vnd_ims_radio_hwservice:hwservice_manager find; +allow radio vnd_qcrilhook_hwservice:hwservice_manager find; +allow radio hal_imsrtp_hwservice:hwservice_manager find; + +allow radio { + mediaextractor_service + mediacodec_service +}:service_manager find; + +r_dir_file(radio, sysfs_msm_subsys) + +# IMS needs permission to use avtimer +allow radio avtimer_device:chr_file r_file_perms; + +binder_call(radio, hal_imsrtp) diff --git a/sepolicy/vendor/ramdump.te b/sepolicy/vendor/ramdump.te new file mode 100644 index 00000000..caa01582 --- /dev/null +++ b/sepolicy/vendor/ramdump.te @@ -0,0 +1,23 @@ +type ramdump_exec, exec_type, vendor_file_type, file_type; + +userdebug_or_eng(` + type ramdump, domain; + init_daemon_domain(ramdump) + + set_prop(ramdump, ramdump_prop) + + allow ramdump self:capability sys_rawio; + + allow ramdump ramdump_vendor_data_file:dir create_dir_perms; + allow ramdump ramdump_vendor_data_file:file create_file_perms; + allow ramdump proc:file r_file_perms; + + allow ramdump block_device:dir search; + allow ramdump misc_block_device:blk_file rw_file_perms; + allow ramdump userdata_block_device:blk_file rw_file_perms; + + # read from /fstab.taimen + allow ramdump rootfs:file r_file_perms; + + r_dir_file(ramdump, sysfs_type) +') diff --git a/sepolicy/vendor/ramdump_app.te b/sepolicy/vendor/ramdump_app.te new file mode 100644 index 00000000..e9c4f056 --- /dev/null +++ b/sepolicy/vendor/ramdump_app.te @@ -0,0 +1,14 @@ +type ramdump_app, domain; + +userdebug_or_eng(` + app_domain(ramdump_app) + + allow ramdump_app app_api_service:service_manager find; + allow ramdump_app surfaceflinger_service:service_manager find; + + allow ramdump_app ramdump_vendor_data_file:file create_file_perms; + allow ramdump_app ramdump_vendor_data_file:dir create_dir_perms; + + set_prop(ramdump_app, ramdump_prop); + get_prop(system_app, ssr_prop) +') diff --git a/sepolicy/vendor/rfs_access.te b/sepolicy/vendor/rfs_access.te new file mode 100644 index 00000000..9b6d9ca3 --- /dev/null +++ b/sepolicy/vendor/rfs_access.te @@ -0,0 +1,18 @@ +type rfs_access, domain; +type rfs_access_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(rfs_access) + +#For tftp server +allow rfs_access self:capability { chown setgid setpcap setuid net_bind_service }; + +wakelock_use(rfs_access) + +# For tftp server file access +allow rfs_access firmware_file:dir search; +allow rfs_access firmware_file:file r_file_perms; +allow rfs_access persist_file:dir search; +allow rfs_access persist_rfs_file:dir create_dir_perms; +allow rfs_access persist_rfs_file:file create_file_perms; + +allow rfs_access self:socket create_socket_perms_no_ioctl; diff --git a/sepolicy/vendor/rild.te b/sepolicy/vendor/rild.te new file mode 100644 index 00000000..15d084ce --- /dev/null +++ b/sepolicy/vendor/rild.te @@ -0,0 +1,27 @@ +binder_call(rild, per_mgr) + +vndbinder_use(rild) + +allow rild qmuxd_socket:dir w_dir_perms; +allow rild qmuxd_socket:sock_file create_file_perms; + +allow rild netmgrd_socket:dir search; +unix_socket_connect(rild, netmgrd, netmgrd) + +allow rild vendor_file:file { execute_no_trans lock }; + +allow rild per_mgr_service:service_manager find; + +add_hwservice(rild, vnd_ims_radio_hwservice) +add_hwservice(rild, vnd_qcrilhook_hwservice) + +allow rild self:socket ioctl; +allowxperm rild self:socket ioctl msm_sock_ipc_ioctls; +allow rild time_daemon:unix_stream_socket connectto; + +userdebug_or_eng(` + domain_auto_trans(rild, smlog_dump_exec, smlog_dump) +') + +allow rild radio_vendor_data_file:dir rw_dir_perms; +allow rild radio_vendor_data_file:file create_file_perms; diff --git a/sepolicy/vendor/rmt_storage.te b/sepolicy/vendor/rmt_storage.te new file mode 100644 index 00000000..b29be944 --- /dev/null +++ b/sepolicy/vendor/rmt_storage.te @@ -0,0 +1,25 @@ +type rmt_storage, domain; +type rmt_storage_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(rmt_storage) + +wakelock_use(rmt_storage) + +allow rmt_storage self:capability { net_bind_service setgid setpcap setuid }; + +allow rmt_storage modem_block_device:blk_file rw_file_perms; +allow rmt_storage uio_device:chr_file rw_file_perms; +allow rmt_storage block_device:dir search; + +allow rmt_storage sysfs_uio:dir r_dir_perms; +allow rmt_storage sysfs_uio:lnk_file r_file_perms; + +allow rmt_storage sysfs_rmtfs:dir search; +allow rmt_storage sysfs_rmtfs:file r_file_perms; +allow rmt_storage sysfs_rmtfs:dir search; + +allow rmt_storage debugfs_rmt_storage:dir search; +allow rmt_storage debugfs_rmt_storage:file w_file_perms; + +allow rmt_storage self:socket create_socket_perms; +allowxperm rmt_storage self:socket ioctl IPC_ROUTER_IOCTL_BIND_CONTROL_PORT; diff --git a/sepolicy/vendor/seapp_contexts b/sepolicy/vendor/seapp_contexts new file mode 100644 index 00000000..d13ddad6 --- /dev/null +++ b/sepolicy/vendor/seapp_contexts @@ -0,0 +1,30 @@ +user=system seinfo=platform name=com.google.SSRestartDetector domain=ssr_detector_app type=system_app_data_file +user=_app seinfo=platform name=com.android.nexuslogger domain=logger_app type=app_data_file levelFrom=all +user=_app seinfo=platform name=com.android.ramdump domain=ramdump_app type=app_data_file levelFrom=all +user=_app seinfo=platform name=com.google.mds domain=mds_app type=app_data_file levelFrom=all + +#TODO Remove user "system" when b/63588267 is resolved +user=system seinfo=platform name=com.qualcomm.telephony domain=qtelephony type=system_app_data_file + +#Add new domain for DataServices +#TODO Remove user "system" when b/38043081 is resolved +user=system seinfo=platform name=.dataservices domain=dataservice_app type=system_app_data_file + +# The default domain for tango_core / arcore process +user=_app seinfo=tango name=com.google.tango* domain=tango_core type=app_data_file levelFrom=user +user=_app seinfo=arcore name=com.google.ar.core* domain=tango_core type=app_data_file levelFrom=user + +# A fallback in case tango_core is missing something critical that untrusted_app provides +user=_app seinfo=tango name=com.google.tango:app domain=untrusted_app type=app_data_file levelFrom=user + +# Hardware Info Collection +user=_app seinfo=platform name=com.google.android.hardwareinfo domain=hardware_info_app type=app_data_file levelFrom=user + +# Use a custom domain for GoogleCamera, to allow for Hexagon DSP access +user=_app seinfo=google name=com.google.android.GoogleCamera domain=google_camera_app type=app_data_file levelFrom=user + +#Needed for time service apk +user=_app seinfo=platform name=com.qualcomm.timeservice domain=timeservice_app type=app_data_file + +# Domain for easelservice app +user=_app seinfo=easel name=com.google.android.imaging.easel.service domain=easelservice_app type=app_data_file levelFrom=user diff --git a/sepolicy/vendor/sensors.te b/sepolicy/vendor/sensors.te new file mode 100644 index 00000000..fb4cf3af --- /dev/null +++ b/sepolicy/vendor/sensors.te @@ -0,0 +1,32 @@ +# Policy for sensor daemon +type sensors, domain; +type sensors_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(sensors) + +allow sensors self:capability { + net_bind_service +}; + +allow sensors self:socket create_socket_perms; +allowxperm sensors self:socket ioctl msm_sock_ipc_ioctls; + +allow sensors persist_sensors_file:dir rw_dir_perms; +allow sensors persist_sensors_file:file create_file_perms; +allow sensors persist_file:dir { getattr search }; + +allow sensors sensors_vendor_data_file:dir create_dir_perms; +allow sensors sensors_vendor_data_file:file create_file_perms; + +allow sensors system_file:dir r_dir_perms; +allow sensors sensors_device:chr_file rw_file_perms; + +allow sensors sysfs_soc:dir r_dir_perms; +allow sensors sysfs_soc:file r_file_perms; + +r_dir_file(sensors, sysfs_msm_subsys) + +userdebug_or_eng(` + r_dir_file(sensors, sysfs_diag) + allow sensors sysfs_timestamp_switch:file r_file_perms; +') diff --git a/sepolicy/vendor/service_contexts b/sepolicy/vendor/service_contexts new file mode 100644 index 00000000..e69de29b diff --git a/sepolicy/vendor/shell.te b/sepolicy/vendor/shell.te new file mode 100644 index 00000000..7496c421 --- /dev/null +++ b/sepolicy/vendor/shell.te @@ -0,0 +1,2 @@ +# To allow non-root to find power_supply management info +allow shell sysfs_msm_subsys:dir search; diff --git a/sepolicy/vendor/smlog_dump.te b/sepolicy/vendor/smlog_dump.te new file mode 100644 index 00000000..bc8d94b4 --- /dev/null +++ b/sepolicy/vendor/smlog_dump.te @@ -0,0 +1,27 @@ +type smlog_dump_exec, exec_type, vendor_file_type, file_type; + +userdebug_or_eng(` + type smlog_dump, domain; + allow smlog_dump modem_dump_file:dir create_dir_perms; + allow smlog_dump modem_dump_file:file create_file_perms; + r_dir_file(smlog_dump, sysfs_uio) + r_dir_file(smlog_dump, sysfs_rmtfs) + + allow smlog_dump diag_device:chr_file rw_file_perms; + allow smlog_dump radio_vendor_data_file:file { append read write }; + allow smlog_dump rild:fd use; + allow smlog_dump rild:fifo_file { read write }; + allow smlog_dump rild:unix_stream_socket { read write }; + allow smlog_dump rild:netlink_generic_socket { read write }; + allow smlog_dump self:socket create_socket_perms; + allowxperm smlog_dump self:socket ioctl msm_sock_ipc_ioctls; + allow smlog_dump sysfs:dir r_dir_perms; + allow smlog_dump sysfs_msm_subsys:dir r_dir_perms; + allow smlog_dump sysfs_msm_subsys:file r_file_perms; + allow smlog_dump sysfs_msm_subsys:lnk_file read; + allow smlog_dump sysfs_soc:dir search; + allow smlog_dump sysfs_soc:file r_file_perms; + allow smlog_dump dumpstate:fd use; + allow smlog_dump hal_dumpstate_impl:fd use; + allow smlog_dump uio_device:chr_file rw_file_perms; +') diff --git a/sepolicy/vendor/ssr_detector.te b/sepolicy/vendor/ssr_detector.te new file mode 100644 index 00000000..27882d51 --- /dev/null +++ b/sepolicy/vendor/ssr_detector.te @@ -0,0 +1,20 @@ +# SSRestartDetector app +type ssr_detector_app, domain; + +app_domain(ssr_detector_app) + +userdebug_or_eng(` + allow ssr_detector_app ramdump_vendor_data_file:dir r_dir_perms; + allow ssr_detector_app ramdump_vendor_data_file:file r_file_perms; + get_prop(ssr_detector_app, ssr_prop) +') + +allow ssr_detector_app app_api_service:service_manager find; + +# ssr_detector app's data type is system_app_data_file. +allow ssr_detector_app system_app_data_file:dir create_dir_perms; +allow ssr_detector_app system_app_data_file:{ file lnk_file } create_file_perms; + +allow ssr_detector_app sysfs:lnk_file r_file_perms; + +r_dir_file(ssr_detector_app, sysfs_msm_subsys) diff --git a/sepolicy/vendor/ssr_diag.te b/sepolicy/vendor/ssr_diag.te new file mode 100644 index 00000000..45a3ee2b --- /dev/null +++ b/sepolicy/vendor/ssr_diag.te @@ -0,0 +1,4 @@ +type ssr_diag, domain; +type ssr_diag_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(ssr_diag); diff --git a/sepolicy/vendor/ssr_setup.te b/sepolicy/vendor/ssr_setup.te new file mode 100644 index 00000000..9aa54ee7 --- /dev/null +++ b/sepolicy/vendor/ssr_setup.te @@ -0,0 +1,10 @@ +type ssr_setup, domain; +type ssr_setup_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(ssr_setup); + +userdebug_or_eng(` +allow ssr_setup sysfs_msm_subsys:dir r_dir_perms; +allow ssr_setup sysfs_msm_subsys:file rw_file_perms; +allow ssr_setup sysfs_msm_subsys:lnk_file read; +') diff --git a/sepolicy/vendor/subsystem_ramdump.te b/sepolicy/vendor/subsystem_ramdump.te new file mode 100644 index 00000000..60a0a6d7 --- /dev/null +++ b/sepolicy/vendor/subsystem_ramdump.te @@ -0,0 +1,17 @@ +type subsystem_ramdump_exec, exec_type, vendor_file_type, file_type; + +userdebug_or_eng(` + type subsystem_ramdump, domain; + + init_daemon_domain(subsystem_ramdump); + + allow subsystem_ramdump device:dir r_dir_perms; + allow subsystem_ramdump ramdump_device:chr_file r_file_perms; + + r_dir_file(subsystem_ramdump, sysfs_type); + + allow subsystem_ramdump ramdump_vendor_data_file:dir rw_dir_perms; + allow subsystem_ramdump ramdump_vendor_data_file:file create_file_perms; + + set_prop(subsystem_ramdump, ssr_prop); +') diff --git a/sepolicy/vendor/surfaceflinger.te b/sepolicy/vendor/surfaceflinger.te new file mode 100644 index 00000000..fee5e123 --- /dev/null +++ b/sepolicy/vendor/surfaceflinger.te @@ -0,0 +1,3 @@ +dontaudit surfaceflinger firmware_file:dir search; +dontaudit surfaceflinger kernel:system module_request; +allow surfaceflinger debugfs_ion:dir search; diff --git a/sepolicy/vendor/system_app.te b/sepolicy/vendor/system_app.te new file mode 100644 index 00000000..d5f20bc3 --- /dev/null +++ b/sepolicy/vendor/system_app.te @@ -0,0 +1,7 @@ +# Needed by Settings app's TelephonyMonitorPreferenceController, available only on a subset of +# userdebug and eng devices +userdebug_or_eng(`set_prop(system_app, tel_mon_prop)') + +# read regulatory info +allow system_app elabel_data_file:dir r_dir_perms; +allow system_app elabel_data_file:file r_file_perms; diff --git a/sepolicy/vendor/system_server.te b/sepolicy/vendor/system_server.te new file mode 100644 index 00000000..719d2a1f --- /dev/null +++ b/sepolicy/vendor/system_server.te @@ -0,0 +1,22 @@ +allow system_server self:socket ioctl; +allowxperm system_server self:socket ioctl msm_sock_ipc_ioctls; + +binder_call(system_server, hal_camera_default) + +allow system_server persist_file:dir search; +allow system_server persist_sensors_file:dir search; +allow system_server persist_sensors_file:file r_file_perms; +allow system_server location_data_file:dir create_dir_perms; +allow system_server location_data_file:file create_file_perms; +allow system_server wlan_device:chr_file rw_file_perms; + +# input files +r_dir_file(system_server, idc_file) +r_dir_file(system_server, keylayout_file) + +# TODO(b/30675296): Remove following dontaudit's upon resolution of this bug +# The timerslack_ns denials spam the system really horribly +dontaudit system_server audioserver:file write; +dontaudit system_server untrusted_app:file write; +dontaudit system_server hal_audio_default:file write; +dontaudit system_server appdomain:file write; diff --git a/sepolicy/vendor/tango_core.te b/sepolicy/vendor/tango_core.te new file mode 100644 index 00000000..9be9dffc --- /dev/null +++ b/sepolicy/vendor/tango_core.te @@ -0,0 +1,20 @@ +type tango_core, domain; + +app_domain(tango_core) + +allow tango_core persist_file:dir search; +allow tango_core persist_sensors_file:dir search; +allow tango_core persist_sensors_file:file { getattr open read }; +allow tango_core shell_data_file:dir search; +allow tango_core shell_data_file:file { open read }; +allow tango_core qdsp_device:chr_file { ioctl open read }; +allow tango_core vendor_file:file { getattr open read }; + +allow tango_core app_api_service:service_manager find; +allow tango_core surfaceflinger_service:service_manager find; +allow tango_core cameraserver_service:service_manager find; +allow tango_core audioserver_service:service_manager find; +allow tango_core mediaserver_service:service_manager find; + +# Allow access to necessary vendor libraries to execute Hexagon code +allow tango_core hexagon_halide_file:file { execute read open getattr }; diff --git a/sepolicy/vendor/tee.te b/sepolicy/vendor/tee.te new file mode 100644 index 00000000..0ddf90ff --- /dev/null +++ b/sepolicy/vendor/tee.te @@ -0,0 +1,24 @@ +allow tee self:capability { chown setgid setuid sys_admin sys_rawio }; + +allow tee device:dir r_dir_perms; + +set_prop(tee, tee_listener_prop) +set_prop(tee, keymaster_prop) + +allow tee firmware_file:dir search; +allow tee block_device:dir { getattr search }; +allow tee ssd_block_device:blk_file rw_file_perms; +allow tee sg_device:chr_file { rw_file_perms setattr }; + +allow tee persist_file:dir r_dir_perms; +allow tee persist_drm_file:dir create_dir_perms; +allow tee persist_drm_file:file create_file_perms; +allow tee persist_data_file:dir create_dir_perms; +allow tee persist_data_file:file create_file_perms; + +allow tee system_data_file:dir r_dir_perms; + +allow tee fingerprintd_data_file:dir rw_dir_perms; +allow tee fingerprintd_data_file:file create_file_perms; + +allow tee time_daemon:unix_stream_socket connectto; diff --git a/sepolicy/vendor/thermal-engine.te b/sepolicy/vendor/thermal-engine.te new file mode 100644 index 00000000..8720021e --- /dev/null +++ b/sepolicy/vendor/thermal-engine.te @@ -0,0 +1,30 @@ +type thermal-engine, domain; +type thermal-engine_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(thermal-engine) + +allow thermal-engine self:capability2 block_suspend; + +# to read /sys/devices +allow thermal-engine sysfs:dir r_dir_perms; + +allow thermal-engine sysfs_msm_subsys:dir r_dir_perms; +allow thermal-engine sysfs_msm_subsys:file rw_file_perms; +allow thermal-engine sysfs_soc:dir search; +allow thermal-engine sysfs_soc:file r_file_perms; +allow thermal-engine sysfs_thermal:dir r_dir_perms; +allow thermal-engine sysfs_thermal:file rw_file_perms; +allow thermal-engine sysfs_rmtfs:dir search; +allow thermal-engine sysfs_rmtfs:file r_file_perms; + +allow thermal-engine audio_device:chr_file rw_file_perms; + +r_dir_file(thermal-engine, sysfs_leds) +r_dir_file(thermal-engine, sysfs_msm_subsys) +r_dir_file(thermal-engine, sysfs_uio) + +allow thermal-engine self:socket create_socket_perms; +allowxperm thermal-engine self:socket ioctl msm_sock_ipc_ioctls; + +# reboot/shutdown for thermal limits exceeded +set_prop(thermal-engine, powerctl_prop) diff --git a/sepolicy/vendor/time_daemon.te b/sepolicy/vendor/time_daemon.te new file mode 100644 index 00000000..82a62e2f --- /dev/null +++ b/sepolicy/vendor/time_daemon.te @@ -0,0 +1,25 @@ +type time_daemon, domain; +type time_daemon_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(time_daemon) + +allow time_daemon self:capability { setgid setuid sys_time }; + +allow time_daemon rtc_device:chr_file r_file_perms; + +r_dir_file(time_daemon, sysfs_msm_subsys) + +allow time_daemon sysfs_soc:dir search; +allow time_daemon sysfs_soc:file r_file_perms; + +# Set sys.time.set property +set_prop(time_daemon, sys_time_prop); + +allow time_daemon persist_time_file:dir w_dir_perms; +allow time_daemon persist_time_file:file create_file_perms; +allow time_daemon persist_time_file:dir search; + +allow time_daemon persist_file:dir search; + +allow time_daemon self:socket create_socket_perms; +allowxperm time_daemon self:socket ioctl msm_sock_ipc_ioctls; diff --git a/sepolicy/vendor/timeservice_app.te b/sepolicy/vendor/timeservice_app.te new file mode 100644 index 00000000..c047793c --- /dev/null +++ b/sepolicy/vendor/timeservice_app.te @@ -0,0 +1,6 @@ +type timeservice_app, domain; +app_domain(timeservice_app); + +allow timeservice_app app_api_service:service_manager find; +allow timeservice_app app_data_file:dir { search getattr }; +allow timeservice_app time_daemon:unix_stream_socket connectto; diff --git a/sepolicy/vendor/ueventd.te b/sepolicy/vendor/ueventd.te new file mode 100644 index 00000000..dce69248 --- /dev/null +++ b/sepolicy/vendor/ueventd.te @@ -0,0 +1,5 @@ +allow ueventd firmware_file:dir search; +allow ueventd firmware_file:file r_file_perms; +allow ueventd tmpfs:blk_file getattr; +allow ueventd persist_file:dir search; +allow ueventd persist_file:file r_file_perms; diff --git a/sepolicy/vendor/update_engine_common.te b/sepolicy/vendor/update_engine_common.te new file mode 100644 index 00000000..e4fab515 --- /dev/null +++ b/sepolicy/vendor/update_engine_common.te @@ -0,0 +1,8 @@ +# Allow update_engine and update_engine_sideload (recovery) read/write on the +# device-specific partitions it should update. +allow update_engine_common xbl_block_device:blk_file rw_file_perms; +allow update_engine_common ab_block_device:blk_file rw_file_perms; +allow update_engine_common modem_block_device:blk_file rw_file_perms; + +allow update_engine_common postinstall_mnt_dir:dir r_dir_perms; +allow update_engine_common tmpfs:lnk_file r_file_perms; diff --git a/sepolicy/vendor/update_verifier.te b/sepolicy/vendor/update_verifier.te new file mode 100644 index 00000000..cdc304f7 --- /dev/null +++ b/sepolicy/vendor/update_verifier.te @@ -0,0 +1,4 @@ +# update_verifier reads /sys/block/dm-X/dm/name to find the device-mapper +# entries for system and vendor partitions. +allow update_verifier sysfs:file r_file_perms; +allow update_verifier sysfs:dir r_dir_perms; diff --git a/sepolicy/vendor/vndservice.te b/sepolicy/vendor/vndservice.te new file mode 100644 index 00000000..44c45ca5 --- /dev/null +++ b/sepolicy/vendor/vndservice.te @@ -0,0 +1,2 @@ +type qdisplay_service, vndservice_manager_type; +type per_mgr_service, vndservice_manager_type; diff --git a/sepolicy/vendor/vndservice_contexts b/sepolicy/vendor/vndservice_contexts new file mode 100644 index 00000000..1db4aa0c --- /dev/null +++ b/sepolicy/vendor/vndservice_contexts @@ -0,0 +1,2 @@ +display.qservice u:object_r:qdisplay_service:s0 +vendor.qcom.PeripheralManager u:object_r:per_mgr_service:s0 diff --git a/sepolicy/vendor/vold.te b/sepolicy/vendor/vold.te new file mode 100644 index 00000000..80edf33c --- /dev/null +++ b/sepolicy/vendor/vold.te @@ -0,0 +1,8 @@ +get_prop(vold, tee_listener_prop) + +allow vold sysfs_scsi_devices_0000:file write; + +allow vold persist_file:dir r_dir_perms; + +# generated by proc scan, unnecessary +dontaudit vold proc_irq:dir read; diff --git a/sepolicy/vendor/wcnss_filter.te b/sepolicy/vendor/wcnss_filter.te new file mode 100644 index 00000000..c7c72c77 --- /dev/null +++ b/sepolicy/vendor/wcnss_filter.te @@ -0,0 +1,22 @@ +type wcnss_filter, domain; +type wcnss_filter_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(wcnss_filter) + +set_prop(wcnss_filter, wc_prop) +set_prop(wcnss_filter, bluetooth_prop) + +allow wcnss_filter hci_attach_dev:chr_file rw_file_perms; + +userdebug_or_eng(` + allow wcnss_filter diag_device:chr_file rw_file_perms; + allow wcnss_filter ramdump_vendor_data_file:dir create_dir_perms; + allow wcnss_filter ramdump_vendor_data_file:file create_file_perms; + r_dir_file(wcnss_filter, debugfs_ipc) +') + +#allow wakelock +wakelock_use(wcnss_filter) + +# allow wcnss to set threads to RT priority +allow wcnss_filter self:capability sys_nice; diff --git a/sepolicy/vendor/wcnss_service.te b/sepolicy/vendor/wcnss_service.te new file mode 100644 index 00000000..15a3cac2 --- /dev/null +++ b/sepolicy/vendor/wcnss_service.te @@ -0,0 +1,38 @@ +type wcnss_service, domain; +type wcnss_service_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(wcnss_service) +net_domain(wcnss_service) + +vndbinder_use(wcnss_service) +binder_call(wcnss_service, per_mgr) + +allow wcnss_service per_mgr_service:service_manager find; + +allow wcnss_service vendor_shell_exec:file rx_file_perms; +allow wcnss_service vendor_toolbox_exec:file rx_file_perms; + +allow wcnss_service proc_net:file w_file_perms; + +allow wcnss_service self:socket create_socket_perms; +allowxperm wcnss_service self:socket ioctl msm_sock_ipc_ioctls; +allowxperm wcnss_service self:udp_socket ioctl { SIOCIWFIRSTPRIV_05 SIOCSIFFLAGS }; +allow wcnss_service self:netlink_generic_socket create_socket_perms_no_ioctl; +allow wcnss_service self:netlink_socket create_socket_perms_no_ioctl; + +allow wcnss_service cnss_vendor_data_file:dir create_dir_perms; +allow wcnss_service cnss_vendor_data_file:file create_file_perms; + +allow wcnss_service proc_net:file getattr; + +r_dir_file(wcnss_service, sysfs_msm_subsys) +# pkt logging for cnss_diag +userdebug_or_eng(` + r_dir_file(wcnss_service, proc_wifi_dbg) +') + +allow wcnss_service sysfs_soc:dir search; +allow wcnss_service sysfs_soc:file r_file_perms; + +# request_firmware causes a denial for /firmware. It can be safely ignored +dontaudit wcnss_service firmware_file:dir search; diff --git a/sepolicy/verizon/keys.conf b/sepolicy/verizon/keys.conf new file mode 100644 index 00000000..bc5298e9 --- /dev/null +++ b/sepolicy/verizon/keys.conf @@ -0,0 +1,2 @@ +[@VERIZON] +ALL : device/google/wahoo/sepolicy/verizon/verizon.x509.pem diff --git a/sepolicy/verizon/mac_permissions.xml b/sepolicy/verizon/mac_permissions.xml new file mode 100644 index 00000000..770f40a6 --- /dev/null +++ b/sepolicy/verizon/mac_permissions.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/sepolicy/verizon/obdm_app.te b/sepolicy/verizon/obdm_app.te new file mode 100644 index 00000000..c8abf8b0 --- /dev/null +++ b/sepolicy/verizon/obdm_app.te @@ -0,0 +1,19 @@ +type obdm_app, domain, coredomain; + +app_domain(obdm_app) +net_domain(obdm_app) + +r_dir_file(obdm_app, proc) + +# talk to /dev/diag +allow obdm_app diag_device:chr_file rw_file_perms; + +allow obdm_app app_api_service:service_manager find; +allow obdm_app radio_service:service_manager find; +allow obdm_app surfaceflinger_service:service_manager find; + +allow obdm_app self:socket create_socket_perms; +allowxperm obdm_app self:socket ioctl { 0x0000c302 0x0000c304 }; + +allow obdm_app sysfs:dir r_dir_perms; +r_dir_file(obdm_app, sysfs_msm_subsys) diff --git a/sepolicy/verizon/seapp_contexts b/sepolicy/verizon/seapp_contexts new file mode 100644 index 00000000..951fef36 --- /dev/null +++ b/sepolicy/verizon/seapp_contexts @@ -0,0 +1,3 @@ +# Verizon for OBDM tool +user=_app seinfo=verizon name=com.verizon.obdm domain=obdm_app type=app_data_file levelFrom=all +user=_app seinfo=verizon name=com.verizon.obdm:background domain=obdm_app type=app_data_file levelFrom=all diff --git a/sepolicy/verizon/verizon.x509.pem b/sepolicy/verizon/verizon.x509.pem new file mode 100644 index 00000000..a06efc24 --- /dev/null +++ b/sepolicy/verizon/verizon.x509.pem @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDczCCAlugAwIBAgIEMzx+mzANBgkqhkiG9w0BAQsFADBpMQswCQYDVQQGEwJV +UzELMAkGA1UECBMCTkoxDzANBgNVBAcTBldhcnJlbjEZMBcGA1UEChMQVmVyaXpv +biBXaXJlbGVzczELMAkGA1UECxMCRFQxFDASBgNVBAMTC0RNQVQgQ2xpZW50MCAX +DTE2MTAxMTIxMzgzN1oYDzIxMTYwOTE3MjEzODM3WjBpMQswCQYDVQQGEwJVUzEL +MAkGA1UECBMCTkoxDzANBgNVBAcTBldhcnJlbjEZMBcGA1UEChMQVmVyaXpvbiBX +aXJlbGVzczELMAkGA1UECxMCRFQxFDASBgNVBAMTC0RNQVQgQ2xpZW50MIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr8y6pz1KPVolO8wj02oWSzuLZHWg +HuatQ5RlbXFBqS9/ScPSw3t/Yt+jg2++VUG726qL7ydx8g3AzMktWHNkdhg6j8Dz +fkEMa/oqcr+VOAQyPw4X0xkUs6ICsEuULRaAwY1NwSVCrTuSlxzlmumbTCg+tp4Y +m2FXEct8VNayJcrLnTwl/IiYmFLNLLiZPrwqbSkMVfYbfxws7c2lVZI4qhIC7WWA +HW5PyhO3Vdhjoj4E1QzkyabtB6el3kfE0xIta1IHV2iJdoAlESjaj3UT1i9d+Twt +7DCsu/ZevIl/g/vwbYi2uqQuSs/a3/qeUcawvcQZR4vWHo/Gx8PyiTZHJwIDAQAB +oyEwHzAdBgNVHQ4EFgQUMytyC5Cq0A2kE99nyokx0kTzVH0wDQYJKoZIhvcNAQEL +BQADggEBAE8AexGFmzTp0ZGgRaiv80ONc5PVA12T7h2F5ZN1Yqg99yhpoS6kBIsw +EG149nIcgOnSYk7ukTcjfsKcbFaB7tV1dw6SUqjmsqLpzVxGI32/DVdIorfxwaHZ +dKjvlC9Yh1uDEipKuEzR+nXRnzMdMzEv6KOXeIXJxTHY/f538oPVuiXksdnjllmV +xL1waQrZzdS15hfeBpGlC0WXk9wMiBbJNfEqQ5/J0EaFu+zPk8R3VLQ8WvKcXPyK +30vZ56McQuwz2MT/gQxnR84LRXUhLGoWOr0MYFzOwhTso2vhIlEysGX+HtkEJh3L +Hc+p+viW7lz17QqvZmOxjb6atkRpOVY= +-----END CERTIFICATE----- diff --git a/sound_trigger_mixer_paths_wcd9340.xml b/sound_trigger_mixer_paths_wcd9340.xml new file mode 100644 index 00000000..607a052a --- /dev/null +++ b/sound_trigger_mixer_paths_wcd9340.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sound_trigger_platform_info.xml b/sound_trigger_platform_info.xml new file mode 100644 index 00000000..30944a80 --- /dev/null +++ b/sound_trigger_platform_info.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spn-conf.xml b/spn-conf.xml new file mode 100644 index 00000000..ec9d8685 --- /dev/null +++ b/spn-conf.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/system.prop b/system.prop new file mode 100644 index 00000000..c13ac420 --- /dev/null +++ b/system.prop @@ -0,0 +1,97 @@ + +persist.rild.nitz_plmn= +persist.rild.nitz_long_ons_0= +persist.rild.nitz_long_ons_1= +persist.rild.nitz_long_ons_2= +persist.rild.nitz_long_ons_3= +persist.rild.nitz_short_ons_0= +persist.rild.nitz_short_ons_1= +persist.rild.nitz_short_ons_2= +persist.rild.nitz_short_ons_3= +DEVICE_PROVISIONED=1 + +# Set network mode to Global by default and no DSDS/DSDA +ro.telephony.default_network=10 + +debug.sf.hw=1 +debug.gralloc.enable_fb_ubwc=1 + +# system props for the cne module +persist.cne.feature=1 + +# system props for the MM modules +media.stagefright.enable-player=true +media.stagefright.enable-http=true +media.stagefright.enable-aac=true +media.stagefright.enable-qcp=true +media.stagefright.enable-scan=true +mmp.enable.3g2=true +media.aac_51_output_enabled=true +mm.enable.smoothstreaming=true +#13631487 is decimal sum of supported codecs in AAL +#codecs:(PARSER_)AAC AC3 AMR_NB AMR_WB ASF AVI DTS FLV 3GP 3G2 MKV MP2PS MP2TS MP3 OGG QCP WAV FLAC AIFF APE DSD +mm.enable.qcom_parser=13631487 +persist.mm.enable.prefetch=true + +# Additional buffers shared between Camera and Video +vendor.vidc.enc.dcvs.extra-buff-count=2 +vendor.vidc.enc.disable.pq=1 + +# system props for the data netmgrd +persist.data.netmgrd.qos.enable=true +persist.data.mode=concurrent + +# system props for time-services +persist.timed.enable=true + +# System prop to turn on CdmaLTEPhone always +telephony.lteOnCdmaDevice=1 + +# Simulate sdcard on /data/media +persist.fuse_sdcard=true + +# settings to enable Device Orientation Sensors +ro.qti.sensors.dev_ori=true + +# settings to disable sensors not needed +# all secondary wakeup +ro.qti.sensors.wu=false +# unused algorithms +ro.qti.sdk.sensors.gestures=false +ro.qti.sensors.amd=false +ro.qti.sensors.cmc=false +ro.qti.sensors.facing=false +ro.qti.sensors.pedometer=false +ro.qti.sensors.rmd=false +ro.qti.sensors.scrn_ortn=false +# use SMGR supplied verison +ro.qti.sensors.step_counter=false +ro.qti.sensors.step_detector=false + +#system prop for RmNet Data +persist.rmnet.data.enable=true +persist.data.wda.enable=true +persist.data.df.dl_mode=5 +persist.data.df.ul_mode=5 +persist.data.df.agg.dl_pkt=10 +persist.data.df.agg.dl_size=4096 +persist.data.df.mux_count=8 +persist.data.df.iwlan_mux=9 +persist.data.df.dev_name=rmnet_usb0 + +# +## system props for the data modules +# +#ro.use_data_netmgrd=true +persist.data.netmgrd.qos.enable=true +persist.data.mode=concurrent + +#system prop for A4WP profile support +ro.bluetooth.a4wp=false + +#system prop for wipower support +ro.bluetooth.emb_wp_mode=false +ro.bluetooth.wipower=false + +# Property for loading BDA from bdaddress module in kernel +ro.bt.bdaddr_path=/sys/module/bdaddress/parameters/bdaddress diff --git a/tango_permissions.xml b/tango_permissions.xml new file mode 100644 index 00000000..e7b4fcc0 --- /dev/null +++ b/tango_permissions.xml @@ -0,0 +1,5 @@ + + + + diff --git a/thermal/Android.mk b/thermal/Android.mk new file mode 100644 index 00000000..a725c83e --- /dev/null +++ b/thermal/Android.mk @@ -0,0 +1,37 @@ +# +# Copyright 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_PROPRIETARY_MODULE := true +LOCAL_MODULE_OWNER := qcom +LOCAL_MODULE_TAGS := optional + +LOCAL_MODULE := android.hardware.thermal@1.0-service.wahoo +LOCAL_INIT_RC := android.hardware.thermal@1.0-service.wahoo.rc +LOCAL_SRC_FILES := service.cpp Thermal.cpp thermal-helper.cpp + +LOCAL_SHARED_LIBRARIES := \ + libhidlbase \ + libhidltransport \ + libutils \ + libbase \ + android.hardware.thermal@1.0 \ + +include $(BUILD_EXECUTABLE) diff --git a/thermal/Thermal.cpp b/thermal/Thermal.cpp new file mode 100644 index 00000000..5bedddee --- /dev/null +++ b/thermal/Thermal.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include + +#include "Thermal.h" +#include "thermal-helper.h" + +namespace android { +namespace hardware { +namespace thermal { +namespace V1_0 { +namespace implementation { + +Thermal::Thermal() : enabled(initThermal()) {} + +// Methods from ::android::hardware::thermal::V1_0::IThermal follow. +Return Thermal::getTemperatures(getTemperatures_cb _hidl_cb) { + ThermalStatus status; + status.code = ThermalStatusCode::SUCCESS; + hidl_vec temperatures; + temperatures.resize(kTemperatureNum); + + if (!enabled) { + status.code = ThermalStatusCode::FAILURE; + status.debugMessage = "Unsupported hardware"; + _hidl_cb(status, temperatures); + return Void(); + } + + ssize_t ret = fillTemperatures(&temperatures); + if (ret < 0) { + status.code = ThermalStatusCode::FAILURE; + status.debugMessage = strerror(-ret); + } + _hidl_cb(status, temperatures); + + for (auto& t : temperatures) { + LOG(DEBUG) << "getTemperatures " + << " Type: " << static_cast(t.type) + << " Name: " << t.name + << " CurrentValue: " << t.currentValue + << " ThrottlingThreshold: " << t.throttlingThreshold + << " ShutdownThreshold: " << t.shutdownThreshold + << " VrThrottlingThreshold: " << t.vrThrottlingThreshold; + } + + return Void(); +} + +Return Thermal::getCpuUsages(getCpuUsages_cb _hidl_cb) { + ThermalStatus status; + status.code = ThermalStatusCode::SUCCESS; + hidl_vec cpuUsages; + cpuUsages.resize(kCpuNum); + + if (!enabled) { + status.code = ThermalStatusCode::FAILURE; + status.debugMessage = "Unsupported hardware"; + _hidl_cb(status, cpuUsages); + return Void(); + } + + ssize_t ret = fillCpuUsages(&cpuUsages); + if (ret < 0) { + status.code = ThermalStatusCode::FAILURE; + status.debugMessage = strerror(-ret); + } + + for (auto& u : cpuUsages) { + LOG(DEBUG) << "getCpuUsages " + << " Name: " << u.name + << " Active: " << u.active + << " Total: " << u.total + << " IsOnline: " << u.isOnline; + } + + _hidl_cb(status, cpuUsages); + return Void(); +} + +Return Thermal::getCoolingDevices(getCoolingDevices_cb _hidl_cb) { + ThermalStatus status; + status.code = ThermalStatusCode::SUCCESS; + hidl_vec coolingDevices; + + if (!enabled) { + status.code = ThermalStatusCode::FAILURE; + status.debugMessage = "Unsupported hardware"; + _hidl_cb(status, coolingDevices); + return Void(); + } + + LOG(DEBUG) << "No Cooling Device"; + _hidl_cb(status, coolingDevices); + return Void(); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace thermal +} // namespace hardware +} // namespace android diff --git a/thermal/Thermal.h b/thermal/Thermal.h new file mode 100644 index 00000000..f9ce7ed8 --- /dev/null +++ b/thermal/Thermal.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ANDROID_HARDWARE_THERMAL_V1_0_WAHOO_THERMAL_H +#define ANDROID_HARDWARE_THERMAL_V1_0_WAHOO_THERMAL_H + +#include +#include +#include + +namespace android { +namespace hardware { +namespace thermal { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::thermal::V1_0::CoolingDevice; +using ::android::hardware::thermal::V1_0::CpuUsage; +using ::android::hardware::thermal::V1_0::IThermal; +using ::android::hardware::thermal::V1_0::Temperature; +using ::android::hardware::thermal::V1_0::ThermalStatus; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::hardware::hidl_vec; +using ::android::hardware::hidl_string; +using ::android::sp; + +struct Thermal : public IThermal { + Thermal(); + // Methods from ::android::hardware::thermal::V1_0::IThermal follow. + Return getTemperatures(getTemperatures_cb _hidl_cb) override; + Return getCpuUsages(getCpuUsages_cb _hidl_cb) override; + Return getCoolingDevices(getCoolingDevices_cb _hidl_cb) override; + + private: + bool enabled; +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace thermal +} // namespace hardware +} // namespace android + +#endif // ANDROID_HARDWARE_THERMAL_V1_0_WAHOO_THERMAL_H diff --git a/thermal/android.hardware.thermal@1.0-service.wahoo.rc b/thermal/android.hardware.thermal@1.0-service.wahoo.rc new file mode 100644 index 00000000..e522cb10 --- /dev/null +++ b/thermal/android.hardware.thermal@1.0-service.wahoo.rc @@ -0,0 +1,4 @@ +service thermal-hal-1-0 /vendor/bin/hw/android.hardware.thermal@1.0-service.wahoo + class hal + user nobody + group nobody diff --git a/thermal/service.cpp b/thermal/service.cpp new file mode 100644 index 00000000..d41953b6 --- /dev/null +++ b/thermal/service.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "Thermal.h" + +using android::sp; +using android::status_t; +using android::OK; + +// libhwbinder: +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; + +// Generated HIDL files +using android::hardware::thermal::V1_0::IThermal; +using android::hardware::thermal::V1_0::implementation::Thermal; + +int main() { + + status_t status; + android::sp service = nullptr; + + LOG(INFO) << "Thermal HAL Service 1.0 is starting"; + + service = new Thermal(); + if (service == nullptr) { + LOG(ERROR) << "Can not create an instance of Thermal HAL Iface, exiting"; + + goto shutdown; + } + + configureRpcThreadpool(1, true /*callerWillJoin*/); + + status = service->registerAsService(); + if (status != OK) { + LOG(ERROR) << "Could not register service for Thermal HAL Iface (" << status << ")"; + goto shutdown; + } + + LOG(INFO) << "Thermal Service is ready"; + joinRpcThreadpool(); + // Should not pass this line + +shutdown: + // In normal operation, we don't expect the thread pool to exit + LOG(ERROR) << "Thermal Service is shutting down"; + return 1; +} diff --git a/thermal/thermal-helper.cpp b/thermal/thermal-helper.cpp new file mode 100644 index 00000000..f5f146cf --- /dev/null +++ b/thermal/thermal-helper.cpp @@ -0,0 +1,293 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "thermal-helper.h" + +namespace android { +namespace hardware { +namespace thermal { +namespace V1_0 { +namespace implementation { + +static unsigned int gSkinSensorNum; +static unsigned int gTsensOffset; +static unsigned int gSkinThrottlingThreshold; +static unsigned int gSkinShutdownThreshold; +static unsigned int gVrThrottledBelowMin; + +/** + * Initialization constants based on platform + * + * @return true on success or false on error. + */ +bool initThermal() { + std::string hardware = android::base::GetProperty("ro.hardware", ""); + if (hardware == "walleye") { + LOG(ERROR) << "Initialization on Walleye"; + gSkinSensorNum = kWalleyeSkinSensorNum; + gTsensOffset = kWalleyeTsensOffset; + gSkinThrottlingThreshold = kWalleyeSkinThrottlingThreshold; + gSkinShutdownThreshold = kWalleyeSkinShutdownThreshold; + gVrThrottledBelowMin = kWalleyeVrThrottledBelowMin; + } else if (hardware == "taimen") { + std::string rev = android::base::GetProperty("ro.revision", ""); + if (rev == "rev_a" || rev == "rev_b") { + LOG(ERROR) << "Initialization on Taimen pre revision C"; + gSkinSensorNum = kTaimenRabSkinSensorNum; + gTsensOffset = kTaimenRabTsensOffset; + gSkinThrottlingThreshold = kTaimenRabSkinThrottlingThreshold; + gSkinShutdownThreshold = kTaimenRabSkinShutdownThreshold; + gVrThrottledBelowMin = kTaimenRabVrThrottledBelowMin; + } else { + LOG(ERROR) << "Initialization on Taimen revision C and later"; + gSkinSensorNum = kTaimenRcSkinSensorNum; + gTsensOffset = kTaimenRcTsensOffset; + gSkinThrottlingThreshold = kTaimenRcSkinThrottlingThreshold; + gSkinShutdownThreshold = kTaimenRcSkinShutdownThreshold; + gVrThrottledBelowMin = kTaimenRcVrThrottledBelowMin; + } + } else { + LOG(ERROR) << "Unsupported hardware: " << hardware; + return false; + } + return true; +} + +/** + * Reads device temperature. + * + * @param sensor_num Number of sensor file with temperature. + * @param type Device temperature type. + * @param name Device temperature name. + * @param mult Multiplier used to translate temperature to Celsius. + * @param throttling_threshold Throttling threshold for the temperature. + * @param shutdown_threshold Shutdown threshold for the temperature. + * @param out Pointer to temperature_t structure that will be filled with current + * values. + * + * @return 0 on success or negative value -errno on error. + */ +static ssize_t readTemperature(int sensor_num, TemperatureType type, const char *name, float mult, + float throttling_threshold, float shutdown_threshold, + float vr_throttling_threshold, Temperature *out) { + FILE *file; + char file_name[PATH_MAX]; + float temp; + + sprintf(file_name, kTemperatureFileFormat, sensor_num); + file = fopen(file_name, "r"); + if (file == NULL) { + PLOG(ERROR) << "readTemperature: failed to open file (" << file_name << ")"; + return -errno; + } + if (1 != fscanf(file, "%f", &temp)) { + fclose(file); + PLOG(ERROR) << "readTemperature: failed to read a float"; + return errno ? -errno : -EIO; + } + + fclose(file); + + (*out).type = type; + (*out).name = name; + (*out).currentValue = temp * mult; + (*out).throttlingThreshold = throttling_threshold; + (*out).shutdownThreshold = shutdown_threshold; + (*out).vrThrottlingThreshold = vr_throttling_threshold; + + LOG(DEBUG) << android::base::StringPrintf( + "readTemperature: %d, %d, %s, %g, %g, %g, %g", + sensor_num, type, name, temp * mult, throttling_threshold, + shutdown_threshold, vr_throttling_threshold); + + return 0; +} + +static ssize_t getCpuTemperatures(hidl_vec *temperatures) { + size_t cpu; + + for (cpu = 0; cpu < kCpuNum; cpu++) { + if (cpu >= temperatures->size()) { + break; + } + // temperature in decidegrees Celsius. + ssize_t result = readTemperature(kCpuTsensOffset[cpu] + gTsensOffset, TemperatureType::CPU, kCpuLabel[cpu], + 0.1, kCpuThrottlingThreshold, kCpuShutdownThreshold, kCpuThrottlingThreshold, + &(*temperatures)[cpu]); + if (result != 0) { + return result; + } + } + return cpu; +} + +ssize_t fillTemperatures(hidl_vec *temperatures) { + ssize_t result = 0; + size_t current_index = 0; + + if (temperatures == NULL || temperatures->size() < kTemperatureNum) { + LOG(ERROR) << "fillTemperatures: incorrect buffer"; + return -EINVAL; + } + + result = getCpuTemperatures(temperatures); + if (result < 0) { + return result; + } + current_index += result; + + // GPU temperature. + if (current_index < temperatures->size()) { + // temperature in decidegrees Celsius. + result = readTemperature(gTsensOffset + kGpuTsensOffset, TemperatureType::GPU, kGpuLabel, 0.1, + NAN, NAN, NAN, &(*temperatures)[current_index]); + if (result < 0) { + return result; + } + current_index++; + } + + // Battery temperature. + if (current_index < temperatures->size()) { + // battery: temperature in millidegrees Celsius. + result = readTemperature(kBatterySensorNum, TemperatureType::BATTERY, kBatteryLabel, + 0.001, NAN, kBatteryShutdownThreshold, NAN, + &(*temperatures)[current_index]); + if (result < 0) { + return result; + } + current_index++; + } + + // Skin temperature. + if (current_index < temperatures->size()) { + // temperature in Celsius. + result = readTemperature(gSkinSensorNum, TemperatureType::SKIN, kSkinLabel, 1., + gSkinThrottlingThreshold, gSkinShutdownThreshold, gVrThrottledBelowMin, + &(*temperatures)[current_index]); + if (result < 0) { + return result; + } + current_index++; + } + return kTemperatureNum; +} + +ssize_t fillCpuUsages(hidl_vec *cpuUsages) { + int vals, cpu_num, online; + ssize_t read; + uint64_t user, nice, system, idle, active, total; + char *line = NULL; + size_t len = 0; + size_t size = 0; + char file_name[PATH_MAX]; + FILE *file; + FILE *cpu_file; + + if (cpuUsages == NULL || cpuUsages->size() < kCpuNum ) { + LOG(ERROR) << "fillCpuUsages: incorrect buffer"; + return -EINVAL; + } + + file = fopen(kCpuUsageFile, "r"); + if (file == NULL) { + PLOG(ERROR) << "fillCpuUsages: failed to open file (" << kCpuUsageFile << ")"; + return -errno; + } + + while ((read = getline(&line, &len, file)) != -1) { + // Skip non "cpu[0-9]" lines. + if (strnlen(line, read) < 4 || strncmp(line, "cpu", 3) != 0 || !isdigit(line[3])) { + free(line); + line = NULL; + len = 0; + continue; + } + + vals = sscanf(line, "cpu%d %" SCNu64 " %" SCNu64 " %" SCNu64 " %" SCNu64, &cpu_num, &user, + &nice, &system, &idle); + + free(line); + line = NULL; + len = 0; + + if (vals != 5 || size == kCpuNum) { + if (vals != 5) { + PLOG(ERROR) << "fillCpuUsages: failed to read CPU information from file (" + << kCpuUsageFile << ")"; + } else { + PLOG(ERROR) << "fillCpuUsages: file has incorrect format (" + << kCpuUsageFile << ")"; + } + fclose(file); + return errno ? -errno : -EIO; + } + + active = user + nice + system; + total = active + idle; + + // Read online CPU information. + snprintf(file_name, PATH_MAX, kCpuOnlineFileFormat, cpu_num); + cpu_file = fopen(file_name, "r"); + online = 0; + if (cpu_file == NULL) { + PLOG(ERROR) << "fillCpuUsages: failed to open file (" << file_name << ")"; + fclose(file); + return -errno; + } + if (1 != fscanf(cpu_file, "%d", &online)) { + PLOG(ERROR) << "fillCpuUsages: failed to read CPU online information from file (" + << file_name << ")"; + fclose(file); + fclose(cpu_file); + return errno ? -errno : -EIO; + } + fclose(cpu_file); + + (*cpuUsages)[size].name = kCpuLabel[size]; + (*cpuUsages)[size].active = active; + (*cpuUsages)[size].total = total; + (*cpuUsages)[size].isOnline = static_cast(online); + + LOG(DEBUG) << "fillCpuUsages: "<< kCpuLabel[size] << ": " + << active << " " << total << " " << online; + size++; + } + fclose(file); + + if (size != kCpuNum) { + PLOG(ERROR) << "fillCpuUsages: file has incorrect format (" << kCpuUsageFile << ")"; + return -EIO; + } + return kCpuNum; +} + +} // namespace implementation +} // namespace V1_0 +} // namespace thermal +} // namespace hardware +} // namespace android diff --git a/thermal/thermal-helper.h b/thermal/thermal-helper.h new file mode 100644 index 00000000..e08d4e72 --- /dev/null +++ b/thermal/thermal-helper.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2017, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __THERMAL_HELPER_H__ +#define __THERMAL_HELPER_H__ + +#include + +namespace android { +namespace hardware { +namespace thermal { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::thermal::V1_0::CpuUsage; +using ::android::hardware::thermal::V1_0::Temperature; + +constexpr const char *kCpuUsageFile = "/proc/stat"; +constexpr const char *kTemperatureFileFormat = "/sys/class/thermal/thermal_zone%d/temp"; +constexpr const char *kCpuOnlineFileFormat = "/sys/devices/system/cpu/cpu%d/online"; + +// thermal-engine.conf +constexpr unsigned int kWalleyeSkinSensorNum = 9; +constexpr unsigned int kWalleyeTsensOffset = 11; +constexpr unsigned int kWalleyeSkinThrottlingThreshold = 40; +constexpr unsigned int kWalleyeSkinShutdownThreshold = 56; +constexpr unsigned int kWalleyeVrThrottledBelowMin = 52; + +constexpr unsigned int kTaimenRabSkinSensorNum = 8; +constexpr unsigned int kTaimenRabTsensOffset = 9; +constexpr unsigned int kTaimenRabSkinThrottlingThreshold = 49; +constexpr unsigned int kTaimenRabSkinShutdownThreshold = 66; +constexpr unsigned int kTaimenRabVrThrottledBelowMin = 62; + +constexpr unsigned int kTaimenRcSkinSensorNum = 8; +constexpr unsigned int kTaimenRcTsensOffset = 9; +constexpr unsigned int kTaimenRcSkinThrottlingThreshold = 38; +constexpr unsigned int kTaimenRcSkinShutdownThreshold = 54; +constexpr unsigned int kTaimenRcVrThrottledBelowMin = 50; + + +constexpr unsigned int kBatterySensorNum = 0; +constexpr unsigned int kGpuTsensOffset = 11; +constexpr unsigned int kCpuNum = 8; + +constexpr const char *kGpuLabel = "GPU"; +constexpr const char *kBatteryLabel = "battery"; +constexpr const char *kSkinLabel = "skin"; +constexpr const char *kCpuLabel[kCpuNum] = {"CPU0", "CPU1", "CPU2", "CPU3", "CPU4", "CPU5", "CPU6", "CPU7"}; +constexpr int kCpuTsensOffset[kCpuNum] = {1, 2, 4, 3, 5, 6, 7, 8}; + +// Sum of kCpuNum + 3 for GPU, BATTERY, and SKIN. +constexpr unsigned int kTemperatureNum = 3 + kCpuNum; + +// qcom, therm-reset-temp +constexpr unsigned int kCpuShutdownThreshold = 115; +// qcom,freq-mitigation-temp +constexpr unsigned int kCpuThrottlingThreshold = 95; + +// config_shutdownBatteryTemperature in overlay/frameworks/base/core/res/res/values/config.xml +constexpr unsigned int kBatteryShutdownThreshold = 60; + + +bool initThermal(); +ssize_t fillTemperatures(hidl_vec *temperatures); +ssize_t fillCpuUsages(hidl_vec *cpuUsages); + +} // namespace implementation +} // namespace V1_0 +} // namespace thermal +} // namespace hardware +} // namespace android + +#endif //__THERMAL_HELPER_H__ diff --git a/ueventd.hardware.rc b/ueventd.hardware.rc new file mode 100644 index 00000000..b6408602 --- /dev/null +++ b/ueventd.hardware.rc @@ -0,0 +1,114 @@ +# +# Copyright (C) 2016 The Android Open-Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# the DIAG device node is not world writable/readable. +/dev/diag 0660 system diag + +/dev/wlan 0666 system system +/dev/kgsl-3d0 0666 system system +/dev/ion 0664 system system +/dev/rtc0 0660 system system +/dev/smd7 0660 bluetooth bluetooth +/dev/ipa 0660 system radio +/dev/wwan_ioctl 0660 system radio +/dev/ipaNatTable 0660 system radio +/dev/rmnet_ctrl 0660 usb usb + +#permissions for CSVT +/dev/smd11 0660 radio radio + +/dev/smdcntl8 0640 radio radio +/dev/at_usb0 0640 radio radio +/dev/at_mdm0 0640 radio radio + +/dev/video* 0660 system camera +/dev/media* 0660 system camera +/dev/v4l-subdev* 0660 system camera + +/dev/qseecom 0660 system drmrpc +/dev/qsee_ipc_irq_spss 0660 system drmrpc +/dev/seemplog 0660 system system +/dev/spcom 0660 system system + +/dev/jpeg0 0660 system camera +/dev/adsprpc-smd 0664 system system + +/dev/hw_random 0600 root root +/dev/sdsprpc-smd 0660 system system + +/dev/wcd-dsp-glink 0660 system audio +/dev/wcd_dsp0_control 0660 system audio + +/dev/msm_qcelp 0660 system audio +/dev/msm_evrc 0660 system audio +/dev/msm_wma 0660 system audio +/dev/msm_wmapro 0660 system audio +/dev/msm_alac 0660 system audio +/dev/msm_ape 0660 system audio +/dev/msm_amrnb 0660 system audio +/dev/msm_amrwb 0660 system audio +/dev/msm_amrwbplus 0660 system audio +/dev/msm_aac 0660 system audio +/dev/msm_multi_aac 0660 system audio +/dev/msm_aac_in 0660 system audio +/dev/msm_qcelp_in 0660 system audio +/dev/msm_evrc_in 0660 system audio +/dev/msm_amrnb_in 0640 system audio +/dev/msm_a2dp_in 0660 system audio +/dev/msm_ac3 0660 system audio +/dev/msm_audio_cal 0660 system audio +/dev/msm_hweffects 0660 system audio +/dev/msm_rtac 0660 system audio + +/dev/i2c-5 0660 media media +/dev/avtimer 0660 system audio + +/dev/uio0 0660 system system +/dev/uio1 0660 system system + +# SSR devices +/dev/subsys_* 0640 system system + +# Ramdump devices +/dev/ramdump_* 0640 system system + +#ImproveTouch device +/dev/hbtp_input 0660 system system +/dev/hbtp_vm 0660 system system + +# BT +/dev/ttyHS0 0660 bluetooth net_bt +/dev/btpower 0660 bluetooth net_bt + +#nfc permissions +/dev/nq-nci 0660 nfc nfc + +# eSE device +/dev/pn81a 0660 ese ese + +# fpc fingerprint +/sys/devices/soc/soc:fp_fpc* irq 0600 system system +/sys/devices/soc/soc:fp_fpc* wakeup_enable 0200 system system + +# Easel +/dev/easelcomm-client 0660 cameraserver camera +/dev/mnh_sm 0664 cameraserver camera + +# TODO (b/37941164): Temporary for easel +/sys/devices/soc/c1b7000.i2c/i2c-9/9-0008* asr_dual_phase 0660 cameraserver camera + +# Storage: for factory reset protection feature +/dev/block/platform/soc/1da4000.ufshc/by-name/frp 0660 system system diff --git a/uinput-fpc.idc b/uinput-fpc.idc new file mode 100644 index 00000000..526d0e8c --- /dev/null +++ b/uinput-fpc.idc @@ -0,0 +1,20 @@ +# Copyright (C) 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# Fingerprint navigation configuration file +# +keyboard.orientationAware = 1 +keyboard.builtIn = 1 + diff --git a/uinput-fpc.kl b/uinput-fpc.kl new file mode 100644 index 00000000..c8f0acd3 --- /dev/null +++ b/uinput-fpc.kl @@ -0,0 +1,4 @@ +key 106 SYSTEM_NAVIGATION_LEFT +key 108 SYSTEM_NAVIGATION_DOWN +key 103 SYSTEM_NAVIGATION_UP +key 105 SYSTEM_NAVIGATION_RIGHT diff --git a/usb/Android.bp b/usb/Android.bp new file mode 100644 index 00000000..4370d6c7 --- /dev/null +++ b/usb/Android.bp @@ -0,0 +1,32 @@ +// +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +cc_binary { + name: "android.hardware.usb@1.1-service.wahoo", + relative_install_path: "hw", + init_rc: ["android.hardware.usb@1.1-service.wahoo.rc"], + srcs: ["service.cpp", "Usb.cpp"], + shared_libs: [ + "libbase", + "libhidlbase", + "libhidltransport", + "liblog", + "libutils", + "libhardware", + "android.hardware.usb@1.0", + "android.hardware.usb@1.1", + "libcutils", + ], + proprietary: true, +} diff --git a/usb/Usb.cpp b/usb/Usb.cpp new file mode 100644 index 00000000..3fc188e6 --- /dev/null +++ b/usb/Usb.cpp @@ -0,0 +1,769 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "android.hardware.usb@1.1-service.wahoo" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "Usb.h" + +namespace android { +namespace hardware { +namespace usb { +namespace V1_1 { +namespace implementation { + +const char GOOGLE_USB_VENDOR_ID_STR[] = "18d1"; +const char GOOGLE_USBC_35_ADAPTER_UNPLUGGED_ID_STR[] = "5029"; + +// Set by the signal handler to destroy the thread +volatile bool destroyThread; + +static void checkUsbDeviceAutoSuspend(const std::string& devicePath); + +static int32_t readFile(const std::string &filename, std::string *contents) { + FILE *fp; + ssize_t read = 0; + char *line = NULL; + size_t len = 0; + + fp = fopen(filename.c_str(), "r"); + if (fp != NULL) { + if ((read = getline(&line, &len, fp)) != -1) { + char *pos; + if ((pos = strchr(line, '\n')) != NULL) *pos = '\0'; + *contents = line; + } + free(line); + fclose(fp); + return 0; + } else { + ALOGE("fopen failed in readFile %s, errno=%d", filename.c_str(), errno); + } + + return -1; +} + +static int32_t writeFile(const std::string &filename, + const std::string &contents) { + FILE *fp; + int ret; + + fp = fopen(filename.c_str(), "w"); + if (fp != NULL) { + ret = fputs(contents.c_str(), fp); + fclose(fp); + if (ret == EOF) { + ALOGE("fputs failed in writeFile %s", filename.c_str()); + return -1; + } + return 0; + } else { + ALOGE("fopen failed in writeFile %s, errno=%d", filename.c_str(), errno); + } + + return -1; +} + +std::string appendRoleNodeHelper(const std::string &portName, + PortRoleType type) { + std::string node("/sys/class/typec/" + portName); + + switch (type) { + case PortRoleType::DATA_ROLE: + return node + "/data_role"; + case PortRoleType::POWER_ROLE: + return node + "/power_role"; + case PortRoleType::MODE: + return node + "/port_type"; + default: + return ""; + } +} + +std::string convertRoletoString(PortRole role) { + if (role.type == PortRoleType::POWER_ROLE) { + if (role.role == static_cast(PortPowerRole::SOURCE)) + return "source"; + else if (role.role == static_cast(PortPowerRole::SINK)) + return "sink"; + } else if (role.type == PortRoleType::DATA_ROLE) { + if (role.role == static_cast(PortDataRole::HOST)) return "host"; + if (role.role == static_cast(PortDataRole::DEVICE)) + return "device"; + } else if (role.type == PortRoleType::MODE) { + if (role.role == static_cast(PortMode_1_1::UFP)) return "sink"; + if (role.role == static_cast(PortMode_1_1::DFP)) return "source"; + } + return "none"; +} + +void extractRole(std::string *roleName) { + std::size_t first, last; + + first = roleName->find("["); + last = roleName->find("]"); + + if (first != std::string::npos && last != std::string::npos) { + *roleName = roleName->substr(first + 1, last - first - 1); + } +} + +void switchToDrp(const std::string &portName) { + std::string filename = + appendRoleNodeHelper(std::string(portName.c_str()), PortRoleType::MODE); + FILE *fp; + + if (filename != "") { + fp = fopen(filename.c_str(), "w"); + if (fp != NULL) { + int ret = fputs("dual", fp); + fclose(fp); + if (ret == EOF) + ALOGE("Fatal: Error while switching back to drp"); + } else { + ALOGE("Fatal: Cannot open file to switch back to drp"); + } + } else { + ALOGE("Fatal: invalid node type"); + } +} + +bool switchMode(const hidl_string &portName, + const PortRole &newRole, struct Usb *usb) { + std::string filename = + appendRoleNodeHelper(std::string(portName.c_str()), newRole.type); + std::string written; + FILE *fp; + bool roleSwitch = false; + + if (filename == "") { + ALOGE("Fatal: invalid node type"); + return false; + } + + fp = fopen(filename.c_str(), "w"); + if (fp != NULL) { + // Hold the lock here to prevent loosing connected signals + // as once the file is written the partner added signal + // can arrive anytime. + pthread_mutex_lock(&usb->mPartnerLock); + usb->mPartnerUp = false; + int ret = fputs(convertRoletoString(newRole).c_str(), fp); + fclose(fp); + + if (ret != EOF) { + struct timespec to; + struct timeval tp; + +wait_again: + gettimeofday(&tp, NULL); + to.tv_sec = tp.tv_sec + PORT_TYPE_TIMEOUT; + to.tv_nsec = tp.tv_usec * 1000;; + + int err = pthread_cond_timedwait(&usb->mPartnerCV, &usb->mPartnerLock, &to); + // There are no uevent signals which implies role swap timed out. + if (err == ETIMEDOUT) { + ALOGI("uevents wait timedout"); + // Sanity check. + } else if (!usb->mPartnerUp) { + goto wait_again; + // Role switch succeeded since usb->mPartnerUp is true. + } else { + roleSwitch = true; + } + } else { + ALOGI("Role switch failed while wrting to file"); + } + pthread_mutex_unlock(&usb->mPartnerLock); + } + + if (!roleSwitch) + switchToDrp(std::string(portName.c_str())); + + return roleSwitch; +} + + + +Return Usb::switchRole(const hidl_string &portName, + const PortRole &newRole) { + std::string filename = + appendRoleNodeHelper(std::string(portName.c_str()), newRole.type); + std::string written; + FILE *fp; + bool roleSwitch = false; + + if (filename == "") { + ALOGE("Fatal: invalid node type"); + return Void(); + } + + pthread_mutex_lock(&mRoleSwitchLock); + + ALOGI("filename write: %s role:%s", filename.c_str(), + convertRoletoString(newRole).c_str()); + + if (newRole.type == PortRoleType::MODE) { + roleSwitch = switchMode(portName, newRole, this); + } else { + fp = fopen(filename.c_str(), "w"); + if (fp != NULL) { + int ret = fputs(convertRoletoString(newRole).c_str(), fp); + fclose(fp); + if ((ret != EOF) && !readFile(filename, &written)) { + extractRole(&written); + ALOGI("written: %s", written.c_str()); + if (written == convertRoletoString(newRole)) { + roleSwitch = true; + } else { + ALOGE("Role switch failed"); + } + } else { + ALOGE("failed to update the new role"); + } + } else { + ALOGE("fopen failed"); + } + } + + pthread_mutex_lock(&mLock); + if (mCallback_1_0 != NULL) { + Return ret = + mCallback_1_0->notifyRoleSwitchStatus(portName, newRole, + roleSwitch ? Status::SUCCESS : Status::ERROR); + if (!ret.isOk()) + ALOGE("RoleSwitchStatus error %s", ret.description().c_str()); + } else { + ALOGE("Not notifying the userspace. Callback is not set"); + } + pthread_mutex_unlock(&mLock); + pthread_mutex_unlock(&mRoleSwitchLock); + + return Void(); +} + +Status getAccessoryConnected(const std::string &portName, std::string *accessory) { + std::string filename = + "/sys/class/typec/" + portName + "-partner/accessory_mode"; + + if (readFile(filename, accessory)) { + ALOGE("getAccessoryConnected: Failed to open filesystem node: %s", + filename.c_str()); + return Status::ERROR; + } + + return Status::SUCCESS; +} + +Status getCurrentRoleHelper(const std::string &portName, bool connected, + PortRoleType type, uint32_t *currentRole) { + std::string filename; + std::string roleName; + std::string accessory; + + // Mode + + if (type == PortRoleType::POWER_ROLE) { + filename = "/sys/class/typec/" + portName + "/power_role"; + *currentRole = static_cast(PortPowerRole::NONE); + } else if (type == PortRoleType::DATA_ROLE) { + filename = "/sys/class/typec/" + portName + "/data_role"; + *currentRole = static_cast(PortDataRole::NONE); + } else if (type == PortRoleType::MODE) { + filename = "/sys/class/typec/" + portName + "/data_role"; + *currentRole = static_cast(PortMode_1_1::NONE); + } else { + return Status::ERROR; + } + + if (!connected) return Status::SUCCESS; + + if (type == PortRoleType::MODE) { + if (getAccessoryConnected(portName, &accessory) != Status::SUCCESS) { + return Status::ERROR; + } + if (accessory == "analog_audio") { + *currentRole = static_cast(PortMode_1_1::AUDIO_ACCESSORY); + return Status::SUCCESS; + } else if (accessory == "debug") { + *currentRole = static_cast(PortMode_1_1::DEBUG_ACCESSORY); + return Status::SUCCESS; + } + } + + if (readFile(filename, &roleName)) { + ALOGE("getCurrentRole: Failed to open filesystem node: %s", + filename.c_str()); + return Status::ERROR; + } + + extractRole(&roleName); + + if (roleName == "source") { + *currentRole = static_cast(PortPowerRole::SOURCE); + } else if (roleName == "sink") { + *currentRole = static_cast(PortPowerRole::SINK); + } else if (roleName == "host") { + if (type == PortRoleType::DATA_ROLE) + *currentRole = static_cast(PortDataRole::HOST); + else + *currentRole = static_cast(PortMode_1_1::DFP); + } else if (roleName == "device") { + if (type == PortRoleType::DATA_ROLE) + *currentRole = static_cast(PortDataRole::DEVICE); + else + *currentRole = static_cast(PortMode_1_1::UFP); + } else if (roleName != "none") { + /* case for none has already been addressed. + * so we check if the role isnt none. + */ + return Status::UNRECOGNIZED_ROLE; + } + + return Status::SUCCESS; +} + +Status getTypeCPortNamesHelper(std::unordered_map *names) { + DIR *dp; + + dp = opendir("/sys/class/typec"); + if (dp != NULL) { + int32_t ports = 0; + int32_t current = 0; + struct dirent *ep; + + while ((ep = readdir(dp))) { + if (ep->d_type == DT_LNK) { + if (std::string::npos == std::string(ep->d_name).find("-partner")) { + std::unordered_map::const_iterator portName = + names->find(ep->d_name); + if (portName == names->end()) { + names->insert({ep->d_name, false}); + } + } else { + (*names)[std::strtok(ep->d_name, "-")] = true; + } + } + } + closedir(dp); + return Status::SUCCESS; + } + + ALOGE("Failed to open /sys/class/typec"); + return Status::ERROR; +} + +bool canSwitchRoleHelper(const std::string &portName, PortRoleType /*type*/) { + std::string filename = + "/sys/class/typec/" + portName + "-partner/supports_usb_power_delivery"; + std::string supportsPD; + + if (!readFile(filename, &supportsPD)) { + if (supportsPD == "yes") { + return true; + } + } + + return false; +} + +/* + * Reuse the same method for both V1_0 and V1_1 callback objects. + * The caller of this method would reconstruct the V1_0::PortStatus + * object if required. + */ +Status getPortStatusHelper(hidl_vec *currentPortStatus_1_1, + bool V1_0) { + std::unordered_map names; + Status result = getTypeCPortNamesHelper(&names); + int i = -1; + + if (result == Status::SUCCESS) { + currentPortStatus_1_1->resize(names.size()); + for (std::pair port : names) { + i++; + ALOGI("%s", port.first.c_str()); + (*currentPortStatus_1_1)[i].status.portName = port.first; + + uint32_t currentRole; + if (getCurrentRoleHelper(port.first, port.second, + PortRoleType::POWER_ROLE, + ¤tRole) == Status::SUCCESS) { + (*currentPortStatus_1_1)[i].status.currentPowerRole = + static_cast(currentRole); + } else { + ALOGE("Error while retreiving portNames"); + goto done; + } + + if (getCurrentRoleHelper(port.first, port.second, PortRoleType::DATA_ROLE, + ¤tRole) == Status::SUCCESS) { + (*currentPortStatus_1_1)[i].status.currentDataRole = + static_cast(currentRole); + } else { + ALOGE("Error while retreiving current port role"); + goto done; + } + + if (getCurrentRoleHelper(port.first, port.second, PortRoleType::MODE, + ¤tRole) == Status::SUCCESS) { + (*currentPortStatus_1_1)[i].currentMode = + static_cast(currentRole); + (*currentPortStatus_1_1)[i].status.currentMode = + static_cast(currentRole); + } else { + ALOGE("Error while retreiving current data role"); + goto done; + } + + (*currentPortStatus_1_1)[i].status.canChangeMode = true; + (*currentPortStatus_1_1)[i].status.canChangeDataRole = + port.second ? canSwitchRoleHelper(port.first, PortRoleType::DATA_ROLE) + : false; + (*currentPortStatus_1_1)[i].status.canChangePowerRole = + port.second + ? canSwitchRoleHelper(port.first, PortRoleType::POWER_ROLE) + : false; + + ALOGI("connected:%d canChangeMode:%d canChagedata:%d canChangePower:%d", + port.second, (*currentPortStatus_1_1)[i].status.canChangeMode, + (*currentPortStatus_1_1)[i].status.canChangeDataRole, + (*currentPortStatus_1_1)[i].status.canChangePowerRole); + + if (V1_0) { + (*currentPortStatus_1_1)[i].status.supportedModes = V1_0::PortMode::DFP; + } else { + (*currentPortStatus_1_1)[i].supportedModes = PortMode_1_1::UFP | PortMode_1_1::DFP; + (*currentPortStatus_1_1)[i].status.supportedModes = V1_0::PortMode::NONE; + (*currentPortStatus_1_1)[i].status.currentMode = V1_0::PortMode::NONE; + } + } + return Status::SUCCESS; + } +done: + return Status::ERROR; +} + +Return Usb::queryPortStatus() { + hidl_vec currentPortStatus_1_1; + hidl_vec currentPortStatus; + Status status; + sp callback_V1_1 = IUsbCallback::castFrom(mCallback_1_0); + + pthread_mutex_lock(&mLock); + if (mCallback_1_0 != NULL) { + if (callback_V1_1 != NULL) { + status = getPortStatusHelper(¤tPortStatus_1_1, false); + } else { + status = getPortStatusHelper(¤tPortStatus_1_1, true); + currentPortStatus.resize(currentPortStatus_1_1.size()); + for (unsigned long i = 0; i < currentPortStatus_1_1.size(); i++) + currentPortStatus[i] = currentPortStatus_1_1[i].status; + } + + Return ret; + + if (callback_V1_1 != NULL) + ret = callback_V1_1->notifyPortStatusChange_1_1(currentPortStatus_1_1, status); + else + ret = mCallback_1_0->notifyPortStatusChange(currentPortStatus, status); + + if (!ret.isOk()) + ALOGE("queryPortStatus_1_1 error %s", ret.description().c_str()); + } else { + ALOGI("Notifying userspace skipped. Callback is NULL"); + } + pthread_mutex_unlock(&mLock); + + return Void(); +} + +struct data { + int uevent_fd; + android::hardware::usb::V1_1::implementation::Usb *usb; +}; + +static void uevent_event(uint32_t /*epevents*/, struct data *payload) { + char msg[UEVENT_MSG_LEN + 2]; + char *cp; + int n; + + n = uevent_kernel_multicast_recv(payload->uevent_fd, msg, UEVENT_MSG_LEN); + if (n <= 0) return; + if (n >= UEVENT_MSG_LEN) /* overflow -- discard */ + return; + + msg[n] = '\0'; + msg[n + 1] = '\0'; + cp = msg; + + while (*cp) { + std::cmatch match; + if (std::regex_match(cp, std::regex("(add)(.*)(-partner)"))) { + ALOGI("partner added"); + pthread_mutex_lock(&payload->usb->mPartnerLock); + payload->usb->mPartnerUp = true; + pthread_cond_signal(&payload->usb->mPartnerCV); + pthread_mutex_unlock(&payload->usb->mPartnerLock); + } else if (!strncmp(cp, "DEVTYPE=typec_", strlen("DEVTYPE=typec_"))) { + hidl_vec currentPortStatus_1_1; + ALOGI("uevent received %s", cp); + pthread_mutex_lock(&payload->usb->mLock); + if (payload->usb->mCallback_1_0 != NULL) { + sp callback_V1_1 = IUsbCallback::castFrom(payload->usb->mCallback_1_0); + Return ret; + + // V1_1 callback + if (callback_V1_1 != NULL) { + Status status = getPortStatusHelper(¤tPortStatus_1_1, false); + ret = callback_V1_1->notifyPortStatusChange_1_1( + currentPortStatus_1_1, status); + } else { // V1_0 callback + Status status = getPortStatusHelper(¤tPortStatus_1_1, true); + + /* + * Copying the result from getPortStatusHelper + * into V1_0::PortStatus to pass back through + * the V1_0 callback object. + */ + hidl_vec currentPortStatus; + currentPortStatus.resize(currentPortStatus_1_1.size()); + for (unsigned long i = 0; i < currentPortStatus_1_1.size(); i++) + currentPortStatus[i] = currentPortStatus_1_1[i].status; + + ret = payload->usb->mCallback_1_0->notifyPortStatusChange( + currentPortStatus, status); + } + if (!ret.isOk()) ALOGE("error %s", ret.description().c_str()); + } else { + ALOGI("Notifying userspace skipped. Callback is NULL"); + } + pthread_mutex_unlock(&payload->usb->mLock); + + //Role switch is not in progress and port is in disconnected state + if (!pthread_mutex_trylock(&payload->usb->mRoleSwitchLock)) { + for (unsigned long i = 0; i < currentPortStatus_1_1.size(); i++) { + DIR *dp = opendir(std::string("/sys/class/typec/" + + std::string(currentPortStatus_1_1[i].status.portName.c_str()) + + "-partner").c_str()); + if (dp == NULL) { + //PortRole role = {.role = static_cast(PortMode::UFP)}; + switchToDrp(currentPortStatus_1_1[i].status.portName); + } else { + closedir(dp); + } + } + pthread_mutex_unlock(&payload->usb->mRoleSwitchLock); + } + break; + } else if (std::regex_match(cp, match, + std::regex("add@(/devices/soc/a800000\\.ssusb/a800000\\.dwc3/xhci-hcd\\.0\\.auto/" + "usb\\d/\\d-\\d)/.*"))) { + if (match.size() == 2) { + std::csub_match submatch = match[1]; + checkUsbDeviceAutoSuspend("/sys" + submatch.str()); + } + } + + /* advance to after the next \0 */ + while (*cp++) {} + } +} + +void *work(void *param) { + int epoll_fd, uevent_fd; + struct epoll_event ev; + int nevents = 0; + struct data payload; + + ALOGE("creating thread"); + + uevent_fd = uevent_open_socket(64 * 1024, true); + + if (uevent_fd < 0) { + ALOGE("uevent_init: uevent_open_socket failed\n"); + return NULL; + } + + payload.uevent_fd = uevent_fd; + payload.usb = (android::hardware::usb::V1_1::implementation::Usb *)param; + + fcntl(uevent_fd, F_SETFL, O_NONBLOCK); + + ev.events = EPOLLIN; + ev.data.ptr = (void *)uevent_event; + + epoll_fd = epoll_create(64); + if (epoll_fd == -1) { + ALOGE("epoll_create failed; errno=%d", errno); + goto error; + } + + if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, uevent_fd, &ev) == -1) { + ALOGE("epoll_ctl failed; errno=%d", errno); + goto error; + } + + while (!destroyThread) { + struct epoll_event events[64]; + + nevents = epoll_wait(epoll_fd, events, 64, -1); + if (nevents == -1) { + if (errno == EINTR) continue; + ALOGE("usb epoll_wait failed; errno=%d", errno); + break; + } + + for (int n = 0; n < nevents; ++n) { + if (events[n].data.ptr) + (*(void (*)(int, struct data *payload))events[n].data.ptr)( + events[n].events, &payload); + } + } + + ALOGI("exiting worker thread"); +error: + close(uevent_fd); + + if (epoll_fd >= 0) close(epoll_fd); + + return NULL; +} + +void sighandler(int sig) { + if (sig == SIGUSR1) { + destroyThread = true; + ALOGI("destroy set"); + return; + } + signal(SIGUSR1, sighandler); +} + +Return Usb::setCallback(const sp &callback) { + + sp callback_V1_1 = IUsbCallback::castFrom(callback); + + if (callback != NULL) + if (callback_V1_1 == NULL) + ALOGI("Registering 1.0 callback"); + + pthread_mutex_lock(&mLock); + /* + * When both the old callback and new callback values are NULL, + * there is no need to spin off the worker thread. + * When both the values are not NULL, we would already have a + * worker thread running, so updating the callback object would + * be suffice. + */ + if ((mCallback_1_0 == NULL && callback == NULL) || + (mCallback_1_0 != NULL && callback != NULL)) { + /* + * Always store as V1_0 callback object. Type cast to V1_1 + * when the callback is actually invoked. + */ + mCallback_1_0 = callback; + pthread_mutex_unlock(&mLock); + return Void(); + } + + mCallback_1_0 = callback; + ALOGI("registering callback"); + + // Kill the worker thread if the new callback is NULL. + if (mCallback_1_0 == NULL) { + pthread_mutex_unlock(&mLock); + if (!pthread_kill(mPoll, SIGUSR1)) { + pthread_join(mPoll, NULL); + ALOGI("pthread destroyed"); + } + return Void(); + } + + destroyThread = false; + signal(SIGUSR1, sighandler); + + /* + * Create a background thread if the old callback value is NULL + * and being updated with a new value. + */ + if (pthread_create(&mPoll, NULL, work, this)) { + ALOGE("pthread creation failed %d", errno); + mCallback_1_0 = NULL; + } + + pthread_mutex_unlock(&mLock); + return Void(); +} + +/* + * whitelisting USB device idProduct and idVendor to allow auto suspend. + */ +static bool canProductAutoSuspend(const std::string &deviceIdVendor, + const std::string &deviceIdProduct) { + if (deviceIdVendor == GOOGLE_USB_VENDOR_ID_STR && + deviceIdProduct == GOOGLE_USBC_35_ADAPTER_UNPLUGGED_ID_STR) { + return true; + } + return false; +} + +static bool canUsbDeviceAutoSuspend(const std::string &devicePath) { + std::string deviceIdVendor; + std::string deviceIdProduct; + readFile(devicePath + "/idVendor", &deviceIdVendor); + readFile(devicePath + "/idProduct", &deviceIdProduct); + + // deviceIdVendor and deviceIdProduct will be empty strings if readFile fails + return canProductAutoSuspend(deviceIdVendor, deviceIdProduct); +} + +/* + * function to consume USB device plugin events (on receiving a + * USB device path string), and enable autosupend on the USB device if + * necessary. + */ +void checkUsbDeviceAutoSuspend(const std::string& devicePath) { + /* + * Currently we only actively enable devices that should be autosuspended, and leave others + * to the defualt. + */ + if (canUsbDeviceAutoSuspend(devicePath)) { + ALOGI("auto suspend usb device %s", devicePath.c_str()); + writeFile(devicePath + "/power/control", "auto"); + } +} + +} // namespace implementation +} // namespace V1_0 +} // namespace usb +} // namespace hardware +} // namespace android diff --git a/usb/Usb.h b/usb/Usb.h new file mode 100644 index 00000000..dfd48ca5 --- /dev/null +++ b/usb/Usb.h @@ -0,0 +1,70 @@ +#ifndef ANDROID_HARDWARE_USB_V1_1_USB_H +#define ANDROID_HARDWARE_USB_V1_1_USB_H + +#include +#include +#include +#include +#include + +#define UEVENT_MSG_LEN 2048 +// The type-c stack waits for 4.5 - 5.5 secs before declaring a port non-pd. +// The -partner directory would not be created until this is done. +// Having a margin of ~3 secs for the directory and other related bookeeping +// structures created and uvent fired. +#define PORT_TYPE_TIMEOUT 8 + +namespace android { +namespace hardware { +namespace usb { +namespace V1_1 { +namespace implementation { + +using ::android::hardware::usb::V1_0::PortRole; +using ::android::hardware::usb::V1_0::PortRoleType; +using ::android::hardware::usb::V1_0::PortDataRole; +using ::android::hardware::usb::V1_0::PortPowerRole; +using ::android::hardware::usb::V1_0::Status; +using ::android::hardware::usb::V1_1::IUsb; +using ::android::hardware::usb::V1_1::IUsbCallback; +using ::android::hardware::usb::V1_1::PortMode_1_1; +using ::android::hardware::usb::V1_1::PortStatus_1_1; +using ::android::hidl::base::V1_0::DebugInfo; +using ::android::hidl::base::V1_0::IBase; +using ::android::hardware::hidl_array; +using ::android::hardware::hidl_memory; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +struct Usb : public IUsb { + Return switchRole(const hidl_string& portName, const PortRole& role) override; + Return setCallback(const sp& callback) override; + Return queryPortStatus() override; + + + sp mCallback_1_0; + // Protects mCallback variable + pthread_mutex_t mLock = PTHREAD_MUTEX_INITIALIZER; + // Protects roleSwitch operation + pthread_mutex_t mRoleSwitchLock = PTHREAD_MUTEX_INITIALIZER; + // Threads waiting for the partner to come back wait here + pthread_cond_t mPartnerCV = PTHREAD_COND_INITIALIZER; + // lock protecting mPartnerCV + pthread_mutex_t mPartnerLock = PTHREAD_MUTEX_INITIALIZER; + // Variable to signal partner coming back online after type switch + bool mPartnerUp; + + private: + pthread_t mPoll; +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace usb +} // namespace hardware +} // namespace android + +#endif // ANDROID_HARDWARE_USB_V1_1_USB_H diff --git a/usb/android.hardware.usb@1.1-service.wahoo.rc b/usb/android.hardware.usb@1.1-service.wahoo.rc new file mode 100644 index 00000000..1451519a --- /dev/null +++ b/usb/android.hardware.usb@1.1-service.wahoo.rc @@ -0,0 +1,12 @@ +service usb-hal-1-1 /vendor/bin/hw/android.hardware.usb@1.1-service.wahoo + class hal + user root + group root system + +on boot + chown root system /sys/class/typec/port0/power_role + chown root system /sys/class/typec/port0/data_role + chown root system /sys/class/typec/port0/port_type + chmod 664 /sys/class/typec/port0/power_role + chmod 664 /sys/class/typec/port0/data_role + chmod 664 /sys/class/typec/port0/port_type diff --git a/usb/service.cpp b/usb/service.cpp new file mode 100644 index 00000000..5fffc4ce --- /dev/null +++ b/usb/service.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "android.hardware.usb@1.1-service.wahoo" + +#include +#include "Usb.h" + +using android::sp; + +// libhwbinder: +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; + +// Generated HIDL files +using android::hardware::usb::V1_1::IUsb; +using android::hardware::usb::V1_1::implementation::Usb; + +using android::status_t; +using android::OK; + +int main() { + android::sp service = new Usb(); + + configureRpcThreadpool(1, true /*callerWillJoin*/); + status_t status = service->registerAsService(); + + if (status != OK) { + ALOGE("Cannot register USB HAL service"); + return 1; + } + + ALOGI("USB HAL Ready."); + joinRpcThreadpool(); + // Under noraml cases, execution will not reach this line. + ALOGI("USB HAL failed to join thread pool."); + return 1; + +} diff --git a/utils.mk b/utils.mk new file mode 100644 index 00000000..c823d211 --- /dev/null +++ b/utils.mk @@ -0,0 +1,201 @@ +# vars for use by utils +empty := +space := $(empty) $(empty) +colon := $(empty):$(empty) +underscore := $(empty)_$(empty) + +# $(call match-word,w1,w2) +# checks if w1 == w2 +# How it works +# if (w1-w2 not empty or w2-w1 not empty) then not_match else match +# +# returns true or empty +#$(warning :$(1): :$(2): :$(subst $(1),,$(2)):) \ +#$(warning :$(2): :$(1): :$(subst $(2),,$(1)):) \ +# +define match-word +$(strip \ + $(if $(or $(subst $(1),$(empty),$(2)),$(subst $(2),$(empty),$(1))),,true) \ +) +endef + +# $(call find-word-in-list,w,wlist) +# finds an exact match of word w in word list wlist +# +# How it works +# fill wlist spaces with colon +# wrap w with colon +# search word w in list wl, if found match m, return stripped word w +# +# returns stripped word or empty +define find-word-in-list +$(strip \ + $(eval wl:= $(colon)$(subst $(space),$(colon),$(strip $(2)))$(colon)) \ + $(eval w:= $(colon)$(strip $(1))$(colon)) \ + $(eval m:= $(findstring $(w),$(wl))) \ + $(if $(m),$(1),) \ +) +endef + +# $(call match-word-in-list,w,wlist) +# does an exact match of word w in word list wlist +# How it works +# if the input word is not empty +# return output of an exact match of word w in wordlist wlist +# else +# return empty +# returns true or empty +define match-word-in-list +$(strip \ + $(if $(strip $(1)), \ + $(call match-word,$(call find-word-in-list,$(1),$(2)),$(strip $(1))), \ + ) \ +) +endef + +# $(call match-prefix,p,delim,w/wlist) +# matches prefix p in wlist using delimiter delim +# +# How it works +# trim the words in wlist w +# if find-word-in-list returns not empty +# return true +# else +# return empty +# +define match-prefix +$(strip \ + $(eval w := $(strip $(1)$(strip $(2)))) \ + $(eval text := $(patsubst $(w)%,$(1),$(3))) \ + $(if $(call match-word-in-list,$(1),$(text)),true,) \ +) +endef + +# ---- +# The following utilities are meant for board platform specific +# featurisation + +# $(call get-vendor-board-platforms,v) +# returns list of board platforms for vendor v +define get-vendor-board-platforms +$($(1)_BOARD_PLATFORMS) +endef + +# $(call is-board-platform,bp) +# returns true or empty +define is-board-platform +$(call match-word,$(1),$(TARGET_BOARD_PLATFORM)) +endef + +# $(call is-not-board-platform,bp) +# returns true or empty +define is-not-board-platform +$(if $(call match-word,$(1),$(TARGET_BOARD_PLATFORM)),,true) +endef + +# $(call is-board-platform-in-list,bpl) +# returns true or empty +define is-board-platform-in-list +$(call match-word-in-list,$(TARGET_BOARD_PLATFORM),$(1)) +endef + +# $(call is-vendor-board-platform,vendor) +# returns true or empty +define is-vendor-board-platform +$(strip \ + $(call match-word-in-list,$(TARGET_BOARD_PLATFORM),\ + $(call get-vendor-board-platforms,$(1)) \ + ) \ +) +endef + +# $(call is-chipset-in-board-platform,chipset) +# does a prefix match of chipset in TARGET_BOARD_PLATFORM +# uses underscore as a delimiter +# +# returns true or empty +define is-chipset-in-board-platform +$(call match-prefix,$(1),$(underscore),$(TARGET_BOARD_PLATFORM)) +endef + +# $(call is-chipset-prefix-in-board-platform,prefix) +# does a chipset prefix match in TARGET_BOARD_PLATFORM +# assumes '_' and 'a' as the delimiter to the chipset prefix +# +# How it works +# if ($(prefix)_ or $(prefix)a match in board platform) +# return true +# else +# return empty +# +define is-chipset-prefix-in-board-platform +$(strip \ + $(eval delim_a := $(empty)a$(empty)) \ + $(if \ + $(or \ + $(call match-prefix,$(1),$(delim_a),$(TARGET_BOARD_PLATFORM)), \ + $(call match-prefix,$(1),$(underscore),$(TARGET_BOARD_PLATFORM)), \ + ), \ + true, \ + ) \ +) +endef + +#---- +# The following utilities are meant for Android Code Name +# specific featurisation +# +# refer http://source.android.com/source/build-numbers.html +# for code names and associated sdk versions +CUPCAKE_SDK_VERSIONS := 3 +DONUT_SDK_VERSIONS := 4 +ECLAIR_SDK_VERSIONS := 5 6 7 +FROYO_SDK_VERSIONS := 8 +GINGERBREAD_SDK_VERSIONS := 9 10 +HONEYCOMB_SDK_VERSIONS := 11 12 13 +ICECREAM_SANDWICH_SDK_VERSIONS := 14 15 +JELLY_BEAN_SDK_VERSIONS := 16 17 18 + +# $(call is-platform-sdk-version-at-least,version) +# version is a numeric SDK_VERSION defined above +define is-platform-sdk-version-at-least +$(strip \ + $(if $(filter 1,$(shell echo "$$(( $(PLATFORM_SDK_VERSION) >= $(1) ))" )), \ + true, \ + ) \ +) +endef + +# $(call is-android-codename,codename) +# codename is one of cupcake,donut,eclair,froyo,gingerbread,icecream +# please refer the $(codename)_SDK_VERSIONS declared above +define is-android-codename +$(strip \ + $(if \ + $(call match-word-in-list,$(PLATFORM_SDK_VERSION),$($(1)_SDK_VERSIONS)), \ + true, \ + ) \ +) +endef + +# $(call is-android-codename-in-list,cnlist) +# cnlist is combination/list of android codenames +define is-android-codename-in-list +$(strip \ + $(eval acn := $(empty)) \ + $(foreach \ + i,$(1),\ + $(eval acn += \ + $(if \ + $(call \ + match-word-in-list,\ + $(PLATFORM_SDK_VERSION),\ + $($(i)_SDK_VERSIONS)\ + ),\ + true,\ + )\ + )\ + ) \ + $(if $(strip $(acn)),true,) \ +) +endef diff --git a/vibrator/Android.bp b/vibrator/Android.bp new file mode 100644 index 00000000..c7510058 --- /dev/null +++ b/vibrator/Android.bp @@ -0,0 +1,32 @@ +// +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +cc_binary { + name: "android.hardware.vibrator@1.1-service.wahoo", + relative_install_path: "hw", + init_rc: ["android.hardware.vibrator@1.1-service.wahoo.rc"], + srcs: ["service.cpp", "Vibrator.cpp"], + shared_libs: [ + "libhidlbase", + "libcutils", + "libhidltransport", + "liblog", + "libhwbinder", + "libutils", + "libhardware", + "android.hardware.vibrator@1.0", + "android.hardware.vibrator@1.1", + ], + proprietary: true, +} diff --git a/vibrator/Vibrator.cpp b/vibrator/Vibrator.cpp new file mode 100644 index 00000000..db64bb13 --- /dev/null +++ b/vibrator/Vibrator.cpp @@ -0,0 +1,220 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "VibratorService" + +#include + +#include +#include +#include + +#include "Vibrator.h" + +#include +#include +#include +#include + + +namespace android { +namespace hardware { +namespace vibrator { +namespace V1_1 { +namespace implementation { + +static constexpr int8_t MAX_RTP_INPUT = 127; +static constexpr int8_t MIN_RTP_INPUT = 0; + +static constexpr char RTP_MODE[] = "rtp"; +static constexpr char WAVEFORM_MODE[] = "waveform"; + +// Use effect #1 in the waveform library +static constexpr char WAVEFORM_CLICK_EFFECT_SEQ[] = "1 0"; +static constexpr int32_t WAVEFORM_CLICK_EFFECT_MS = 6; + +// Use effect #2 in the waveform library +static constexpr char WAVEFORM_TICK_EFFECT_SEQ[] = "2 0"; +static constexpr int32_t WAVEFORM_TICK_EFFECT_MS = 2; + +// Use effect #3 in the waveform library +static constexpr char WAVEFORM_DOUBLE_CLICK_EFFECT_SEQ[] = "3 0"; +static constexpr uint32_t WAVEFORM_DOUBLE_CLICK_EFFECT_MS = 135; + +// Timeout threshold for selecting open or closed loop mode +static constexpr int8_t LOOP_MODE_THRESHOLD_MS = 20; + +using Status = ::android::hardware::vibrator::V1_0::Status; +using EffectStrength = ::android::hardware::vibrator::V1_0::EffectStrength; + +Vibrator::Vibrator(std::ofstream&& activate, std::ofstream&& duration, + std::ofstream&& state, std::ofstream&& rtpinput, + std::ofstream&& mode, std::ofstream&& sequencer, + std::ofstream&& scale, std::ofstream&& ctrlloop, std::ofstream&& lptrigger) : + mActivate(std::move(activate)), + mDuration(std::move(duration)), + mState(std::move(state)), + mRtpInput(std::move(rtpinput)), + mMode(std::move(mode)), + mSequencer(std::move(sequencer)), + mScale(std::move(scale)), + mCtrlLoop(std::move(ctrlloop)), + mLpTriggerEffect(std::move(lptrigger)) { + + mClickDuration = property_get_int32("ro.vibrator.hal.click.duration", WAVEFORM_CLICK_EFFECT_MS); + mTickDuration = property_get_int32("ro.vibrator.hal.tick.duration", WAVEFORM_TICK_EFFECT_MS); + + // This enables effect #1 from the waveform library to be triggered by SLPI + // while the AP is in suspend mode + mLpTriggerEffect << 1 << std::endl; + if (!mLpTriggerEffect) { + ALOGW("Failed to set LP trigger mode (%d): %s", errno, strerror(errno)); + } +} + +Return Vibrator::on(uint32_t timeoutMs, bool forceOpenLoop, bool isWaveform) { + uint32_t loopMode = 1; + + // Open-loop mode is used for short click for over-drive + // Close-loop mode is used for long notification for stability + if (!forceOpenLoop && timeoutMs > LOOP_MODE_THRESHOLD_MS) { + loopMode = 0; + } + + mCtrlLoop << loopMode << std::endl; + mDuration << timeoutMs << std::endl; + if (!mDuration) { + ALOGE("Failed to set duration (%d): %s", errno, strerror(errno)); + return Status::UNKNOWN_ERROR; + } + + if (isWaveform) { + mMode << WAVEFORM_MODE << std::endl; + } else { + mMode << RTP_MODE << std::endl; + } + + mActivate << 1 << std::endl; + if (!mActivate) { + ALOGE("Failed to activate (%d): %s", errno, strerror(errno)); + return Status::UNKNOWN_ERROR; + } + + return Status::OK; +} + +// Methods from ::android::hardware::vibrator::V1_1::IVibrator follow. +Return Vibrator::on(uint32_t timeoutMs) { + return on(timeoutMs, false /* forceOpenLoop */, false /* isWaveform */); +} + +Return Vibrator::off() { + mActivate << 0 << std::endl; + if (!mActivate) { + ALOGE("Failed to turn vibrator off (%d): %s", errno, strerror(errno)); + return Status::UNKNOWN_ERROR; + } + return Status::OK; +} + +Return Vibrator::supportsAmplitudeControl() { + return (mRtpInput ? true : false); +} + +Return Vibrator::setAmplitude(uint8_t amplitude) { + + if (amplitude == 0) { + return Status::BAD_VALUE; + } + + int32_t rtp_input = + std::round((amplitude - 1) / 254.0 * (MAX_RTP_INPUT - MIN_RTP_INPUT) + + MIN_RTP_INPUT); + + mRtpInput << rtp_input << std::endl; + if (!mRtpInput) { + ALOGE("Failed to set amplitude (%d): %s", errno, strerror(errno)); + return Status::UNKNOWN_ERROR; + } + + return Status::OK; +} + +static uint8_t convertEffectStrength(EffectStrength strength) { + uint8_t scale; + + switch (strength) { + case EffectStrength::LIGHT: + scale = 1; // 50% + break; + case EffectStrength::MEDIUM: + case EffectStrength::STRONG: + scale = 0; // 100% + break; + } + + return scale; +} + +Return Vibrator::perform(Effect effect, EffectStrength strength, perform_cb _hidl_cb) { + Status status = Status::OK; + uint32_t timeMS; + + if (effect == Effect::CLICK) { + mSequencer << WAVEFORM_CLICK_EFFECT_SEQ << std::endl; + timeMS = mClickDuration; + } else if (effect == Effect::DOUBLE_CLICK) { + mSequencer << WAVEFORM_DOUBLE_CLICK_EFFECT_SEQ << std::endl; + timeMS = WAVEFORM_DOUBLE_CLICK_EFFECT_MS; + } else { + _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); + return Void(); + } + + mScale << convertEffectStrength(strength) << std::endl; + on(timeMS, true /* forceOpenLoop */, true /* isWaveform */); + + _hidl_cb(status, timeMS); + return Void(); +} + +Return Vibrator::perform_1_1(Effect_1_1 effect, EffectStrength strength, + perform_cb _hidl_cb) { + Status status = Status::OK; + uint32_t timeMS; + + if (effect == Effect_1_1::TICK) { + mSequencer << WAVEFORM_TICK_EFFECT_SEQ << std::endl; + timeMS = mTickDuration; + } else if (effect < Effect_1_1::TICK) { + return perform(static_cast(effect), strength, _hidl_cb); + } else { + _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); + return Void(); + } + + mScale << convertEffectStrength(strength) << std::endl; + on(timeMS, true /* forceOpenLoop */, true /* isWaveform */); + + _hidl_cb(status, timeMS); + return Void(); +} + +} // namespace implementation +} // namespace V1_1 +} // namespace vibrator +} // namespace hardware +} // namespace android diff --git a/vibrator/Vibrator.h b/vibrator/Vibrator.h new file mode 100644 index 00000000..82d4da20 --- /dev/null +++ b/vibrator/Vibrator.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ANDROID_HARDWARE_VIBRATOR_V1_1_VIBRATOR_H +#define ANDROID_HARDWARE_VIBRATOR_V1_1_VIBRATOR_H + +#include +#include + +#include + +namespace android { +namespace hardware { +namespace vibrator { +namespace V1_1 { +namespace implementation { + +class Vibrator : public IVibrator { +public: + Vibrator(std::ofstream&& activate, std::ofstream&& duration, + std::ofstream&& state, std::ofstream&& rtpinput, + std::ofstream&& mode, std::ofstream&& sequencer, + std::ofstream&& scale, std::ofstream&& ctrlloop, std::ofstream&& lptrigger); + + // Methods from ::android::hardware::vibrator::V1_0::IVibrator follow. + using Status = ::android::hardware::vibrator::V1_0::Status; + Return on(uint32_t timeoutMs) override; + Return off() override; + Return supportsAmplitudeControl() override; + Return setAmplitude(uint8_t amplitude) override; + + using EffectStrength = ::android::hardware::vibrator::V1_0::EffectStrength; + using Effect = ::android::hardware::vibrator::V1_0::Effect; + Return perform(Effect effect, EffectStrength strength, perform_cb _hidl_cb) override; + Return perform_1_1(Effect_1_1 effect, EffectStrength strength, perform_cb _hidl_cb) override; + +private: + Return on(uint32_t timeoutMs, bool forceOpenLoop, bool isWaveform); + std::ofstream mActivate; + std::ofstream mDuration; + std::ofstream mState; + std::ofstream mRtpInput; + std::ofstream mMode; + std::ofstream mSequencer; + std::ofstream mScale; + std::ofstream mCtrlLoop; + std::ofstream mLpTriggerEffect; + int32_t mClickDuration; + int32_t mTickDuration; +}; +} // namespace implementation +} // namespace V1_1 +} // namespace vibrator +} // namespace hardware +} // namespace android + +#endif // ANDROID_HARDWARE_VIBRATOR_V1_1_VIBRATOR_H diff --git a/vibrator/android.hardware.vibrator@1.1-service.wahoo.rc b/vibrator/android.hardware.vibrator@1.1-service.wahoo.rc new file mode 100644 index 00000000..f9db6b01 --- /dev/null +++ b/vibrator/android.hardware.vibrator@1.1-service.wahoo.rc @@ -0,0 +1,4 @@ +service vibrator-1-1 /vendor/bin/hw/android.hardware.vibrator@1.1-service.wahoo + class hal + user system + group system diff --git a/vibrator/service.cpp b/vibrator/service.cpp new file mode 100644 index 00000000..c3af647b --- /dev/null +++ b/vibrator/service.cpp @@ -0,0 +1,210 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#define LOG_TAG "android.hardware.vibrator@1.1-service.wahoo" + +#include +#include +#include +#include +#include + +#include "Vibrator.h" + +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; +using android::hardware::vibrator::V1_1::IVibrator; +using android::hardware::vibrator::V1_1::implementation::Vibrator; +using namespace android; + +// Refer to Documentation/ABI/testing/sysfs-class-led-driver-drv2624 +// kernel documentation on the detail usages for ABIs below +static constexpr char ACTIVATE_PATH[] = "/sys/class/leds/vibrator/activate"; +static constexpr char DURATION_PATH[] = "/sys/class/leds/vibrator/duration"; +static constexpr char STATE_PATH[] = "/sys/class/leds/vibrator/state"; +static constexpr char RTP_INPUT_PATH[] = "/sys/class/leds/vibrator/device/rtp_input"; +static constexpr char MODE_PATH[] = "/sys/class/leds/vibrator/device/mode"; +static constexpr char SEQUENCER_PATH[] = "/sys/class/leds/vibrator/device/set_sequencer"; +static constexpr char SCALE_PATH[] = "/sys/class/leds/vibrator/device/scale"; +static constexpr char CTRL_LOOP_PATH[] = "/sys/class/leds/vibrator/device/ctrl_loop"; +static constexpr char LP_TRIGGER_PATH[] = "/sys/class/leds/vibrator/device/lp_trigger_effect"; + +// File path to the calibration file +static constexpr char CALIBRATION_FILEPATH[] = "/persist/haptics/drv2624.cal"; + +// Kernel ABIs for updating the calibration data +static constexpr char AUTOCAL_CONFIG[] = "autocal"; +static constexpr char LRA_PERIOD_CONFIG[] = "lra_period"; +static constexpr char AUTOCAL_FILEPATH[] = "/sys/class/leds/vibrator/device/autocal"; +static constexpr char OL_LRA_PERIOD_FILEPATH[] = "/sys/class/leds/vibrator/device/ol_lra_period"; + +static std::string trim(const std::string& str, + const std::string& whitespace = " \t") { + const auto str_begin = str.find_first_not_of(whitespace); + if (str_begin == std::string::npos) { + return ""; + } + + const auto str_end = str.find_last_not_of(whitespace); + const auto str_range = str_end - str_begin + 1; + + return str.substr(str_begin, str_range); +} + +static bool loadCalibrationData() { + std::map config_data; + + std::ofstream autocal{AUTOCAL_FILEPATH}; + if (!autocal) { + int error = errno; + ALOGE("Failed to open %s (%d): %s", AUTOCAL_FILEPATH, error, + strerror(error)); + return false; + } + + std::ofstream ol_lra_period{OL_LRA_PERIOD_FILEPATH}; + if (!ol_lra_period) { + int error = errno; + ALOGE("Failed to open %s (%d): %s", OL_LRA_PERIOD_FILEPATH, error, + strerror(error)); + return false; + } + + std::ifstream cal_data{CALIBRATION_FILEPATH}; + if (!cal_data) { + int error = errno; + ALOGE("Failed to open %s (%d): %s", CALIBRATION_FILEPATH, error, + strerror(error)); + return false; + } + + std::string line; + + while (std::getline(cal_data, line)) { + if (line.empty() || line[0] == '#') { + continue; + } + std::istringstream is_line(line); + std::string key; + if (std::getline(is_line, key, ':')) { + std::string value; + + if (std::getline(is_line, value)) { + config_data[trim(key)] = trim(value); + } + } + } + + if(config_data.find(AUTOCAL_CONFIG) != config_data.end()) { + autocal << config_data[AUTOCAL_CONFIG] << std::endl; + } + + if(config_data.find(LRA_PERIOD_CONFIG) != config_data.end()) { + ol_lra_period << config_data[LRA_PERIOD_CONFIG] << std::endl; + } + + return true; +} + +status_t registerVibratorService() { + // ostreams below are required + std::ofstream activate{ACTIVATE_PATH}; + if (!activate) { + int error = errno; + ALOGE("Failed to open %s (%d): %s", ACTIVATE_PATH, error, strerror(error)); + return -error; + } + + std::ofstream duration{DURATION_PATH}; + if (!duration) { + int error = errno; + ALOGE("Failed to open %s (%d): %s", DURATION_PATH, error, strerror(error)); + return -error; + } + + std::ofstream state{STATE_PATH}; + if (!state) { + int error = errno; + ALOGE("Failed to open %s (%d): %s", STATE_PATH, error, strerror(error)); + return -error; + } + + state << 1 << std::endl; + if (!state) { + int error = errno; + ALOGE("Failed to set state (%d): %s", errno, strerror(errno)); + return -error; + } + + // ostreams below are optional + std::ofstream rtpinput{RTP_INPUT_PATH}; + if (!rtpinput) { + int error = errno; + ALOGW("Failed to open %s (%d): %s", RTP_INPUT_PATH, error, strerror(error)); + } + + std::ofstream mode{MODE_PATH}; + if (!mode) { + int error = errno; + ALOGW("Failed to open %s (%d): %s", MODE_PATH, error, strerror(error)); + } + + std::ofstream sequencer{SEQUENCER_PATH}; + if (!sequencer) { + int error = errno; + ALOGW("Failed to open %s (%d): %s", SEQUENCER_PATH, error, strerror(error)); + } + + std::ofstream scale{SCALE_PATH}; + if (!scale) { + int error = errno; + ALOGW("Failed to open %s (%d): %s", SCALE_PATH, error, strerror(error)); + } + + std::ofstream ctrlloop{CTRL_LOOP_PATH}; + if (!ctrlloop) { + int error = errno; + ALOGW("Failed to open %s (%d): %s", CTRL_LOOP_PATH, error, strerror(error)); + } + + std::ofstream lptrigger{LP_TRIGGER_PATH}; + if (!lptrigger) { + int error = errno; + ALOGW("Failed to open %s (%d): %s", LP_TRIGGER_PATH, error, strerror(error)); + } + + if (!loadCalibrationData()) { + ALOGW("Failed load calibration data"); + } + + sp vibrator = new Vibrator(std::move(activate), std::move(duration), + std::move(state), std::move(rtpinput), std::move(mode), + std::move(sequencer), std::move(scale), std::move(ctrlloop), std::move(lptrigger)); + + vibrator->registerAsService(); + + return OK; +} + +int main() { + configureRpcThreadpool(1, true); + status_t status = registerVibratorService(); + + if (status != OK) { + return status; + } + + joinRpcThreadpool(); +} diff --git a/vndk/Android.mk b/vndk/Android.mk new file mode 100644 index 00000000..eb4fbc36 --- /dev/null +++ b/vndk/Android.mk @@ -0,0 +1,55 @@ +ifneq ($(filter muskie walleye taimen, $(TARGET_DEVICE)),) +LOCAL_PATH := $(call my-dir) + +VNDK_SP_LIBRARIES := \ + android.hardware.renderscript@1.0\ + android.hardware.graphics.allocator@2.0\ + android.hardware.graphics.mapper@2.0\ + android.hardware.graphics.common@1.0\ + libhwbinder\ + libbase\ + libcutils\ + libhardware\ + libhidlbase\ + libhidltransport\ + libutils\ + libc++\ + libRS_internal\ + libRSDriver\ + libRSCpuRef\ + libbcinfo\ + libblas\ + libft2\ + libpng\ + libcompiler_rt\ + libbacktrace\ + libunwind\ + liblzma\ + +define add-vndk-sp-lib +include $$(CLEAR_VARS) +LOCAL_MODULE := $1.vndk-sp +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_PREBUILT_MODULE_FILE := $$(TARGET_OUT)/lib/$1.so +LOCAL_MULTILIB := 32 +LOCAL_MODULE_TAGS := optional +LOCAL_INSTALLED_MODULE_STEM := $1.so +LOCAL_MODULE_SUFFIX := .so +LOCAL_MODULE_RELATIVE_PATH := vndk-sp +include $$(BUILD_PREBUILT) + +include $$(CLEAR_VARS) +LOCAL_MODULE := $1.vndk-sp +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_PREBUILT_MODULE_FILE := $$(TARGET_OUT)/lib64/$1.so +LOCAL_MULTILIB := 64 +LOCAL_MODULE_TAGS := optional +LOCAL_INSTALLED_MODULE_STEM := $1.so +LOCAL_MODULE_SUFFIX := .so +LOCAL_MODULE_RELATIVE_PATH := vndk-sp +include $$(BUILD_PREBUILT) +endef + +$(foreach lib,$(VNDK_SP_LIBRARIES),\ + $(eval $(call add-vndk-sp-lib,$(lib)))) +endif # if TARGET_DEVICE is muskie or walleye diff --git a/vr/Android.bp b/vr/Android.bp new file mode 100644 index 00000000..99aef7d8 --- /dev/null +++ b/vr/Android.bp @@ -0,0 +1,30 @@ +// +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +cc_binary { + name: "android.hardware.vr@1.0-service.wahoo", + relative_install_path: "hw", + init_rc: ["android.hardware.vr@1.0-service.wahoo.rc"], + srcs: ["service.cpp", "VrDevice.cpp"], + cflags: ["-Werror", "-Wall"], + shared_libs: [ + "libbase", + "libhidlbase", + "libhidltransport", + "liblog", + "libutils", + "android.hardware.vr@1.0", + ], + proprietary: true, +} diff --git a/vr/NOTICE b/vr/NOTICE new file mode 100644 index 00000000..667db97b --- /dev/null +++ b/vr/NOTICE @@ -0,0 +1,10 @@ +Copyright (C) 2017 The Android Open Source Project + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vr/VrDevice.cpp b/vr/VrDevice.cpp new file mode 100644 index 00000000..c9966abf --- /dev/null +++ b/vr/VrDevice.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "VrDevice" + +#include +#include +#include "VrDevice.h" + +namespace android { +namespace hardware { +namespace vr { +namespace V1_0 { +namespace implementation { + +VrDevice::VrDevice() {} + +Return VrDevice::init() { + // NOOP + return Void(); +} + +Return VrDevice::setVrMode(bool enabled) { + if (enabled) { + if (!android::base::SetProperty("sys.qcom.thermalcfg", "/vendor/etc/thermal-engine-vr.conf")) { + LOG(ERROR) << "Couldn't set thermal_engine enable property"; + return Void(); + } + } else { + if (!android::base::SetProperty("sys.qcom.thermalcfg", "/vendor/etc/thermal-engine.conf")) { + LOG(ERROR) << "Couldn't set thermal_engine disable property"; + return Void(); + } + } + if (!android::base::SetProperty("ctl.restart", "thermal-engine")) { + LOG(ERROR) << "Couldn't set thermal_engine restart property"; + } + if (!access("/sys/devices/virtual/input/ftm4_touch/vrmode", W_OK)) { + FILE *f = fopen("/sys/devices/virtual/input/ftm4_touch/vrmode", "w"); + if (f) { + fprintf(f, "%d", (enabled ? 1 : 0)); + fclose(f); + } + else { + LOG(ERROR) << "Couldn't open vrmode sysfs node"; + } + } + return Void(); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace vr +} // namespace hardware +} // namespace android diff --git a/vr/VrDevice.h b/vr/VrDevice.h new file mode 100644 index 00000000..cd754508 --- /dev/null +++ b/vr/VrDevice.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ANDROID_HARDWARE_VR_V1_0_VR_H +#define ANDROID_HARDWARE_VR_V1_0_VR_H + +#include + +namespace android { +namespace hardware { +namespace vr { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::vr::V1_0::IVr; +using ::android::hardware::Return; + +struct VrDevice : public IVr { + VrDevice(); + + Return init() override; + Return setVrMode(bool enabled) override; +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace vr +} // namespace hardware +} // namespace android + +#endif // ANDROID_HARDWARE_VR_V1_0_VR_H diff --git a/vr/android.hardware.vr@1.0-service.wahoo.rc b/vr/android.hardware.vr@1.0-service.wahoo.rc new file mode 100644 index 00000000..7a66e903 --- /dev/null +++ b/vr/android.hardware.vr@1.0-service.wahoo.rc @@ -0,0 +1,4 @@ +service vr-wahoo-1-0 /vendor/bin/hw/android.hardware.vr@1.0-service.wahoo + class hal + user system + group system diff --git a/vr/service.cpp b/vr/service.cpp new file mode 100644 index 00000000..a04991b0 --- /dev/null +++ b/vr/service.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#define LOG_TAG "android.hardware.vr@1.0-service.wahoo" + +#include +#include +#include +#include + +#include "VrDevice.h" + +using ::android::hardware::configureRpcThreadpool; +using ::android::hardware::joinRpcThreadpool; +using ::android::hardware::vr::V1_0::implementation::VrDevice; +using ::android::hardware::vr::V1_0::IVr; +using ::android::sp; + +int main(int /* argc */, char* /* argv */ []) { + sp vr = new VrDevice; + configureRpcThreadpool(1, true); + CHECK_EQ(vr->registerAsService(), android::NO_ERROR) + << "Failed to register vr HAL"; + joinRpcThreadpool(); + return 0; +} diff --git a/wifi_concurrency_cfg.txt b/wifi_concurrency_cfg.txt new file mode 100644 index 00000000..fa2764c6 --- /dev/null +++ b/wifi_concurrency_cfg.txt @@ -0,0 +1,3 @@ +ENABLE_STA_SAP_CONCURRENCY:1 +SAP_INTERFACE_NAME:softap0 +SAP_CHANNEL:6 diff --git a/wifi_offload/Android.bp b/wifi_offload/Android.bp new file mode 100644 index 00000000..00a12b9d --- /dev/null +++ b/wifi_offload/Android.bp @@ -0,0 +1,89 @@ +// +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +cc_library_static { + name: "android.hardware.wifi.offload@1.0-lib", + vendor: true, + srcs: ["Offload.cpp", + "chre_constants.cpp", + "chre_interface.cpp", + "offload_server.cpp", + "chre_interface_factory.cpp", + "offload_status_util.cpp", + ], + cflags: ["-Wall", "-Wextra"], + shared_libs: [ + "libbase", + "libhidlbase", + "libhidltransport", + "liblog", + "libutils", + "android.hardware.wifi.offload@1.0", + ], + whole_static_libs: [ + "chre_client" + ] +} + +cc_binary { + name: "android.hardware.wifi.offload@1.0-service", + relative_install_path: "hw", + init_rc: ["android.hardware.wifi.offload@1.0-service.rc"], + srcs: ["service.cpp"], + cflags: ["-Wall", "-Wextra"], + shared_libs: [ + "libbase", + "libhidlbase", + "libhidltransport", + "liblog", + "libutils", + "android.hardware.wifi.offload@1.0", + ], + static_libs: [ + "android.hardware.wifi.offload@1.0-lib", + ], + vendor: true, +} + +cc_test { + name: "wifi-offload-service-unit-tests", + vendor: true, + srcs: [ + "test/main.cpp", + "test/mock_chre_interface_callbacks.cpp", + "test/mock_chre_interface_factory.cpp", + "test/mock_chre_interface.cpp", + "test/offload_server_test.cpp", + "test/chre_interface_test.cpp", + ], + local_include_dirs: [ + "test", + ".", + ], + shared_libs: [ + "libbase", + "libhidlbase", + "libhidltransport", + "libutils", + "liblog", + "android.hardware.wifi.offload@1.0", + ], + static_libs: [ + "libgmock", + "libgtest", + "android.hardware.wifi.offload@1.0-lib", + ], +} + diff --git a/wifi_offload/AndroidTest.xml b/wifi_offload/AndroidTest.xml new file mode 100644 index 00000000..107e31ca --- /dev/null +++ b/wifi_offload/AndroidTest.xml @@ -0,0 +1,26 @@ + + + + + + diff --git a/wifi_offload/Offload.cpp b/wifi_offload/Offload.cpp new file mode 100644 index 00000000..78009e4d --- /dev/null +++ b/wifi_offload/Offload.cpp @@ -0,0 +1,82 @@ +#include "Offload.h" + +#include + +#include "chre_interface_factory.h" +#include "hidl_return_util.h" + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +using hidl_return_util::validateAndCall; + +Offload::Offload() + : mOffloadServer(new OffloadServer(new ChreInterfaceFactory())), cookie_(0), + death_handler_(new HidlDeathHandler( + std::bind(&Offload::onObjectDeath, this, std::placeholders::_1))) { + LOG(android::base::INFO) << "Wifi Offload HAL impl"; +} + +// Methods from ::android::hardware::wifi::offload::V1_0::IOffload follow. +Return Offload::configureScans(const ScanParam ¶m, const ScanFilter &filter, + configureScans_cb _hidl_cb) { + return validateAndCall(this, &Offload::configureScansInternal, _hidl_cb, param, filter); +} + +Return Offload::getScanStats(getScanStats_cb _hidl_cb) { + return validateAndCall(this, &Offload::getScanStatsInternal, _hidl_cb); +} + +Return Offload::subscribeScanResults(uint32_t delayMs, subscribeScanResults_cb _hidl_cb) { + return validateAndCall(this, &Offload::subscribeScanResultsInternal, _hidl_cb, delayMs); +} + +Return Offload::unsubscribeScanResults() { + if (!mOffloadServer->unsubscribeScanResults()) { + LOG(ERROR) << "Unable to unsubscribe"; + } + return Void(); +} + +Return Offload::setEventCallback(const sp& cb) { + if (!mOffloadServer->setEventCallback(cb)) { + LOG(ERROR) << "No callback set"; + return Void(); + } + cookie_ = reinterpret_cast(cb.get()); + death_handler_->setCallback(cb); + cb->linkToDeath(death_handler_, cookie_); + return Void(); +} + +OffloadStatus Offload::configureScansInternal(const ScanParam ¶m, const ScanFilter &filter) { + return mOffloadServer->configureScans(param, filter); +} + +std::pair Offload::getScanStatsInternal() { + return mOffloadServer->getScanStats(); +} + +OffloadStatus Offload::subscribeScanResultsInternal(uint32_t delayMs) { + return mOffloadServer->subscribeScanResults(delayMs); +} + +void Offload::onObjectDeath(uint64_t cookie) { + if (cookie == cookie_) { + LOG(DEBUG) << "OffloadCallback death notification received"; + mOffloadServer->clearEventCallback(); + cookie_ = 0; + } +} +// Methods from ::android::hidl::base::V1_0::IBase follow. + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android diff --git a/wifi_offload/Offload.h b/wifi_offload/Offload.h new file mode 100644 index 00000000..4510f680 --- /dev/null +++ b/wifi_offload/Offload.h @@ -0,0 +1,87 @@ +#ifndef ANDROID_HARDWARE_WIFI_OFFLOAD_V1_0_OFFLOAD_H +#define ANDROID_HARDWARE_WIFI_OFFLOAD_V1_0_OFFLOAD_H + +#include + +#include +#include +#include + +#include "offload_server.h" + +namespace { +// Type of callback invoked by the death handler. +using on_death_cb_function = std::function; + +// Private class used to keep track of death of callbacks +template +class HidlDeathHandler : public android::hardware::hidl_death_recipient { + public: + HidlDeathHandler(const on_death_cb_function &user_cb_function) + : cb_function_(user_cb_function) { + } + ~HidlDeathHandler() = default; + + // Death notification for callbacks. + void serviceDied(uint64_t cookie, + const android::wp &who) override { + cb_.clear(); + cb_function_(cookie); + } + + void setCallback(android::wp cb) { + cb_ = cb; + } + + private: + android::wp cb_; + on_death_cb_function cb_function_; + + DISALLOW_COPY_AND_ASSIGN(HidlDeathHandler); +}; +} // namespace + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +/** + * Interface object to communicate with Offload HAL + */ +class Offload : public IOffload { + public: + Offload(); + + // Methods from ::android::hardware::wifi::offload::V1_0::IOffload follow. + Return configureScans(const ScanParam ¶m, const ScanFilter &filter, + configureScans_cb _hidl_cb) override; + Return getScanStats(getScanStats_cb _hidl_cb) override; + Return subscribeScanResults(uint32_t delayMs, subscribeScanResults_cb _hidl_cb) override; + Return unsubscribeScanResults() override; + Return setEventCallback(const sp& cb) override; + // Methods from ::android::hidl::base::V1_0::IBase follow. + + private: + OffloadStatus configureScansInternal(const ScanParam ¶m, const ScanFilter &filter); + std::pair getScanStatsInternal(); + OffloadStatus subscribeScanResultsInternal(uint32_t delayMs); + void onObjectDeath(uint64_t cookie); + + std::unique_ptr mOffloadServer; + uint64_t cookie_; + sp> death_handler_; + + DISALLOW_COPY_AND_ASSIGN(Offload); +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android + +#endif // ANDROID_HARDWARE_WIFI_OFFLOAD_V1_0_OFFLOAD_H diff --git a/wifi_offload/android.hardware.wifi.offload@1.0-service.rc b/wifi_offload/android.hardware.wifi.offload@1.0-service.rc new file mode 100644 index 00000000..84e03911 --- /dev/null +++ b/wifi_offload/android.hardware.wifi.offload@1.0-service.rc @@ -0,0 +1,4 @@ +service offload-hal-1-0 /vendor/bin/hw/android.hardware.wifi.offload@1.0-service + class hal + user wifi + group wifi system diff --git a/wifi_offload/chre_constants.cpp b/wifi_offload/chre_constants.cpp new file mode 100644 index 00000000..e82a5556 --- /dev/null +++ b/wifi_offload/chre_constants.cpp @@ -0,0 +1,27 @@ +#include "chre_constants.h" + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { +namespace chre_constants { + +const char kSocketName[] = "chre"; +const uint64_t kWifiOffloadNanoAppId = 5147455389092024332; +const uint32_t kMaxMessageLen = 2048; +const uint32_t kHubInfoRequestBufLen = 64; +const uint32_t kNanoAppListRequestBufLen = 64; +const uint32_t kSubscriptionDelayMsBufLen = 4; +const uint32_t kNanosecondsPerMillisecond = 1e6; +const size_t kBssidLen = 6; +const size_t kHistogramChannels = 256; + +} // namespace chre_constants +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android diff --git a/wifi_offload/chre_constants.h b/wifi_offload/chre_constants.h new file mode 100644 index 00000000..da8e6f6e --- /dev/null +++ b/wifi_offload/chre_constants.h @@ -0,0 +1,32 @@ +#ifndef WIFI_OFFLOAD_CHRE_CONSTANTS_H_ +#define WIFI_OFFLOAD_CHRE_CONSTANTS_H_ + +#include + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { +namespace chre_constants { + +extern const char kSocketName[]; +extern const uint64_t kWifiOffloadNanoAppId; +extern const uint32_t kMaxMessageLen; +extern const uint32_t kHubInfoRequestBufLen; +extern const uint32_t kNanoAppListRequestBufLen; +extern const uint32_t kSubscriptionDelayMsBufLen; +extern const uint32_t kNanosecondsPerMillisecond; +extern const size_t kHistogramChannels; +extern const size_t kBssidLen; + +} // namespace chre_constants +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android + +#endif // WIFI_OFFLOAD_CHRE_CONSTANTS_H_ diff --git a/wifi_offload/chre_interface.cpp b/wifi_offload/chre_interface.cpp new file mode 100644 index 00000000..456e6682 --- /dev/null +++ b/wifi_offload/chre_interface.cpp @@ -0,0 +1,189 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "chre_interface.h" + +#include + +#include + +#include "chre_host/host_protocol_host.h" + +using android::chre::HostProtocolHost; +using flatbuffers::FlatBufferBuilder; + +namespace chre_constants = android::hardware::wifi::offload::V1_0::implementation::chre_constants; + +namespace fbs = ::chre::fbs; + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +SocketCallbacks::SocketCallbacks(ChreInterface* parent) : mParent(parent) { +} + +void SocketCallbacks::onMessageReceived(const void* data, size_t length) { + LOG(VERBOSE) << "Message received from CHRE socket"; + if (!HostProtocolHost::decodeMessageFromChre(data, length, *this)) { + LOG(WARNING) << "Failed to decode message"; + } +} + +void SocketCallbacks::onConnected() { + LOG(INFO) << "Connected to CHRE socket"; + mParent->reportConnectionEvent(ChreInterfaceCallbacks::CONNECTED); +} + +void SocketCallbacks::onConnectionAborted() { + LOG(WARNING) << "Connection to CHRE socket Aborted"; + mParent->reportConnectionEvent(ChreInterfaceCallbacks::CONNECTION_ABORT); +} + +void SocketCallbacks::onDisconnected() { + LOG(WARNING) << "Disconnected from CHRE socket"; + mParent->reportConnectionEvent(ChreInterfaceCallbacks::DISCONNECTED); +} + +void SocketCallbacks::handleNanoappMessage(uint64_t appId, uint32_t messageType, + uint16_t hostEndpoint, const void* messageData, + size_t messageDataLen) { + LOG(VERBOSE) << "handleNanoappMessage from appId: " << appId; + LOG(VERBOSE) << "HostEndPoint: " << hostEndpoint; + if (appId == chre_constants::kWifiOffloadNanoAppId) { + mParent->handleMessage(messageType, messageData, messageDataLen); + } +} + +void SocketCallbacks::handleHubInfoResponse(const char* name, const char* vendor, + const char* toolchain, uint32_t legacyPlatformVersion, + uint32_t legacyToolchainVersion, float peakMips, + float stoppedPower, float sleepPower, float peakPower, + uint32_t maxMessageLen, uint64_t platformId, + uint32_t version) { + LOG(VERBOSE) << "Hub Info response"; + LOG(VERBOSE) << "Hub Info name: " << name; + LOG(VERBOSE) << "Version : " << version; + LOG(VERBOSE) << "Legacy Platform Version: " << legacyPlatformVersion; + LOG(VERBOSE) << "Legacy Toolchain Version: " << legacyToolchainVersion; + LOG(VERBOSE) << "Peak Mips: " << peakMips; + LOG(VERBOSE) << "Stopped Power: " << stoppedPower; + LOG(VERBOSE) << "Sleep Power: " << sleepPower; + LOG(VERBOSE) << "Peak Power: " << peakPower; + LOG(VERBOSE) << "Platform ID: " << platformId; + LOG(VERBOSE) << "Vendor : " << vendor; + LOG(VERBOSE) << "Toolchain : " << toolchain; + LOG(VERBOSE) << "maxMessageLen : " << maxMessageLen; + if (maxMessageLen < chre_constants::kMaxMessageLen) { + LOG(WARNING) << "Incorrect max message length"; + } +} + +void SocketCallbacks::handleNanoappListResponse(const fbs::NanoappListResponseT& response) { + LOG(VERBOSE) << "handleNanoAppListResponse"; + for (const std::unique_ptr& nanoapp : response.nanoapps) { + if (nanoapp == nullptr) { + continue; + } + if (nanoapp->app_id == chre_constants::kWifiOffloadNanoAppId && nanoapp->enabled) { + LOG(INFO) << "Wifi Offload Nano app found"; + LOG(INFO) << "Version: " << nanoapp->version; + break; + } + } +} + +void SocketCallbacks::handleLoadNanoappResponse(const fbs::LoadNanoappResponseT& response) { + LOG(VERBOSE) << "Load Nano app response"; + LOG(VERBOSE) << "Transaction ID: " << response.transaction_id; + LOG(VERBOSE) << "Status: " << response.success; +} + +void SocketCallbacks::handleUnloadNanoappResponse(const fbs::UnloadNanoappResponseT& response) { + LOG(VERBOSE) << "Unload Nano app response"; + LOG(VERBOSE) << "Transaction ID: " << response.transaction_id; + LOG(VERBOSE) << "Status: " << response.success; +} + +ChreInterface::ChreInterface(ChreInterfaceCallbacks* callback) + : mSocketCallbacks(new SocketCallbacks(this)), mServerCallbacks(callback), + mSocketConnected(false) { + if (!mClient.connectInBackground(chre_constants::kSocketName, mSocketCallbacks)) { + LOG(ERROR) << "Offload HAL is not connected to Chre"; + } +} + +ChreInterface::~ChreInterface() { + mClient.disconnect(); +} + +bool ChreInterface::isConnected() { + std::lock_guard lock(mChreInterfaceLock); + return mSocketConnected; +} + +void ChreInterface::reportConnectionEvent(ChreInterfaceCallbacks::ConnectionEvent event) { + bool connectionStatus = false; + switch (event) { + case ChreInterfaceCallbacks::ConnectionEvent::CONNECTED: + connectionStatus = true; + break; + case ChreInterfaceCallbacks::ConnectionEvent::DISCONNECTED: + case ChreInterfaceCallbacks::ConnectionEvent::CONNECTION_ABORT: + break; + default: + LOG(WARNING) << "Invalid connection event recieved"; + return; + } + { + std::lock_guard lock(mChreInterfaceLock); + mSocketConnected = connectionStatus; + } + mServerCallbacks->handleConnectionEvents(event); +} + +bool ChreInterface::sendCommandToApp(uint32_t messageType, const std::vector& message) { + FlatBufferBuilder builder(chre_constants::kMaxMessageLen); + void* messageData = nullptr; + size_t messageDataLen = message.size(); + if (messageDataLen > 0) { + messageData = (void*)message.data(); + } + HostProtocolHost::encodeNanoappMessage(builder, chre_constants::kWifiOffloadNanoAppId, + messageType, 0, messageData, messageDataLen); + if (!mClient.sendMessage(builder.GetBufferPointer(), builder.GetSize())) { + LOG(WARNING) << "Failed to send message to Nano app"; + return false; + } + LOG(VERBOSE) << "Command sent " << messageType; + return true; +} + +void ChreInterface::handleMessage(uint32_t messageType, const void* messageData, + size_t messageDataLen) { + const uint8_t* messageBuf = reinterpret_cast(messageData); + std::vector message(messageBuf, messageBuf + messageDataLen); + mServerCallbacks->handleMessage(messageType, message); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android diff --git a/wifi_offload/chre_interface.h b/wifi_offload/chre_interface.h new file mode 100644 index 00000000..72420af5 --- /dev/null +++ b/wifi_offload/chre_interface.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef WIFI_OFFLOAD_CHRE_INTERFACE_H_ +#define WIFI_OFFLOAD_CHRE_INTERFACE_H_ + +#include "chre_constants.h" +#include "chre_host/host_protocol_host.h" +#include "chre_host/socket_client.h" +#include "chre_interface_callbacks.h" + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +class ChreInterface; + +class SocketCallbacks + : public ::android::chre::SocketClient::ICallbacks, + public ::android::chre::IChreMessageHandlers { + public: + SocketCallbacks(ChreInterface* parent); + void onMessageReceived(const void* data, size_t length) override; + void onConnected() override; + void onConnectionAborted() override; + void onDisconnected() override; + void handleNanoappMessage(uint64_t appId, uint32_t messageType, uint16_t hostEndpoint, + const void* messageData, size_t messageDataLen) override; + void handleHubInfoResponse(const char* name, const char* vendor, const char* toolchain, + uint32_t legacyPlatformVersion, uint32_t legacyToolchainVersion, + float peakMips, float stoppedPower, float sleepPower, + float peakPower, uint32_t maxMessageLen, uint64_t platformId, + uint32_t version) override; + void handleNanoappListResponse(const ::chre::fbs::NanoappListResponseT& response) override; + void handleLoadNanoappResponse(const ::chre::fbs::LoadNanoappResponseT& response) override; + void handleUnloadNanoappResponse(const ::chre::fbs::UnloadNanoappResponseT& response) override; + + private: + ChreInterface* mParent; +}; + +class ChreInterface { + public: + ChreInterface(ChreInterfaceCallbacks* callback); + ~ChreInterface(); + /* Return the status of socket connection */ + bool isConnected(); + /* Send a message to the Nano app, returns true if send successful */ + bool sendCommandToApp(uint32_t messageType, const std::vector& message); + /* Connected or connection restart handling method */ + void reportConnectionEvent(ChreInterfaceCallbacks::ConnectionEvent /* event */); + /* Requests Hub Information, returns true if Hub Info request was sent */ + bool getHubInfo(); + /* Request list of Nano apps, returns true if Nano app List request was sent */ + bool getNanoAppList(); + /* Invoked by the socket callbacks when a message is recieved from Nano app */ + void handleMessage(uint32_t messageType, const void* messageData, size_t messageDataLen); + + private: + ::android::chre::SocketClient mClient; + sp mSocketCallbacks; + ChreInterfaceCallbacks* mServerCallbacks; + std::mutex mChreInterfaceLock; + bool mSocketConnected; +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android +#endif // WIFI_OFFLOAD_CHRE_INTERFACE_H_ diff --git a/wifi_offload/chre_interface_callbacks.h b/wifi_offload/chre_interface_callbacks.h new file mode 100644 index 00000000..7528214f --- /dev/null +++ b/wifi_offload/chre_interface_callbacks.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef WIFI_OFFLOAD_CHRE_INTERFACE_CALLBACKS_H +#define WIFI_OFFLOAD_CHRE_INTERFACE_CALLBACKS_H + +#include + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +class ChreInterfaceCallbacks { + public: + enum ConnectionEvent { CONNECTED, DISCONNECTED, CONNECTION_ABORT }; + virtual ~ChreInterfaceCallbacks() {} + + /* Invoked by the Chre interface when connection events are received */ + virtual void handleConnectionEvents(ConnectionEvent event) = 0; + /* Invoked by the Chre interface when a message is recieved from Nano app */ + virtual void handleMessage(uint32_t messageType, const std::vector& message) = 0; +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android +#endif // WIFI_OFFLOAD_CHRE_INTERFACE_CALLBACKS_H diff --git a/wifi_offload/chre_interface_factory.cpp b/wifi_offload/chre_interface_factory.cpp new file mode 100644 index 00000000..40ba47cc --- /dev/null +++ b/wifi_offload/chre_interface_factory.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "chre_interface_factory.h" + +#include + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +ChreInterface* ChreInterfaceFactory::getChreInterface(ChreInterfaceCallbacks* serverCallbacks) { + return new ChreInterface(serverCallbacks); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android diff --git a/wifi_offload/chre_interface_factory.h b/wifi_offload/chre_interface_factory.h new file mode 100644 index 00000000..69247b25 --- /dev/null +++ b/wifi_offload/chre_interface_factory.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef WIFI_OFFLOAD_CHRE_INTERFACE_FACTORY_H_ +#define WIFI_OFFLOAD_CHRE_INTERFACE_FACTORY_H_ + +#include "chre_interface.h" +#include "chre_interface_callbacks.h" + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +class ChreInterfaceFactory { + public: + ChreInterfaceFactory() = default; + virtual ~ChreInterfaceFactory() = default; + virtual ChreInterface* getChreInterface(ChreInterfaceCallbacks* server); +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android + +#endif // WIFI_OFFLOAD_CHRE_INTERFACE_FACTORY_H_ diff --git a/wifi_offload/hidl_return_util.h b/wifi_offload/hidl_return_util.h new file mode 100644 index 00000000..b96fb011 --- /dev/null +++ b/wifi_offload/hidl_return_util.h @@ -0,0 +1,71 @@ +/* + * hidl interface for wpa_supplicant daemon + * Copyright (c) 2004-2016, Jouni Malinen + * Copyright (c) 2004-2016, Roshan Pius + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#ifndef HIDL_RETURN_UTIL_H_ +#define HIDL_RETURN_UTIL_H_ + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { +namespace hidl_return_util { + +/** + * These utility functions are used to invoke a method on the provided + * HIDL interface object. + * It then invokes the HIDL continuation callback with the status and + * any returned values. + */ +// Use for HIDL methods which return only an instance of OffloadStatus. +template +Return validateAndCall(ObjT* obj, WorkFuncT&& work, + const std::function& hidl_cb, + Args&&... args) { + hidl_cb((obj->*work)(std::forward(args)...)); + return Void(); +} + +// Use for HIDL methods which return instance of OffloadStatus and a single +// return value. +template +Return validateAndCall(ObjT* obj, WorkFuncT&& work, + const std::function& hidl_cb, + Args&&... args) { + const auto& ret_pair = (obj->*work)(std::forward(args)...); + const OffloadStatus& status = std::get<0>(ret_pair); + const auto& ret_value = std::get<1>(ret_pair); + hidl_cb(status, ret_value); + return Void(); +} + +// Use for HIDL methods which return instance of OffloadStatus and 2 return +// values. +template +Return +validateAndCall(ObjT* obj, WorkFuncT&& work, + const std::function& hidl_cb, + Args&&... args) { + const auto& ret_tuple = (obj->*work)(std::forward(args)...); + const OffloadStatus& status = std::get<0>(ret_tuple); + const auto& ret_value1 = std::get<1>(ret_tuple); + const auto& ret_value2 = std::get<2>(ret_tuple); + hidl_cb(status, ret_value1, ret_value2); + return Void(); +} + +} // namespace hidl_return_util +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android +#endif // HIDL_RETURN_UTIL_H_ diff --git a/wifi_offload/offload_server.cpp b/wifi_offload/offload_server.cpp new file mode 100644 index 00000000..88277ec5 --- /dev/null +++ b/wifi_offload/offload_server.cpp @@ -0,0 +1,85 @@ +#include "offload_server.h" + +#include + +#include "offload_status_util.h" + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +class OffloadServer; + +OffloadServer::OffloadServer(ChreInterfaceFactory* factory) + : mChreInterfaceCallbacks(new ChreInterfaceCallbacksImpl(this)), + mChreInterface(factory->getChreInterface(mChreInterfaceCallbacks.get())) { + LOG(VERBOSE) << "Wifi Offload HAL impl"; +} + +OffloadStatus OffloadServer::configureScans(const ScanParam& param, const ScanFilter& filter) { + LOG(INFO) << "configureScans"; + return createOffloadStatus(OffloadStatusCode::OK); +} + +std::pair OffloadServer::getScanStats() { + LOG(INFO) << "getScanStats"; + OffloadStatus status = createOffloadStatus(OffloadStatusCode::OK); + return std::make_pair(status, mScanStats); +} + +OffloadStatus OffloadServer::subscribeScanResults(uint32_t delayMs) { + LOG(INFO) << "subscribeScanResults with delay:" << delayMs; + return createOffloadStatus(OffloadStatusCode::OK); +} + +bool OffloadServer::unsubscribeScanResults() { + LOG(INFO) << "unsubscribeScanResults"; + return true; +} + +bool OffloadServer::setEventCallback(const sp& cb) { + LOG(INFO) << "Set Event callback"; + bool result = false; + if (cb != nullptr) { + mEventCallback = cb; + result = true; + } else { + LOG(WARNING) << "Invalid callback object"; + } + return result; +} + +void OffloadServer::clearEventCallback() { + if (mEventCallback != nullptr) { + mEventCallback.clear(); + } + LOG(INFO) << "Event callback cleared"; +} + +ChreInterfaceCallbacksImpl::ChreInterfaceCallbacksImpl(OffloadServer* server) : mServer(server) { +} + +ChreInterfaceCallbacksImpl::~ChreInterfaceCallbacksImpl() { +} + +void ChreInterfaceCallbacksImpl::handleConnectionEvents( + ChreInterfaceCallbacks::ConnectionEvent event) { + LOG(VERBOSE) << "Connection event received " << (int)event; +} + +void ChreInterfaceCallbacksImpl::handleMessage(uint32_t messageType, + const std::vector& message) { + LOG(VERBOSE) << "Message from Nano app " << messageType; +} + +// Methods from ::android::hidl::base::V1_0::IBase follow. + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android diff --git a/wifi_offload/offload_server.h b/wifi_offload/offload_server.h new file mode 100644 index 00000000..f10ace16 --- /dev/null +++ b/wifi_offload/offload_server.h @@ -0,0 +1,59 @@ +#ifndef WIFI_OFFLOAD_SERVER_H_ +#define WIFI_OFFLOAD_SERVER_H_ + +#include + +#include "chre_interface_factory.h" + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +class OffloadServer; + +class ChreInterfaceCallbacksImpl : public ChreInterfaceCallbacks { + public: + ChreInterfaceCallbacksImpl(OffloadServer* server); + ~ChreInterfaceCallbacksImpl() override; + + void handleConnectionEvents(ChreInterfaceCallbacks::ConnectionEvent event); + void handleMessage(uint32_t messageType, const std::vector& message); + + private: + OffloadServer* mServer; +}; + +/** + * Interface object to communicate with Offload HAL + */ +class OffloadServer { + public: + OffloadServer(ChreInterfaceFactory* factory); + + OffloadStatus configureScans(const ScanParam& param, const ScanFilter& filter); + std::pair getScanStats(); + OffloadStatus subscribeScanResults(uint32_t delayMs); + bool unsubscribeScanResults(); + bool setEventCallback(const sp& cb); + void clearEventCallback(); + + private: + ScanStats mScanStats; + std::unique_ptr mChreInterfaceCallbacks; + std::unique_ptr mChreInterface; + sp mEventCallback; + + friend class ChreInterfaceCallbacksImpl; +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android + +#endif // WIFI_OFFLOAD_SERVER_H_ diff --git a/wifi_offload/offload_status_util.cpp b/wifi_offload/offload_status_util.cpp new file mode 100644 index 00000000..d6335e8c --- /dev/null +++ b/wifi_offload/offload_status_util.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "offload_status_util.h" + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +OffloadStatus createOffloadStatus(OffloadStatusCode code, const std::string &description) { + return {code, description}; +} + +OffloadStatus createOffloadStatus(OffloadStatusCode code) { + return createOffloadStatus(code, ""); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android diff --git a/wifi_offload/offload_status_util.h b/wifi_offload/offload_status_util.h new file mode 100644 index 00000000..8e2cb9b9 --- /dev/null +++ b/wifi_offload/offload_status_util.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OFFLOAD_STATUS_UTIL_H_ +#define OFFLOAD_STATUS_UTIL_H_ + +#include + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +OffloadStatus createOffloadStatus(OffloadStatusCode code, const std::string &description); +OffloadStatus createOffloadStatus(OffloadStatusCode code); + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android + +#endif // OFFLOAD_STATUS_UTIL_H_ diff --git a/wifi_offload/service.cpp b/wifi_offload/service.cpp new file mode 100644 index 00000000..acec0787 --- /dev/null +++ b/wifi_offload/service.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include +#include + +#include "Offload.h" + +// libhwbinder +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; + +using android::hardware::wifi::offload::V1_0::IOffload; +using android::hardware::wifi::offload::V1_0::implementation::Offload; + +int main(int /*argc*/, char **argv) { + android::base::InitLogging( + argv, android::base::LogdLogger(android::base::SYSTEM)); + LOG(android::base::INFO) << "Wifi Offload HAL service start "; + + // Setup hwbinder + configureRpcThreadpool(1, true /* callerWillJoin */); + + // Register service + android::sp service = new Offload(); + CHECK_EQ(service->registerAsService(), android::NO_ERROR) + << "Failed to register Wifi Offload HAL"; + + joinRpcThreadpool(); + + LOG(android::base::INFO) << "Wifi Offload HAL service exit"; + return 0; +} diff --git a/wifi_offload/test/chre_interface_test.cpp b/wifi_offload/test/chre_interface_test.cpp new file mode 100644 index 00000000..fe2fab53 --- /dev/null +++ b/wifi_offload/test/chre_interface_test.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2016, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +#include + +#include "mock_chre_interface_callbacks.h" + +#include "chre_interface.h" + +namespace { + +const size_t kBufSize = 256; +const uint8_t kDefaultValue = 0xaa; +const uint32_t kDefaultMessageType = 0; + +} // namespace + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +class ChreInterfaceTest : public ::testing::Test { + protected: + virtual void SetUp() { + chre_interface_.reset(new ChreInterface(chre_interface_callback_.get())); + } + + void TearDown() override { + } + + std::unique_ptr> chre_interface_callback_{ + new testing::NiceMock()}; + std::unique_ptr chre_interface_; +}; + +TEST_F(ChreInterfaceTest, ChreInterfaceConnectionEventTest) { + EXPECT_CALL(*chre_interface_callback_, handleConnectionEvents(testing::_)); + chre_interface_->reportConnectionEvent(ChreInterfaceCallbacks::CONNECTED); + EXPECT_TRUE(chre_interface_->isConnected()); +} + +TEST_F(ChreInterfaceTest, ChreInterfaceHandleMessageTest) { + EXPECT_CALL(*chre_interface_callback_, handleMessage(testing::_, testing::_)); + uint32_t messageType; + std::vector buffer_recvd; + ON_CALL(*chre_interface_callback_, handleMessage(testing::_, testing::_)) + .WillByDefault( + DoAll(testing::SaveArg<0>(&messageType), testing::SaveArg<1>(&buffer_recvd))); + uint8_t buffer_sent[kBufSize]; + for (size_t j = 0; j < kBufSize; j++) { + buffer_sent[j] = kDefaultValue; + } + chre_interface_->handleMessage(kDefaultMessageType, (void*)&buffer_sent[0], kBufSize); + EXPECT_EQ(messageType, kDefaultMessageType); + EXPECT_EQ(buffer_recvd.size(), kBufSize); + for (size_t i = 0; i < buffer_recvd.size(); i++) { + EXPECT_EQ(buffer_recvd[i], buffer_sent[i]); + } +} + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android diff --git a/wifi_offload/test/main.cpp b/wifi_offload/test/main.cpp new file mode 100644 index 00000000..9aac8372 --- /dev/null +++ b/wifi_offload/test/main.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ::testing::InitGoogleMock(&argc, argv); + // Force ourselves to always log to stderr + android::base::InitLogging(argv, android::base::StderrLogger); + return RUN_ALL_TESTS(); +} diff --git a/wifi_offload/test/mock_chre_interface.cpp b/wifi_offload/test/mock_chre_interface.cpp new file mode 100644 index 00000000..9cb7fc92 --- /dev/null +++ b/wifi_offload/test/mock_chre_interface.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mock_chre_interface.h" + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +MockChreInterface::MockChreInterface(ChreInterfaceCallbacks* callback) : ChreInterface(callback) { +} + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android diff --git a/wifi_offload/test/mock_chre_interface.h b/wifi_offload/test/mock_chre_interface.h new file mode 100644 index 00000000..e74444ee --- /dev/null +++ b/wifi_offload/test/mock_chre_interface.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_H_ +#define WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_H_ + +#include +#include + +#include "chre_interface.h" +#include "chre_interface_callbacks.h" + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +class MockChreInterface : public ChreInterface { + public: + MockChreInterface(ChreInterfaceCallbacks* callback); + ~MockChreInterface() = default; + + MOCK_METHOD0(isConnected, bool()); + MOCK_METHOD2(sendCommandToApp, bool(uint32_t messageType, const std::vector& message)); + MOCK_METHOD1(reportConnectionEvent, void(ChreInterfaceCallbacks::ConnectionEvent event)); + MOCK_METHOD0(getHubInfo, bool()); + MOCK_METHOD0(getNanoAppList, bool()); + MOCK_METHOD3(handleMessage, + void(uint32_t messageType, const void* messageData, size_t messageDataLen)); +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android + +#endif // WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_H_ diff --git a/wifi_offload/test/mock_chre_interface_callbacks.cpp b/wifi_offload/test/mock_chre_interface_callbacks.cpp new file mode 100644 index 00000000..953ab8f5 --- /dev/null +++ b/wifi_offload/test/mock_chre_interface_callbacks.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "mock_chre_interface_callbacks.h" + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +MockChreInterfaceCallbacks::MockChreInterfaceCallbacks() { +} + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android diff --git a/wifi_offload/test/mock_chre_interface_callbacks.h b/wifi_offload/test/mock_chre_interface_callbacks.h new file mode 100644 index 00000000..e96bb617 --- /dev/null +++ b/wifi_offload/test/mock_chre_interface_callbacks.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_CALLBACKS_H_ +#define WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_CALLBACKS_H_ + +#include +#include + +#include "chre_interface_callbacks.h" + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +class MockChreInterfaceCallbacks : public ChreInterfaceCallbacks { + public: + MockChreInterfaceCallbacks(); + ~MockChreInterfaceCallbacks() override = default; + + MOCK_METHOD1(handleConnectionEvents, void(ChreInterfaceCallbacks::ConnectionEvent event)); + MOCK_METHOD2(handleMessage, void(uint32_t messageType, const std::vector& message)); +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android +#endif // WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_CALLBACKS_H_ diff --git a/wifi_offload/test/mock_chre_interface_factory.cpp b/wifi_offload/test/mock_chre_interface_factory.cpp new file mode 100644 index 00000000..9c04ccfd --- /dev/null +++ b/wifi_offload/test/mock_chre_interface_factory.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mock_chre_interface_factory.h" + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +MockChreInterfaceFactory::MockChreInterfaceFactory() { +} + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android diff --git a/wifi_offload/test/mock_chre_interface_factory.h b/wifi_offload/test/mock_chre_interface_factory.h new file mode 100644 index 00000000..644e49c2 --- /dev/null +++ b/wifi_offload/test/mock_chre_interface_factory.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_FACTORY_H_ +#define WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_FACTORY_H_ + +#include +#include + +#include "chre_interface_callbacks.h" +#include "chre_interface_factory.h" + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +class MockChreInterfaceFactory : public ChreInterfaceFactory { + public: + MockChreInterfaceFactory(); + ~MockChreInterfaceFactory() override = default; + + MOCK_METHOD1(getChreInterface, ChreInterface*(ChreInterfaceCallbacks* handlers)); +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android + +#endif // WIFI_OFFLOAD_MOCK_CHRE_INTERFACE_FACTORY_H_ diff --git a/wifi_offload/test/offload_server_test.cpp b/wifi_offload/test/offload_server_test.cpp new file mode 100644 index 00000000..e43fd531 --- /dev/null +++ b/wifi_offload/test/offload_server_test.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2016, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +#include + +#include "mock_chre_interface.h" +#include "mock_chre_interface_factory.h" + +#include "chre_interface_callbacks.h" +#include "offload_server.h" + +namespace { + +using android::hardware::wifi::offload::V1_0::implementation::ChreInterfaceCallbacks; +using android::hardware::wifi::offload::V1_0::implementation::MockChreInterface; +using android::hardware::wifi::offload::V1_0::implementation::ChreInterface; + +ChreInterface* + CaptureCallback(ChreInterfaceCallbacks* callback, + std::unique_ptr* chre_interface_callback, + std::unique_ptr>* chre_interface) { + chre_interface->reset(new testing::NiceMock(callback)); + chre_interface_callback->reset(callback); + return chre_interface->get(); +} + +} // namespace + +namespace android { +namespace hardware { +namespace wifi { +namespace offload { +namespace V1_0 { +namespace implementation { + +class OffloadServerTest : public ::testing::Test { + protected: + virtual void SetUp() { + ON_CALL(*chre_interface_factory_, getChreInterface(testing::_)) + .WillByDefault(testing::Invoke(std::bind(CaptureCallback, std::placeholders::_1, + &chre_interface_callback_, &chre_interface_))); + } + + void TearDown() override { + } + + std::unique_ptr> chre_interface_factory_{ + new testing::NiceMock()}; + std::unique_ptr> chre_interface_; + std::unique_ptr chre_interface_callback_; +}; + +TEST_F(OffloadServerTest, createOffloadServerTest) { + EXPECT_CALL(*chre_interface_factory_, getChreInterface(testing::_)); + OffloadServer* server = new OffloadServer(chre_interface_factory_.get()); + EXPECT_FALSE(chre_interface_callback_.get() == nullptr); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace offload +} // namespace wifi +} // namespace hardware +} // namespace android diff --git a/wifi_offload/test/runtest.sh b/wifi_offload/test/runtest.sh new file mode 100755 index 00000000..f8dbd7e6 --- /dev/null +++ b/wifi_offload/test/runtest.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if [ -z $ANDROID_BUILD_TOP ]; then + echo "You need to source and lunch before you can use this script" + exit 1 +fi + +echo "Running tests" +set -e # fail early + +# NOTE We can't actually run these commands, since they rely on functions added by +# build/envsetup.sh to the bash shell environment. +echo "+ mmma -j32 $ANDROID_BUILD_TOP/device/google/wahoo" +make -j32 -C $ANDROID_BUILD_TOP -f build/core/main.mk \ + MODULES-IN-device-google-wahoo-wifi_offload + +set -x # print commands + +adb root +adb wait-for-device +adb remount +adb sync + +adb shell /data/nativetest/wifi-offload-service-unit-tests/wifi-offload-service-unit-tests +adb shell /data/nativetest64/wifi-offload-service-unit-tests/wifi-offload-service-unit-tests diff --git a/wpa_supplicant_overlay.conf b/wpa_supplicant_overlay.conf new file mode 100644 index 00000000..e1f530db --- /dev/null +++ b/wpa_supplicant_overlay.conf @@ -0,0 +1,3 @@ +disable_scan_offload=1 +p2p_disabled=1 +tdls_external_control=1 diff --git a/wpa_supplicant_wcn.conf b/wpa_supplicant_wcn.conf new file mode 100644 index 00000000..287954e1 --- /dev/null +++ b/wpa_supplicant_wcn.conf @@ -0,0 +1,830 @@ +##### Example wpa_supplicant configuration file ############################### +# +# This file describes configuration file format and lists all available option. +# Please also take a look at simpler configuration examples in 'examples' +# subdirectory. +# +# Empty lines and lines starting with # are ignored + +# NOTE! This file may contain password information and should probably be made +# readable only by root user on multiuser systems. + +# Note: All file paths in this configuration file should use full (absolute, +# not relative to working directory) path in order to allow working directory +# to be changed. This can happen if wpa_supplicant is run in the background. + +# Whether to allow wpa_supplicant to update (overwrite) configuration +# +# This option can be used to allow wpa_supplicant to overwrite configuration +# file whenever configuration is changed (e.g., new network block is added with +# wpa_cli or wpa_gui, or a password is changed). This is required for +# wpa_cli/wpa_gui to be able to store the configuration changes permanently. +# Please note that overwriting configuration file will remove the comments from +# it. +update_config=1 + +# global configuration (shared by all network blocks) +# +# Parameters for the control interface. If this is specified, wpa_supplicant +# will open a control interface that is available for external programs to +# manage wpa_supplicant. The meaning of this string depends on which control +# interface mechanism is used. For all cases, the existance of this parameter +# in configuration is used to determine whether the control interface is +# enabled. +# +# For UNIX domain sockets (default on Linux and BSD): This is a directory that +# will be created for UNIX domain sockets for listening to requests from +# external programs (CLI/GUI, etc.) for status information and configuration. +# The socket file will be named based on the interface name, so multiple +# wpa_supplicant processes can be run at the same time if more than one +# interface is used. +# /var/run/wpa_supplicant is the recommended directory for sockets and by +# default, wpa_cli will use it when trying to connect with wpa_supplicant. +# +# Access control for the control interface can be configured by setting the +# directory to allow only members of a group to use sockets. This way, it is +# possible to run wpa_supplicant as root (since it needs to change network +# configuration and open raw sockets) and still allow GUI/CLI components to be +# run as non-root users. However, since the control interface can be used to +# change the network configuration, this access needs to be protected in many +# cases. By default, wpa_supplicant is configured to use gid 0 (root). If you +# want to allow non-root users to use the control interface, add a new group +# and change this value to match with that group. Add users that should have +# control interface access to this group. If this variable is commented out or +# not included in the configuration file, group will not be changed from the +# value it got by default when the directory or socket was created. +# +# When configuring both the directory and group, use following format: +# DIR=/var/run/wpa_supplicant GROUP=wheel +# DIR=/var/run/wpa_supplicant GROUP=0 +# (group can be either group name or gid) +ctrl_interface=wlan0 + +# IEEE 802.1X/EAPOL version +# wpa_supplicant is implemented based on IEEE Std 802.1X-2004 which defines +# EAPOL version 2. However, there are many APs that do not handle the new +# version number correctly (they seem to drop the frames completely). In order +# to make wpa_supplicant interoperate with these APs, the version number is set +# to 1 by default. This configuration value can be used to set it to the new +# version (2). +eapol_version=1 + +# AP scanning/selection +# By default, wpa_supplicant requests driver to perform AP scanning and then +# uses the scan results to select a suitable AP. Another alternative is to +# allow the driver to take care of AP scanning and selection and use +# wpa_supplicant just to process EAPOL frames based on IEEE 802.11 association +# information from the driver. +# 1: wpa_supplicant initiates scanning and AP selection +# 0: driver takes care of scanning, AP selection, and IEEE 802.11 association +# parameters (e.g., WPA IE generation); this mode can also be used with +# non-WPA drivers when using IEEE 802.1X mode; do not try to associate with +# APs (i.e., external program needs to control association). This mode must +# also be used when using wired Ethernet drivers. +# 2: like 0, but associate with APs using security policy and SSID (but not +# BSSID); this can be used, e.g., with ndiswrapper and NDIS drivers to +# enable operation with hidden SSIDs and optimized roaming; in this mode, +# the network blocks in the configuration file are tried one by one until +# the driver reports successful association; each network block should have +# explicit security policy (i.e., only one option in the lists) for +# key_mgmt, pairwise, group, proto variables +ap_scan=1 + +# EAP fast re-authentication +# By default, fast re-authentication is enabled for all EAP methods that +# support it. This variable can be used to disable fast re-authentication. +# Normally, there is no need to disable this. +fast_reauth=1 + +#Disable the default behavior of adding a separate interface for the P2P +#group when driver support for concurrent interfaces is available. +p2p_no_group_iface=1 + +# OpenSSL Engine support +# These options can be used to load OpenSSL engines. +# The two engines that are supported currently are shown below: +# They are both from the opensc project (http://www.opensc.org/) +# By default no engines are loaded. +# make the opensc engine available +#opensc_engine_path=/usr/lib/opensc/engine_opensc.so +# make the pkcs11 engine available +#pkcs11_engine_path=/usr/lib/opensc/engine_pkcs11.so +# configure the path to the pkcs11 module required by the pkcs11 engine +#pkcs11_module_path=/usr/lib/pkcs11/opensc-pkcs11.so + +# Dynamic EAP methods +# If EAP methods were built dynamically as shared object files, they need to be +# loaded here before being used in the network blocks. By default, EAP methods +# are included statically in the build, so these lines are not needed +#load_dynamic_eap=/usr/lib/wpa_supplicant/eap_tls.so +#load_dynamic_eap=/usr/lib/wpa_supplicant/eap_md5.so + +# Driver interface parameters +# This field can be used to configure arbitrary driver interace parameters. The +# format is specific to the selected driver interface. This field is not used +# in most cases. +#driver_param="field=value" + +# Country code +# The ISO/IEC alpha2 country code for the country in which this device is +# currently operating. +#country=US + +# Maximum lifetime for PMKSA in seconds; default 43200 +#dot11RSNAConfigPMKLifetime=43200 +# Threshold for reauthentication (percentage of PMK lifetime); default 70 +#dot11RSNAConfigPMKReauthThreshold=70 +# Timeout for security association negotiation in seconds; default 60 +#dot11RSNAConfigSATimeout=60 + +# Wi-Fi Protected Setup (WPS) parameters + +# Universally Unique IDentifier (UUID; see RFC 4122) of the device +# If not configured, UUID will be generated based on the local MAC address. +#uuid=12345678-9abc-def0-1234-56789abcdef0 + +# Device Name +# User-friendly description of device; up to 32 octets encoded in UTF-8 +#device_name=Wireless Client + +# Manufacturer +# The manufacturer of the device (up to 64 ASCII characters) +#manufacturer=Company + +# Model Name +# Model of the device (up to 32 ASCII characters) +#model_name=cmodel + +# Model Number +# Additional device description (up to 32 ASCII characters) +#model_number=123 + +# Serial Number +# Serial number of the device (up to 32 characters) +#serial_number=12345 + +# Primary Device Type +# Used format: -- +# categ = Category as an integer value +# OUI = OUI and type octet as a 4-octet hex-encoded value; 0050F204 for +# default WPS OUI +# subcateg = OUI-specific Sub Category as an integer value +# Examples: +# 1-0050F204-1 (Computer / PC) +# 1-0050F204-2 (Computer / Server) +# 5-0050F204-1 (Storage / NAS) +# 6-0050F204-1 (Network Infrastructure / AP) +#device_type=1-0050F204-1 + +# OS Version +# 4-octet operating system version number (hex string) +#os_version=01020300 + +# Credential processing +# 0 = process received credentials internally (default) +# 1 = do not process received credentials; just pass them over ctrl_iface to +# external program(s) +# 2 = process received credentials internally and pass them over ctrl_iface +# to external program(s) +#wps_cred_processing=0 + +# network block +# +# Each network (usually AP's sharing the same SSID) is configured as a separate +# block in this configuration file. The network blocks are in preference order +# (the first match is used). +# +# network block fields: +# +# disabled: +# 0 = this network can be used (default) +# 1 = this network block is disabled (can be enabled through ctrl_iface, +# e.g., with wpa_cli or wpa_gui) +# +# id_str: Network identifier string for external scripts. This value is passed +# to external action script through wpa_cli as WPA_ID_STR environment +# variable to make it easier to do network specific configuration. +# +# ssid: SSID (mandatory); either as an ASCII string with double quotation or +# as hex string; network name +# +# scan_ssid: +# 0 = do not scan this SSID with specific Probe Request frames (default) +# 1 = scan with SSID-specific Probe Request frames (this can be used to +# find APs that do not accept broadcast SSID or use multiple SSIDs; +# this will add latency to scanning, so enable this only when needed) +# +# bssid: BSSID (optional); if set, this network block is used only when +# associating with the AP using the configured BSSID +# +# priority: priority group (integer) +# By default, all networks will get same priority group (0). If some of the +# networks are more desirable, this field can be used to change the order in +# which wpa_supplicant goes through the networks when selecting a BSS. The +# priority groups will be iterated in decreasing priority (i.e., the larger the +# priority value, the sooner the network is matched against the scan results). +# Within each priority group, networks will be selected based on security +# policy, signal strength, etc. +# Please note that AP scanning with scan_ssid=1 and ap_scan=2 mode are not +# using this priority to select the order for scanning. Instead, they try the +# networks in the order that used in the configuration file. +# +# mode: IEEE 802.11 operation mode +# 0 = infrastructure (Managed) mode, i.e., associate with an AP (default) +# 1 = IBSS (ad-hoc, peer-to-peer) +# Note: IBSS can only be used with key_mgmt NONE (plaintext and static WEP) +# and key_mgmt=WPA-NONE (fixed group key TKIP/CCMP). In addition, ap_scan has +# to be set to 2 for IBSS. WPA-None requires following network block options: +# proto=WPA, key_mgmt=WPA-NONE, pairwise=NONE, group=TKIP (or CCMP, but not +# both), and psk must also be set. +# +# frequency: Channel frequency in megahertz (MHz) for IBSS, e.g., +# 2412 = IEEE 802.11b/g channel 1. This value is used to configure the initial +# channel for IBSS (adhoc) networks. It is ignored in the infrastructure mode. +# In addition, this value is only used by the station that creates the IBSS. If +# an IBSS network with the configured SSID is already present, the frequency of +# the network will be used instead of this configured value. +# +# proto: list of accepted protocols +# WPA = WPA/IEEE 802.11i/D3.0 +# RSN = WPA2/IEEE 802.11i (also WPA2 can be used as an alias for RSN) +# If not set, this defaults to: WPA RSN +# +# key_mgmt: list of accepted authenticated key management protocols +# WPA-PSK = WPA pre-shared key (this requires 'psk' field) +# WPA-EAP = WPA using EAP authentication +# IEEE8021X = IEEE 802.1X using EAP authentication and (optionally) dynamically +# generated WEP keys +# NONE = WPA is not used; plaintext or static WEP could be used +# WPA-PSK-SHA256 = Like WPA-PSK but using stronger SHA256-based algorithms +# WPA-EAP-SHA256 = Like WPA-EAP but using stronger SHA256-based algorithms +# If not set, this defaults to: WPA-PSK WPA-EAP +# +# auth_alg: list of allowed IEEE 802.11 authentication algorithms +# OPEN = Open System authentication (required for WPA/WPA2) +# SHARED = Shared Key authentication (requires static WEP keys) +# LEAP = LEAP/Network EAP (only used with LEAP) +# If not set, automatic selection is used (Open System with LEAP enabled if +# LEAP is allowed as one of the EAP methods). +# +# pairwise: list of accepted pairwise (unicast) ciphers for WPA +# CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0] +# TKIP = Temporal Key Integrity Protocol [IEEE 802.11i/D7.0] +# NONE = Use only Group Keys (deprecated, should not be included if APs support +# pairwise keys) +# If not set, this defaults to: CCMP TKIP +# +# group: list of accepted group (broadcast/multicast) ciphers for WPA +# CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0] +# TKIP = Temporal Key Integrity Protocol [IEEE 802.11i/D7.0] +# WEP104 = WEP (Wired Equivalent Privacy) with 104-bit key +# WEP40 = WEP (Wired Equivalent Privacy) with 40-bit key [IEEE 802.11] +# If not set, this defaults to: CCMP TKIP WEP104 WEP40 +# +# psk: WPA preshared key; 256-bit pre-shared key +# The key used in WPA-PSK mode can be entered either as 64 hex-digits, i.e., +# 32 bytes or as an ASCII passphrase (in which case, the real PSK will be +# generated using the passphrase and SSID). ASCII passphrase must be between +# 8 and 63 characters (inclusive). +# This field is not needed, if WPA-EAP is used. +# Note: Separate tool, wpa_passphrase, can be used to generate 256-bit keys +# from ASCII passphrase. This process uses lot of CPU and wpa_supplicant +# startup and reconfiguration time can be optimized by generating the PSK only +# only when the passphrase or SSID has actually changed. +# +# eapol_flags: IEEE 802.1X/EAPOL options (bit field) +# Dynamic WEP key required for non-WPA mode +# bit0 (1): require dynamically generated unicast WEP key +# bit1 (2): require dynamically generated broadcast WEP key +# (3 = require both keys; default) +# Note: When using wired authentication, eapol_flags must be set to 0 for the +# authentication to be completed successfully. +# +# mixed_cell: This option can be used to configure whether so called mixed +# cells, i.e., networks that use both plaintext and encryption in the same +# SSID, are allowed when selecting a BSS form scan results. +# 0 = disabled (default) +# 1 = enabled +# +# proactive_key_caching: +# Enable/disable opportunistic PMKSA caching for WPA2. +# 0 = disabled (default) +# 1 = enabled +# +# wep_key0..3: Static WEP key (ASCII in double quotation, e.g. "abcde" or +# hex without quotation, e.g., 0102030405) +# wep_tx_keyidx: Default WEP key index (TX) (0..3) +# +# peerkey: Whether PeerKey negotiation for direct links (IEEE 802.11e DLS) is +# allowed. This is only used with RSN/WPA2. +# 0 = disabled (default) +# 1 = enabled +#peerkey=1 +# +# wpa_ptk_rekey: Maximum lifetime for PTK in seconds. This can be used to +# enforce rekeying of PTK to mitigate some attacks against TKIP deficiencies. +# +# Following fields are only used with internal EAP implementation. +# eap: space-separated list of accepted EAP methods +# MD5 = EAP-MD5 (unsecure and does not generate keying material -> +# cannot be used with WPA; to be used as a Phase 2 method +# with EAP-PEAP or EAP-TTLS) +# MSCHAPV2 = EAP-MSCHAPv2 (cannot be used separately with WPA; to be used +# as a Phase 2 method with EAP-PEAP or EAP-TTLS) +# OTP = EAP-OTP (cannot be used separately with WPA; to be used +# as a Phase 2 method with EAP-PEAP or EAP-TTLS) +# GTC = EAP-GTC (cannot be used separately with WPA; to be used +# as a Phase 2 method with EAP-PEAP or EAP-TTLS) +# TLS = EAP-TLS (client and server certificate) +# PEAP = EAP-PEAP (with tunnelled EAP authentication) +# TTLS = EAP-TTLS (with tunnelled EAP or PAP/CHAP/MSCHAP/MSCHAPV2 +# authentication) +# If not set, all compiled in methods are allowed. +# +# identity: Identity string for EAP +# This field is also used to configure user NAI for +# EAP-PSK/PAX/SAKE/GPSK. +# anonymous_identity: Anonymous identity string for EAP (to be used as the +# unencrypted identity with EAP types that support different tunnelled +# identity, e.g., EAP-TTLS) +# password: Password string for EAP. This field can include either the +# plaintext password (using ASCII or hex string) or a NtPasswordHash +# (16-byte MD4 hash of password) in hash:<32 hex digits> format. +# NtPasswordHash can only be used when the password is for MSCHAPv2 or +# MSCHAP (EAP-MSCHAPv2, EAP-TTLS/MSCHAPv2, EAP-TTLS/MSCHAP, LEAP). +# EAP-PSK (128-bit PSK), EAP-PAX (128-bit PSK), and EAP-SAKE (256-bit +# PSK) is also configured using this field. For EAP-GPSK, this is a +# variable length PSK. +# ca_cert: File path to CA certificate file (PEM/DER). This file can have one +# or more trusted CA certificates. If ca_cert and ca_path are not +# included, server certificate will not be verified. This is insecure and +# a trusted CA certificate should always be configured when using +# EAP-TLS/TTLS/PEAP. Full path should be used since working directory may +# change when wpa_supplicant is run in the background. +# On Windows, trusted CA certificates can be loaded from the system +# certificate store by setting this to cert_store://, e.g., +# ca_cert="cert_store://CA" or ca_cert="cert_store://ROOT". +# Note that when running wpa_supplicant as an application, the user +# certificate store (My user account) is used, whereas computer store +# (Computer account) is used when running wpasvc as a service. +# ca_path: Directory path for CA certificate files (PEM). This path may +# contain multiple CA certificates in OpenSSL format. Common use for this +# is to point to system trusted CA list which is often installed into +# directory like /etc/ssl/certs. If configured, these certificates are +# added to the list of trusted CAs. ca_cert may also be included in that +# case, but it is not required. +# client_cert: File path to client certificate file (PEM/DER) +# Full path should be used since working directory may change when +# wpa_supplicant is run in the background. +# Alternatively, a named configuration blob can be used by setting this +# to blob://. +# private_key: File path to client private key file (PEM/DER/PFX) +# When PKCS#12/PFX file (.p12/.pfx) is used, client_cert should be +# commented out. Both the private key and certificate will be read from +# the PKCS#12 file in this case. Full path should be used since working +# directory may change when wpa_supplicant is run in the background. +# Windows certificate store can be used by leaving client_cert out and +# configuring private_key in one of the following formats: +# cert://substring_to_match +# hash://certificate_thumbprint_in_hex +# for example: private_key="hash://63093aa9c47f56ae88334c7b65a4" +# Note that when running wpa_supplicant as an application, the user +# certificate store (My user account) is used, whereas computer store +# (Computer account) is used when running wpasvc as a service. +# Alternatively, a named configuration blob can be used by setting this +# to blob://. +# private_key_passwd: Password for private key file (if left out, this will be +# asked through control interface) +# dh_file: File path to DH/DSA parameters file (in PEM format) +# This is an optional configuration file for setting parameters for an +# ephemeral DH key exchange. In most cases, the default RSA +# authentication does not use this configuration. However, it is possible +# setup RSA to use ephemeral DH key exchange. In addition, ciphers with +# DSA keys always use ephemeral DH keys. This can be used to achieve +# forward secrecy. If the file is in DSA parameters format, it will be +# automatically converted into DH params. +# subject_match: Substring to be matched against the subject of the +# authentication server certificate. If this string is set, the server +# sertificate is only accepted if it contains this string in the subject. +# The subject string is in following format: +# /C=US/ST=CA/L=San Francisco/CN=Test AS/emailAddress=as@example.com +# altsubject_match: Semicolon separated string of entries to be matched against +# the alternative subject name of the authentication server certificate. +# If this string is set, the server sertificate is only accepted if it +# contains one of the entries in an alternative subject name extension. +# altSubjectName string is in following format: TYPE:VALUE +# Example: EMAIL:server@example.com +# Example: DNS:server.example.com;DNS:server2.example.com +# Following types are supported: EMAIL, DNS, URI +# phase1: Phase1 (outer authentication, i.e., TLS tunnel) parameters +# (string with field-value pairs, e.g., "peapver=0" or +# "peapver=1 peaplabel=1") +# 'peapver' can be used to force which PEAP version (0 or 1) is used. +# 'peaplabel=1' can be used to force new label, "client PEAP encryption", +# to be used during key derivation when PEAPv1 or newer. Most existing +# PEAPv1 implementation seem to be using the old label, "client EAP +# encryption", and wpa_supplicant is now using that as the default value. +# Some servers, e.g., Radiator, may require peaplabel=1 configuration to +# interoperate with PEAPv1; see eap_testing.txt for more details. +# 'peap_outer_success=0' can be used to terminate PEAP authentication on +# tunneled EAP-Success. This is required with some RADIUS servers that +# implement draft-josefsson-pppext-eap-tls-eap-05.txt (e.g., +# Lucent NavisRadius v4.4.0 with PEAP in "IETF Draft 5" mode) +# include_tls_length=1 can be used to force wpa_supplicant to include +# TLS Message Length field in all TLS messages even if they are not +# fragmented. +# sim_min_num_chal=3 can be used to configure EAP-SIM to require three +# challenges (by default, it accepts 2 or 3) +# result_ind=1 can be used to enable EAP-SIM and EAP-AKA to use +# protected result indication. +# 'crypto_binding' option can be used to control PEAPv0 cryptobinding +# behavior: +# * 0 = do not use cryptobinding (default) +# * 1 = use cryptobinding if server supports it +# * 2 = require cryptobinding +# EAP-WSC (WPS) uses following options: pin= or +# pbc=1. +# phase2: Phase2 (inner authentication with TLS tunnel) parameters +# (string with field-value pairs, e.g., "auth=MSCHAPV2" for EAP-PEAP or +# "autheap=MSCHAPV2 autheap=MD5" for EAP-TTLS) +# Following certificate/private key fields are used in inner Phase2 +# authentication when using EAP-TTLS or EAP-PEAP. +# ca_cert2: File path to CA certificate file. This file can have one or more +# trusted CA certificates. If ca_cert2 and ca_path2 are not included, +# server certificate will not be verified. This is insecure and a trusted +# CA certificate should always be configured. +# ca_path2: Directory path for CA certificate files (PEM) +# client_cert2: File path to client certificate file +# private_key2: File path to client private key file +# private_key2_passwd: Password for private key file +# dh_file2: File path to DH/DSA parameters file (in PEM format) +# subject_match2: Substring to be matched against the subject of the +# authentication server certificate. +# altsubject_match2: Substring to be matched against the alternative subject +# name of the authentication server certificate. +# +# fragment_size: Maximum EAP fragment size in bytes (default 1398). +# This value limits the fragment size for EAP methods that support +# fragmentation (e.g., EAP-TLS and EAP-PEAP). This value should be set +# small enough to make the EAP messages fit in MTU of the network +# interface used for EAPOL. The default value is suitable for most +# cases. +# +# EAP-FAST variables: +# pac_file: File path for the PAC entries. wpa_supplicant will need to be able +# to create this file and write updates to it when PAC is being +# provisioned or refreshed. Full path to the file should be used since +# working directory may change when wpa_supplicant is run in the +# background. Alternatively, a named configuration blob can be used by +# setting this to blob:// +# phase1: fast_provisioning option can be used to enable in-line provisioning +# of EAP-FAST credentials (PAC): +# 0 = disabled, +# 1 = allow unauthenticated provisioning, +# 2 = allow authenticated provisioning, +# 3 = allow both unauthenticated and authenticated provisioning +# fast_max_pac_list_len= option can be used to set the maximum +# number of PAC entries to store in a PAC list (default: 10) +# fast_pac_format=binary option can be used to select binary format for +# storing PAC entries in order to save some space (the default +# text format uses about 2.5 times the size of minimal binary +# format) +# +# wpa_supplicant supports number of "EAP workarounds" to work around +# interoperability issues with incorrectly behaving authentication servers. +# These are enabled by default because some of the issues are present in large +# number of authentication servers. Strict EAP conformance mode can be +# configured by disabling workarounds with eap_workaround=0. + +# Example blocks: + +# Simple case: WPA-PSK, PSK as an ASCII passphrase, allow all valid ciphers +#network={ +# ssid="simple" +# psk="very secret passphrase" +# priority=5 +#} +# +## Same as previous, but request SSID-specific scanning (for APs that reject +## broadcast SSID) +#network={ +# ssid="second ssid" +# scan_ssid=1 +# psk="very secret passphrase" +# priority=2 +#} +# +## Only WPA-PSK is used. Any valid cipher combination is accepted. +#network={ +# ssid="example" +# proto=WPA +# key_mgmt=WPA-PSK +# pairwise=CCMP TKIP +# group=CCMP TKIP WEP104 WEP40 +# psk=06b4be19da289f475aa46a33cb793029d4ab3db7a23ee92382eb0106c72ac7bb +# priority=2 +#} +# +## WPA-Personal(PSK) with TKIP and enforcement for frequent PTK rekeying +#network={ +# ssid="example" +# proto=WPA +# key_mgmt=WPA-PSK +# pairwise=TKIP +# group=TKIP +# psk="not so secure passphrase" +# wpa_ptk_rekey=600 +#} +# +## Only WPA-EAP is used. Both CCMP and TKIP is accepted. An AP that used WEP104 +## or WEP40 as the group cipher will not be accepted. +#network={ +# ssid="example" +# proto=RSN +# key_mgmt=WPA-EAP +# pairwise=CCMP TKIP +# group=CCMP TKIP +# eap=TLS +# identity="user@example.com" +# ca_cert="/etc/cert/ca.pem" +# client_cert="/etc/cert/user.pem" +# private_key="/etc/cert/user.prv" +# private_key_passwd="password" +# priority=1 +#} +# +## EAP-PEAP/MSCHAPv2 configuration for RADIUS servers that use the new peaplabel +## (e.g., Radiator) +#network={ +# ssid="example" +# key_mgmt=WPA-EAP +# eap=PEAP +# identity="user@example.com" +# password="foobar" +# ca_cert="/etc/cert/ca.pem" +# phase1="peaplabel=1" +# phase2="auth=MSCHAPV2" +# priority=10 +#} +# +## EAP-TTLS/EAP-MD5-Challenge configuration with anonymous identity for the +## unencrypted use. Real identity is sent only within an encrypted TLS tunnel. +#network={ +# ssid="example" +# key_mgmt=WPA-EAP +# eap=TTLS +# identity="user@example.com" +# anonymous_identity="anonymous@example.com" +# password="foobar" +# ca_cert="/etc/cert/ca.pem" +# priority=2 +#} +# +## EAP-TTLS/MSCHAPv2 configuration with anonymous identity for the unencrypted +## use. Real identity is sent only within an encrypted TLS tunnel. +#network={ +# ssid="example" +# key_mgmt=WPA-EAP +# eap=TTLS +# identity="user@example.com" +# anonymous_identity="anonymous@example.com" +# password="foobar" +# ca_cert="/etc/cert/ca.pem" +# phase2="auth=MSCHAPV2" +#} +# +## WPA-EAP, EAP-TTLS with different CA certificate used for outer and inner +## authentication. +#network={ +# ssid="example" +# key_mgmt=WPA-EAP +# eap=TTLS +# # Phase1 / outer authentication +# anonymous_identity="anonymous@example.com" +# ca_cert="/etc/cert/ca.pem" +# # Phase 2 / inner authentication +# phase2="autheap=TLS" +# ca_cert2="/etc/cert/ca2.pem" +# client_cert2="/etc/cer/user.pem" +# private_key2="/etc/cer/user.prv" +# private_key2_passwd="password" +# priority=2 +#} +# +## Both WPA-PSK and WPA-EAP is accepted. Only CCMP is accepted as pairwise and +## group cipher. +#network={ +# ssid="example" +# bssid=00:11:22:33:44:55 +# proto=WPA RSN +# key_mgmt=WPA-PSK WPA-EAP +# pairwise=CCMP +# group=CCMP +# psk=06b4be19da289f475aa46a33cb793029d4ab3db7a23ee92382eb0106c72ac7bb +#} +# +## Special characters in SSID, so use hex string. Default to WPA-PSK, WPA-EAP +## and all valid ciphers. +#network={ +# ssid=00010203 +# psk=000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +#} +# +# +## EAP-SIM with a GSM SIM or USIM +#network={ +# ssid="eap-sim-test" +# key_mgmt=WPA-EAP +# eap=SIM +# pin="1234" +# pcsc="" +#} +# +# +## EAP-PSK +#network={ +# ssid="eap-psk-test" +# key_mgmt=WPA-EAP +# eap=PSK +# anonymous_identity="eap_psk_user" +# password=06b4be19da289f475aa46a33cb793029 +# identity="eap_psk_user@example.com" +#} +# +# +## IEEE 802.1X/EAPOL with dynamically generated WEP keys (i.e., no WPA) using +## EAP-TLS for authentication and key generation; require both unicast and +## broadcast WEP keys. +#network={ +# ssid="1x-test" +# key_mgmt=IEEE8021X +# eap=TLS +# identity="user@example.com" +# ca_cert="/etc/cert/ca.pem" +# client_cert="/etc/cert/user.pem" +# private_key="/etc/cert/user.prv" +# private_key_passwd="password" +# eapol_flags=3 +#} +# +# +## LEAP with dynamic WEP keys +#network={ +# ssid="leap-example" +# key_mgmt=IEEE8021X +# eap=LEAP +# identity="user" +# password="foobar" +#} +# +## EAP-IKEv2 using shared secrets for both server and peer authentication +#network={ +# ssid="ikev2-example" +# key_mgmt=WPA-EAP +# eap=IKEV2 +# identity="user" +# password="foobar" +#} +# +## EAP-FAST with WPA (WPA or WPA2) +#network={ +# ssid="eap-fast-test" +# key_mgmt=WPA-EAP +# eap=FAST +# anonymous_identity="FAST-000102030405" +# identity="username" +# password="password" +# phase1="fast_provisioning=1" +# pac_file="/etc/wpa_supplicant.eap-fast-pac" +#} +# +#network={ +# ssid="eap-fast-test" +# key_mgmt=WPA-EAP +# eap=FAST +# anonymous_identity="FAST-000102030405" +# identity="username" +# password="password" +# phase1="fast_provisioning=1" +# pac_file="blob://eap-fast-pac" +#} +# +## Plaintext connection (no WPA, no IEEE 802.1X) +#network={ +# ssid="plaintext-test" +# key_mgmt=NONE +#} +# +# +## Shared WEP key connection (no WPA, no IEEE 802.1X) +#network={ +# ssid="static-wep-test" +# key_mgmt=NONE +# wep_key0="abcde" +# wep_key1=0102030405 +# wep_key2="1234567890123" +# wep_tx_keyidx=0 +# priority=5 +#} +# +# +## Shared WEP key connection (no WPA, no IEEE 802.1X) using Shared Key +## IEEE 802.11 authentication +#network={ +# ssid="static-wep-test2" +# key_mgmt=NONE +# wep_key0="abcde" +# wep_key1=0102030405 +# wep_key2="1234567890123" +# wep_tx_keyidx=0 +# priority=5 +# auth_alg=SHARED +#} +# +# +## IBSS/ad-hoc network with WPA-None/TKIP. +#network={ +# ssid="test adhoc" +# mode=1 +# frequency=2412 +# proto=WPA +# key_mgmt=WPA-NONE +# pairwise=NONE +# group=TKIP +# psk="secret passphrase" +#} +# +# +## Catch all example that allows more or less all configuration modes +#network={ +# ssid="example" +# scan_ssid=1 +# key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE +# pairwise=CCMP TKIP +# group=CCMP TKIP WEP104 WEP40 +# psk="very secret passphrase" +# eap=TTLS PEAP TLS +# identity="user@example.com" +# password="foobar" +# ca_cert="/etc/cert/ca.pem" +# client_cert="/etc/cert/user.pem" +# private_key="/etc/cert/user.prv" +# private_key_passwd="password" +# phase1="peaplabel=0" +#} +# +## Example of EAP-TLS with smartcard (openssl engine) +#network={ +# ssid="example" +# key_mgmt=WPA-EAP +# eap=TLS +# proto=RSN +# pairwise=CCMP TKIP +# group=CCMP TKIP +# identity="user@example.com" +# ca_cert="/etc/cert/ca.pem" +# client_cert="/etc/cert/user.pem" +# +# engine=1 +# +# # The engine configured here must be available. Look at +# # OpenSSL engine support in the global section. +# # The key available through the engine must be the private key +# # matching the client certificate configured above. +# +# # use the opensc engine +# #engine_id="opensc" +# #key_id="45" +# +# # use the pkcs11 engine +# engine_id="pkcs11" +# key_id="id_45" +# +# # Optional PIN configuration; this can be left out and PIN will be +# # asked through the control interface +# pin="1234" +#} +# +## Example configuration showing how to use an inlined blob as a CA certificate +## data instead of using external file +#network={ +# ssid="example" +# key_mgmt=WPA-EAP +# eap=TTLS +# identity="user@example.com" +# anonymous_identity="anonymous@example.com" +# password="foobar" +# ca_cert="blob://exampleblob" +# priority=20 +#} +# +#blob-base64-exampleblob={ +#SGVsbG8gV29ybGQhCg== +#} + + +# Wildcard match for SSID (plaintext APs only). This example select any +# open AP regardless of its SSID. +#network={ +# key_mgmt=NONE +#}