* based on https://github.com/Cyanogenmod-for-Lenovo-Tab2A7-10F/android_device_lenovo_Tab2A710F
* some bits taken from https://github.com/lineage-geminipda/android_device_planet_geminipda
Change-Id: I5a0ea7e0444fcd0298bec0bf5c3e3b4debf1df71
--- /dev/null
+LOCAL_PATH := $(call my-dir)
+
+ifeq ($(TARGET_DEVICE),ttab)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
+
+endif
--- /dev/null
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+ALL_PREBUILT += $(INSTALLED_KERNEL_TARGET)
+
+# include the non-open-source counterpart to this file
+-include vendor/alcatel/ttab/AndroidBoardVendor.mk
--- /dev/null
+PRODUCT_MAKEFILES := \
+ $(LOCAL_DIR)/full_ttab.mk
--- /dev/null
+USE_CAMERA_STUB := true
+
+DEVICE_DIR := device/alcatel/ttab
+VENDOR_DIR := vendor/alcatel/ttab
+KERNEL_DIR := kernel/alcatel/ttab
+
+# Additional includes
+TARGET_SPECIFIC_HEADER_PATH := $(DEVICE_DIR)/include
+
+# inherit from the proprietary version
+-include $(VENDOR_DIR)/BoardConfigVendor.mk
+
+# Platform
+TARGET_BOARD_PLATFORM := mt8127
+TARGET_BOARD_PLATFORM_GPU := mali-450mp4
+
+# Arch
+TARGET_ARCH := arm
+TARGET_ARCH_VARIANT := armv7-a-neon
+TARGET_CPU_VARIANT := cortex-a7
+TARGET_CPU_ABI := armeabi-v7a
+TARGET_CPU_ABI2 := armeabi
+TARGET_CPU_SMP := true
+ARCH_ARM_HAVE_TLS_REGISTER := true
+ARCH_ARM_HAVE_NEON := true
+
+TARGET_NO_BOOTLOADER := true
+BOARD_HAS_NO_SELECT_BUTTON := true
+TARGET_BOOTLOADER_BOARD_NAME := ttab
+TARGET_OTA_ASSERT_DEVICE := ttab
+
+TARGET_INIT_VENDOR_LIB := libinit_ttab
+
+
+BOARD_BOOTIMAGE_PARTITION_SIZE := 16777216
+BOARD_RECOVERYIMAGE_PARTITION_SIZE := 16777216
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1468006400
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 12852920320
+TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_CACHEIMAGE_PARTITION_SIZE := 268435456
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_FLASH_BLOCK_SIZE := 131072
+
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := false
+BOARD_HAS_NO_MISC_PARTITION := true
+
+BACKLIGHT_PATH := "/sys/class/leds/lcd-backlight/brightness"
+
+# Vold
+TARGET_USE_CUSTOM_LUN_FILE_PATH := /sys/devices/platform/mt_usb/musb-hdrc.0.auto/gadget/lun%d/file
+
+# Kernel
+TARGET_KERNEL_CONFIG := ttab_defconfig
+TARGET_KERNEL_SOURCE := kernel/alcatel/ttab
+BOARD_KERNEL_IMAGE_NAME := zImage
+BOARD_KERNEL_CMDLINE := androidboot.selinux=permissive androidboot.hardware=mt8127
+BOARD_KERNEL_BASE := 0x80000000
+BOARD_KERNEL_PAGESIZE := 2048
+BOARD_CUSTOM_BOOTIMG_MK := device/alcatel/ttab/mkbootimg.mk
+BOARD_MKBOOTIMG_ARGS := --cmdline "$(BOARD_KERNEL_CMDLINE)" --base 0x80000000 --pagesize 2048 --kernel_offset 0x00008000 --ramdisk_offset 0x04000000 --second_offset 0x00f00000 --tags_offset 0x00000100 --board vC29-0
+
+# MTK
+BOARD_HAS_MTK_HARDWARE := true
+MTK_HARDWARE := true
+
+# to be used with hardware/mediatek repo
+BOARD_HAS_MTK := true
+MTK_HWC_CHIP := mt8127
+MTK_HWC_SUPPORT := true
+MTK_WFD_SUPPORT := true
+MTK_PQ_SUPPORT := true
+MTK_ION_SUPPORT := true
+MTK_HDMI_SUPPORT := false
+MTK_SENSOR_SUPPORT := true
+
+# Flags
+TARGET_GLOBAL_CFLAGS += -mfpu=neon -mfloat-abi=softfp
+TARGET_GLOBAL_CPPFLAGS += -DMTK_HARDWARE -mfpu=neon -mfloat-abi=softfp
+TARGET_GLOBAL_CFLAGS += -DREFRESH_RATE=60
+TARGET_GLOBAL_CFLAGS += -DMTK_HARDWARE
+TARGET_GLOBAL_CFLAGS += -DADD_LEGACY_ACQUIRE_BUFFER_SYMBOL
+TARGET_GLOBAL_CFLAGS += -DNO_SECURE_DISCARD
+
+# Graphics
+USE_OPENGL_RENDERER := true
+BOARD_EGL_CFG := $(DEVICE_DIR)/configs/egl.cfg
+TARGET_USES_C2D_COMPOSITION := true
+TARGET_USES_OVERLAY := true
+TARGET_USES_ION := true
+TARGET_DISPLAY_USE_RETIRE_FENCE := true
+MAX_EGL_CACHE_KEY_SIZE := 12*1024
+MAX_EGL_CACHE_SIZE := 1024*1024
+BOARD_EGL_NEEDS_HANDLE_VALUE := true
+
+TARGET_HAS_LEGACY_CAMERA_HAL1 := true
+TARGET_USES_MEDIA_EXTENSIONS := true
+
+# Surfaceflinger optimization for VD surfaces
+TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS := true
+NUM_FRAMEBUFFER_SURFACE_BUFFERS := 3
+
+# WIFI
+BOARD_WLAN_DEVICE := MediaTek
+WPA_SUPPLICANT_VERSION := VER_0_8_X
+BOARD_HOSTAPD_DRIVER := NL80211
+BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_mt66xx
+BOARD_WPA_SUPPLICANT_DRIVER := NL80211
+BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_mt66xx
+WIFI_DRIVER_FW_PATH_PARAM := /dev/wmtWifi
+WIFI_DRIVER_FW_PATH_AP := AP
+WIFI_DRIVER_FW_PATH_STA := STA
+WIFI_DRIVER_FW_PATH_P2P := P2P
+WIFI_DRIVER_STATE_CTRL_PARAM := /dev/wmtWifi
+WIFI_DRIVER_STATE_ON := 1
+WIFI_DRIVER_STATE_OFF := 0
+
+# BT (added 03/10/2016)
+BOARD_HAVE_BLUETOOTH := true
+BOARD_HAVE_BLUETOOTH_MTK := true
+BOARD_BLUETOOTH_DOES_NOT_USE_RFKILL := true
+BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := $(DEVICE_DIR)/bluetooth
+
+# RECOVERY
+TARGET_RECOVERY_FSTAB := $(DEVICE_DIR)/recovery.fstab
+
+# libxlog
+TARGET_LDPRELOAD := libxlog.so:libmtk_symbols.so
+LINKER_FORCED_SHIM_LIBS := /system/lib/egl/libEGL_mali.so|libxlog.so:/system/lib/egl/libGLESv1_CM_mali.so|libxlog.so:/system/lib/egl/libGLESv2_mali.so|libxlog.so:/system/lib/libMtkOmxVenc.so|libmtk_symbols.so:/system/lib/libcam_utils.so|libmtk_symbols.so:/system/vendor/lib/libwvm.so|libmtk_symbols.so
+
+
+# SELinux
+BOARD_SECCOMP_POLICY := $(DEVICE_DIR)/seccomp
+BOARD_SEPOLICY_DIRS += $(DEVICE_DIR)/sepolicy
--- /dev/null
+Device Tree For Telekom Puls
+============================
+
+Basic | Spec Sheet
+-------:|:-------------------------
+CPU | Quad 1.3 GHz Cortex-A7
+CHIPSET | Mediatek MT8127
+GPU | Mali-450 MP
+Memory | 1GB RAM
+Android | 5.0
+Storage | 16 GB
+MicroSD | yes
+Battery | 4060 mAh
+Display | 8"
+Front Camera | 2 MP
+Rear Camera | 5 MP
+
+![Telekom Puls](https://scr3.golem.de/screenshots/1509/Telekom_Puls/thumb620/150904_Tablet_Puls_wei_1.jpg "Telekom Puls")
--- /dev/null
+/*
+ * Copyright (C) 2014 The CyanogenMod 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
+
+#define BTM_DEF_LOCAL_NAME "Telekom Puls"
+#define BTA_AV_MAX_A2DP_MTU 1788
+#define BLE_INCLUDED TRUE
+#define BTA_GATT_INCLUDED TRUE
+#define SMP_INCLUDED TRUE
+
+#endif
+
--- /dev/null
+# Release name
+PRODUCT_RELEASE_NAME := ttab
+
+# Inherit device configuration
+$(call inherit-product, device/alcatel/ttab/full_ttab.mk)
+
+# Inherit some common CM stuff.
+$(call inherit-product, vendor/cm/config/common_full_tablet_wifionly.mk)
+
+
+## Device identifier. This must come after all inclusions
+PRODUCT_DEVICE := ttab
+PRODUCT_NAME := cm_ttab
+PRODUCT_BRAND := alcatel
+PRODUCT_MODEL := ttab
+PRODUCT_MANUFACTURER := alcatel
+PRODUCT_RELEASE_NAME := ttab
+PRODUCT_GMS_CLIENTID_BASE := android-alcatel
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<mtk_agps_profiles maj_ver="1" min_ver="2">
+
+ <!-- cur_supl_profile and supl_profile
+
+ name:
+ SLP name will be displayed on LocatioEM2 - SLP Template list
+
+ addr:
+ SLP address
+
+ port:
+ SLP port
+
+ tls:
+ enable/disable TLS connection
+ available value: true (default), false
+
+ ===== load SLP profile automatically based on PLMN =====
+ mcc (optional):
+ auto configure the supl_profile if the current MCC on DUT are the same as mcc parameter you specified and auto_profile_enable is enabled
+
+ mcc_mnc (optional):
+ auto configure the supl_profile if the current MCC and MNC on DUT are the same as mcc_mnc paramter you specified and auto_profile_enable is enabled
+
+ supl_version (optional):
+ auto configure supl_version if above mcc_mnc condition is met
+ available value: 1 -> SUPL1.0 (default)
+ available value: 2 -> SUPL2.0
+
+ tls_version (optional):
+ auto configure tls_version if above mcc_mnc condition is met
+ available value: 0 -> TLS1.0 (default)
+ available value: 1 -> TLS1.1
+ available value: 2 -> TLS1.2
+
+ sha_version (optional):
+ auto configure sha_version if above mcc_mnc condition is met
+ available value: 0 -> SHA1 for SUPL1.0 and SHA256 for SUPL2.0 (default)
+ available value: 1 -> SHA1 for SUPL1.0 and SUPL2.0
+ available value: 2 -> SHA256 for SUPL1.0 and SUPL2.0
+
+ ===== other parameters are used for DM =====
+ app_id (optional):
+ "ap0004"
+
+ provider_id (optional):
+ "221.176.0.55"
+
+ default_apn (optional):
+ "XXX WAP"
+
+ optional_apn (optional):
+ "internet"
+
+ optional_apn_2 (optional):
+ ""
+
+ address_type (optional):
+ "IPv4address:port"
+ -->
+
+ <cur_supl_profile name="GOOGLE"
+ addr="supl.google.com"
+ port="7275"
+ tls="true"
+ />
+
+ <!-- GOOGLE-->
+ <supl_profile name="GOOGLE"
+ addr="supl.google.com"
+ port="7275"
+ tls="true"
+ />
+
+ <!-- GOOGLE-->
+ <supl_profile name="GOOGLE nonTLS"
+ addr="supl.google.com"
+ port="7276"
+ tls="false"
+ />
+
+ <!-- GOOGLE-->
+ <supl_profile name="GOOGLE IP"
+ addr="173.194.72.192"
+ port="7276"
+ tls="false"
+ />
+
+ <!-- Spirent Lab -->
+ <supl_profile name="Spirent"
+ addr="www.spirent-lcs.com"
+ port="7275"
+ tls="true"
+ />
+
+ <!-- R&S Lab -->
+ <supl_profile name="RnS"
+ addr="slp.rs.de"
+ port="7275"
+ tls="true"
+ />
+
+ <!-- CMCC Lab -->
+ <supl_profile name="CMCC Lab"
+ addr="218.206.176.50"
+ port="7275"
+ tls="true"
+ />
+
+ <!-- Andrew Lab -->
+ <supl_profile name="Andrew"
+ addr="slp1acva.andrew.com"
+ port="7275"
+ tls="true"
+ />
+
+ <!-- Ericsson Lab -->
+ <supl_profile name="Ericsson"
+ addr="172.22.1.100"
+ port="7275"
+ tls="true"
+ />
+
+ <!-- Ericsson Lab FQDN -->
+ <supl_profile name="Ericsson FQDN"
+ addr="mvtvltegmpc.naladmz.ericsson.ca"
+ port="7275"
+ tls="true"
+ />
+
+ <!-- Ericsson Lab FQDN 2 -->
+ <supl_profile name="Ericsson FQDN 2"
+ addr="mvtv-broadcom.naladmz.ericsson.ca"
+ port="7275"
+ tls="true"
+ />
+
+ <!-- ORANGE -->
+ <supl_profile name="ORANGE"
+ addr="agpss.orange.fr"
+ port="7275"
+ tls="true"
+ />
+
+ <!-- CMCC-->
+ <supl_profile name="CMCC"
+ addr="221.176.0.55"
+ port="7275"
+ tls="true"
+ app_id="ap0004"
+ provider_id="221.176.0.55"
+ default_apn="CMCC WAP"
+ optional_apn="CMNET"
+ optional_apn_2=""
+ address_type="IPv4address:port"
+ />
+
+ <!-- Telstra -->
+ <supl_profile name="Telstra"
+ addr="agps.supl.telstra.com"
+ port="7275"
+ tls="true"
+ />
+
+ <!-- CHUAN HWA -->
+ <supl_profile name="Chunghwa"
+ addr="10.1.101.137"
+ port="8025"
+ tls="false"
+ />
+
+ <!-- T-Mobile -->
+ <supl_profile name="T-Mobile"
+ addr="lbs.geo.t-mobile.com"
+ port="7275"
+ tls="true"
+ />
+
+ <!-- Vodafone -->
+ <supl_profile name="Vodafone"
+ addr="supl.vodafone.com"
+ port="7275"
+ tls="true"
+ mcc_mnc="22010"
+ supl_version="2"
+ tls_version="1"
+ sha_version="0"
+ />
+
+ <!-- Test 1 -->
+ <supl_profile name="Test 1"
+ addr="127.0.0.1"
+ port="7276"
+ tls="false"
+ mcc_mnc="999998"
+ supl_version="1"
+ tls_version="0"
+ sha_version="2"
+ />
+
+ <!-- Test 2 -->
+ <supl_profile name="Test 2"
+ addr="127.0.0.1"
+ port="7276"
+ tls="false"
+ mcc_mnc="999999"
+ supl_version="2"
+ tls_version="1"
+ sha_version="0"
+ />
+
+ <!-- Test 3 -->
+ <supl_profile name="Test 3"
+ addr="127.0.0.1"
+ port="7276"
+ tls="false"
+ mcc="998"
+ supl_version="1"
+ tls_version="2"
+ sha_version="1"
+ />
+
+ <!-- cdma_profile
+
+ name:
+ SLP name
+
+ mcp_enable:
+ enable/disable MCP parameters
+ available value: true, false (default)
+
+ mcp_addr:
+ MCP address
+
+ mcp_port:
+ MCP port
+
+ pde_addr_valid:
+ PDE address is valid or invalid
+ available value: true, false (default)
+
+ pde_ip_type:
+ PDE's address type
+ available value: 0 -> IPv4 (default)
+ available value: 1 -> IPv6
+
+ pde_addr:
+ PDE IP address
+
+ pde_port:
+ PDE port
+
+ pde_url_valid:
+ PDE URL is valid or invalid
+ available value: true, false (default)
+
+ pde_url_addr:
+ PDE URL
+ -->
+
+ <!-- CDMA profile template -->
+ <cdma_profile name="CDMA1"
+ mcp_enable="false"
+ mcp_addr="10.199.2.165"
+ mcp_port="6066"
+ pde_addr_valid="false"
+ pde_ip_type="0"
+ pde_addr="11.11.11.11"
+ pde_port="1111"
+ pde_url_valid="false"
+ pde_url_addr="www.mediatek.com"
+ />
+
+
+ <!-- agps_setting
+
+ agps_enable:
+ enable/disable A-GPS
+ available value: true (default), false
+
+ agps_protocol:
+ choose which A-GPS you want to use for SET Initiated
+ available value: 0 -> User Plane (default)
+ available value: 1 -> Control Plane
+
+ gpevt:
+ enable/disable GPEVT report
+ available value: true, false (default)
+ -->
+ <agps_setting
+ agps_enable="true"
+ agps_protocol="0"
+ gpevt="false"
+ />
+
+
+ <!-- cp_setting
+
+ molr_pos_method:
+ available value: 0 (Location Estimate) (default)
+ available value: 1 (Assistance Data)
+
+ external_addr_enable:
+ enable/disable the external address
+ available value: true, false (default)
+
+ external_addr:
+ external_address
+
+ mlc_number_enable:
+ enable/disable the mlc number
+ available value: true, false (default)
+
+ mlc_number:
+ MLC number
+
+ cp_auto_reset:
+ enable/disable to send PMTK997_5
+ available value: true, false (default)
+
+ epc_molr_lpp_payload_enable:
+ enable/disable to send LPP payload in the EPC-MOLR message
+ available value: true, false (default)
+
+ epc_molr_lpp_payload:
+ specify the LPP payload in the EPC-MOLR message in hexString format (ex: "010203ff" = { 0x01, 0x02, 0x03, 0xff }
+ the purpose of this parameter is used for LAB testing only, please do not change it.
+
+ -->
+ <cp_setting
+ molr_pos_method="0"
+ external_addr_enable="false"
+ external_addr="0123456789*#+"
+ mlc_number_enable="false"
+ mlc_number="0123456789*#+"
+ cp_auto_reset="false"
+ epc_molr_lpp_payload_enable="false"
+ epc_molr_lpp_payload="D2000010237B2026404FB8007202BFFFFFFFF80000000020C0000100940FB9001202B7FFFFF8000000000061800002018A00"
+ />
+
+ <!-- up_setting
+
+ ca_enable:
+ enable/disable the certificate verification
+ available value: true, false (default)
+
+ ni_request:
+ enable/disable Network Initiated (NI) functionality
+ available value: true (default), false
+
+ roaming:
+ enable/disable to use A-GPS when device is under roaming state
+ available value: true (default), false
+
+ cdma_preferred:
+ when CDMA network and WCDMA network are available, which AGPS protocol you prefer?
+ available value: 0 (WCDMA AGPS protocol is preferred) (default)
+ available value: 2 (FORCE CDMA AGPS protocol)
+
+ pref_method:
+ the preferred method in SUPL_START and SUPL_POS_INIT
+ available value: 0 -> SET assisted Preferred
+ available value: 1 -> SET Based Preferred (default)
+ available value: 2 -> no Preference
+
+ supl_version:
+ SUPL version for ULP
+ available value: 1 -> SUPL1.0 (default)
+ available value: 2 -> SUPL2.0
+
+ tls_version:
+ TLS version for TLS connection
+ available value: 0 -> TLS1.0 (default)
+ available value: 1 -> TLS1.1
+ available value: 2 -> TLS1.2
+
+ sha_version:
+ SHA version for calculating VER
+ available value: 0 -> SHA1 for SUPL1.0 and SHA256 for SUPL2.0 (default)
+ available value: 1 -> SHA1 for SUPL1.0 and SUPL2.0
+ available value: 2 -> SHA256 for SUPL1.0 and SUPL2.0
+
+ supl_log:
+ enable or disable the AGPS log
+ available value: true, false (default)
+
+ msa_enable:
+ enable/disable the MSA capability
+ available value: true (default), false
+
+ msb_enable:
+ enable/disable the MSB capability
+ available value: true (default), false
+
+ ecid_enable:
+ enable/disable the eCID capability
+ available value: true (default), false
+
+ otdoa_enable:
+ enable/disable the OTDOA capability
+ available value: true, false (default)
+
+ udp_port_enable:
+ enable/disable the UDP 7275 port by default, if you enable it, you may cause Android/CTS failure for checking netstat
+ available value: true, false (default)
+
+ dedicated_apn_enable:
+ enable/disable the dedicated SUPL APN flow
+ available value: true, false (default)
+
+ preferred_2g3g_cell_age:
+ max age of 2G / 3G cell info in history is OK to send to SLP server instead if the latest cell is of 3G or 4G.
+ available value: non-negative integer, from 0 ~ 1800, unit in second
+ 0 (always use the latest cell info)
+ 300 (prefer to use 2G / 3G cell if its age is less than 5 mins)
+
+ lpp_enable:
+ enable/disable the LPP capability
+ available value: true (default), false
+
+ cert_from_sdcard:
+ enable/disable the AGPS certification installation from SDCard
+ available value: true (default), false
+
+ auto_profile_enable:
+ enable/disable the auto profile configuration based on current mcc or mcc_mnc specified in cur_supl_profile or supl_profile
+ available value: true (default), false
+
+ ut2:
+ customize the SUPL UT2 timer
+ available value: 1~60, default value is 11 (OMA spec)
+
+ ut3:
+ customize the SUPL UT3 timer
+ available value: 1~60, default value is 10 (OMA spec)
+ -->
+ <up_setting
+ ca_enable="false"
+ ni_request="true"
+ roaming="true"
+ cdma_preferred="0"
+ pref_method="1"
+ supl_version="1"
+ tls_version="0"
+ sha_version="0"
+ supl_log="false"
+ msa_enable="true"
+ msb_enable="true"
+ ecid_enable="true"
+ otdoa_enable="false"
+ qop_hacc="22"
+ qop_vacc="0"
+ qop_loc_age="0"
+ qop_delay="0"
+ udp_port_enable="false"
+ dedicated_apn_enable="false"
+ preferred_2g3g_cell_age="300"
+ lpp_enable="true"
+ cert_from_sdcard="true"
+ auto_profile_enable="true"
+ ut2="11"
+ ut3="10"
+ />
+
+</mtk_agps_profiles>
--- /dev/null
+#
+# Audio policy configuration for MT8135 common
+#
+
+# Global configuration section: lists input and output devices always present on the device
+# as well as the output device selected by default.
+# Devices are designated by a string that corresponds to the enum in audio.h
+
+#global_configuration {
+# attached_output_devices AUDIO_DEVICE_OUT_SPEAKER
+# default_output_device AUDIO_DEVICE_OUT_SPEAKER
+# attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_REMOTE_SUBMIX|AUDIO_DEVICE_IN_FM
+#}
+
+# audio hardware module section: contains descriptors for all audio hw modules present on the
+# device. Each hw module node is named after the corresponding hw module library base name.
+# For instance, "primary" corresponds to audio.primary.<device>.so.
+# The "primary" module is mandatory and must include at least one output with
+# AUDIO_OUTPUT_FLAG_PRIMARY flag.
+# Each module descriptor contains one or more output profile descriptors and zero or more
+# input profile descriptors. Each profile lists all the parameters supported by a given output
+# or input stream category.
+# The "channel_masks", "formats", "devices" and "flags" are specified using strings corresponding
+# to enums in audio.h and audio_policy.h. They are concatenated by use of "|" without space or "\n".
+
+audio_hw_modules {
+ primary {
+ global_configuration {
+ attached_output_devices AUDIO_DEVICE_OUT_SPEAKER
+ default_output_device AUDIO_DEVICE_OUT_SPEAKER
+ attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_REMOTE_SUBMIX|AUDIO_DEVICE_IN_FM
+ audio_hal_version 3.0
+ }
+ devices {
+ headset {
+ type AUDIO_DEVICE_OUT_WIRED_HEADSET
+ gains {
+ gain_1 {
+ mode AUDIO_GAIN_MODE_JOINT
+ channel_mask AUDIO_CHANNEL_OUT_STEREO
+ min_value_mB -6400
+ max_value_mB 0
+ default_value_mB 0
+ step_value_mB 100
+ min_ramp_ms 0
+ max_ramp_ms 0
+ }
+ }
+ }
+ headphone {
+ type AUDIO_DEVICE_OUT_WIRED_HEADPHONE
+ gains {
+ gain_1 {
+ mode AUDIO_GAIN_MODE_JOINT
+ channel_mask AUDIO_CHANNEL_OUT_STEREO
+ min_value_mB -6400
+ max_value_mB 0
+ default_value_mB 0
+ step_value_mB 100
+ min_ramp_ms 0
+ max_ramp_ms 0
+ }
+ }
+ }
+ }
+ outputs {
+ primary {
+ sampling_rates 44100
+ channel_masks AUDIO_CHANNEL_OUT_STEREO
+ formats AUDIO_FORMAT_PCM_16_BIT
+ devices AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET|AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_FM_TX|AUDIO_DEVICE_OUT_DEFAULT
+ flags AUDIO_OUTPUT_FLAG_PRIMARY
+ gains {
+ gain_1 {
+ mode AUDIO_GAIN_MODE_JOINT
+ channel_mask AUDIO_CHANNEL_OUT_STEREO
+ min_value_mB -6400
+ max_value_mB 0
+ default_value_mB 0
+ step_value_mB 100
+ min_ramp_ms 0
+ max_ramp_ms 0
+ }
+ }
+ }
+ hdmi_stereo {
+ sampling_rates 44100
+ channel_masks AUDIO_CHANNEL_OUT_STEREO
+ formats AUDIO_FORMAT_PCM_16_BIT
+ devices AUDIO_DEVICE_OUT_AUX_DIGITAL
+ }
+ hdmi_multi_ch {
+ sampling_rates 32000|44100|48000
+ channel_masks dynamic
+ formats AUDIO_FORMAT_PCM_16_BIT
+ devices AUDIO_DEVICE_OUT_AUX_DIGITAL
+ flags AUDIO_OUTPUT_FLAG_DIRECT
+ }
+ }
+ inputs {
+ primary {
+ sampling_rates 8000|16000|48000
+ channel_masks AUDIO_CHANNEL_IN_MONO|AUDIO_CHANNEL_IN_STEREO
+ formats AUDIO_FORMAT_PCM_16_BIT
+ devices AUDIO_DEVICE_IN_COMMUNICATION|AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_AMBIENT|AUDIO_DEVICE_IN_WIRED_HEADSET|AUDIO_DEVICE_IN_AUX_DIGITAL|AUDIO_DEVICE_IN_VOICE_CALL|AUDIO_DEVICE_IN_BACK_MIC|AUDIO_DEVICE_IN_ALL_SCO|AUDIO_DEVICE_IN_FM|AUDIO_DEVICE_IN_DEFAULT
+ }
+ }
+ }
+ a2dp {
+ global_configuration {
+ audio_hal_version 2.0
+ }
+ outputs {
+ a2dp {
+ sampling_rates 44100
+ channel_masks AUDIO_CHANNEL_OUT_STEREO
+ formats AUDIO_FORMAT_PCM_16_BIT
+ devices AUDIO_DEVICE_OUT_ALL_A2DP
+ }
+ }
+ inputs {
+ a2dp {
+ sampling_rates 44100
+ channel_masks AUDIO_CHANNEL_IN_STEREO
+ formats AUDIO_FORMAT_PCM_16_BIT
+ devices AUDIO_DEVICE_IN_BLUETOOTH_A2DP
+ }
+ }
+ }
+ usb {
+ global_configuration {
+ audio_hal_version 2.0
+ }
+ outputs {
+ usb_accessory {
+ sampling_rates 44100
+ channel_masks AUDIO_CHANNEL_OUT_STEREO
+ formats AUDIO_FORMAT_PCM_16_BIT
+ devices AUDIO_DEVICE_OUT_USB_ACCESSORY
+ }
+ usb_device {
+ sampling_rates 44100
+ channel_masks AUDIO_CHANNEL_OUT_STEREO
+ formats AUDIO_FORMAT_PCM_16_BIT
+ devices AUDIO_DEVICE_OUT_USB_DEVICE
+ }
+ }
+ inputs {
+ usb_device {
+ sampling_rates 44100
+ channel_masks AUDIO_CHANNEL_IN_STEREO
+ formats AUDIO_FORMAT_PCM_16_BIT
+ devices AUDIO_DEVICE_IN_USB_DEVICE
+ }
+ }
+ }
+ r_submix {
+ global_configuration {
+ attached_input_devices AUDIO_DEVICE_IN_REMOTE_SUBMIX
+ audio_hal_version 2.0
+ }
+ outputs {
+ r_submix {
+ sampling_rates 48000
+ channel_masks AUDIO_CHANNEL_OUT_STEREO
+ formats AUDIO_FORMAT_PCM_16_BIT
+ devices AUDIO_DEVICE_OUT_REMOTE_SUBMIX
+ }
+ }
+ inputs {
+ r_submix {
+ sampling_rates 48000
+ channel_masks AUDIO_CHANNEL_IN_MONO|AUDIO_CHANNEL_IN_STEREO
+ formats AUDIO_FORMAT_PCM_16_BIT
+ devices AUDIO_DEVICE_IN_REMOTE_SUBMIX
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+# Device ID (DID) configuration
+[DID1]
+
+# Primary Record - true or false (default)
+# There can be only one primary record
+primaryRecord = true
+
+# Vendor ID '0xFFFF' indicates no Device ID Service Record is present in the device
+# 0x000F = Broadcom Corporation (default)
+#vendorId = 0x000F
+
+# Vendor ID Source
+# 0x0001 = Bluetooth SIG assigned Device ID Vendor ID value (default)
+# 0x0002 = USB Implementer\92s Forum assigned Device ID Vendor ID value
+#vendorIdSource = 0x0001
+
+# Product ID & Product Version
+# Per spec DID v1.3 0xJJMN for version is interpreted as JJ.M.N
+# JJ: major version number, M: minor version number, N: sub-minor version number
+# For example: 1200, v14.3.6
+productId = 0x1200
+version = 0x1436
+
+# Optional attributes
+#clientExecutableURL =
+#serviceDescription =
+#documentationURL =
+
+#=================================================================================================#
+# Device ID (DID) configuration
+[DID2]
+
+# Primary Record - true or false (default)
+# There can be only one primary record
+#primaryRecord = false
+
+# Vendor ID '0xFFFF' indicates no Device ID Service Record is present in the device
+# 0x000F = Broadcom Corporation (default)
+#vendorId = 0x000F
+
+# Vendor ID Source
+# 0x0001 = Bluetooth SIG assigned Device ID Vendor ID value (default)
+# 0x0002 = USB Implementer\92s Forum assigned Device ID Vendor ID value
+#vendorIdSource = 0x0001
+
+# Product ID & Product Version
+# Per spec DID v1.3 0xJJMN for version is interpreted as JJ.M.N
+# JJ: major version number, M: minor version number, N: sub-minor version number
+# Default: 0x0000, v00.0.0
+#productId = 0x0000
+#version = 0x0000
+
+# Optional attributes
+#clientExecutableURL =
+#serviceDescription =
+#documentationURL =
+
+#=================================================================================================#
+# Device ID (DID) configuration
+[DID3]
+
+# Primary Record - true or false (default)
+# There can be only one primary record
+#primaryRecord = false
+
+# Vendor ID '0xFFFF' indicates no Device ID Service Record is present in the device
+# 0x000F = Broadcom Corporation (default)
+#vendorId = 0x000F
+
+# Vendor ID Source
+# 0x0001 = Bluetooth SIG assigned Device ID Vendor ID value (default)
+# 0x0002 = USB Implementer\92s Forum assigned Device ID Vendor ID value
+#vendorIdSource = 0x0001
+
+# Product ID & Product Version
+# Per spec DID v1.3 0xJJMN for version is interpreted as JJ.M.N
+# JJ: major version number, M: minor version number, N: sub-minor version number
+# Default: 0x0000, v00.0.0
+#productId = 0x0000
+#version = 0x0000
+
+# Optional attributes
+#clientExecutableURL =
+#serviceDescription =
+#documentationURL =
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <profile>
+ <name>profile_supported_simap</name>
+ <value>false</value>
+ </profile>
+ <profile>
+ <name>profile_supported_prxm</name>
+ <value>false</value>
+ </profile>
+ <profile>
+ <name>profile_supported_prxr</name>
+ <value>false</value>
+ </profile>
+ <profile>
+<!--[DUGFIX]-Mod-BEGIN by SCDTABLET.(weihong.chen),06/03/2015,1016628, -->
+<!--T-TAB should support ftp profile -->
+<!--[DUGFIX]-Mod-BEGIN by SCDTABLET.(weihong.chen),06/25/2015,1027225, -->
+<!--[t-tab]disable bluetooth ftp -->
+ <name>profile_supported_ftp</name>
+ <value>false</value>
+<!--[DUGFIX]-Mod-END by SCDTABLET.(weihong.chen)-->
+<!--[DUGFIX]-Mod-END by SCDTABLET.(weihong.chen)-->
+ </profile>
+ <profile>
+ <name>profile_supported_bpp</name>
+ <value>false</value>
+ </profile>
+ <profile>
+ <name>profile_supported_bip</name>
+ <value>false</value>
+ </profile>
+ <profile>
+ <name>profile_supported_dun</name>
+ <value>false</value>
+ </profile>
+</resources>
--- /dev/null
+# NOTICE: This is an autogenerated file, do not edit\n
+0 0 android
+0 1 mali
\ No newline at end of file
--- /dev/null
+# List of MAC addresses that are allowed to authenticate (IEEE 802.11)
+# with the AP. Optional VLAN ID can be assigned for clients based on the
+# MAC address if dynamic VLANs (hostapd.conf dynamic_vlan option) are used.
\ No newline at end of file
--- /dev/null
+# List of MAC addresses that are not allowed to authenticate (IEEE 802.11)
+# with the AP.
\ No newline at end of file
--- /dev/null
+##### hostapd configuration file ##############################################
+# Empty lines and lines starting with # are ignored
+
+# AP netdevice name (without 'ap' postfix, i.e., wlan0 uses wlan0ap for
+# management frames); ath0 for madwifi
+interface=wlan0
+
+# Driver interface type (hostap/wired/madwifi/prism54/test/none/nl80211/bsd);
+# default: hostap). nl80211 is used with all Linux mac80211 drivers.
+# Use driver=none if building hostapd as a standalone RADIUS server that does
+# not control any wireless/wired driver.
+driver=nl80211
+
+# hostapd event logger configuration
+#
+# Two output method: syslog and stdout (only usable if not forking to
+# background).
+#
+# Module bitfield (ORed bitfield of modules that will be logged; -1 = all
+# modules):
+# bit 0 (1) = IEEE 802.11
+# bit 1 (2) = IEEE 802.1X
+# bit 2 (4) = RADIUS
+# bit 3 (8) = WPA
+# bit 4 (16) = driver interface
+# bit 5 (32) = IAPP
+# bit 6 (64) = MLME
+#
+# Levels (minimum value for logged events):
+# 0 = verbose debugging
+# 1 = debugging
+# 2 = informational messages
+# 3 = notification
+# 4 = warning
+#
+logger_syslog=-1
+logger_syslog_level=2
+logger_stdout=-1
+logger_stdout_level=2
+
+# Dump file for state information (on SIGUSR1)
+dump_file=/tmp/hostapd.dump
+
+# Interface for separate control program. If this is specified, hostapd
+# will create this directory and a UNIX domain socket 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 hostapd processes/interfaces can be run at the same time if more
+# than one interface is used.
+# /var/run/hostapd is the recommended directory for sockets and by default,
+# hostapd_cli will use it when trying to connect with hostapd.
+ctrl_interface=/data/misc/wifi/hostapd
+
+##### IEEE 802.11 related configuration #######################################
+
+# SSID to be used in IEEE 802.11 management frames
+ssid=AndroidAP
+
+# Operation mode (a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g,
+# n = IEEE 802.11n, g_only = IEEE 802.11g_only, n_only = IEEE 802.11n_only,
+# Default: IEEE 802.11n
+hw_mode=g
+
+# Channel number (IEEE 802.11)
+# (default: 0, i.e., not set)
+# Please note that some drivers (e.g., madwifi) do not use this value from
+# hostapd and the channel will need to be configuration separately with
+# iwconfig.
+channel=6
+
+# ieee80211n: Whether IEEE 802.11n (HT) is enabled
+# 0 = disabled (default)
+# 1 = enabled
+# Note: You will also need to enable WMM for full HT functionality.
+ieee80211n=1
+
+# Accept/deny lists are read from separate files (containing list of
+# MAC addresses, one per line). Use absolute path name to make sure that the
+# files can be read on SIGHUP configuration reloads.
+accept_mac_file=/data/hostapd/hostapd.accept
+deny_mac_file=/data/hostapd/hostapd.deny
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+<!-- 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.
+-->
+
+<!--
+<!DOCTYPE MediaCodecs [
+<!ELEMENT MediaCodecs (Decoders,Encoders)>
+<!ELEMENT Decoders (MediaCodec*)>
+<!ELEMENT Encoders (MediaCodec*)>
+<!ELEMENT MediaCodec (Type*,Quirk*)>
+<!ATTLIST MediaCodec name CDATA #REQUIRED>
+<!ATTLIST MediaCodec type CDATA>
+<!ELEMENT Type EMPTY>
+<!ATTLIST Type name CDATA #REQUIRED>
+<!ELEMENT Quirk EMPTY>
+<!ATTLIST Quirk name CDATA #REQUIRED>
+]>
+
+There's a simple and a complex syntax to declare the availability of a
+media codec:
+
+A codec that properly follows the OpenMax spec and therefore doesn't have any
+quirks and that only supports a single content type can be declared like so:
+
+ <MediaCodec name="OMX.foo.bar" type="something/interesting" />
+
+If a codec has quirks OR supports multiple content types, the following syntax
+can be used:
+
+ <MediaCodec name="OMX.foo.bar" >
+ <Type name="something/interesting" />
+ <Type name="something/else" />
+ ...
+ <Quirk name="requires-allocate-on-input-ports" />
+ <Quirk name="requires-allocate-on-output-ports" />
+ <Quirk name="output-buffers-are-unreadable" />
+ </MediaCodec>
+
+Only the three quirks included above are recognized at this point:
+
+"requires-allocate-on-input-ports"
+ must be advertised if the component does not properly support specification
+ of input buffers using the OMX_UseBuffer(...) API but instead requires
+ OMX_AllocateBuffer to be used.
+
+"requires-allocate-on-output-ports"
+ must be advertised if the component does not properly support specification
+ of output buffers using the OMX_UseBuffer(...) API but instead requires
+ OMX_AllocateBuffer to be used.
+
+"output-buffers-are-unreadable"
+ must be advertised if the emitted output buffers of a decoder component
+ are not readable, i.e. use a custom format even though abusing one of
+ the official OMX colorspace constants.
+ Clients of such decoders will not be able to access the decoded data,
+ naturally making the component much less useful. The only use for
+ a component with this quirk is to render the output to the screen.
+ Audio decoders MUST NOT advertise this quirk.
+ Video decoders that advertise this quirk must be accompanied by a
+ corresponding color space converter for thumbnail extraction,
+ matching surfaceflinger support that can render the custom format to
+ a texture and possibly other code, so just DON'T USE THIS QUIRK.
+
+ 2012/07/13 config for MTK OMX Media Codecs, created by Morris Yang (mtk03147)
+-->
+
+<MediaCodecs>
+ <Include href="media_codecs_google_audio.xml" />
+ <Include href="media_codecs_google_telephony.xml" />
+
+ <Decoders>
+ <!-- DOLBY_UDC -->
+ <MediaCodec name="OMX.dolby.ac3.decoder" >
+ <Type name="audio/ac3" />
+ <Quirk name="needs-flush-before-disable" />
+ <Quirk name="requires-flush-complete-emulation" />
+ </MediaCodec>
+ <MediaCodec name="OMX.dolby.ec3.decoder" >
+ <Type name="audio/eac3" />
+ <Quirk name="needs-flush-before-disable" />
+ <Quirk name="requires-flush-complete-emulation" />
+ </MediaCodec>
+ <!-- DOLBY_UDC END -->
+
+ <!-- ffmpeg video codecs -->
+ <MediaCodec name="OMX.ffmpeg.h263.decoder" type="video/3gpp">
+ <Limit name="size" min="2x2" max="352x288" />
+ <Limit name="alignment" value="2x2" />
+ <Feature name="adaptive-playback" />
+ </MediaCodec>
+
+ <MediaCodec name="OMX.ffmpeg.h264.decoder" type="video/avc">
+ <Limit name="size" min="2x2" max="2048x2048" />
+ <Limit name="alignment" value="2x2" />
+ <Feature name="adaptive-playback" />
+ </MediaCodec>
+
+ <MediaCodec name="OMX.ffmpeg.hevc.decoder" type="video/hevc">
+ <Limit name="size" min="2x2" max="2048x2048" />
+ <Limit name="alignment" value="2x2" />
+ <Feature name="adaptive-playback" />
+ </MediaCodec>
+ </Decoders>
+
+ <Encoders>
+ <MediaCodec name="OMX.MTK.VIDEO.ENCODER.MPEG4" type="video/mp4v-es" >
+ <Limit name="size" min="64x64" max="640x480" />
+ <Limit name="alignment" value="16x16" />
+ <Limit name="block-size" value="16x16" />
+ <Quirk name="requires-allocate-on-input-ports" />
+ <Quirk name="requires-allocate-on-output-ports" />
+ </MediaCodec>
+ <MediaCodec name="OMX.MTK.VIDEO.ENCODER.H263" type="video/3gpp" >
+ <Limit name="size" min="64x64" max="640x480" />
+ <Limit name="alignment" value="16x16" />
+ <Limit name="block-size" value="16x16" />
+ <Quirk name="requires-allocate-on-input-ports" />
+ <Quirk name="requires-allocate-on-output-ports" />
+ </MediaCodec>
+ <MediaCodec name="OMX.MTK.VIDEO.ENCODER.AVC" type="video/avc" >
+ <Limit name="size" min="128x96" max="1920x1080" />
+ <Limit name="alignment" value="16x16" />
+ <Limit name="block-size" value="16x16" />
+ <Quirk name="requires-allocate-on-input-ports" />
+ <Quirk name="requires-allocate-on-output-ports" />
+ </MediaCodec>
+ </Encoders>
+
+ <Include href="media_codecs_google_video.xml" />
+ <Include href="media_codecs_ffmpeg.xml" />
+</MediaCodecs>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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.
+-->
+<!DOCTYPE MediaSettings [
+<!ELEMENT MediaSettings (CamcorderProfiles,
+ EncoderOutputFileFormat+,
+ VideoEncoderCap+,
+ AudioEncoderCap+,
+ VideoDecoderCap,
+ AudioDecoderCap)>
+<!ELEMENT CamcorderProfiles (EncoderProfile+, ImageEncoding+, ImageDecoding, Camera)>
+<!ELEMENT EncoderProfile (Video, Audio)>
+<!ATTLIST EncoderProfile quality (high|low) #REQUIRED>
+<!ATTLIST EncoderProfile fileFormat (mp4|3gp) #REQUIRED>
+<!ATTLIST EncoderProfile duration (30|60) #REQUIRED>
+<!ATTLIST EncoderProfile cameraId (0|1) #REQUIRED>
+<!ELEMENT Video EMPTY>
+<!ATTLIST Video codec (h264|h263|m4v) #REQUIRED>
+<!ATTLIST Video bitRate CDATA #REQUIRED>
+<!ATTLIST Video width CDATA #REQUIRED>
+<!ATTLIST Video height CDATA #REQUIRED>
+<!ATTLIST Video frameRate CDATA #REQUIRED>
+<!ELEMENT Audio EMPTY>
+<!ATTLIST Audio codec (amrnb|amrwb|aac) #REQUIRED>
+<!ATTLIST Audio bitRate CDATA #REQUIRED>
+<!ATTLIST Audio sampleRate CDATA #REQUIRED>
+<!ATTLIST Audio channels (1|2) #REQUIRED>
+<!ELEMENT ImageEncoding EMPTY>
+<!ATTLIST ImageEncoding quality (90|80|70|60|50|40) #REQUIRED>
+<!ELEMENT ImageDecoding EMPTY>
+<!ATTLIST ImageDecoding memCap CDATA #REQUIRED>
+<!ELEMENT Camera EMPTY>
+<!ELEMENT EncoderOutputFileFormat EMPTY>
+<!ATTLIST EncoderOutputFileFormat name (mp4|3gp) #REQUIRED>
+<!ELEMENT VideoEncoderCap EMPTY>
+<!ATTLIST VideoEncoderCap name (h264|h263|m4v|wmv) #REQUIRED>
+<!ATTLIST VideoEncoderCap enabled (true|false) #REQUIRED>
+<!ATTLIST VideoEncoderCap minBitRate CDATA #REQUIRED>
+<!ATTLIST VideoEncoderCap maxBitRate CDATA #REQUIRED>
+<!ATTLIST VideoEncoderCap minFrameWidth CDATA #REQUIRED>
+<!ATTLIST VideoEncoderCap maxFrameWidth CDATA #REQUIRED>
+<!ATTLIST VideoEncoderCap minFrameHeight CDATA #REQUIRED>
+<!ATTLIST VideoEncoderCap maxFrameHeight CDATA #REQUIRED>
+<!ATTLIST VideoEncoderCap minFrameRate CDATA #REQUIRED>
+<!ATTLIST VideoEncoderCap maxFrameRate CDATA #REQUIRED>
+<!ELEMENT AudioEncoderCap EMPTY>
+<!ATTLIST AudioEncoderCap name (amrnb|amrwb|aac|wma) #REQUIRED>
+<!ATTLIST AudioEncoderCap enabled (true|false) #REQUIRED>
+<!ATTLIST AudioEncoderCap minBitRate CDATA #REQUIRED>
+<!ATTLIST AudioEncoderCap maxBitRate CDATA #REQUIRED>
+<!ATTLIST AudioEncoderCap minSampleRate CDATA #REQUIRED>
+<!ATTLIST AudioEncoderCap maxSampleRate CDATA #REQUIRED>
+<!ATTLIST AudioEncoderCap minChannels (1|2) #REQUIRED>
+<!ATTLIST AudioEncoderCap maxChannels (1|2) #REQUIRED>
+<!ELEMENT VideoDecoderCap EMPTY>
+<!ATTLIST VideoDecoderCap name (wmv) #REQUIRED>
+<!ATTLIST VideoDecoderCap enabled (true|false) #REQUIRED>
+<!ELEMENT AudioDecoderCap EMPTY>
+<!ATTLIST AudioDecoderCap name (wma) #REQUIRED>
+<!ATTLIST AudioDecoderCap enabled (true|false) #REQUIRED>
+<!ELEMENT VideoEditorCap EMPTY>
+<!ATTLIST VideoEditorCap maxInputFrameWidth CDATA #REQUIRED>
+<!ATTLIST VideoEditorCap maxInputFrameHeight CDATA #REQUIRED>
+<!ATTLIST VideoEditorCap maxOutputFrameWidth CDATA #REQUIRED>
+<!ATTLIST VideoEditorCap maxOutputFrameHeight CDATA #REQUIRED>
+<!ATTLIST VideoEditorCap maxPrefetchYUVFrames CDATA #REQUIRED>
+<!ELEMENT ExportVideoProfile EMPTY>
+<!ATTLIST ExportVideoProfile name (h264|h263|m4v) #REQUIRED>
+<!ATTLIST ExportVideoProfile profile CDATA #REQUIRED>
+<!ATTLIST ExportVideoProfile level CDATA #REQUIRED>
+]>
+<!--
+ This file is used to declare the multimedia profiles and capabilities
+ on an android-powered device.
+-->
+<MediaSettings>
+ <!-- Each camcorder profile defines a set of predefined configuration parameters -->
+ <CamcorderProfiles cameraId="0">
+
+ <EncoderProfile quality="qvga" fileFormat="mp4" duration="60">
+ <Video codec="m4v"
+ bitRate="128000"
+ width="320"
+ height="240"
+ frameRate="15" />
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
+ <EncoderProfile quality="timelapseqcif" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="192000"
+ width="176"
+ height="144"
+ frameRate="30" />
+ <!-- audio setting is ignored -->
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
+ <ImageEncoding quality="95" />
+ <ImageEncoding quality="80" />
+ <ImageEncoding quality="70" />
+ <ImageDecoding memCap="20000000" />
+
+ </CamcorderProfiles>
+
+ <CamcorderProfiles cameraId="1">
+
+ <EncoderProfile quality="qvga" fileFormat="mp4" duration="60">
+ <Video codec="m4v"
+ bitRate="128000"
+ width="320"
+ height="240"
+ frameRate="15" />
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
+ <EncoderProfile quality="timelapseqcif" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="192000"
+ width="176"
+ height="144"
+ frameRate="30" />
+ <!-- audio setting is ignored -->
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
+ <ImageEncoding quality="95" />
+ <ImageEncoding quality="80" />
+ <ImageEncoding quality="70" />
+ <ImageDecoding memCap="20000000" />
+
+ </CamcorderProfiles>
+
+ <CamcorderProfiles cameraId="2">
+
+ <EncoderProfile quality="qvga" fileFormat="mp4" duration="60">
+ <Video codec="m4v"
+ bitRate="128000"
+ width="320"
+ height="240"
+ frameRate="15" />
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
+ <EncoderProfile quality="timelapseqcif" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="192000"
+ width="176"
+ height="144"
+ frameRate="30" />
+ <!-- audio setting is ignored -->
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
+ <ImageEncoding quality="95" />
+ <ImageEncoding quality="80" />
+ <ImageEncoding quality="70" />
+ <ImageDecoding memCap="20000000" />
+
+ </CamcorderProfiles>
+
+ <CamcorderProfiles cameraId="3">
+
+ <EncoderProfile quality="qvga" fileFormat="mp4" duration="60">
+ <Video codec="m4v"
+ bitRate="128000"
+ width="320"
+ height="240"
+ frameRate="15" />
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
+ <EncoderProfile quality="timelapseqcif" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="192000"
+ width="176"
+ height="144"
+ frameRate="30" />
+ <!-- audio setting is ignored -->
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
+ <ImageEncoding quality="95" />
+ <ImageEncoding quality="80" />
+ <ImageEncoding quality="70" />
+ <ImageDecoding memCap="20000000" />
+
+ </CamcorderProfiles>
+
+ <CamcorderProfiles cameraId="4">
+
+ <EncoderProfile quality="qvga" fileFormat="mp4" duration="60">
+ <Video codec="m4v"
+ bitRate="128000"
+ width="320"
+ height="240"
+ frameRate="15" />
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
+ <EncoderProfile quality="timelapseqcif" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="192000"
+ width="176"
+ height="144"
+ frameRate="30" />
+ <!-- audio setting is ignored -->
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
+ <ImageEncoding quality="95" />
+ <ImageEncoding quality="80" />
+ <ImageEncoding quality="70" />
+ <ImageDecoding memCap="20000000" />
+
+ </CamcorderProfiles>
+
+ <CamcorderProfiles cameraId="5">
+
+ <EncoderProfile quality="qvga" fileFormat="mp4" duration="60">
+ <Video codec="m4v"
+ bitRate="128000"
+ width="320"
+ height="240"
+ frameRate="15" />
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
+ <EncoderProfile quality="timelapseqcif" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="192000"
+ width="176"
+ height="144"
+ frameRate="30" />
+ <!-- audio setting is ignored -->
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
+ <ImageEncoding quality="95" />
+ <ImageEncoding quality="80" />
+ <ImageEncoding quality="70" />
+ <ImageDecoding memCap="20000000" />
+
+ </CamcorderProfiles>
+
+ <CamcorderProfiles cameraId="6">
+
+ <EncoderProfile quality="qvga" fileFormat="mp4" duration="60">
+ <Video codec="m4v"
+ bitRate="128000"
+ width="320"
+ height="240"
+ frameRate="15" />
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
+ <EncoderProfile quality="timelapseqcif" fileFormat="mp4" duration="30">
+ <Video codec="h264"
+ bitRate="192000"
+ width="176"
+ height="144"
+ frameRate="30" />
+ <!-- audio setting is ignored -->
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
+ <ImageEncoding quality="95" />
+ <ImageEncoding quality="80" />
+ <ImageEncoding quality="70" />
+ <ImageDecoding memCap="20000000" />
+
+ </CamcorderProfiles>
+
+ <EncoderOutputFileFormat name="3gp" />
+ <EncoderOutputFileFormat name="mp4" />
+
+ <!--
+ If a codec is not enabled, it is invisible to the applications
+ In other words, the applications won't be able to use the codec
+ or query the capabilities of the codec at all if it is disabled
+ -->
+ <VideoEncoderCap name="h264" enabled="true"
+ minBitRate="64000" maxBitRate="192000"
+ minFrameWidth="176" maxFrameWidth="320"
+ minFrameHeight="144" maxFrameHeight="240"
+ minFrameRate="15" maxFrameRate="30" />
+
+ <VideoEncoderCap name="h263" enabled="true"
+ minBitRate="64000" maxBitRate="192000"
+ minFrameWidth="176" maxFrameWidth="320"
+ minFrameHeight="144" maxFrameHeight="240"
+ minFrameRate="15" maxFrameRate="30" />
+
+ <VideoEncoderCap name="m4v" enabled="true"
+ minBitRate="64000" maxBitRate="192000"
+ minFrameWidth="176" maxFrameWidth="320"
+ minFrameHeight="144" maxFrameHeight="240"
+ minFrameRate="15" maxFrameRate="30" />
+
+ <AudioEncoderCap name="aac" enabled="true"
+ minBitRate="8000" maxBitRate="96000"
+ minSampleRate="8000" maxSampleRate="48000"
+ minChannels="1" maxChannels="1" />
+
+ <AudioEncoderCap name="amrwb" enabled="true"
+ minBitRate="6600" maxBitRate="23050"
+ minSampleRate="16000" maxSampleRate="16000"
+ minChannels="1" maxChannels="1" />
+
+ <AudioEncoderCap name="amrnb" enabled="true"
+ minBitRate="5525" maxBitRate="12200"
+ minSampleRate="8000" maxSampleRate="8000"
+ minChannels="1" maxChannels="1" />
+
+ <!--
+ FIXME:
+ We do not check decoder capabilities at present
+ At present, we only check whether windows media is visible
+ for TEST applications. For other applications, we do
+ not perform any checks at all.
+ -->
+ <VideoDecoderCap name="wmv" enabled="false"/>
+ <AudioDecoderCap name="wma" enabled="false"/>
+
+ <!--
+ The VideoEditor Capability configuration:
+ - maxInputFrameWidth: maximum video width of imported video clip.
+ - maxInputFrameHeight: maximum video height of imported video clip.
+ - maxOutputFrameWidth: maximum video width of exported video clip.
+ - maxOutputFrameHeight: maximum video height of exported video clip.
+ - maxPrefetchYUVFrames: maximum prefetch YUV frames for encoder,
+ used to limit the amount of memory for prefetched YUV frames.
+ For this platform, it allows maximum ~1MB(~0.1MB per QVGA frame x 10
+ frames) memory.
+ -->
+
+ <VideoEditorCap maxInputFrameWidth="320"
+ maxInputFrameHeight="240" maxOutputFrameWidth="320"
+ maxOutputFrameHeight="240" maxPrefetchYUVFrames="10" />
+ <!--
+ The VideoEditor Export codec profile and level values
+ correspond to the values in OMX_Video.h.
+ E.g. for h264, profile value 1 means OMX_VIDEO_AVCProfileBaseline
+ and level 4096 means OMX_VIDEO_AVCLevel41.
+ Please note that the values are in decimal.
+ These values are for video encoder.
+ -->
+ <!--
+ Codec = h.264, Baseline profile, level 4.1
+ -->
+ <ExportVideoProfile name="h264" profile= "1" level="512"/>
+ <!--
+ Codec = h.263, Baseline profile, level 0
+ -->
+ <ExportVideoProfile name="h263" profile= "1" level="1"/>
+ <!--
+ Codec = mpeg4, Simple profile, level 3
+ -->
+ <ExportVideoProfile name="m4v" profile= "1" level="16"/>
+</MediaSettings>
--- /dev/null
+p2p_no_group_iface=1
+driver_param=use_p2p_group_interface=1
+bss_expiration_scan_count=1
+wowlan_triggers=disconnect
+p2p_search_delay=50
--- /dev/null
+ctrl_interface=wlan0
+update_config=1
+manufacturer=MediaTek Inc.
+device_name=Wireless Client
+model_name=MTK Wireless Model
+model_number=1.0
+serial_number=2.0
+device_type=10-0050F204-5
+os_version=01020300
+config_methods=display push_button keypad
+p2p_no_group_iface=1
+driver_param=use_p2p_group_interface=1
--- /dev/null
+p2p_no_group_iface=1
+driver_param=use_p2p_group_interface=1
+wowlan_triggers=disconnect
--- /dev/null
+LOCAL_PATH := device/alcatel/ttab
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/languages_full.mk)
+
+# Device overlay
+DEVICE_PACKAGE_OVERLAYS += $(LOCAL_PATH)/overlay
+
+# Device uses high-density artwork where available
+PRODUCT_AAPT_CONFIG := normal mdpi
+PRODUCT_AAPT_PREF_CONFIG := mdpi
+# A list of dpis to select prebuilt apk, in precedence order.
+PRODUCT_AAPT_PREBUILT_DPI := hdpi mdpi
+
+# Boot animation
+TARGET_SCREEN_HEIGHT := 1280
+TARGET_SCREEN_WIDTH := 800
+
+ifeq ($(TARGET_BUILD_VARIANT),eng)
+
+PRODUCT_PROPERTY_OVERRIDES += \
+ ro.secure=0 \
+ ro.adb.secure=0 \
+ persist.service.adb.enable=1 \
+ persist.service.debuggable=1 \
+ persist.sys.usb.config=adb \
+ ro.securestorage.support=false
+
+endif
+
+# no RIL
+PRODUCT_PROPERTY_OVERRIDES += \
+ keyguard.no_require_sim=1 \
+ ro.radio.use-ppp=no \
+ ro.config.nocheckin=yes \
+ ro.radio.noril=1 \
+ ro.carrier=wifi-only \
+ persist.radio.noril=1
+
+# Permissions
+PRODUCT_COPY_FILES += \
+ frameworks/native/data/etc/android.hardware.camera.xml:system/etc/permissions/android.hardware.camera.xml \
+ frameworks/native/data/etc/android.hardware.audio.low_latency.xml:system/etc/permissions/android.hardware.audio.low_latency.xml \
+ frameworks/native/data/etc/tablet_core_hardware.xml:system/etc/permissions/tablet_core_hardware.xml \
+ frameworks/native/data/etc/android.hardware.camera.flash-autofocus.xml:system/etc/permissions/android.hardware.camera.flash-autofocus.xml \
+ frameworks/native/data/etc/android.hardware.camera.front.xml:system/etc/permissions/android.hardware.camera.front.xml \
+ frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml \
+ frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hardware.wifi.direct.xml \
+ frameworks/native/data/etc/android.hardware.sensor.accelerometer.xml:system/etc/permissions/android.hardware.sensor.accelerometer.xml \
+ frameworks/native/data/etc/android.hardware.sensor.barometer.xml:system/etc/permissions/android.hardware.sensor.barometer.xml \
+ frameworks/native/data/etc/android.hardware.sensor.compass.xml:system/etc/permissions/android.hardware.compass.xml \
+ frameworks/native/data/etc/android.hardware.sensor.gyroscope.xml:system/etc/permissions/android.hardware.sensor.gyroscope.xml \
+ frameworks/native/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.jazzhand.xml \
+ frameworks/native/data/etc/android.hardware.usb.accessory.xml:system/etc/permissions/android.hardware.usb.accessory.xml \
+ frameworks/native/data/etc/android.hardware.usb.host.xml:system/etc/permissions/android.hardware.usb.host.xml \
+ frameworks/native/data/etc/android.software.sip.voip.xml:system/etc/permissions/android.software.sip.voip.xml \
+ frameworks/native/data/etc/android.hardware.sensor.light.xml:system/etc/permissions/android.hardware.sensor.light.xml \
+ frameworks/native/data/etc/android.hardware.sensor.proximity.xml:system/etc/permissions/android.hardware.sensor.proximity.xml \
+ frameworks/native/data/etc/android.hardware.sensor.stepcounter.xml:system/etc/permissions/android.hardware.sensor.stepcounter.xml \
+ frameworks/native/data/etc/android.hardware.sensor.stepdetector.xml:system/etc/permissions/android.hardware.sensor.stepdetector.xml \
+ frameworks/native/data/etc/android.hardware.bluetooth_le.xml:system/etc/permissions/android.hardware.bluetooth_le.xml \
+ frameworks/native/data/etc/handheld_core_hardware.xml:system/etc/permissions/handheld_core_hardware.xml \
+ frameworks/native/data/etc/android.hardware.touchscreen.xml:system/etc/permissions/android.hardware.touchscreen.xml \
+ frameworks/native/data/etc/android.hardware.touchscreen.multitouch.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.xml \
+ frameworks/native/data/etc/android.hardware.touchscreen.multitouch.distinct.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.distinct.xml \
+ frameworks/native/data/etc/android.software.webview.xml:system/etc/permissions/android.software.webview.xml \
+ frameworks/native/data/etc/android.software.sip.xml:system/etc/permissions/android.software.sip.xml \
+ frameworks/native/data/etc/android.hardware.bluetooth.xml:system/etc/permissions/android.hardware.bluetooth.xml \
+ frameworks/native/data/etc/android.hardware.location.xml:system/etc/permissions/android.hardware.location.xml \
+ frameworks/native/data/etc/android.hardware.location.gps.xml:system/etc/permissions/android.hardware.location.gps.xml
+
+# media codecs files that are not copied from stock rom
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/media_codecs.xml:system/etc/media_codecs.xml \
+ $(LOCAL_PATH)/configs/media_profiles.xml:system/etc/media_profiles.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml
+
+# Bluetooth config files
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/bluetooth/bt_did.conf:system/etc/bluetooth/bt_did.conf \
+ $(LOCAL_PATH)/configs/bluetooth/btconfig.xml:system/etc/bluetooth/btconfig.xml
+
+# Wifi config files
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/wifi/p2p_supplicant_overlay.conf:system/etc/wifi/p2p_supplicant_overlay.conf \
+ $(LOCAL_PATH)/configs/wifi/wpa_supplicant.conf:system/etc/wifi/wpa_supplicant.conf \
+ $(LOCAL_PATH)/configs/wifi/wpa_supplicant_overlay.conf:system/etc/wifi/wpa_supplicant_overlay.conf
+
+# Audio policy
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/audio_policy.conf:system/etc/audio_policy.conf
+
+# ramdisk
+PRODUCT_COPY_FILES += $(call find-copy-subdir-files,*,$(LOCAL_PATH)/ramdisk,root)
+
+# Audio
+PRODUCT_PACKAGES += \
+ audio.a2dp.default
+
+# Bluetooth
+PRODUCT_PACKAGES += \
+ bluetooth.default
+
+# Charger
+# Use cm images if available, aosp ones otherwise
+PRODUCT_PACKAGES += \
+ charger_res_images \
+ cm_charger_res_images \
+ charger
+
+# Power
+PRODUCT_PACKAGES += \
+ power.default
+
+# network
+PRODUCT_PACKAGES += \
+ netd
+
+PRODUCT_PACKAGES += \
+ Camera2
+
+# IPv6 tethering
+PRODUCT_PACKAGES += \
+ ebtables \
+ ethertypes
+
+# libxlog
+PRODUCT_PACKAGES += \
+ libxlog \
+ libmtk_symbols \
+ libstlport \
+ lights.mt8127
+
+# Wifi
+PRODUCT_PACKAGES += \
+ lib_driver_cmd_mt66xx \
+ libwifi-hal-mt66xx \
+ wifi_hal \
+ libwpa_client \
+ hostapd \
+ wpa_supplicant
+
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/hostapd/hostapd_default.conf:system/etc/hostapd/hostapd_default.conf \
+ $(LOCAL_PATH)/configs/hostapd/hostapd.accept:system/etc/hostapd/hostapd.accept \
+ $(LOCAL_PATH)/configs/hostapd/hostapd.deny:system/etc/hostapd/hostapd.deny
+
+
+# libbt-vendor
+PRODUCT_PACKAGES += \
+ libbt-vendor
+
+# Get non-open-source specific aspects
+$(call inherit-product-if-exists, vendor/alcatel/ttab/ttab-vendor.mk)
--- /dev/null
+#!/bin/bash
+
+set -e
+
+VENDOR=alcatel
+DEVICE=ttab
+
+function extract() {
+ for FILE in `egrep -v '(^#|^$)' $1`; do
+ OLDIFS=$IFS IFS=":" PARSING_ARRAY=($FILE) IFS=$OLDIFS
+ FILE=`echo ${PARSING_ARRAY[0]} | sed -e "s/^-//g"`
+ DEST=${PARSING_ARRAY[1]}
+ if [ -z $DEST ]; then
+ DEST=$FILE
+ fi
+ DIR=`dirname $FILE`
+ if [ ! -d $2/$DIR ]; then
+ mkdir -p $2/$DIR
+ fi
+ if [ "$SRC" = "adb" ]; then
+ # Try CM target first
+ adb pull /system/$DEST $2/$DEST
+ # if file does not exist try OEM target
+ if [ "$?" != "0" ]; then
+ adb pull /system/$FILE $2/$DEST
+ fi
+ else
+ cp $SRC/system/$FILE $2/$DEST
+ # if file dot not exist try destination
+ if [ "$?" != "0" ]
+ then
+ cp $SRC/system/$DEST $2/$DEST
+ fi
+ fi
+ done
+}
+
+if [ $# -eq 0 ]; then
+ SRC=adb
+else
+ if [ $# -eq 1 ]; then
+ SRC=$1
+ else
+ echo "$0: bad number of arguments"
+ echo ""
+ echo "usage: $0 [PATH_TO_EXPANDED_ROM]"
+ echo ""
+ echo "If PATH_TO_EXPANDED_ROM is not specified, blobs will be extracted from"
+ echo "the device using adb pull."
+ exit 1
+ fi
+fi
+
+DEVBASE=../../../vendor/$VENDOR/$DEVICE/proprietary
+rm -rf $DEVBASE/*
+
+extract ../../$VENDOR/$DEVICE/proprietary-files.txt $DEVBASE
+
+./setup-makefiles.sh
\ No newline at end of file
--- /dev/null
+DEVICE_DIR := device/alcatel/ttab
+
+# Inherit from those products. Most specific first.
+$(call inherit-product, $(DEVICE_DIR)/device.mk)
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
+
+PRODUCT_CHARACTERISTICS := tablet
+
+PRODUCT_DEVICE := ttab
+PRODUCT_NAME :ttab
+PRODUCT_BRAND := alcatel
+PRODUCT_MANUFACTURER := alcatel
+PRODUCT_MODEL := ttab
--- /dev/null
+#if !defined(__ALE_H__)
+#define __ALE_H__
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#define LOGGER_ALE_MASK 0xf0
+
+#define LOGGER_ALE_MSG_RAW 0x00
+#define LOGGER_ALE_MSG_K 0x10
+#define LOGGER_ALE_MSG_N 0x20
+#define LOGGER_ALE_MSG_J 0x30
+#define LOGGER_ALE_XMSG_K 0x40
+#define LOGGER_ALE_XMSG_N 0x50
+#define LOGGER_ALE_XMSG_J 0x60
+
+#define LOGGER_ALE_MSG_SIZE 768
+
+#define LOGGER_ALE_ARGS_MAX 16
+struct ale_convert {
+ const char *tag_str;
+ const char *fmt_ptr;
+ const char *file;
+ int lineno;
+ unsigned int hash;
+ char params[LOGGER_ALE_ARGS_MAX];
+};
+
+int ale_log_output_binary(int prio, const char *tag, const void *payload, size_t len);
+
+int ale_log_output(int bufid, int prio, const struct ale_convert *convert, ...);
+
+#define ale_log_print(bufid, prio, tag, fmt, ...) \
+ ({ \
+ if (__builtin_constant_p(tag) && __builtin_constant_p(fmt)) { \
+ static const struct ale_convert ____ale_rec____ = \
+ { \
+ __builtin_constant_p(tag) ? tag : NULL, \
+ __builtin_constant_p(fmt) ? fmt : NULL, \
+ __FILE__, \
+ __builtin_constant_p(prio) ? prio : 0, \
+ 0, \
+ "" }; \
+ ale_log_output(bufid, prio, &____ale_rec____, ##__VA_ARGS__); \
+ } \
+ else { \
+ struct ale_convert ale = \
+ {tag, fmt, NULL, \
+ 0, 0, ""}; \
+ ale_log_output(bufid, prio, &ale, ##__VA_ARGS__); \
+ } \
+ })
+
+#if defined(__cplusplus)
+};
+#endif
+
+#endif
--- /dev/null
+#if !defined(_XLOG_H)
+#define _XLOG_H
+
+#include <cutils/log.h>
+#include <cutils/alelog.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int xlogf_java_tag_is_on(const char *name, int level);
+int xlogf_native_tag_is_on(const char *name, int level);
+
+int xlogf_java_xtag_is_on(const char *name, int level);
+int xlogf_native_xtag_is_on(const char *name, int level);
+
+#ifndef XLOG_TAG
+#define XLOG_TAG NULL
+#endif
+
+#ifndef SXLOGV
+#define SXLOGV(...) ((void)SXLOG_PRI(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
+#endif
+#ifndef SXLOGD
+#define SXLOGD(...) ((void)SXLOG_PRI(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
+#endif
+#ifndef SXLOGI
+#define SXLOGI(...) ((void)SXLOG_PRI(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
+#endif
+#ifndef SXLOGW
+#define SXLOGW(...) ((void)SXLOG_PRI(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
+#endif
+#ifndef SXLOGE
+#define SXLOGE(...) ((void)SXLOG_PRI(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
+#endif
+#ifndef SXLOGF
+#define SXLOGF(...) ((void)SXLOG_PRI(ANDROID_LOG_FATAL, LOG_TAG, __VA_ARGS__))
+#endif
+#if LOG_NDEBUG
+#define SXLOG_ASSERT(cond, ...) \
+ ( (CONDITION(cond)) \
+ ? ((void)SXLOGF(LOG_TAG, __VA_ARGS__)) \
+ : (void)0 )
+#else
+#define SXLOG_ASSERT(cond, ...) ((void)0)
+#endif
+
+#define SXLOG_ALWAYS_ASSERT(cond,...) \
+ ( (CONDITION(cond)) \
+ ? ((void)SXLOGF(LOG_TAG, __VA_ARGS__)) \
+ : (void)0 )
+
+#ifndef XLOGV
+#define XLOGV(...) ((void)XLOG_PRI(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
+#endif
+#ifndef XLOGD
+#define XLOGD(...) ((void)XLOG_PRI(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
+#endif
+#ifndef XLOGI
+#define XLOGI(...) ((void)XLOG_PRI(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
+#endif
+#ifndef XLOGW
+#define XLOGW(...) ((void)XLOG_PRI(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
+#endif
+#ifndef XLOGE
+#define XLOGE(...) ((void)XLOG_PRI(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
+#endif
+#ifndef XLOGF
+#define XLOGF(...) ((void)XLOG_PRI(ANDROID_LOG_FATAL, LOG_TAG, __VA_ARGS__))
+#endif
+
+#if LOG_NDEBUG
+#define XLOG_ASSERT(cond, ...) \
+ (!(cond) \
+ ? ((void)XLOGF(__VA_ARGS__)) \
+ : (void)0)
+#else
+#define XLOG_ASSERT(cond, ...) ((void)0)
+#endif
+
+#define XLOG_ALWAY_ASSERT(cond, ...) \
+ (!(cond) \
+ ? ((void)XLOGF(__VA_ARGS__)) \
+ : (void)0)
+
+
+#ifndef SXLOGV2
+#define SXLOGV2(...) ((void)SXLOG_PRI(ANDROID_LOG_VERBOSE, XLOG_TAG, __VA_ARGS__))
+#endif
+#ifndef SXLOGD2
+#define SXLOGD2(...) ((void)SXLOG_PRI(ANDROID_LOG_DEBUG, XLOG_TAG, __VA_ARGS__))
+#endif
+#ifndef SXLOGI2
+#define SXLOGI2(...) ((void)SXLOG_PRI(ANDROID_LOG_INFO, XLOG_TAG, __VA_ARGS__))
+#endif
+#ifndef SXLOGW2
+#define SXLOGW2(...) ((void)SXLOG_PRI(ANDROID_LOG_WARN, XLOG_TAG, __VA_ARGS__))
+#endif
+#ifndef SXLOGE2
+#define SXLOGE2(...) ((void)SXLOG_PRI(ANDROID_LOG_ERROR, XLOG_TAG, __VA_ARGS__))
+#endif
+#ifndef SXLOGF2
+#define SXLOGF2(...) ((void)SXLOG_PRI(ANDROID_LOG_FATAL, XLOG_TAG, __VA_ARGS__))
+#endif
+
+#ifndef XLOGV2
+#define XLOGV2(...) ((void)XLOG_PRI(ANDROID_LOG_VERBOSE, XLOG_TAG, __VA_ARGS__))
+#endif
+#ifndef XLOGD2
+#define XLOGD2(...) ((void)XLOG_PRI(ANDROID_LOG_DEBUG, XLOG_TAG, __VA_ARGS__))
+#endif
+#ifndef XLOGI2
+#define XLOGI2(...) ((void)XLOG_PRI(ANDROID_LOG_INFO, XLOG_TAG, __VA_ARGS__))
+#endif
+#ifndef XLOGW2
+#define XLOGW2(...) ((void)XLOG_PRI(ANDROID_LOG_WARN, XLOG_TAG, __VA_ARGS__))
+#endif
+#ifndef XLOGE2
+#define XLOGE2(...) ((void)XLOG_PRI(ANDROID_LOG_ERROR, XLOG_TAG, __VA_ARGS__))
+#endif
+#ifndef XLOGF2
+#define XLOGF2(...) ((void)XLOG_PRI(ANDROID_LOG_FATAL, XLOG_TAG, __VA_ARGS__))
+#endif
+
+struct xlog_record {
+ const char *tag_str;
+ const char *fmt_str;
+ int prio;
+};
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+int __xlog_buf_printf(int bufid, const struct xlog_record *rec, ...);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#if !defined(HAVE_ALE_FEATURE)
+
+#define xlog_buf_printf(bufid, prio, tag, fmt, ...) \
+ ({ \
+ static const struct xlog_record _xlog_rec = \
+ {tag, fmt, prio}; \
+ __xlog_buf_printf(bufid, &_xlog_rec, ##__VA_ARGS__); \
+ })
+
+#else
+
+#define xlog_buf_printf(bufid, prio, tag, fmt, ...) \
+ ({ \
+ static const struct ale_convert ____xlog_ale_rec____ = \
+ { tag, fmt, __FILE__, prio, 0, "" }; \
+ ale_log_output(bufid, prio, &____xlog_ale_rec____, \
+ ##__VA_ARGS__); \
+ })
+
+#endif
+
+#define XLOG_PRI(priority, tag, ...) \
+ xlog_buf_printf(LOG_ID_MAIN, priority, tag, __VA_ARGS__)
+
+#define SXLOG_PRI(priority, tag, ...) \
+ xlog_buf_printf(LOG_ID_MAIN, priority, tag, __VA_ARGS__)
+
+#define xlog_printf(priority, tag, ...) \
+ xlog_buf_printf(LOG_ID_MAIN, priority, tag, __VA_ARGS__)
+
+#define sxlog_printf(priority, tag, ...) \
+ xlog_buf_printf(LOG_ID_SYSTEM, priority, tag, __VA_ARGS__)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := system/core/init
+LOCAL_SRC_FILES := init_ttab.cpp
+LOCAL_MODULE := libinit_ttab
+
+include $(BUILD_STATIC_LIBRARY)
\ No newline at end of file
--- /dev/null
+/*
+ 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.
+ */
+
+#include <stdlib.h>
+
+#include "vendor_init.h"
+#include "property_service.h"
+#include "log.h"
+#include "util.h"
+
+#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
+#include <sys/_system_properties.h>
+
+void property_override(char const prop[], char const value[])
+{
+ prop_info *pi;
+
+ pi = (prop_info*) __system_property_find(prop);
+ if (pi)
+ __system_property_update(pi, value, strlen(value));
+ else
+ __system_property_add(prop, strlen(prop), value, strlen(value));
+}
+
+void vendor_load_properties()
+{
+ property_override("ro.build.fingerprint", "T-Mobile/Telekom_Puls/T-Tab:5.0.1/LRX21M/vC29-0:user/release-keys");
+ property_override("ro.build.description", "Telekom_Puls-user 5.0.1 LRX21M vC29-0 release-keys");
+ property_override("ro.product.model", "Telekom Puls");
+ property_override("ro.product.device", "T-Tab");
+
+ ERROR("setting build properties for T-Tab\n");
+}
--- /dev/null
+#
+# 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.
+#
+
+ifneq ($(BOARD_HAVE_BLUETOOTH_MTK),)
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_C_INCLUDES := system/bt/hci/include
+
+LOCAL_CFLAGS := -g -c -W -Wall -O2 -D_POSIX_SOURCE
+
+LOCAL_SRC_FILES := libbt-vendor-mtk.c
+
+LOCAL_SHARED_LIBRARIES := \
+ libnativehelper \
+ libcutils \
+ libutils \
+ liblog \
+ libdl
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libbt-vendor
+LOCAL_MODULE_TAGS := optional
+
+# Force installation into normal /system/lib
+#LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif
--- /dev/null
+/*
+ * Bluetooth Vendor Library for MTK's libbluetoothdrv blob
+ *
+ * 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 "libbt_vendor_mtk"
+
+#include <stdio.h>
+#include <dlfcn.h>
+#include <utils/Log.h>
+#include <pthread.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <bt_vendor_lib.h>
+#include <bt_hci_bdroid.h>
+#include <hardware/bluetooth.h>
+
+/**
+ * TODO: check/fix this value. does this make sense for MTK? It is taken from TI
+ * Low power mode: default transport idle timer
+ */
+#define WL_DEFAULT_LPM_IDLE_TIMEOUT 200
+
+static void *mtklib_handle = NULL;
+typedef int (*ENABLE)(int flag, void *func_cb);
+typedef int (*DISABLE)(int bt_fd);
+
+unsigned int hci_tty_fd = -1;
+
+ENABLE mtk_bt_enable = NULL;
+DISABLE mtk_bt_disable = NULL;
+
+bt_vendor_callbacks_t *bt_vendor_cbacks = NULL;
+void hw_config_cback(HC_BT_HDR *p_evt_buf);
+
+/*******************************************************************************
+ *
+ * Function hw_config_cback
+ *
+ * Description Callback function for controller configuration
+ *
+ * Returns None
+ *
+ * *******************************************************************************/
+void hw_config_cback(HC_BT_HDR *p_evt_buf)
+{
+ ALOGI("hw_config_cback");
+}
+
+int mtk_init(const bt_vendor_callbacks_t* p_cb, unsigned char *local_bdaddr) {
+ const char *dlerrors;
+
+ ALOGI("libbt-vendor init for MTK blob");
+
+ if (p_cb == NULL)
+ {
+ ALOGE("init failed with no user callbacks!");
+ return -1;
+ }
+
+ bt_vendor_cbacks = (bt_vendor_callbacks_t *) p_cb;
+
+ dlerror();
+
+ mtklib_handle = dlopen("libbluetoothdrv.so", RTLD_LAZY);
+ if (! mtklib_handle) {
+ ALOGE("Failed to open libbluetoothdrv library");
+ return (int)mtklib_handle;
+ }
+
+ mtk_bt_enable = dlsym(mtklib_handle, "mtk_bt_enable");
+ mtk_bt_disable = dlsym(mtklib_handle, "mtk_bt_disable");
+
+ if ((dlerrors = dlerror()) != NULL){
+ ALOGE("Errors while opening symbols from mtk blob");
+ dlclose(mtklib_handle);
+ }
+ return 0;
+}
+
+void mtk_cleanup(void) {
+ ALOGI("vendor cleanup");
+ bt_vendor_cbacks = NULL;
+
+ if (mtklib_handle) {
+ dlclose(mtklib_handle);
+ }
+}
+
+int mtk_open(void **param) {
+ int (*fd_array)[] = (int (*)[]) param;
+ int fd, idx;
+ fd = mtk_bt_enable(0, NULL);
+ if (fd < 0) {
+ ALOGE(" Can't open mtk fd");
+ return -1;
+ }
+ for (idx = 0; idx < CH_MAX; idx++)
+ (*fd_array)[idx] = fd;
+
+ hci_tty_fd = fd; /* for userial_close op */
+ return 1; /* CMD/EVT/ACL on same fd */
+}
+
+int mtk_close() {
+ if (hci_tty_fd == (unsigned int) -1)
+ return -1;
+ return mtk_bt_disable(hci_tty_fd);
+}
+
+int mtk_op(bt_vendor_opcode_t opcode, void **param) {
+ int ret = 0;
+
+ switch(opcode)
+ {
+ case BT_VND_OP_POWER_CTRL:
+ break;
+ case BT_VND_OP_SCO_CFG:
+ break;
+ case BT_VND_OP_GET_LPM_IDLE_TIMEOUT:
+ *((uint32_t *) param) = WL_DEFAULT_LPM_IDLE_TIMEOUT;
+ break;
+ case BT_VND_OP_LPM_SET_MODE:
+ break;
+ case BT_VND_OP_LPM_WAKE_SET_STATE:
+ break;
+ case BT_VND_OP_USERIAL_OPEN:
+ ret = mtk_open(param);
+ break;
+ case BT_VND_OP_USERIAL_CLOSE:
+ ret = mtk_close();
+ break;
+ /* Since new stack expects fwcfg_cb we are returning SUCCESS here
+ * in actual, firmware download is already happened when /dev/hci_tty
+ * opened.
+ */
+ case BT_VND_OP_FW_CFG:
+ bt_vendor_cbacks->fwcfg_cb(BT_VND_OP_RESULT_SUCCESS);
+ break;
+ case BT_VND_OP_EPILOG:
+ bt_vendor_cbacks->epilog_cb(BT_VND_OP_RESULT_SUCCESS);
+ break;
+ default:
+ ALOGW("Unknown opcode: %d", opcode);
+ break;
+ }
+
+ return ret;
+}
+const bt_vendor_interface_t BLUETOOTH_VENDOR_LIB_INTERFACE = {
+ .init = mtk_init,
+ .op = mtk_op,
+ .cleanup = mtk_cleanup,
+};
+
+int main()
+{
+ return 0;
+}
\ No newline at end of file
--- /dev/null
+# 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.
+# 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)
+# HAL module implemenation, not prelinked and stored in
+# hw/<COPYPIX_HARDWARE_MODULE_ID>.<ro.board.platform>.so
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := lights.c
+LOCAL_MULTILIB := both
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE_RELATIVE_PATH := hw
+
+LOCAL_SHARED_LIBRARIES := liblog
+
+LOCAL_MODULE := lights.$(TARGET_BOARD_PLATFORM)
+
+include $(BUILD_SHARED_LIBRARY)
--- /dev/null
+/*
+ * Copyright (C) 2016 The M.A.D. Team
+ *
+ * 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 "lights"
+
+#include <cutils/log.h>
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+
+#include <sys/ioctl.h>
+#include <sys/types.h>
+
+#include <hardware/lights.h>
+
+/******************************************************************************/
+
+static pthread_once_t g_init = PTHREAD_ONCE_INIT;
+static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
+static struct light_state_t g_attention;
+static struct light_state_t g_notification;
+static struct light_state_t g_battery;
+
+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 BUTTONS_FILE
+ = "/sys/class/leds/button-backlight/brightness";
+
+/**
+ * device methods
+ */
+
+void init_globals(void)
+{
+ // init the mutex
+ pthread_mutex_init(&g_lock, NULL);
+}
+
+static int
+write_int(char const* path, int value)
+{
+ int fd;
+ static int already_warned = 0;
+
+ fd = open(path, O_RDWR);
+ if (fd >= 0) {
+ char buffer[20];
+ int bytes = snprintf(buffer, sizeof(buffer), "%d\n", value);
+ ssize_t amt = write(fd, buffer, (size_t)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)
+{
+ if (!dev) {
+ return -1;
+ }
+ int err = 0;
+ int brightness = rgb_to_brightness(state);
+ pthread_mutex_lock(&g_lock);
+ err = write_int(LCD_FILE, brightness);
+ pthread_mutex_unlock(&g_lock);
+ return err;
+}
+
+static int
+set_light_buttons(struct light_device_t* dev,
+ struct light_state_t const* state)
+{
+ if (!dev) {
+ return -1;
+ }
+ int err = 0;
+ int on = is_lit(state);
+ pthread_mutex_lock(&g_lock);
+ err = write_int(BUTTONS_FILE, on ? 255 : 0);
+ 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, 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;
+
+ ALOGV("set_speaker_light_locked mode %d, colorRGB=%08X, onMS=%d, offMS=%d\n",
+ state->flashMode, colorRGB, onMS, offMS);
+
+ red = (colorRGB >> 16) & 0xFF;
+ green = (colorRGB >> 8) & 0xFF;
+ blue = colorRGB & 0xFF;
+ blink = onMS > 0 && offMS > 0;
+
+ write_int(RED_LED_FILE, 0);
+ write_int(GREEN_LED_FILE, 0);
+ write_int(BLUE_LED_FILE, 0);
+
+ if (blink) {
+ if (red >= 128) {
+ write_int(RED_LED_FILE, 128);
+ }
+ if (green >= 128) {
+ write_int(GREEN_LED_FILE, 128);
+ }
+ if (blue >= 128) {
+ write_int(BLUE_LED_FILE, 128);
+ }
+ }
+ else {
+ if (red >= 128) {
+ write_int(RED_LED_FILE, 255);
+ }
+ if (green >= 128) {
+ write_int(GREEN_LED_FILE, 255);
+ }
+ if (blue >= 128) {
+ write_int(BLUE_LED_FILE, 255);
+ }
+ }
+
+ return 0;
+}
+
+static void
+handle_speaker_light_locked(struct light_device_t* dev)
+{
+ if (is_lit(&g_attention)) {
+ set_speaker_light_locked(dev, &g_attention);
+ } else if (is_lit(&g_notification)) {
+ set_speaker_light_locked(dev, &g_notification);
+ } else {
+ set_speaker_light_locked(dev, &g_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_light_locked(dev);
+ pthread_mutex_unlock(&g_lock);
+ return 0;
+}
+
+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_light_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);
+ g_attention = *state;
+ handle_speaker_light_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;
+ else if (0 == strcmp(LIGHT_ID_BUTTONS, name))
+ set_light = set_light_buttons;
+ else if (0 == strcmp(LIGHT_ID_BATTERY, name))
+ set_light = set_light_battery;
+ 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 = 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 = "M.A.D. Lights Module",
+ .author = "M.A.D. Team",
+ .methods = &lights_module_methods,
+};
--- /dev/null
+# Copyright (C) 2016 fire855 <thefire855@gmail.com>
+#
+# 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 := \
+ mtk_asc.cpp \
+ mtk_audio.cpp \
+ mtk_audioCompat.c \
+ mtk_cam.cpp \
+ mtk_fence.cpp \
+ mtk_gui.cpp \
+ mtk_omx.cpp \
+ mtk_ui.cpp \
+ mtk_icu53.cpp \
+ mtk_wvm.cpp
+
+# only for 64bit libraries
+LOCAL_SRC_FILES_64 := mtk_parcel.cpp
+
+LOCAL_SHARED_LIBRARIES := libbinder libutils liblog libgui libui libicuuc libstagefright
+LOCAL_MODULE := libmtk_symbols
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_SHARED_LIBRARY)
--- /dev/null
+#include <stdint.h>
+
+extern "C" {
+ void _ZN7android14SurfaceControl8setLayerEj(uint32_t);
+
+ void _ZN7android14SurfaceControl8setLayerEi(int32_t layer){
+ _ZN7android14SurfaceControl8setLayerEj(static_cast<uint32_t>(layer));
+ }
+}
\ No newline at end of file
--- /dev/null
+#include <stdint.h>
+
+extern "C" {
+ bool _ZN7android11AudioSystem24getVoiceUnlockDLInstanceEv(){
+ return 0;
+ }
+
+ int _ZN7android11AudioSystem23GetVoiceUnlockDLLatencyEv(){
+ return 0;
+ }
+
+ int _ZN7android11AudioSystem17SetVoiceUnlockSRCEjj(uint32_t outSR, uint32_t outChannel){
+ return 0;
+ }
+
+ bool _ZN7android11AudioSystem18startVoiceUnlockDLEv(){
+ return 0;
+ }
+
+ int _ZN7android11AudioSystem15ReadRefFromRingEPvjS1_(void*buf, uint32_t datasz, void* DLtime){
+ return 0;
+ }
+
+ int _ZN7android11AudioSystem20GetVoiceUnlockULTimeEPv(void* DLtime) {
+ return 0;
+ }
+
+ void _ZN7android11AudioSystem25freeVoiceUnlockDLInstanceEv(){}
+
+ bool _ZN7android11AudioSystem17stopVoiceUnlockDLEv(){
+ return 0;
+ }
+
+ int _ZN7android11AudioSystem12SetAudioDataEijPv(int par1,size_t byte_len,void *ptr) {
+ return 0;
+ }
+
+ int _ZN7android11AudioSystem15SetAudioCommandEii(int var1,int var2) {
+ return 0;
+ }
+
+ int _ZN7android11AudioSystem15GetAudioCommandEiPi(int var1) {
+ return 0;
+ }
+}
--- /dev/null
+int get_capture_position(void)
+{
+ return 0;
+}
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <malloc.h>
+#include <pthread.h>
+
+extern "C" {
+ //android::String8::String8(char const*)
+ extern void _ZN7android7String8C1EPKc(void **str8P, const char *str);
+
+ //android::String8::~String8()
+ extern void _ZN7android7String8D1Ev(void **str8P);
+
+ //android::String16::String16(char const*)
+ extern void _ZN7android8String16C1EPKc(void **str16P, const char *str);
+
+ //android::String16::~String16()
+ extern void _ZN7android8String16D1Ev(void **str16P);
+
+ //android::SensorManager::SensorManager(android::String16 const&)
+ extern void _ZN7android13SensorManagerC1ERKNS_8String16E(void *sensorMgr, void **str16P);
+
+ //android::SensorManager::createEventQueue(android::String8, int)
+ extern void _ZN7android13SensorManager16createEventQueueENS_7String8Ei(void **retVal, void *sensorMgr, void **str8P, int mode);
+
+ //void _ZN7android9SingletonINS_13SensorManagerEE9sInstanceE() { }
+ //void _ZN7android9SingletonINS_13SensorManagerEE5sLockE() { }
+ //void _ZN7android13SensorManagerC1Ev() { }
+ //void _ZN7android13SensorManager16createEventQueueEv() { }
+ void* _ZN7android9SingletonINS_13SensorManagerEE9sInstanceE = NULL;
+ pthread_mutex_t _ZN7android9SingletonINS_13SensorManagerEE5sLockE = PTHREAD_MUTEX_INITIALIZER;
+
+ void _ZN7android13SensorManagerC1Ev(void *sensorMgr) {
+ void *string;
+
+ _ZN7android8String16C1EPKc(&string, "gpsd");
+ _ZN7android13SensorManagerC1ERKNS_8String16E(sensorMgr, &string);
+ _ZN7android8String16D1Ev(&string);
+ }
+
+ void _ZN7android13SensorManager16createEventQueueEv(void **retVal, void *sensorMgr) {
+ void *string;
+
+ _ZN7android7String8C1EPKc(&string, "");
+ _ZN7android13SensorManager16createEventQueueENS_7String8Ei(retVal, sensorMgr, &string, 0);
+ _ZN7android7String8D1Ev(&string);
+ }
+}
--- /dev/null
+extern "C" {
+ void _ZN7android5Fence4waitEi(int);
+}
--- /dev/null
+#include <ui/GraphicBufferMapper.h>
+#include <ui/PixelFormat.h>
+#include <ui/Rect.h>
+#include <stdint.h>
+
+extern "C" {
+ void _ZN7android13GraphicBufferC1EjjijNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE(
+ uint32_t inWidth, uint32_t inHeight, android::PixelFormat inFormat,
+ uint32_t inUsage, std::string requestorName);
+
+ void _ZN7android13GraphicBufferC1Ejjij(uint32_t inWidth, uint32_t inHeight, int32_t inFormat, uint32_t inUsage) {
+ _ZN7android13GraphicBufferC1EjjijNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE(
+ inWidth, inHeight, inFormat, inUsage, "<Unknown>");
+ }
+}
--- /dev/null
+#include "unicode/ucnv.h"
+
+U_STABLE UConverter* U_EXPORT2
+ucnv_open_53(const char *converterName, UErrorCode *err)
+{
+ return ucnv_open(converterName, err);
+}
+
+U_STABLE void U_EXPORT2
+ucnv_close_53(UConverter * converter)
+{
+ return ucnv_close(converter);
+}
+
+U_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP_53(
+ const void *context,
+ UConverterToUnicodeArgs *toUArgs,
+ const char* codeUnits,
+ int32_t length,
+ UConverterCallbackReason reason,
+ UErrorCode * err)
+{
+ UCNV_TO_U_CALLBACK_STOP(context, toUArgs, codeUnits, length, reason, err);
+}
+
+U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP_53(
+ const void *context,
+ UConverterFromUnicodeArgs *fromUArgs,
+ const UChar* codeUnits,
+ int32_t length,
+ UChar32 codePoint,
+ UConverterCallbackReason reason,
+ UErrorCode * err)
+{
+ UCNV_FROM_U_CALLBACK_STOP (context, fromUArgs, codeUnits, length, codePoint, reason, err);
+}
+
+U_STABLE void U_EXPORT2
+ucnv_setToUCallBack_53(UConverter * converter,
+ UConverterToUCallback newAction,
+ const void* newContext,
+ UConverterToUCallback *oldAction,
+ const void** oldContext,
+ UErrorCode * err)
+{
+ ucnv_setToUCallBack(converter, newAction, newContext, oldAction, oldContext, err);
+}
+
+U_STABLE void U_EXPORT2
+ucnv_setFromUCallBack_53(UConverter * converter,
+ UConverterFromUCallback newAction,
+ const void *newContext,
+ UConverterFromUCallback *oldAction,
+ const void **oldContext,
+ UErrorCode * err)
+{
+ ucnv_setFromUCallBack(converter, newAction, newContext, oldAction, oldContext, err);
+}
+
+U_STABLE void U_EXPORT2
+ucnv_convertEx_53(UConverter *targetCnv, UConverter *sourceCnv,
+ char **target, const char *targetLimit,
+ const char **source, const char *sourceLimit,
+ UChar *pivotStart, UChar **pivotSource,
+ UChar **pivotTarget, const UChar *pivotLimit,
+ UBool reset, UBool flush,
+ UErrorCode *pErrorCode)
+{
+ ucnv_convertEx(targetCnv, sourceCnv, target, targetLimit, source, sourceLimit,
+ pivotStart, pivotSource, pivotTarget, pivotLimit, reset, flush,
+ pErrorCode);
+}
--- /dev/null
+extern "C" {
+ void _ZN7android13AwesomePlayer24mtk_omx_get_current_timeEPx(long long* time){
+ time = (long long*)-1;
+ }
+}
\ No newline at end of file
--- /dev/null
+extern "C" {
+ void _ZN7android6Parcel13writeString16EPKDsm(char16_t const*, unsigned long);
+}
--- /dev/null
+#include <ui/GraphicBufferMapper.h>
+#include <ui/Rect.h>
+
+extern "C" {
+ void _ZN7android19GraphicBufferMapper9lockYCbCrEPK13native_handlejRKNS_4RectEP13android_ycbcr(buffer_handle_t, uint32_t, const android::Rect&, android_ycbcr*);
+
+ void _ZN7android19GraphicBufferMapper9lockYCbCrEPK13native_handleiRKNS_4RectEP13android_ycbcr(buffer_handle_t handle, int usage, const android::Rect& bounds, android_ycbcr *ycbcr) {
+ _ZN7android19GraphicBufferMapper9lockYCbCrEPK13native_handlejRKNS_4RectEP13android_ycbcr(handle, static_cast<uint32_t>(usage), bounds, ycbcr);
+ }
+
+ void _ZN7android19GraphicBufferMapper4lockEPK13native_handlejRKNS_4RectEPPv(buffer_handle_t, uint32_t, const android::Rect&, void**);
+
+ void _ZN7android19GraphicBufferMapper4lockEPK13native_handleiRKNS_4RectEPPv(buffer_handle_t handle, int usage, const android::Rect& bounds, void** vaddr) {
+ _ZN7android19GraphicBufferMapper4lockEPK13native_handlejRKNS_4RectEPPv(handle, static_cast<uint32_t>(usage), bounds, vaddr);
+ }
+}
--- /dev/null
+extern "C" {
+ void _ZN7android16MediaBufferGroupC1Ev() { }
+ void _ZNK7android11MediaSource11ReadOptions14getNonBlockingEv() { }
+ void _ZNK7android11MediaSource11ReadOptions9getSeekToEPxPNS1_8SeekModeE() { }
+ void _ZN7android16MediaBufferGroup14acquire_bufferEPPNS_11MediaBufferE() { }
+ void _ZN7android16MediaBufferGroup14acquire_bufferEPPNS_11MediaBufferEb() { }
+}
--- /dev/null
+#
+# 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.
+# 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 := $(my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS += $(LIBLOG_CFLAGS)
+LOCAL_MODULE := libxlog
+LOCAL_SRC_FILES := xlog.c mtkaudio.cpp
+LOCAL_C_INCLUDES += frameworks/av/media/mtp/ system/core/include/ frameworks/rs/server/ frameworks/av/include/ hardware/libhardware/include/
+LOCAL_SHARED_LIBRARIES := libcutils liblog libutils libbinder
+
+include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
--- /dev/null
+#include <MtpTypes.h>
+#include <system/audio.h>
+#include <StrongPointer.h>
+#include <media/IAudioFlinger.h>
+#include <hardware/audio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+
+namespace android {
+
+typedef void (*audio_error_callback)(status_t err);
+
+class AudioSystem
+{
+public:
+ static bool getVoiceUnlockDLInstance();
+ static int GetVoiceUnlockDLLatency();
+ static int SetVoiceUnlockSRC(uint outSR, uint outChannel);
+ static bool stopVoiceUnlockDL();
+ static bool startVoiceUnlockDL();
+ static int ReadRefFromRing(void*buf, uint32_t datasz,void* DLtime);
+ static int GetVoiceUnlockULTime(void* DLtime);
+ static void freeVoiceUnlockDLInstance();
+
+}; // class
+
+bool AudioSystem::getVoiceUnlockDLInstance()
+{
+ return 0;
+}
+
+int AudioSystem::GetVoiceUnlockDLLatency()
+{
+ return 0;
+}
+
+int AudioSystem::SetVoiceUnlockSRC(uint outSR, uint outChannel)
+{
+ return 0;
+}
+
+bool AudioSystem::stopVoiceUnlockDL()
+{
+ return 0;
+}
+
+bool AudioSystem::startVoiceUnlockDL()
+{
+ return 0;
+}
+
+int AudioSystem::ReadRefFromRing(void*buf, uint32_t datasz,void* DLtime)
+{
+ return 0;
+}
+
+int AudioSystem::GetVoiceUnlockULTime(void* DLtime)
+{
+ return 0;
+}
+
+void AudioSystem::freeVoiceUnlockDLInstance()
+{
+ return;
+}
+
+class IATVCtrlClient
+{
+};
+
+class IATVCtrlService: public IInterface
+{
+public:
+ DECLARE_META_INTERFACE(ATVCtrlService);
+};
+
+class BpATVCtrlService : public BpInterface<IATVCtrlService>
+{
+public:
+ BpATVCtrlService(const sp<IBinder>& impl)
+ : BpInterface<IATVCtrlService>(impl)
+ {
+ }
+ virtual ~BpATVCtrlService()
+ {
+ }
+ virtual int ATVCS_matv_init()
+ {
+ return 0;
+ }
+ virtual int ATVCS_matv_ps_init(int on)
+ {
+ return 0;
+ }
+ virtual int ATVCS_matv_set_parameterb(int in)
+ {
+ return 0;
+ }
+ virtual int ATVCS_matv_suspend(int on)
+ {
+ return 0;
+ }
+ virtual int ATVCS_matv_shutdown()
+ {
+ return 0;
+ }
+ virtual void ATVCS_matv_chscan(int mode)
+ {
+ }
+ virtual void ATVCS_matv_chscan_stop()
+ {
+ }
+ virtual int ATVCS_matv_get_chtable(int ch, void *entry, int len)
+ {
+ return 0;
+ }
+ virtual int ATVCS_matv_set_chtable(int ch, void *entry, int len)
+ {
+ return 0;
+ }
+ virtual int ATVCS_matv_clear_chtable()
+ {
+ return 0;
+ }
+ virtual void ATVCS_matv_change_channel(int ch)
+ {
+ }
+ virtual void ATVCS_matv_set_country(int country)
+ {
+ }
+ virtual void ATVCS_matv_set_tparam(int mode)
+ {
+ }
+ virtual void ATVCS_matv_audio_play()
+ {
+ }
+ virtual void ATVCS_matv_audio_stop()
+ {
+ }
+ virtual int ATVCS_matv_audio_get_format()
+ {
+ return 0;
+ }
+ virtual void ATVCS_matv_audio_set_format(int val)
+ {
+ }
+ virtual int ATVCS_matv_audio_get_sound_system()
+ {
+ return 0;
+ }
+ virtual int ATVCS_matv_adjust(int item, int val)
+ {
+ return 0;
+ }
+ virtual int ATVCS_matv_get_chipdep(int item)
+ {
+ return 0;
+ }
+ virtual int ATVCS_matv_set_chipdep(int item, int val)
+ {
+ return 0;
+ }
+ virtual void ATVCS_matv_register_callback()
+ {
+ }
+ virtual void registerClient(const sp<IATVCtrlClient>& client)
+ {
+ }
+ virtual void registerClient_FM(const sp<IATVCtrlClient>& client)
+ {
+ }
+ virtual void CLI(char input)
+ {
+ }
+ virtual int ATVCS_fm_powerup(void *parm, int len)
+ {
+ return 0;
+ }
+ virtual int ATVCS_fm_powerdown()
+ {
+ return 0;
+ }
+ virtual int ATVCS_fm_getrssi()
+ {
+ return 0;
+ }
+ virtual int ATVCS_fm_tune(void *parm, int len)
+ {
+ return 0;
+ }
+ virtual int ATVCS_fm_seek(void *parm, int len)
+ {
+ return 0;
+ }
+ virtual int ATVCS_fm_scan(void *parm, int len)
+ {
+ return 0;
+ }
+ virtual int ATVCS_fm_mute(int val)
+ {
+ return 0;
+ }
+ virtual int ATVCS_fm_getchipid()
+ {
+ return 0;
+ }
+ virtual int ATVCS_fm_isFMPowerUp()
+ {
+ return 0;
+ }
+};
+
+IMPLEMENT_META_INTERFACE(ATVCtrlService, "android.media.IATVCtrlService");
+
+} // namespace
\ No newline at end of file
--- /dev/null
+#include <cutils/log.h>
+
+struct xlog_record {
+ const char *tag_str;
+ const char *fmt_str;
+ int prio;
+};
+
+static void init(void) __attribute__ ((constructor));
+
+void init(void)
+{
+}
+
+int __xlog_buf_printf(int bufid, const struct xlog_record *rec, ...)
+{
+ va_list args;
+ va_start(args, rec);
+ LOG_PRI_VA(rec->prio, rec->tag_str, rec->fmt_str, args);
+ va_end(args);
+
+ return 0;
+}
+
+void dl_unregister_notify_function(void){ }
+
+void dl_register_notify_function(int (*load_notify_function) (const char *name,uintptr_t address,uintptr_t size ),int (*unload_notify_function) (const char *name, uintptr_t address)){ }
+
--- /dev/null
+#
+# 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.
+#
+
+# can this be done in bash? credits go to bgcngm
+define make_header
+ perl -e 'print pack("a4 L a32 a472", "\x88\x16\x88\x58", $$ARGV[0], $$ARGV[1], "\xFF"x472)' $(1) $(2) > $(3)
+endef
+
+# this is overriding targets from build/core/Makefile
+$(INSTALLED_KERNEL_TARGET).mtk.header: $(INSTALLED_KERNEL_TARGET)
+ size=$$($(call get-file-size,$(INSTALLED_KERNEL_TARGET))); \
+ $(call make_header, $$((size)), "KERNEL", $@)
+$(INSTALLED_KERNEL_TARGET).mtk: $(INSTALLED_KERNEL_TARGET).mtk.header
+ $(call pretty,"Adding MTK header to kernel.")
+ cat $(INSTALLED_KERNEL_TARGET).mtk.header $(INSTALLED_KERNEL_TARGET) \
+ > $@
+
+$(INSTALLED_RAMDISK_TARGET).mtk.header: $(INSTALLED_RAMDISK_TARGET)
+ size=$$($(call get-file-size,$(INSTALLED_RAMDISK_TARGET))); \
+ $(call make_header, $$((size)), "ROOTFS", $@)
+$(INSTALLED_RAMDISK_TARGET).mtk: $(INSTALLED_RAMDISK_TARGET).mtk.header
+ $(call pretty,"Adding MTK header to ramdisk.")
+ cat $(INSTALLED_RAMDISK_TARGET).mtk.header $(INSTALLED_RAMDISK_TARGET) \
+ > $@
+
+$(PRODUCT_OUT)/recovery_kernel.mtk.header: $(recovery_kernel)
+ size=$$($(call get-file-size,$(recovery_kernel))); \
+ $(call make_header, $$((size)), "KERNEL", $@)
+$(PRODUCT_OUT)/recovery_kernel.mtk: $(PRODUCT_OUT)/recovery_kernel.mtk.header
+ $(call pretty,"Adding MTK header to recovery kernel.")
+ cat $(PRODUCT_OUT)/recovery_kernel.mtk.header $(recovery_kernel) > $@
+
+$(recovery_ramdisk).mtk.header: $(recovery_ramdisk)
+ size=$$($(call get-file-size,$(recovery_ramdisk))); \
+ $(call make_header, $$((size)), "RECOVERY", $@)
+$(recovery_ramdisk).mtk: $(MKBOOTIMG) $(recovery_ramdisk).mtk.header
+ $(call pretty,"Adding MTK header to recovery ramdisk.")
+ cat $(recovery_ramdisk).mtk.header $(recovery_ramdisk) > $@
+
+INTERNAL_MTK_BOOTIMAGE_ARGS := \
+ --kernel $(INSTALLED_KERNEL_TARGET).mtk \
+ --ramdisk $(INSTALLED_RAMDISK_TARGET).mtk
+
+$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG)\
+ $(INSTALLED_RAMDISK_TARGET).mtk $(INSTALLED_KERNEL_TARGET).mtk
+ $(call pretty,"Target boot image: $@")
+ $(MKBOOTIMG) $(INTERNAL_MTK_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) \
+ --output $@
+ $(hide) $(call assert-max-image-size,$@, \
+ $(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
+ @echo -e ${CL_CYN}"Made boot image: $@"${CL_RST}
+
+INTERNAL_MTK_RECOVERYIMAGE_ARGS := \
+ --kernel $(INSTALLED_KERNEL_TARGET).mtk \
+ --ramdisk $(recovery_ramdisk).mtk
+
+$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTIMG) \
+ $(recovery_ramdisk).mtk $(INSTALLED_KERNEL_TARGET).mtk
+ @echo -e ${CL_CYN}"----- Making recovery image ------"${CL_RST}
+ $(MKBOOTIMG) $(INTERNAL_MTK_RECOVERYIMAGE_ARGS) \
+ $(BOARD_MKBOOTIMG_ARGS) --output $@
+ $(hide) $(call assert-max-image-size,$@, \
+ $(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw)
+ @echo -e ${CL_CYN}"Made recovery image: $@"${CL_RST}
--- /dev/null
+#!/system/bin/sh
+
+/system/bin/chmod 666 /sys/kernel/debug/ion/heaps/*
+/system/bin/chmod -R 777 /data/nvram/APCFG/APRDCL
+
--- /dev/null
+OVERLAY_BIN := device/alcatel/ttab/overlay-binaries
+
+# install-recovery.sh used to initialise init.d support
+#PRODUCT_COPY_FILES += \
+# $(OVERLAY_BIN)/install-recovery.sh:system/bin/new-install-recovery.sh \
+# $(OVERLAY_BIN)/install-recovery.sh:system/etc/install-recovery-2.sh
+
+# Install init.d scripts
+PRODUCT_COPY_FILES += \
+ $(OVERLAY_BIN)/00permissions:system/etc/init.d/00permissions
+# $(OVERLAY_BIN)/99exfat-support:system/etc/init.d/99exfat-support \
+# $(OVERLAY_BIN)/99sudaemon:system/etc/init.d/99sudaemon
+
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 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.
+*/
+-->
+
+<!-- These resources are around just to allow their values to be customized
+ for different hardware and product builds. -->
+<resources>
+
+<!-- This string array should be overridden by the device to present a list of network
+ attributes. This is used by the connectivity manager to decide which networks can coexist
+ based on the hardware -->
+ <!-- An Array of "[Connection name],[ConnectivityManager connection type],
+ [associated radio-type],[priority],[restoral-timer(ms)],[dependencyMet] -->
+ <!-- the 5th element "resore-time" indicates the number of milliseconds to delay
+ before automatically restore the default connection. Set -1 if the connection
+ does not require auto-restore. -->
+ <!-- the 6th element indicates boot-time dependency-met value. -->
+ <string-array translatable="false" name="networkAttributes">
+ <item>"wifi,1,1,1,-1,true"</item>
+ <item>"mobile,0,0,0,-1,true"</item>
+ <item>"mobile_mms,2,0,2,60000,true"</item>
+ <item>"mobile_supl,3,0,2,60000,true"</item>
+ <item>"mobile_dun,4,0,2,60000,true"</item>
+ <item>"mobile_hipri,5,0,3,60000,true"</item>
+ <item>"mobile_fota,10,0,2,60000,true"</item>
+ <item>"mobile_ims,11,0,2,60000,true"</item>
+ <item>"mobile_cbs,12,0,2,60000,true"</item>
+ <item>"wifi_p2p,13,1,0,-1,true"</item>
+ <item>"bluetooth,7,7,2,-1,true"</item>
+ </string-array>
+
+ <!-- This string array should be overridden by the device to present a list of radio
+ attributes. This is used by the connectivity manager to decide which networks can coexist
+ based on the hardware -->
+ <!-- An Array of "[ConnectivityManager connectionType],
+ [# simultaneous connection types]" -->
+ <string-array translatable="false" name="radioAttributes">
+ <item>"1,1"</item>
+ <item>"0,1"</item>
+ <item>"7,1"</item>
+ <item>"40,1"</item>
+ <item>"41,1"</item>
+ </string-array>
+
+ <!-- Array of allowable ConnectivityManager network types for tethering -->
+ <integer-array name="config_tether_upstream_types">
+ <item>0</item>
+ <item>1</item>
+ <item>5</item>
+ <item>7</item>
+ <item>9</item>
+ </integer-array>
+
+ <!-- List of regexpressions describing the interface (if any) that represent tetherable
+ USB interfaces. If the device doesn't want to support tething over USB this should
+ be empty. An example would be "usb.*" -->
+ <string-array translatable="false" name="config_tether_usb_regexs">
+ <item>"rndis\\d"</item>
+ </string-array>
+
+ <!-- List of regexpressions describing the interface (if any) that represent tetherable
+ Wifi interfaces. If the device doesn't want to support tethering over Wifi this
+ should be empty. An example would be "softap.*" -->
+ <string-array translatable="false" name="config_tether_wifi_regexs">
+ <item>"ap\\d"</item>
+ </string-array>
+
+ <string-array translatable="false" name="config_tether_bluetooth_regexs">
+ <item>"bt-pan"</item>
+ <item>"bt-dun"</item>
+ </string-array>
+
+ <bool name="config_wifi_background_scan_support">true</bool>
+
+ <!-- This device does not allow sms service. -->
+ <bool name="config_sms_capable">false</bool>
+
+ <!-- Flag indicating whether the current device is "voice capable".
+ If true, this means that the device supports circuit-switched
+ (i.e. voice) phone calls over the telephony network, and is
+ allowed to display the in-call UI while a cellular voice call is
+ active. This can be overridden to false for "data only" devices
+ which can't make voice calls and don't support any in-call UI.
+ Note: this flag is subtly different from the
+ PackageManager.FEATURE_TELEPHONY system feature, which is
+ available on *any* device with a telephony radio, even if the
+ device is data-only. -->
+ <bool name="config_voice_capable">false</bool>
+
+ <!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
+ autodetected from the Configuration. -->
+ <bool name="config_showNavigationBar">true</bool>
+
+ <!-- Maximum number of supported users -->
+ <bool name="config_enableMultiUserUI">true</bool>
+ <integer name="config_multiuserMaximumUsers">5</integer>
+
+ <!-- Whether WiFi display is supported by this device.
+ There are many prerequisites for this feature to work correctly.
+ Here are a few of them:
+ * The WiFi radio must support WiFi P2P.
+ * The WiFi radio must support concurrent connections to the WiFi display and
+ to an access point.
+ * The Audio Flinger audio_policy.conf file must specify a rule for the "r_submix"
+ remote submix module. This module is used to record and stream system
+ audio output to the WiFi display encoder in the media server.
+ * The remote submix module "audio.r_submix.default" must be installed on the device.
+ * The device must be provisioned with HDCP keys (for protected content).
+ -->
+ <bool name="config_enableWifiDisplay">true</bool>
+
+</resources>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<device name="Android">
+ <item name="none">0</item>
+ <item name="screen.on">82.75</item>
+ <item name="screen.full">201.16</item>
+ <item name="bluetooth.active">51.55</item>
+ <item name="bluetooth.on">0.79</item>
+ <item name="wifi.on">3.5</item>
+ <item name="wifi.active">73.24</item>
+ <item name="wifi.scan">75.48</item>
+ <item name="dsp.audio">0.1</item>
+ <item name="dsp.video">0.1</item>
+ <array name="cpu.speeds">
+ <value>598000</value>
+ <value>747000</value>
+ <value>1040000</value>
+ <value>1196000</value>
+ <value>1300000</value>
+ </array>
+ <item name="cpu.idle">3.2</item>
+ <item name="cpu.awake">17.4</item>
+ <array name="cpu.active">
+ <value>95.4</value>
+ <value>140.2</value>
+ <value>178.5</value>
+ <value>189.3</value>
+ <value>234.2</value>
+ </array>
+ <item name="battery.capacity">3450</item>
+ <array name="wifi.batchedscan">
+ <value>.0076</value>
+ <value>.0613</value>
+ <value>.4845</value>
+ <value>3.870</value>
+ <value>30.96</value>
+ </array>
+</device>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 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.
+*/
+-->
+
+<!-- The <device> element should contain one or more <storage> elements.
+ Exactly one of these should have the attribute primary="true".
+ This storage will be the primary external storage and should have path="/mnt/sdcard".
+ Each storage should have both a path and description attribute set.
+ The following boolean attributes are optional:
+
+ primary: this storage is the primary external storage
+ removable: this is removable storage (for example, a real SD card)
+ emulated: the storage is emulated via the FUSE sdcard daemon
+ mtp-reserve: number of megabytes of storage MTP should reserve for free storage
+ (used for emulated storage that is shared with system's data partition)
+ allowMassStorage: (boolean) true if this volume can be shared via USB mass storage
+ maxFileSize: (integer) maximum file size in megabytes
+
+ A storage should not have both emulated and removable set to true
+-->
+
+<StorageList xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- internal emulated storage -->
+ <storage android:mountPoint="/storage/sdcard0"
+ android:storageDescription="@string/storage_internal"
+ android:primary="true"
+ android:emulated="true"
+ android:removable="false"
+ android:allowMassStorage="true" />
+
+ <!-- external SD card -->
+ <storage android:mountPoint="/storage/sdcard1"
+ android:storageDescription="@string/storage_sd_card"
+ android:primary="false"
+ android:removable="true"
+ android:allowMassStorage="true" />
+
+ <!-- external USB OTG storage -->
+ <storage android:mountPoint="/storage/usbotg"
+ android:storageDescription="@string/storage_usb"
+ android:primary="false"
+ android:removable="true" />
+
+</StorageList>
--- /dev/null
+#app/MTKThermalManager/MTKThermalManager.apk
+bin/6620_launcher
+bin/6620_wmt_concurrency
+bin/6620_wmt_lpbk
+bin/MtkCodecService
+bin/aee
+bin/aee_archive
+bin/aee_core_forwarder
+bin/aee_dumpstate
+bin/akmd09911
+bin/akmd8963
+bin/audiocmdservice_atci
+#bin/boot_logo_updater
+#bin/em_svr
+#bin/factory
+#bin/guiext-server
+bin/kisd
+bin/kpoc_charger
+bin/meta_tst
+bin/mmp
+bin/msensord
+bin/nvram_agent_binder
+bin/nvram_daemon
+bin/pq
+#bin/sbchk
+#bin/thermal
+#bin/thermal_manager
+#bin/thermald
+bin/wmt_loader
+etc/.tp/.ht120.mtc
+etc/.tp/thermal.conf
+etc/.tp/thermal.off.conf
+etc/bluetooth/auto_pair_blacklist.conf
+etc/bluetooth/auto_pair_devlist.conf
+etc/bluetooth/bt_stack.conf
+etc/clatd.conf
+etc/custom.conf
+etc/dhcpcd/dhcpcd-hooks/20-dns.conf
+etc/dhcpcd/dhcpcd-hooks/95-configured
+etc/dhcpcd/dhcpcd-run-hooks
+#etc/dongleselect.conf
+lib/egl/egl.cfg
+etc/factory.ini
+etc/firmware/ROMv2_patch_1_0_hdr.bin
+etc/firmware/ROMv2_patch_1_1_hdr.bin
+etc/firmware/S_ANDRO_SFL.ini
+etc/firmware/WIFI_RAM_CODE_8127
+etc/firmware/WMT_SOC.cfg
+etc/firmware/mt6627/mt6627_fm_v1_coeff.bin
+etc/firmware/mt6627/mt6627_fm_v1_patch.bin
+etc/firmware/mt6627/mt6627_fm_v2_coeff.bin
+etc/firmware/mt6627/mt6627_fm_v2_patch.bin
+etc/firmware/mt6627/mt6627_fm_v3_coeff.bin
+etc/firmware/mt6627/mt6627_fm_v3_patch.bin
+etc/firmware/mt6627/mt6627_fm_v4_coeff.bin
+etc/firmware/mt6627/mt6627_fm_v4_patch.bin
+etc/firmware/mt6627/mt6627_fm_v5_coeff.bin
+etc/firmware/mt6627/mt6627_fm_v5_patch.bin
+etc/fmr/mt6627_fm_cust.cfg
+etc/mtk_omx_core.cfg
+etc/mtklog-config.prop
+etc/wide-dhcpv6/dhcp6c.conf
+etc/wide-dhcpv6/dhcp6c.script
+etc/wide-dhcpv6/dhcp6cDNS.conf
+etc/wide-dhcpv6/dhcp6cctlkey
+etc/wide-dhcpv6/dhcp6s.conf
+#framework/com.mediatek.effect.jar
+#framework/tedongle-telephony.jar
+lib/egl/libEGL_mali.so
+lib/egl/libGLESv1_CM_mali.so
+lib/egl/libGLESv2_mali.so
+lib/hw/audio.primary.default.so
+lib/hw/audio.primary.mt8127.so
+lib/hw/audio.r_submix.default.so
+lib/hw/audio.usb.default.so
+lib/hw/audio_policy.default.so
+lib/hw/audio_policy.stub.so
+#lib/hw/bluetooth.default.so
+lib/hw/camera.mt8127.so
+#lib/hw/gps.default.so
+lib/hw/gralloc.default.so
+lib/hw/gralloc.mt8127.so
+lib/hw/hwcomposer.mt8127.so
+#lib/hw/keystore.default.so
+#lib/hw/lights.default.so
+lib/hw/local_time.default.so
+lib/hw/power.default.so
+lib/hw/sensors.mt8127.so
+lib/hw/vibrator.default.so
+lib/lib3a.so
+lib/libBnMtkCodec.so
+#lib/libGLES_trace.so
+#lib/libGLESv1_CM.so
+#lib/libGLESv2.so
+#lib/libGLESv3.so
+lib/libGdmaScalerPipe.so
+lib/libJpgDecPipe.so
+lib/libJpgEncPipe.so
+lib/libMali.so
+lib/libMtkOmxAdpcmDec.so
+lib/libMtkOmxAdpcmEnc.so
+lib/libMtkOmxAlacDec.so
+lib/libMtkOmxApeDec.so
+lib/libMtkOmxCore.so
+lib/libMtkOmxFlacDec.so
+lib/libMtkOmxG711Dec.so
+lib/libMtkOmxGsmDec.so
+lib/libMtkOmxMp3Dec.so
+lib/libMtkOmxRawDec.so
+#lib/libMtkOmxVdec.so
+#lib/libMtkOmxVenc.so
+lib/libMtkOmxVorbisEnc.so
+lib/libMtkVideoTranscoder.so
+lib/libSwJpgCodec.so
+lib/lib_uree_mtk_crypto.so
+lib/lib_uree_mtk_video_secure_al.so
+lib/libaed.so
+lib/libaudio-resampler.so
+lib/libaudiocompensationfilter.so
+lib/libaudiocomponentengine.so
+lib/libaudiocustparam.so
+lib/libaudiodcrflt.so
+lib/libaudiomtkdcremoval.so
+lib/libaudiosetting.so
+lib/libbessound_hd_mtk.so
+lib/libblisrc.so
+lib/libblisrc32.so
+lib/libbluetooth_mtk.so
+lib/libbluetooth_relayer.so
+lib/libbluetoothdrv.so
+lib/libbluetoothem_mtk.so
+lib/libbwc.so
+lib/libcam.camadapter.so
+lib/libcam.campipe.so
+lib/libcam.camshot.so
+lib/libcam.client.so
+lib/libcam.device1.so
+lib/libcam.exif.so
+lib/libcam.paramsmgr.so
+lib/libcam.utils.sensorlistener.so
+lib/libcam.utils.so
+lib/libcam_hwutils.so
+lib/libcam_mmp.so
+lib/libcam_platform.so
+lib/libcam_utils.so
+lib/libcamalgo.so
+lib/libcamdrv.so
+#lib/libcamera_client.so
+lib/libcamera_client_mtk.so
+lib/libcamera_metadata.so
+lib/libcameraanalyzer.so
+lib/libcameracustom.so
+#lib/libcameraservice.so
+#lib/libcurl.so
+lib/libcustom_nvram.so
+lib/libcvsd_mtk.so
+lib/libdpframework.so
+lib/libdrmdecrypt.so
+lib/libdrmmtkutil.so
+lib/libdrmmtkwhitelist.so
+lib/libem_support_jni.so
+lib/libfeatureio.so
+lib/libfile_op.so
+#lib/libfmcust.so
+lib/libfmjni.so
+#lib/libfmmt6620.so
+#lib/libfmmt6627.so
+#lib/libfmmt6628.so
+lib/libgralloc_extra.so
+#lib/libgui.so
+lib/libgui_ext.so
+lib/libhwm.so
+lib/libimageio.so
+lib/libimageio_plat_drv.so
+lib/libion.so
+lib/libion_mtk.so
+lib/libm4u.so
+lib/libmatv_cust.so
+lib/libmemtrack.so
+lib/libmhalImageCodec.so
+lib/libmmprofile.so
+#lib/libmnl.so
+lib/libmp2dec_sa.ca7.so
+lib/libmp4enc_sa.ca7.so
+lib/libmpo.so
+lib/libmpodecoder.so
+lib/libmpoencoder.so
+lib/libmsbc_mtk.so
+lib/libmtcloader.so
+lib/libmtk_drvb.so
+lib/libmtk_mali_user.so
+lib/libmtk_mmutils.so
+lib/libmtkjpeg.so
+lib/libmtklimiter.so
+lib/libmtkplayer.so
+lib/libmtkshifter.so
+lib/libnvram.so
+lib/libnvram_daemon_callback.so
+lib/libnvram_platform.so
+lib/libnvram_sec.so
+lib/libnvramagentclient.so
+lib/libperfservicenative.so
+#lib/libsbccodec.so
+lib/libshowlogo.so
+lib/libspeech_enh_lib.so
+lib/libstagefright_memutil.so
+lib/libstagefrighthw.so
+lib/libtz_uree.so
+lib/libui_ext.so
+lib/liburee_meta_drmkeyinstall_v2.so
+lib/libvc1dec_sa.ca7.so
+lib/libvcodec_oal.so
+lib/libvcodec_utility.so
+#lib/libgpu_aux.so
+lib/libvcodecdrv.so
+lib/libvp8dec_sa.ca7.so
+lib/libvp9dec_sa.ca7.so
+#lib/libwapi.so
+#vendor/lib/drm/libdrmwvmplugin.so
+#vendor/lib/hw/audio.a2dp.blueangel.so
+#vendor/lib/hw/bluetooth.blueangel.so
+vendor/lib/libWVStreamControlAPI_L3.so
+vendor/lib/libwvdrm_L3.so
+vendor/lib/libwvm.so
+vendor/lib/mediadrm/libdrmclearkeyplugin.so
+vendor/lib/mediadrm/libmockdrmcryptoplugin.so
+vendor/lib/mediadrm/libwvdrmengine.so
+vendor/media/LMspeed_508.emd
+vendor/media/PFFprec_600.emd
+#xbin/mnld
--- /dev/null
+mkdir /data/misc/sensors 0664 system system
+
+on post-fs-data
+
+on post-fs
+#
+# Connectivity related modules and character device nodes (Begin)
+#
+ #for 662x_launcher
+ chmod 0660 /dev/ttyMT2
+ chown system system /dev/ttyMT2
+
+ # STP, SDIO, WMT, GPS, FM and BT Driver
+# insmod /system/lib/modules/mtk_hif_sdio.ko
+# insmod /system/lib/modules/mtk_stp_wmt.ko
+# insmod /system/lib/modules/mtk_stp_uart.ko
+# insmod /system/lib/modules/mtk_stp_gps.ko
+# insmod /system/lib/modules/mtk_stp_bt.ko
+# insmod /system/lib/modules/mtk_fm_drv.ko
+# insmod /system/lib/modules/mtk_fm_priv.ko
+# insmod /system/lib/modules/mtk_wmt_wifi.ko
+
+ insmod /system/lib/modules/mtk_wmt_detect.ko
+
+ # Create char device file for WMT, GPS, BT, FM, WIFI
+ mknod /dev/stpwmt c 190 0;
+ mknod /dev/stpgps c 191 0;
+ mknod /dev/stpbt c 192 0;
+ mknod /dev/fm c 193 0;
+ chmod 0660 /dev/stpwmt
+ chown system system /dev/stpwmt
+ chmod 0660 /dev/wmtdetect
+ chown system system /dev/wmtdetect
+
+ # FM Radio device, FIXME: this is not a proper way to set permissions
+ chmod 0666 /dev/fm
+
+ mknod /dev/wmtWifi c 153 0
+ chmod 0666 /dev/wmtWifi
+ chmod 0660 /dev/stpgps
+ chmod 0660 /dev/stpbt
+ chown bluetooth radio /dev/stpbt
+
+ # Load WiFi Driver
+ #insmod /system/lib/modules/wlan.ko
+
+#
+# Connectivity related modules and character device nodes (Ends)
+#
+
+on boot
+
+
+#
+# Connectivity related services (Begin)
+#
+
+service wmtLoader /system/bin/wmt_loader
+ user root
+ group root
+ oneshot
+
+service conn_launcher /system/bin/6620_launcher -p /system/etc/firmware/
+ user system
+ group system
+
+
+#
+# Connectivity related services (End)
+#
+
--- /dev/null
+import /init.environ.rc
+import init.ssd.rc
+import init.no_ssd.rc
+import init.ssd_nomuser.rc
+import init.fon.rc
+
+on early-init
+ # Set init and its forked children's oom_adj.
+ write /proc/1/oom_score_adj -1000
+
+ # Apply strict SELinux checking of PROT_EXEC on mmap/mprotect calls.
+ #write /sys/fs/selinux/checkreqprot 0
+
+ # Set the security context for the init process.
+ # This should occur before anything else (e.g. ueventd) is started.
+ setcon u:r:init:s0
+
+ # Set the security context of /adb_keys if present.
+ restorecon /adb_keys
+
+ start ueventd
+
+ write /proc/bootprof "INIT: usr/eng build setting"
+# create mountpoints
+ mkdir /mnt 0775 root system
+
+on init
+
+sysclktz 0
+
+loglevel 5
+
+# Backward compatibility
+ symlink /system/etc /etc
+ symlink /sys/kernel/debug /d
+
+# Right now vendor lives on the same filesystem as system,
+# but someday that may change.
+ symlink /system/vendor /vendor
+
+# Create cgroup mount point for cpu accounting
+ mkdir /acct
+ mount cgroup none /acct cpuacct
+ mkdir /acct/uid
+
+# Backwards Compat - XXX: Going away in G*
+ symlink /mnt/sdcard /sdcard
+
+ mkdir /system
+ mkdir /data 0771 system system
+ mkdir /cache 0770 system cache
+ mkdir /config 0500 root root
+
+ # See storage config details at http://source.android.com/tech/storage/
+ mkdir /mnt/shell 0700 shell shell
+ mkdir /mnt/media_rw 0700 media_rw media_rw
+ mkdir /storage 0751 root sdcard_r
+
+ # Directory for putting things only root should see.
+ mkdir /mnt/secure 0700 root root
+ # Create private mountpoint so we can MS_MOVE from staging
+ mount tmpfs tmpfs /mnt/secure mode=0700,uid=0,gid=0
+
+ # Directory for staging bindmounts
+ mkdir /mnt/secure/staging 0700 root root
+
+ # Directory-target for where the secure container
+ # imagefile directory will be bind-mounted
+ mkdir /mnt/secure/asec 0700 root root
+
+ # Secure container public mount points.
+ mkdir /mnt/asec 0700 root system
+ mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
+
+ # Filesystem image public mount points.
+ mkdir /mnt/obb 0700 root system
+ mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000
+
+ write /proc/sys/kernel/panic_on_oops 1
+ write /proc/sys/kernel/hung_task_timeout_secs 0
+ write /proc/cpu/alignment 4
+ write /proc/sys/kernel/sched_latency_ns 10000000
+ write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
+ write /proc/sys/kernel/sched_compat_yield 1
+ write /proc/sys/kernel/sched_child_runs_first 0
+ write /proc/sys/kernel/randomize_va_space 2
+ write /proc/sys/kernel/kptr_restrict 2
+ write /proc/sys/kernel/dmesg_restrict 1
+ write /proc/sys/vm/mmap_min_addr 32768
+ write /proc/sys/kernel/sched_rt_runtime_us 950000
+ write /proc/sys/kernel/sched_rt_period_us 1000000
+
+ # change key_provisioning
+ mkdir /data/key_provisioning
+ chmod 0777 /data/key_provisioning
+
+ mkdir /dev/cpuctl
+ mount cgroup none /dev/cpuctl cpu
+ chown system system /dev/cpuctl
+ chown system system /dev/cpuctl/tasks
+ chmod 0660 /dev/cpuctl/tasks
+ write /dev/cpuctl/cpu.shares 1024
+ write /dev/cpuctl/cpu.rt_runtime_us 950000
+ write /dev/cpuctl/cpu.rt_period_us 1000000
+
+ mkdir /dev/cpuctl/apps
+ chown system system /dev/cpuctl/apps/tasks
+ chmod 0666 /dev/cpuctl/apps/tasks
+ write /dev/cpuctl/apps/cpu.shares 1024
+ write /dev/cpuctl/apps/cpu.rt_runtime_us 800000
+ write /dev/cpuctl/apps/cpu.rt_period_us 1000000
+
+#USB function for factory mode
+# write /sys/class/android_usb/android0/enable 0
+# write /sys/class/android_usb/android0/idVendor 0e8d
+# write /sys/class/android_usb/android0/idProduct 2006
+# write /sys/class/android_usb/android0/f_acm/instances 1
+# write /sys/class/android_usb/android0/functions mass_storage,adb,acm
+# write /sys/class/android_usb/android0/enable 1
+# start adbd
+# setprop sys.usb.state mass_storage,adb,acm
+
+ mkdir /dev/cpuctl/apps/bg_non_interactive
+ chown system system /dev/cpuctl/apps/bg_non_interactive/tasks
+ chmod 0666 /dev/cpuctl/apps/bg_non_interactive/tasks
+ # 5.0 %
+ write /dev/cpuctl/apps/bg_non_interactive/cpu.shares 52
+ write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_runtime_us 700000
+ write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_period_us 1000000
+
+# Allow everybody to read the xt_qtaguid resource tracking misc dev.
+# This is needed by any process that uses socket tagging.
+ chmod 0644 /dev/xt_qtaguid
+
+# Healthd can trigger a full boot from charger mode by signaling this
+# property when the power button is held.
+on property:sys.boot_from_charger_mode=1
+ class_stop charger
+ trigger late-init
+
+# Load properties from /system/ + /factory after fs mount.
+on load_all_props_action
+ load_all_props
+
+# Mount filesystems and start core system services.
+on late-init
+ trigger early-fs
+ trigger fs
+ trigger post-fs
+ trigger post-fs-data
+
+ # Load properties from /system/ + /factory after fs mount. Place
+ # this in another action so that the load will be scheduled after the prior
+ # issued fs triggers have completed.
+ trigger load_all_props_action
+
+ trigger early-boot
+ trigger boot
+
+on fs
+ write /proc/bootprof "INIT:Mount_START"
+ mount_all /fstab.mt8127
+
+ #change partition permissions
+ exec /system/bin/chmod 0640 /dev/block/platform/mtk-msdc.0/by-name/boot
+ exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/boot
+ exec /system/bin/chmod 0640 /dev/block/platform/mtk-msdc.0/by-name/recovery
+ exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/recovery
+ exec /system/bin/chmod 0640 /dev/block/platform/mtk-msdc.0/by-name/secro
+ exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/secro
+ exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/seccfg
+ exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/seccfg
+ exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/proinfo
+ exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/proinfo
+ exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/otp
+ exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/otp
+ exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/nvram
+ exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/nvram
+ exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/para
+ exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/para
+ exec /system/bin/chmod 0660 /dev/block/platform/mtk-msdc.0/by-name/logo
+ exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/logo
+ exec /system/bin/chown root:system /dev/block/platform/mtk-msdc.0/by-name/para
+ write /proc/bootprof "INIT:Mount_END"
+
+on post-fs
+ # once everything is setup, no need to modify /
+ mount rootfs rootfs / ro remount
+ # mount shared so changes propagate into child namespaces
+ mount rootfs rootfs / shared rec
+ mount tmpfs tmpfs /mnt/secure private rec
+
+ # We chown/chmod /data again so because mount is run as root + defaults
+ chown system system /system/data
+ chmod 0777 /system/data
+
+ # Same reason as /data above
+ chown system cache /cache
+ chmod 0770 /cache
+ # We restorecon /cache in case the cache partition has been reset.
+ restorecon_recursive /cache
+
+ mkdir /cache/recovery 0770 system system
+ restorecon /cache
+ #mount yaffs2 mtd@nvram /nvram nandboot
+ mount ext4 /dev/block/platform/mtk-msdc.0/by-name/SEC_RO /system/secro
+ mount ext4 /dev/block/platform/mtk-msdc.0/by-name/SEC_RO /system/secro ro remount
+
+ # This may have been created by the recovery system with odd permissions
+ chown system cache /cache/recovery
+ chmod 0770 /cache/recovery
+ # This may have been created by the recovery system with the wrong context.
+ restorecon /cache/recovery
+
+ #change permissions on vmallocinfo so we can grab it from bugreports
+ chown root log /proc/vmallocinfo
+ chmod 0440 /proc/vmallocinfo
+
+ chown root log /proc/slabinfo
+ chmod 0440 /proc/slabinfo
+
+ #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
+ chown root system /proc/kmsg
+ chmod 0440 /proc/kmsg
+ chown root system /proc/sysrq-trigger
+ chmod 0220 /proc/sysrq-trigger
+ chown system log /proc/last_kmsg
+ chmod 0440 /proc/last_kmsg
+
+ # create the lost+found directories, so as to enforce our permissions
+ mkdir /cache/lost+found 0770 root root
+
+ # make the selinux kernel policy world-readable
+ chmod 0444 /sys/fs/selinux/policy
+
+ # create the lost+found directories, so as to enforce our permissions
+ mkdir /cache/lost+found 0770 root root
+#SeLinux
+ restorecon_recursive /protect_f
+ restorecon_recursive /protect_s
+
+on post-fs-data
+ # We chown/chmod /data again so because mount is run as root + defaults
+ chown system system /data
+ chmod 0771 /data
+ # We restorecon /data in case the userdata partition has been reset.
+ restorecon /data
+
+ # Create dump dir and collect dumps.
+ # Do this before we mount cache so eventually we can use cache for
+ # storing dumps on platforms which do not have a dedicated dump partition.
+ mkdir /data/dontpanic 0750 root log
+
+ # Collect apanic data, free resources and re-arm trigger
+ copy /proc/apanic_console /data/dontpanic/apanic_console
+ chown root log /data/dontpanic/apanic_console
+ chmod 0640 /data/dontpanic/apanic_console
+
+ copy /proc/apanic_threads /data/dontpanic/apanic_threads
+ chown root log /data/dontpanic/apanic_threads
+ chmod 0640 /data/dontpanic/apanic_threads
+
+ write /proc/apanic_console 1
+# create basic filesystem structure
+ mkdir /data/nvram 2770 root system
+ mkdir /data/misc 01771 system misc
+ mkdir /data/misc/adb 02750 system shell
+ mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
+ mkdir /data/misc/bluetooth 0770 system system
+ mkdir /data/misc/keystore 0700 keystore keystore
+ mkdir /data/misc/keychain 0771 system system
+ mkdir /data/misc/sms 0770 system radio
+ mkdir /data/misc/vpn 0770 system vpn
+ mkdir /data/misc/systemkeys 0700 system system
+ # give system access to wpa_supplicant.conf for backup and restore
+ mkdir /data/misc/wifi 0770 wifi wifi
+ chmod 0660 /data/misc/wifi/wpa_supplicant.conf
+ mkdir /data/local 0771 shell shell
+ mkdir /data/local/tmp 0771 shell shell
+ mkdir /data/data 0771 system system
+ mkdir /data/app-private 0771 system system
+ mkdir /data/app-asec 0700 root root
+ mkdir /data/app-lib 0771 system system
+ mkdir /data/app 0771 system system
+ mkdir /data/property 0700 root root
+ mkdir /data/ssh 0750 root shell
+ mkdir /data/ssh/empty 0700 root root
+
+ # create dalvik-cache, so as to enforce our permissions
+ mkdir /data/dalvik-cache 0771 system system
+
+ # create resource-cache and double-check the perms
+ mkdir /data/resource-cache 0771 system system
+ chown system system /data/resource-cache
+ chmod 0771 /data/resource-cache
+
+ # create the lost+found directories, so as to enforce our permissions
+ mkdir /data/lost+found 0770
+ mkdir /cache/lost+found 0770
+
+ # double check the perms, in case lost+found already exists, and set owner
+ chown root root /data/lost+found
+ chmod 0770 /data/lost+found
+ chown root root /cache/lost+found
+ chmod 0770 /cache/lost+found
+
+ mkdir /data/drm 0770 drm drm
+
+ # dhcp server
+ mkdir /data/misc/dhcp 0770 dhcp dhcp
+ chown dhcp dhcp /data/misc/dhcp
+
+ # device info interface
+ #insmod /system/lib/modules/devinfo.ko
+ #mknod /dev/devmap c 196 0;
+ chmod 0444 /dev/devmap
+ chown root system /dev/devmap
+
+ # load driver base driver
+ insmod /system/lib/modules/mtk_drvb_75.ko
+ mknod /dev/drvb c 176 0
+ chmod 0666 /dev/drvb
+
+start NvRAMAgent
+
+## Custom pos-fs area (START)
+ write /proc/sys/vm/overcommit_memory 1
+ write /proc/sys/vm/min_free_order_shift 4
+ chown root system /sys/module/lowmemorykiller/parameters/adj
+ chmod 0664 /sys/module/lowmemorykiller/parameters/adj
+ chown root system /sys/module/lowmemorykiller/parameters/minfree
+ chmod 0664 /sys/module/lowmemorykiller/parameters/minfree
+
+ # Tweak background writeout
+ write /proc/sys/vm/dirty_expire_centisecs 200
+ write /proc/sys/vm/dirty_background_ratio 5
+
+ # Permissions for System Server and daemons.
+ chown radio system /sys/android_power/state
+ chown radio system /sys/android_power/request_state
+ chown radio system /sys/android_power/acquire_full_wake_lock
+ chown radio system /sys/android_power/acquire_partial_wake_lock
+ chown radio system /sys/android_power/release_wake_lock
+ chown system system /sys/power/autosleep
+ chown system system /sys/power/state
+ chown system system /sys/power/wakeup_count
+ chown radio system /sys/power/wake_lock
+ chown radio system /sys/power/wake_unlock
+ chmod 0660 /sys/power/state
+ chmod 0660 /sys/power/wake_lock
+ chmod 0660 /sys/power/wake_unlock
+
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_rate
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_rate
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/min_sample_time
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/min_sample_time
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/boost
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boost
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/input_boost
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/input_boost
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration
+
+ # Assume SMP uses shared cpufreq policy for all CPUs
+ chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
+ chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
+
+ chown system system /sys/class/timed_output/vibrator/enable
+ chown system system /sys/class/leds/keyboard-backlight/brightness
+ chown system system /sys/class/leds/lcd-backlight/brightness
+ chown system system /sys/class/leds/button-backlight/brightness
+ chown system system /sys/class/leds/jogball-backlight/brightness
+ chown system system /sys/class/leds/red/brightness
+ chown system system /sys/class/leds/green/brightness
+ chown system system /sys/class/leds/blue/brightness
+ chown system system /sys/class/leds/red/device/grpfreq
+ chown system system /sys/class/leds/red/device/grppwm
+ chown system system /sys/class/leds/red/device/blink
+ chown system system /sys/class/leds/red/brightness
+ chown system system /sys/class/leds/green/brightness
+ chown system system /sys/class/leds/blue/brightness
+ chown system system /sys/class/leds/red/device/grpfreq
+ chown system system /sys/class/leds/red/device/grppwm
+ chown system system /sys/class/leds/red/device/blink
+ chown system system /sys/class/timed_output/vibrator/enable
+ chown system system /sys/module/sco/parameters/disable_esco
+ chown system system /sys/kernel/ipv4/tcp_wmem_min
+ chown system system /sys/kernel/ipv4/tcp_wmem_def
+ chown system system /sys/kernel/ipv4/tcp_wmem_max
+ chown system system /sys/kernel/ipv4/tcp_rmem_min
+ chown system system /sys/kernel/ipv4/tcp_rmem_def
+ chown system system /sys/kernel/ipv4/tcp_rmem_max
+ chown root radio /proc/cmdline
+
+# Define TCP buffer sizes for various networks
+# ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
+ setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208
+ setprop net.tcp.buffersize.wifi 524288,1048576,2097152,262144,524288,1048576
+ setprop net.tcp.buffersize.lte 524288,1048576,2097152,262144,524288,1048576
+ setprop net.tcp.buffersize.umts 4094,87380,110208,4096,16384,110208
+ setprop net.tcp.buffersize.hspa 4094,87380,262144,4096,16384,262144
+ setprop net.tcp.buffersize.hsupa 4094,87380,262144,4096,16384,262144
+ setprop net.tcp.buffersize.hsdpa 4094,87380,262144,4096,16384,262144
+ setprop net.tcp.buffersize.hspap 4094,87380,1220608,4096,16384,1220608
+ setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040
+ setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680
+ setprop net.tcp.buffersize.evdo 4094,87380,262144,4096,16384,262144
+
+# Set this property so surfaceflinger is not started by system_init
+ setprop system_init.startsurfaceflinger 0
+
+ # Touch Panel
+ chown root diag /sys/module/tpd_setting/parameters/tpd_calmat
+ chown root diag /sys/module/tpd_setting/parameters/tpd_em_debounce_time
+ chown root diag /sys/module/tpd_debug/parameters/tpd_em_log
+ chown root diag /sys/module/tpd_debug/parameters/tpd_em_log_to_fs
+
+ chmod 0777 /dev/pmem_multimedia
+ chmod 0777 /dev/mt6516-isp
+ chmod 0777 /dev/mt6516-IDP
+ chmod 0777 /dev/mt9p012
+ chmod 0777 /dev/mt6516_jpeg
+ chmod 0777 /dev/FM50AF
+
+ # RTC
+ mkdir /data/misc/rtc 0770 system system
+
+ # M4U
+ #insmod /system/lib/modules/m4u.ko
+ #mknod /dev/M4U_device c 188 0
+ chmod 0444 /dev/M4U_device
+
+ # Sensor
+ chmod 0666 /dev/hwmsensor
+ chmod 0666 /dev/msensor
+ chmod 0666 /dev/gsensor
+ chmod 0666 /dev/alsps
+
+ #VideoCodec
+ insmod /system/lib/modules/vcodec_kernel_driver.ko
+ mknod /dev/Vcodec c 189 0
+ chmod 0666 /dev/Vcodec
+
+
+ mkdir /data/amit/
+
+ # GPIO
+ chmod 0666 /dev/mtgpio
+
+ #NFC
+ rm /data/mtknfc_server
+
+## Custom pos_fs area (END)
+
+ # Separate location for storing security policy files on data
+ mkdir /data/security 0711 system system
+
+ # Reload policy from /data/security if present.
+ setprop selinux.reload_policy 1
+
+ # Set SELinux security contexts on upgrade or policy update.
+ restorecon_recursive /data
+
+ # If there is no fs-post-data action in the init.<device>.rc file, you
+ # must uncomment this line, otherwise encrypted filesystems
+ # won't work.
+ # Set indication (checked by vold) that we have finished this action
+ setprop vold.post_fs_data_done 1
+
+on boot
+
+start drvbd
+
+# basic network init
+ ifup lo
+ hostname localhost
+ domainname localdomain
+
+# Define RIL properties
+ setprop rild.nw.operlist /system/etc/ril/oper.lis
+ # AGPS
+ chmod 0777 /system/bin/mtk_agpsd
+
+# Start default class, this line is very important!!
+ class_start default
+ class_start core
+
+on nonencrypted
+ class_start main
+ class_start late_start
+
+on property:vold.decrypt=trigger_default_encryption
+ start defaultcrypto
+
+on property:vold.decrypt=trigger_encryption
+ start surfaceflinger
+ start encrypt
+
+on property:vold.decrypt=trigger_reset_main
+ class_reset main
+
+on property:vold.decrypt=trigger_load_persist_props
+ load_persist_props
+
+on property:vold.decrypt=trigger_post_fs_data
+ trigger post-fs-data
+
+on property:vold.decrypt=trigger_restart_min_framework
+ class_start main
+
+on property:vold.decrypt=trigger_restart_framework
+ start nvram_daemon
+ class_start main
+ class_start late_start
+ start permission_check
+
+on property:vold.decrypt=trigger_shutdown_framework
+ class_reset late_start
+ class_reset main
+
+## Daemon processes to be run by init.
+##
+
+# Update the second boot logo
+# service bootlogoupdater /system/bin/boot_logo_updater
+# oneshot
+
+service ueventd /sbin/ueventd
+ class core
+ critical
+ seclabel u:r:ueventd:s0
+
+service logd /system/bin/logd
+ class core
+ socket logd stream 0666 logd logd
+ socket logdr seqpacket 0666 logd logd
+ socket logdw dgram 0222 logd logd
+ seclabel u:r:logd:s0
+
+service kisd /system/bin/kisd
+ user system
+ group system media
+
+service console /system/bin/sh
+ class core
+ console
+ disabled
+ user shell
+ group shell log
+ seclabel u:r:shell:s0
+
+on property:sys.powerctl=*
+ powerctl ${sys.powerctl}
+
+on property:ro.debuggable=1
+ start console
+
+# adbd is controlled via property triggers in init.<platform>.usb.rc
+service adbd /sbin/adbd --root_seclabel=u:r:su:s0
+ class core
+ socket adbd stream 660 system system
+ disabled
+ seclabel u:r:adbd:s0
+
+# adbd on at boot in emulator
+on property:ro.kernel.qemu=1
+ start adbd
+service servicemanager /system/bin/servicemanager
+ class core
+ user system
+ group system
+ critical
+
+service vold /system/bin/vold
+ class core
+ socket vold stream 0660 root mount
+ ioprio be 2
+
+# One shot invocation to deal with encrypted volume.
+service defaultcrypto /system/bin/vdc --wait cryptfs mountdefaultencrypted
+ disabled
+ oneshot
+ # vold will set vold.decrypt to trigger_restart_framework (default
+ # encryption) or trigger_restart_min_framework (other encryption)
+
+# One shot invocation to encrypt unencrypted volumes
+service encrypt /system/bin/vdc --wait cryptfs enablecrypto inplace default
+ disabled
+ oneshot
+ # vold will set vold.decrypt to trigger_restart_framework (default
+ # encryption)
+
+service netd /system/bin/netd
+ class main
+ socket netd stream 0660 root system
+ socket dnsproxyd stream 0660 root inet
+ socket mdns stream 0660 root system
+
+#service debuggerd /system/bin/debuggerd
+# class main
+
+service ril-daemon /system/bin/rild
+ class main
+ socket rild stream 660 root radio
+ socket rild-debug stream 660 radio system
+ user root
+ group radio cache inet misc audio log
+
+# adbd is controlled via property triggers in init.<platform>.usb.rc
+service adbd /sbin/adbd
+ class core
+
+service drvbd /system/bin/drvbd
+ class main
+ user system
+ group system
+
+## Custom service area (START)
+# Please add custom service below
+service nvram_daemon /system/bin/nvram_daemon
+ class main
+ user root
+ group system
+ oneshot
+
+service NvRAMAgent /system/bin/nvram_agent_binder
+ user system
+ group system
+
+service mdlogger /system/bin/mdlogger
+ class main
+ user shell
+ group shell system radio sdcard_rw inet
+ disabled
+ oneshot
+
+service dualmdlogger /system/bin/dualmdlogger
+ class main
+ user shell
+ group shell system radio sdcard_rw inet
+ disabled
+ oneshot
+
+service factory_no_image /system/bin/factory
+ disabled
+ oneshot
+
+service factory_with_image /sbin/factory
+ disabled
+ oneshot
+
+#
+## Custom service area (END)
+
+
+on property:sys.mtk.no.factoryimage=1
+ start factory_no_image
+
+on property:sys.mtk.no.factoryimage=0
+ start factory_with_image
+
+#mass_storage,adb,acm
+on property:ro.boot.usbconfig=0
+ write /sys/class/android_usb/android0/iSerial $ro.serialno
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor 0e8d
+ write /sys/class/android_usb/android0/idProduct 2006
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions mass_storage,adb,acm
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+
+#acm
+on property:ro.boot.usbconfig=1
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/iSerial " "
+ write /sys/class/android_usb/android0/idVendor 0e8d
+ write /sys/class/android_usb/android0/idProduct 2007
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions acm
+ write /sys/class/android_usb/android0/bDeviceClass 02
+ write /sys/class/android_usb/android0/enable 1
--- /dev/null
+# Android fstab file.
+#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
+# The filesystem that contains the filesystem checker binary (typically /system) cannot
+# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
+/dev/block/platform/mtk-msdc.0/mmcblk0p6 /system ext4 ro wait
+/dev/block/platform/mtk-msdc.0/mmcblk0p8 /data ext4 noatime,nosuid,nodev,noauto_da_alloc,discard wait,check,resize,encryptable=footer
+/dev/block/platform/mtk-msdc.0/mmcblk0p7 /cache ext4 noatime,nosuid,nodev,noauto_da_alloc,discard wait,check
+
+#/dev/block/platform/mtk-msdc.0/mmcblk0p2 /misc emmc defaults defaults
+
+/devices/platform/mtk-msdc.0/mmc_host auto vfat defaults voldmanaged=sdcard0:emmc@fat,noemulatedsd
+/devices/platform/mtk-msdc.1/mmc_host auto vfat defaults voldmanaged=sdcard1:auto
+/devices/platform/mt_usb auto vfat defaults voldmanaged=usbotg:auto
--- /dev/null
+on property:ro.build.type=eng
+ write /proc/sys/fs/suid_dumpable 2
+ write /proc/sys/kernel/core_pattern "|/system/bin/aee_core_forwarder /data/core/ %p %s UID=%u GID=%g"
+
+on property:persist.aee.core.dump=enable
+ write /proc/sys/fs/suid_dumpable 2
+ write /proc/sys/kernel/core_pattern "|/system/bin/aee_core_forwarder /data/core/ %p %s UID=%u GID=%g"
+
+on init
+ write /proc/self/coredump_filter 39
--- /dev/null
+# LPM
+on property:ro.bootmode=charger
+ mount ext4 /dev/block/platform/mtk-msdc.0/mmcblk0p6 /system wait ro
+
+service charger /charger
+ class charger
+ critical
+ seclabel u:r:healthd:s0
+
+on charger
+ # Set cpu governor to powersave while in charging mode
+ write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor powersave
--- /dev/null
+# set up the global environment
+on init
+ export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
+ export ANDROID_BOOTLOGO 1
+ export ANDROID_ROOT /system
+ export ANDROID_ASSETS /system/app
+ export ANDROID_DATA /data
+ export ANDROID_STORAGE /storage
+ export ASEC_MOUNTPOINT /mnt/asec
+ export LOOP_MOUNTPOINT /mnt/obb
+ export BOOTCLASSPATH /system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/apache-xml.jar:/system/framework/mediatek-common.jar:/system/framework/mediatek-framework.jar:/system/framework/mediatek-telephony-common.jar
+ export SYSTEMSERVERCLASSPATH /system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar
+ export LD_PRELOAD libsigchain.so
--- /dev/null
+
+#connectivity related init script
+import init.project.rc
+import init.connectivity.rc
+import init.charging.rc
+import init.mt8127usb.rc
+import init.aee.rc
+import init.ssd.rc
+import init.no_ssd.rc
+import init.ssd_nomuser.rc
+
+on init
+# export LD_PRELOAD "libxlog.so"
+# export LD_SHIM_LIBS /system/libdpframework.so|libxlog.so:/system/lib/egl/libEGL_mali.so|libxlog.so
+ export USBOTG_STORAGE /storage/usbotg
+ mount tmpfs tmpfs /mnt/media_rw/ mode=0755,uid=1000,gid=1000
+ mkdir /mnt/media_rw/usbotg 0700 media_rw media_rw
+ mkdir /storage/usbotg 0700 root root
+ mount tmpfs tmpfs /storage/usbotg mode=0755,uid=1000,gid=1000
+
+ symlink /sdcard /storage/sdcard0
+ symlink /storage/usbdisk /mnt/usbdisk
+
+ export EXTERNAL_STORAGE /sdcard
+
+
+# Backward compatibility
+ symlink /system/etc /etc
+ symlink /sys/kernel/debug /d
+
+# Right now vendor lives on the same filesystem as system,
+# but someday that may change.
+ symlink /system/vendor /vendor
+
+# Create cgroup mount point for cpu accounting
+ mkdir /acct
+ mount cgroup none /acct cpuacct
+ mkdir /acct/uid
+
+
+ mkdir /system
+ mkdir /custpack
+ mkdir /data 0771 system system
+ mkdir /cache 0770 system cache
+ mkdir /config 0500 root root
+
+ mkdir /mnt/cd-rom 0000 system system
+
+ # Directory for putting things only root should see.
+ mkdir /mnt/secure 0700 root root
+ # Create private mountpoint so we can MS_MOVE from staging
+ mount tmpfs tmpfs /mnt/secure mode=0700,uid=0,gid=0
+
+ # Directory for staging bindmounts
+ mkdir /mnt/secure/staging 0700 root root
+
+ # Directory-target for where the secure container
+ # imagefile directory will be bind-mounted
+ mkdir /mnt/secure/asec 0700 root root
+
+ # Secure container public mount points.
+ mkdir /mnt/asec 0700 root system
+ mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
+
+ # Filesystem image public mount points.
+ mkdir /mnt/obb 0700 root system
+ mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000
+
+ write /proc/sys/kernel/panic_on_oops 1
+ write /proc/sys/kernel/hung_task_timeout_secs 0
+ write /proc/cpu/alignment 4
+ write /proc/sys/kernel/sched_latency_ns 10000000
+ write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
+ write /proc/sys/kernel/sched_compat_yield 1
+ write /proc/sys/kernel/sched_child_runs_first 0
+ write /proc/sys/kernel/randomize_va_space 2
+ write /proc/sys/kernel/kptr_restrict 2
+ write /proc/sys/kernel/dmesg_restrict 1
+ write /proc/sys/vm/mmap_min_addr 32768
+ write /proc/sys/net/ipv4/ping_group_range "0 2147483647"
+ write /proc/sys/kernel/sched_rt_runtime_us 950000
+ write /proc/sys/kernel/sched_rt_period_us 1000000
+
+
+# Allow everybody to read the xt_qtaguid resource tracking misc dev.
+# This is needed by any process that uses socket tagging.
+ chmod 0644 /dev/xt_qtaguid
+
+#HWComposer fb0
+ chmod 0666 /dev/graphics/fb0
+ chown system graphics /dev/graphics/fb0
+
+#HWComposer Vsync
+ chmod 0666 /dev/mtkfb_vsync
+ chown system graphics /dev/mtkfb_vsync
+
+
+#HWComposer fence
+ chmod 0666 /dev/sw_sync
+ chown system graphics /dev/sw_sync
+
+# Change ION driver permission
+ chmod 0666 /dev/ion
+
+# Change BWC permission
+ chmod 0664 /sys/bus/platform/drivers/mem_bw_ctrl/concurrency_scenario
+ chown system media /sys/bus/platform/drivers/mem_bw_ctrl/concurrency_scenario
+
+# Change M4U driver permission
+# chmod 0444 /dev/M4U_device
+
+# Change SMI driver permission
+ chmod 0660 /dev/MTK_SMI
+ chown system media /dev/MTK_SMI
+
+ #Use uinput's default permission
+ chown system net_bt_admin /dev/uinput
+
+# Change SMI mtk_sched permission
+ chmod 0660 /dev/mtk_sched
+ chown system media /dev/mtk_sched
+
+#BT SCO CVSD
+ chmod 0660 /dev/ebc
+ chown system media /dev/ebc
+
+# Change DISP permission
+ chmod 0666 /dev/mtk_disp
+ chown system system /dev/mtk_disp
+
+# Change Camera permission
+ chmod 0660 /dev/camera-sysram
+ chmod 0660 /dev/camera-isp
+ chmod 0660 /dev/camera-pipemgr
+ chmod 0660 /dev/kd_camera_hw
+ chmod 0660 /dev/kd_camera_flashlight
+ chmod 0660 /dev/kd_camera_hw_bus2
+ chmod 0660 /dev/FM50AF
+ chmod 0660 /dev/CAM_CAL_DRV
+
+ chown system camera /dev/camera-sysram
+ chown system camera /dev/camera-isp
+ chown system camera /dev/camera-pipemgr
+ chown system camera /dev/kd_camera_hw
+ chown system camera /dev/kd_camera_flashlight
+ chown system camera /dev/kd_camera_hw_bus2
+ chown system camera /dev/FM50AF
+ chown system camera /dev/CAM_CAL_DRV
+
+# Change OVL permission
+ chmod 0440 /dev/mtk_ovl
+ chown system system /dev/mtk_ovl
+
+# Change Jpeg permission
+ # chmod 0444 /dev/mtk_jpeg
+ # chmod 0444 /dev/mtk_gdma
+ # chmod 0444 /dev/mtk_gfmt
+ chmod 0440 /dev/mtk_almk
+
+# otg_test
+ chown root radio /dev/mt_otg_test
+ chmod 0660 /dev/mt_otg_test
+
+# Enable AAL
+ setprop ro.mediatek.aal 1
+
+ # mount debugfs for ftrace
+ mount debugfs none /sys/kernel/debug
+
+ # change owner
+ chown system system /proc/bootprof
+ chown root system /proc/mtprof/cputime
+ chown root system /proc/mtprof/reboot_pid
+
+on boot
+# start sensor services
+# start akmd8963
+
+# start nvram
+start NvRAMAgent
+
+ chown system system /sys/devices/system/cpu/cpufreq/hotplug/cpu_num_base
+ chmod 0660 /sys/devices/system/cpu/cpufreq/hotplug/cpu_num_base
+
+on fs
+
+# mount mtd partitions
+ # Mount /system rw first to give the filesystem a chance to save a checkpoint
+ #write /proc/bootprof "INIT:NAND:Mount_START"
+ #mount yaffs2 mtd@system /system
+
+# via: set ril and pppd
+ #chown root /system/bin/pppd
+ #chmod 4755 /system/bin/pppd
+ #chown root /system/etc/ppp/ip-up-cdma
+ #chmod 4755 /system/et/ppp/ip-up-cdma
+ #chown root /system/etc/ppp/ipv6-up-cdma
+ #chmod 4755 /system/etc/ppp/ipv6-up-cdma
+ #chown root /system/etc/ppp/link-down-cdma
+ #chmod 4755 /system/etc/ppp/link-down-cdma
+ #mount yaffs2 mtd@system /system ro remount
+ #mount yaffs2 mtd@userdata /data nosuid nodev
+ #mount yaffs2 mtd@cache /cache nosuid nodev
+ #write /proc/bootprof "INIT:NAND:Mount_END"
+
+#on fs_property:ro.mount.fs=EXT4
+ write /proc/bootprof "INIT:eMMC:Mount_START"
+ mount_all /fstab.mt8127
+ setprop ro.crypto.fuse_sdcard true
+ write /proc/bootprof "INIT:eMMC:Mount_END"
+ mount iso9660 loop@/system/etc/iAmCdRom.iso /mnt/cd-rom ro
+
+ write /sys/class/misc/tp_cfg/data_is_mount 1
+ #change partition permission
+ exec /system/etc/partition_permission.sh
+
+# RGX init
+service pvrsrvctl /system/vendor/bin/pvrsrvctl --start
+ class core
+ user root
+ group root
+ oneshot
+
+on post-fs-data
+ mkdir /data/nvram 2770 root system
+ mkdir /data/media 0770 media_rw media_rw
+ chmod 0660 /data/misc/wifi/p2p_supplicant.conf
+
+
+# dhcp server
+ mkdir /data/misc/dhcp 0770 dhcp wifi
+ chown dhcp wifi /data/misc/dhcp
+
+# dhcpv6 server
+ mkdir /data/misc/wide-dhcpv6 0770 dhcp wifi
+ chown dhcp wifi /data/misc/wide-dhcpv6
+
+ # GPS
+ mkdir /data/gps_mnl 0771 gps system
+
+ # remove /data/system/wpa_supplicant which was created in meta mode of JB version,
+ # wlan will be not able to enabled if this directory exists in L version.
+ rmdir /data/system/wpa_supplicant
+
+ # for ppp options file
+ mkdir /data/misc/ppp 0770 bluetooth net_bt
+ # bluetooth
+ mkdir /data/@btmtk 0770 bluetooth net_bt
+ chown bluetooth bluetooth /data/@btmtk/host_cache
+ chown bluetooth bluetooth /data/@btmtk/dev_cache
+ chown bluetooth bluetooth /dev/hid-keyboard
+ chmod 0660 /dev/hid-keyboard
+
+ # NFC
+ mkdir /data/nfc_socket 0771 nfc radio
+
+#VideoCodec
+ insmod /system/lib/modules/vcodec_kernel_driver.ko
+
+# JPEG
+ chmod 0440 /dev/mtk_jpeg
+ chown system camera /dev/mtk_jpeg
+
+# UIBC
+ chown system media /dev/uibc
+ chmod 0660 /dev/uibc
+
+#HDMI
+ chmod 0664 /dev/hdmitx
+
+# Sensor
+ chmod 0660 /dev/hwmsensor
+ chmod 0660 /dev/msensor
+ chmod 0660 /dev/gsensor
+ chmod 0660 /dev/als_ps
+ chmod 0660 /dev/gyroscope
+ chmod 0660 /dev/aal_als
+
+ chmod 0660 /sys/devices/platform/msensor/driver/cpsopmode
+ chmod 0660 /sys/devices/platform/msensor/driver/cpsreptxy
+ chmod 0660 /sys/devices/platform/msensor/driver/cpsreptz
+ chmod 0660 /sys/devices/platform/gsensor/driver/cpsopmode
+ chmod 0660 /sys/devices/platform/gsensor/driver/cpsrange
+
+ chown system system /dev/hwmsensor
+ chown system system /dev/msensor
+ chown system system /dev/gsensor
+ chown radio system /dev/als_ps
+ chown system system /dev/gyroscope
+ chown system system /dev/aal_als
+
+ chmod 0660 /sys/class/misc/m_acc_misc/accenablenodata
+ chmod 0660 /sys/class/misc/m_acc_misc/accactive
+ chmod 0660 /sys/class/misc/m_acc_misc/accdelay
+ chmod 0660 /sys/class/misc/m_acc_misc/accbatch
+ chmod 0660 /sys/class/misc/m_acc_misc/accflush
+ chown system system /sys/class/misc/m_acc_misc/accenablenodata
+ chown system system /sys/class/misc/m_acc_misc/accactive
+ chown system system /sys/class/misc/m_acc_misc/accdelay
+ chown system system /sys/class/misc/m_acc_misc/accbatch
+ chown system system /sys/class/misc/m_acc_misc/accflush
+
+ chmod 0660 /sys/class/misc/m_mag_misc/magactive
+ chmod 0660 /sys/class/misc/m_mag_misc/magdelay
+ chmod 0660 /sys/class/misc/m_mag_misc/magbatch
+ chmod 0660 /sys/class/misc/m_mag_misc/magflush
+ chmod 0660 /sys/class/misc/m_mag_misc/magoactive
+ chmod 0660 /sys/class/misc/m_mag_misc/magodelay
+ chmod 0660 /sys/class/misc/m_mag_misc/magobatch
+ chmod 0660 /sys/class/misc/m_mag_misc/magoflush
+ chown system system /sys/class/misc/m_mag_misc/magactive
+ chown system system /sys/class/misc/m_mag_misc/magdelay
+ chown system system /sys/class/misc/m_mag_misc/magbatch
+ chown system system /sys/class/misc/m_mag_misc/magflush
+ chown system system /sys/class/misc/m_mag_misc/magoactive
+ chown system system /sys/class/misc/m_mag_misc/magodelay
+ chown system system /sys/class/misc/m_mag_misc/magobatch
+ chown system system /sys/class/misc/m_mag_misc/magoflush
+ chmod 0660 /sys/class/misc/m_batch_misc/batchactive
+ chmod 0660 /sys/class/misc/m_batch_misc/batchdelay
+ chmod 0660 /sys/class/misc/m_batch_misc/batchbatch
+ chmod 0660 /sys/class/misc/m_batch_misc/batchflush
+ chown system system /sys/class/misc/m_batch_misc/batchactive
+ chown system system /sys/class/misc/m_batch_misc/batchdelay
+ chown system system /sys/class/misc/m_batch_misc/batchbatch
+ chown system system /sys/class/misc/m_batch_misc/batchflush
+
+ chmod 0660 /sys/class/misc/m_gyro_misc/gyroenablenodata
+ chmod 0660 /sys/class/misc/m_gyro_misc/gyroactive
+ chmod 0660 /sys/class/misc/m_gyro_misc/gyrodelay
+ chmod 0660 /sys/class/misc/m_gyro_misc/gyrobatch
+ chmod 0660 /sys/class/misc/m_gyro_misc/gyroflush
+ chown system system /sys/class/misc/m_gyro_misc/gyroenablenodata
+ chown system system /sys/class/misc/m_gyro_misc/gyroactive
+ chown system system /sys/class/misc/m_gyro_misc/gyrodelay
+ chown system system /sys/class/misc/m_gyro_misc/gyrobatch
+ chown system system /sys/class/misc/m_gyro_misc/gyroflush
+
+ chmod 0660 /sys/class/misc/m_alsps_misc/alsactive
+ chmod 0660 /sys/class/misc/m_alsps_misc/alsdelay
+ chmod 0660 /sys/class/misc/m_alsps_misc/alsbatch
+ chmod 0660 /sys/class/misc/m_alsps_misc/alsflush
+ chmod 0660 /sys/class/misc/m_alsps_misc/psactive
+ chmod 0660 /sys/class/misc/m_alsps_misc/psdelay
+ chmod 0660 /sys/class/misc/m_alsps_misc/psbatch
+ chmod 0660 /sys/class/misc/m_alsps_misc/psflush
+ chown system system /sys/class/misc/m_alsps_misc/alsactive
+ chown system system /sys/class/misc/m_alsps_misc/alsdelay
+ chown system system /sys/class/misc/m_alsps_misc/alsbatch
+ chown system system /sys/class/misc/m_alsps_misc/alsflush
+ chown system system /sys/class/misc/m_alsps_misc/psactive
+ chown system system /sys/class/misc/m_alsps_misc/psdelay
+ chown system system /sys/class/misc/m_alsps_misc/psbatch
+ chown system system /sys/class/misc/m_alsps_misc/psflush
+
+ chmod 0660 /sys/class/misc/m_baro_misc/baroenablenodata
+ chmod 0660 /sys/class/misc/m_baro_misc/baroactive
+ chmod 0660 /sys/class/misc/m_baro_misc/barodelay
+ chmod 0660 /sys/class/misc/m_baro_misc/barobatch
+ chmod 0660 /sys/class/misc/m_baro_misc/baroflush
+ chown system system /sys/class/misc/m_baro_misc/baroenablenodata
+ chown system system /sys/class/misc/m_baro_misc/baroactive
+ chown system system /sys/class/misc/m_baro_misc/barodelay
+ chown system system /sys/class/misc/m_baro_misc/barobatch
+ chown system system /sys/class/misc/m_baro_misc/baroflush
+
+
+ mkdir /data/misc/sensors 0664 system system
+ mkdir /data/misc/akmd 0770 system system
+ mkdir /data/acdapi/ 0770 system system
+ chmod 0660 /data/misc/acdapi/calib.dat
+ chmod 0660 /data/misc/acdapi/param.dat
+ chmod 0660 /data/misc/acdapi/sensors.dat
+ chown system /sys/devices/platform/msensor/driver/cpsopmode
+ chown system /sys/devices/platform/msensor/driver/cpsreptxy
+ chown system /sys/devices/platform/msensor/driver/cpsreptz
+
+ chown system system /system/bin/sbchk
+ chmod 0771 /system/bin/sbchk
+
+ # change key_provisioning
+ mkdir /data/key_provisioning
+ chmod 0770 /data/key_provisioning
+ chown system system /data/key_provisioning
+ restorecon /data/key_provisioning
+
+ # encryption flow
+ setprop vold.post_fs_data_done 1
+
+ # Recycle stuffs
+ exec /system/bin/rm -f /cache/.ipoh.img
+ rm /data/logcat.txt
+
+on property:vold.decrypt=trigger_restart_framework
+ start msensord
+ start nvram_daemon
+ start permission_check
+
+#
+#sensor service (begin)
+service msensord /system/bin/msensord
+ class main
+ oneshot
+
+#
+#drm operation server
+service kisd /system/bin/kisd
+ user system
+ group system media drmrpc
+ class main
+
+service nvram_daemon /system/bin/nvram_daemon
+ class main
+ user root
+ group system
+ oneshot
+
+# write proc for test sim
+ on property:gsm.sim.ril.testsim=0
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 0
+ write /proc/sys/net/ipv4/tcp_rto_min 200
+ on property:gsm.sim.ril.testsim=1
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 1
+ write /proc/sys/net/ipv4/tcp_rto_min 400
+ on property:gsm.sim.ril.testsim.2=0
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 0
+ write /proc/sys/net/ipv4/tcp_rto_min 200
+ on property:gsm.sim.ril.testsim.2=1
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 1
+ write /proc/sys/net/ipv4/tcp_rto_min 400
+ on property:gsm.sim.ril.testsim.3=0
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 0
+ write /proc/sys/net/ipv4/tcp_rto_min 200
+ on property:gsm.sim.ril.testsim.3=1
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 1
+ write /proc/sys/net/ipv4/tcp_rto_min 400
+ on property:gsm.sim.ril.testsim.4=0
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 0
+ write /proc/sys/net/ipv4/tcp_rto_min 200
+ on property:gsm.sim.ril.testsim.4=1
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 1
+ write /proc/sys/net/ipv4/tcp_rto_min 400
+service NvRAMAgent /system/bin/nvram_agent_binder
+ user system
+ group system
+
+service akmd8963 /system/bin/akmd8963
+ disabled
+ user system
+ group system
+ oneshot
+
+service akmd09911 /system/bin/akmd09911
+ disabled
+ user system
+ group system
+ class main
+
+service GoogleOtaAgent /system/bin/GoogleOtaBinder
+ class main
+ user system
+ group system
+
+# workaround: disable mtkbt to avoid NE
+service mtkbt /system/bin/mtkbt
+ class late_start
+ socket bt.int.adp dgram 660 bluetooth net_bt
+ socket bt.a2dp.stream dgram 660 bluetooth net_bt
+ user bluetooth
+ group system vpn net_admin inet net_raw net_bt bluetooth net_bt_admin net_bt_stack sdcard_r
+ oneshot
+
+service dhcpcd_bt-pan /system/bin/dhcpcd -BK -dd
+ class main
+ user dhcp
+ group net_admin net_raw
+ disabled
+ oneshot
+
+service dhcpcd_wlan0 /system/bin/dhcpcd -BK -dd
+ class main
+ user dhcp
+ group net_admin net_raw
+ disabled
+ oneshot
+
+service dhcpcd_p2p /system/bin/dhcpcd -BK -dd
+ class main
+ user dhcp
+ group net_admin net_raw
+ disabled
+ oneshot
+
+service iprenew_wlan0 /system/bin/dhcpcd -n
+ class main
+ user dhcp
+ group net_admin net_raw
+ disabled
+ oneshot
+
+service iprenew_p2p /system/bin/dhcpcd -n
+ class main
+ user dhcp
+ group net_admin net_raw
+ disabled
+ oneshot
+
+service dhcp6cDNS_wlan0 /system/bin/dhcp6c -c "/etc/wide-dhcpv6/dhcp6cDNS.conf" -Df wlan0
+ disabled
+ oneshot
+
+service dhcp6c_wlan0 /system/bin/dhcp6c -c "/etc/wide-dhcpv6/dhcp6c.conf" -Df wlan0
+ disabled
+ oneshot
+
+on property:service.dhcp6c_wlan0.enable=0
+ stop dhcp6c_wlan0
+
+on property:service.dhcp6c_wlan0.enable=1
+ start dhcp6c_wlan0
+
+service dhcp6c_PD /system/bin/dhcp6c -c "/etc/wide-dhcpv6/dhcp6cPD.conf" -Df
+ disabled
+ oneshot
+
+#
+#sensor service (end)
+#
+
+#thermal service
+service thermal_manager /system/bin/thermal_manager
+ class main
+ user root
+ disabled
+ oneshot
+
+service thermal /system/bin/thermal
+ class main
+ user system
+ group system
+ disabled
+
+service thermald /system/bin/thermald
+ class main
+ user system
+ group system
+ disabled
+
+service aal /system/bin/aal
+ class core
+ user system
+ group system graphics radio
+
+service pq /system/bin/pq
+ class main
+ user system
+ group system graphics
+ oneshot
+
+# FOTA upgrade
+service rbfota /system/bin/fota1
+ class main
+ disabled
+ oneshot
+
+#
+# MT6620 related services (Begin)
+#
+
+# monitor property and power on/off wlan
+on property:wlan.driver.status=ok
+ write /dev/wmtWifi "1"
+
+on property:wlan.driver.status=unloaded
+ write /dev/wmtWifi "0"
+
+#remove -puse_p2p_group_interface=1, our driver doesnot support this feature
+#
+service p2p_supplicant /system/bin/wpa_supplicant \
+ -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
+ -I/system/etc/wifi/wpa_supplicant_overlay.conf -N \
+ -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf -e/data/misc/wifi/entropy.bin -ddd \
+ -I/system/etc/wifi/p2p_supplicant_overlay.conf \
+ -O/data/misc/wifi/sockets -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 wpa_supplicant /system/bin/wpa_supplicant \
+ -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf -e/data/misc/wifi/entropy.bin -ddd \
+ -I/system/etc/wifi/wpa_supplicant_overlay.conf \
+ -O/data/misc/wifi/sockets -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 ap_daemon /system/bin/wpa_supplicant \
+ -iap0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf -e/data/misc/wifi/entropy.bin -puse_p2p_group_interface=1 -ddd
+ # 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
+ disabled
+ oneshot
+
+service mobile_log_d /system/bin/mobile_log_d
+ class main
+
+service netdiag /system/bin/netdiag
+ class main
+ socket netdiag stream 0660 root inet
+
+#
+# MT6620 related services (End)
+#
+
+## mtk printk uart controller
+on property:persist.uartconsole.enable=1
+ write /proc/mtprintk 1
+
+# Update the second boot logo
+service bootlogoupdater /system/bin/boot_logo_updater
+ class core
+ oneshot
+
+service auto_shutdown /system/bin/sh /auto_shutdown.sh
+ oneshot
+ disabled
+
+service audio-daemon /system/bin/audiocmdservice_atci
+ class main
+ socket atci-audio stream 660 media system
+ user root
+ group media system sdcard_rw
+ disabled
+ oneshot
+
+# OTA update backup partition
+service flash_tee2 /system/etc/install-tee2.sh
+ class main
+ oneshot
+
+# GuiExt Server init
+service guiext-server /system/bin/guiext-server
+ class main
+ user system
+ group system graphics
+
+#Define device for ATCID
+ chmod 660 /dev/ttyGS0
+ chown system /dev/ttyGS0
+ chmod 660 /dev/ttyGS1
+ chown system /dev/ttyGS1
+
+# BT relayer mode used VCOM
+ chmod 0660 /dev/ttyGS2
+ chown bluetooth radio /dev/ttyGS2
+
+service atci_service /system/bin/atci_service
+ class core
+ socket atci-service stream 660 radio system
+ socket atci-serv-fw stream 660 radio system
+ user root
+ disabled
+ group radio system
+ oneshot
+
+service atcid-daemon-u /system/bin/atcid
+ class main
+ user system
+ group radio system media
+ disabled
+ oneshot
+
+service atcid-daemon-e /system/bin/atcid
+ class core
+ user root
+ group radio system
+ disabled
+ oneshot
+
+service sbchk /system/bin/sbchk
+ class main
+ user system
+ group system
+ oneshot
+
+on property:init.svc.servicemanager=restarting
+ restart aal
+ restart pq
+
+on property:init.svc.bootanim=running
+ write /proc/bootprof "BOOT_Animation:START"
+
+on property:init.svc.bootanim=stopped
+ write /proc/bootprof "BOOT_Animation:END"
+ start auto_shutdown
+
+on property:ro.build.type=eng
+ start atci_service
+ start atcid-daemon-e
+
+#emsvr service (start)
+#
+on property:ro.build.type=eng
+ start emsvr
+
+on property:ro.build.type=user
+ start emsvr_user
+
+on property:ro.build.type=userdebug
+ start emsvr_user
+
+service emsvr_user /system/bin/em_svr
+ disabled
+ user system
+ group system radio diag
+
+service emsvr /system/bin/em_svr
+ disabled
+ user root
+
+#
+#emsvr service (end)
+#
+
+
+#
+#ape codec service
+#
+
+service MtkCodecService /system/bin/MtkCodecService
+ class main
+ user system
+ group audio media sdcard_r
+
+#MNLD daemon
+service mnld /system/xbin/mnld
+ class main
+ user gps
+ group gps inet misc sdcard_rw sdcard_r media_rw system
+ socket mnld stream 660 gps system
+
+on boot
+# AGPS
+ mkdir /data/agps_supl 0771 gps system
+
+ ###########add for 3Gdongle
+
+on boot
+#
+# change the right of ip-up ip-down scripts(begin)
+#
+chmod 777 /etc/ppp/ip-up
+chmod 777 /etc/ppp/ip-down
+#
+# change the right of ip-up ip-down scripts(end)
+#
+
+#
+# change the right of ip-up-ppp0 ip-down-ppp0 scripts(begin)
+#
+chmod 777 /etc/ppp/ip-up-ppp0
+chmod 777 /etc/ppp/ip-down-ppp0
+#
+# change the right of ip-up ip-down scripts(end)
+#
+
+#set the property of persiste.radio.reset_on_switch
+setprop persist.radio.reset_on_switch true
+#end
+
+#set the property of rild.mark_switchuser
+setprop rild.mark_switchuser 0
+#end
+
+chmod 0644 /system/lib/libzteevdo-ril.so
+chomd 0644 /system/lib/zterilPara
+chown root /system/bin/pppd
+chmod 4755 /system/bin/pppd
+chown root /system/bin/chat
+chmod 4755 /system/bin/chat
+#[BUGFIX]-ADD-BEGIN by SCDTABLET.(bo.yang@jrdcom.com),03/05/2015,1006752
+chmod 0660 /dev/ebc
+chown root audio /dev/ebc
+#[BUGFIX]-ADD-END by SCDTABLET.(bo.yang@jrdcom.com),05/05/2015,1006752
+
+chmod 0664 /sys/class/leds/lcd-backlight/brightness
+chown system system /sys/class/leds/red/trigger
+chown system system /sys/class/leds/green/trigger
+chown system system /sys/class/leds/blue/trigger
+#
+#ril-daemon (begin)
+#
+service ril-3gddaemon /system/bin/rild_dongle
+ class main
+ socket rild-dongle stream 660 root radio
+ socket rild-dongle-debug stream 660 radio radio
+ user root
+ group radio cache inet misc audio log
+ disabled
+
+#
+#ril-daemon (end)
+#
+
+#
+#usbdongled(begin)
+#
+service usbdongled /system/bin/dongled
+ class main
+ user root
+ group radio cache inet misc
+ enabled
+
+#
+#usbdongled(end)
+#
+
+#
+# add the service for call pppd(begin)
+#
+service zpppd_gprs /system/bin/init.gprs-pppd
+ user root
+ group radio cache inet misc
+ disabled
+ oneshot
+#
+# add the service for call pppd(end)
+#
+
+#
+# ipo
+#
+service ipod /system/bin/ipod
+ user root
+ group root
+ disabled
+
+#
+# swap
+#
+service enableswap /system/bin/sh /enableswap.sh
+ class core
+ oneshot
+ seclabel u:r:enableswap:s0
+
+#monitor battery status
+service batterywarning /system/bin/batterywarning
+ class main
+ user shell
+ group shell
+
+# Logcat
+service logcat_debug /system/bin/logcat -b all -f /data/logcat.txt -v threadtime
+ class main
+ user root
+ group system
--- /dev/null
+on init
+# Workarunod for USB unknow device issue
+# USB would switch correct function when set properity sys.usb.config
+# update usb vid 0E8D to 1BBB by SCDTABLET.(lilin.liu@jrdcom.com), PR1005181 05/18/2015
+ setprop sys.usb.vid 1BBB
+ write /sys/class/android_usb/android0/iSerial $ro.serialno
+ write /sys/class/android_usb/android0/idVendor $sys.usb.vid
+
+on post-fs-data
+ chown system system /sys/class/android_usb/android0/f_mass_storage/lun/file
+ chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file
+ chown system system /sys/class/android_usb/android0/f_rndis/ethaddr
+ chmod 0660 /sys/class/android_usb/android0/f_rndis/ethaddr
+
+ write /sys/class/android_usb/android0/f_rndis/wceis 1
+ write /sys/class/android_usb/android0/f_rndis/manufacturer MediaTek
+ write /sys/class/android_usb/android0/f_rndis/vendorID $sys.usb.vid
+
+# Used to set USB configuration at boot and to switch the configuration
+# when changing the default configuration
+on property:persist.sys.usb.config=*
+ setprop sys.usb.config $persist.sys.usb.config
+
+# Used to disable USB when switching states
+on property:sys.usb.config=none
+ stop adbd
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/bDeviceClass 0
+ setprop sys.usb.state $sys.usb.config
+
+#1.acm
+on property:sys.usb.config=acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2007
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/bDeviceClass 02
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#2.adb
+on property:sys.usb.config=adb
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 201C
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#3.adb,acm
+on property:sys.usb.config=adb,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 200E
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#4.mass_storage
+on property:sys.usb.config=mass_storage
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2002
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#5.mass_storage,adb
+on property:sys.usb.config=mass_storage,adb
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2003
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#6.mtp
+on property:sys.usb.config=mtp
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2008
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#7.mtp,acm
+on property:sys.usb.config=mtp,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2012
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#8.mtp,adb
+on property:sys.usb.config=mtp,adb
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 201D
+ write /sys/class/android_usb/android0/functions mtp,adb
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#9.mtp,adb,acm
+on property:sys.usb.config=mtp,adb,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 200A
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#10.mtp,mass_storage
+on property:sys.usb.config=mtp,mass_storage
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2016
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#11.mtp,mass_storage,adb
+on property:sys.usb.config=mtp,mass_storage,adb
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2017
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#12.ptp
+on property:sys.usb.config=ptp
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 200B
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#13.ptp,acm
+on property:sys.usb.config=ptp,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2013
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#14.ptp,adb
+on property:sys.usb.config=ptp,adb
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 200C
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#15.ptp,adb,acm
+on property:sys.usb.config=ptp,adb,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 200D
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#16.ptp,mass_storage
+on property:sys.usb.config=ptp,mass_storage
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2015
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#17.ptp,mass_storage,adb
+on property:sys.usb.config=ptp,mass_storage,adb
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2014
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#18.rndis
+on property:sys.usb.config=rndis
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2004
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/bDeviceClass 224
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#19.rndis,acm
+on property:sys.usb.config=rndis,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2011
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#20.rndis,adb
+on property:sys.usb.config=rndis,adb
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2005
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#21.rndis,adb,acm
+on property:sys.usb.config=rndis,adb,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2010
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#22.mass_storage,acm
+on property:sys.usb.config=mass_storage,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 200F
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#23.mass_storage,adb,acm
+on property:sys.usb.config=mass_storage,adb,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2006
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#24.mtp,mass_storage,acm
+on property:sys.usb.config=mtp,mass_storage,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2018
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#25.mtp,mass_storage,adb,acm
+on property:sys.usb.config=mtp,mass_storage,adb,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2019
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#26.ptp,mass_storage,acm
+on property:sys.usb.config=ptp,mass_storage,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 201A
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#27.ptp,mass_storage,adb,acm
+on property:sys.usb.config=ptp,mass_storage,adb,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 201B
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+# duplicate of init.usb.rc
+
+#28. USB accessory configuration
+#on property:sys.usb.config=accessory
+# write /sys/class/android_usb/android0/enable 0
+# write /sys/class/android_usb/android0/idVendor 18d1
+# write /sys/class/android_usb/android0/idProduct 2d00
+# write /sys/class/android_usb/android0/functions ${sys.usb.config}
+# write /sys/class/android_usb/android0/enable 1
+# setprop sys.usb.state ${sys.usb.config}
+
+#39. USB accessory configuration, with adb
+#on property:sys.usb.config=accessory,adb
+# write /sys/class/android_usb/android0/enable 0
+# write /sys/class/android_usb/android0/idVendor 18d1
+# write /sys/class/android_usb/android0/idProduct 2d01
+# write /sys/class/android_usb/android0/functions ${sys.usb.config}
+# write /sys/class/android_usb/android0/enable 1
+# start adbd
+# setprop sys.usb.state ${sys.usb.config}
+
+#30. audio accessory configuration
+#on property:sys.usb.config=audio_source
+# write /sys/class/android_usb/android0/enable 0
+# write /sys/class/android_usb/android0/idVendor 18d1
+# write /sys/class/android_usb/android0/idProduct 2d02
+# write /sys/class/android_usb/android0/functions ${sys.usb.config}
+# write /sys/class/android_usb/android0/enable 1
+# setprop sys.usb.state ${sys.usb.config}
+
+#31. audio accessory configuration, with adb
+#on property:sys.usb.config=audio_source,adb
+# write /sys/class/android_usb/android0/enable 0
+# write /sys/class/android_usb/android0/idVendor 18d1
+# write /sys/class/android_usb/android0/idProduct 2d03
+# write /sys/class/android_usb/android0/functions ${sys.usb.config}
+# write /sys/class/android_usb/android0/enable 1
+# start adbd
+# setprop sys.usb.state ${sys.usb.config}
+
+#32. USB and audio accessory configuration
+#on property:sys.usb.config=accessory,audio_source
+# write /sys/class/android_usb/android0/enable 0
+# write /sys/class/android_usb/android0/idVendor 18d1
+# write /sys/class/android_usb/android0/idProduct 2d04
+# write /sys/class/android_usb/android0/functions ${sys.usb.config}
+# write /sys/class/android_usb/android0/enable 1
+# setprop sys.usb.state ${sys.usb.config}
+
+#33. USB and audio accessory configuration, with adb
+#on property:sys.usb.config=accessory,audio_source,adb
+# write /sys/class/android_usb/android0/enable 0
+# write /sys/class/android_usb/android0/idVendor 18d1
+# write /sys/class/android_usb/android0/idProduct 2d05
+# write /sys/class/android_usb/android0/functions ${sys.usb.config}
+# write /sys/class/android_usb/android0/enable 1
+# start adbd
+# setprop sys.usb.state ${sys.usb.config}
+
+#34.USB Charging Only configuration
+on property:sys.usb.config=charging
+ setprop sys.usb.state ${sys.usb.config}
+ setprop sys.usb.charging yes
+
+on property:sys.usb.charging=yes
+ write /sys/devices/platform/mt_usb/cmode 2
+
+on property:sys.usb.charging=no
+ write /sys/devices/platform/mt_usb/cmode 1
+
+#35.USB BICR configuration(mass_storage)
+on property:sys.usb.config=bicr
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2002
+ write /sys/class/android_usb/android0/functions mass_storage
+ write /sys/class/android_usb/android0/f_mass_storage/bicr 1
+ write /sys/class/android_usb/android0/f_mass_storage/lun/file "/dev/block/loop0"
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#36.USB BICR configuration(mass_storage+adb)
+on property:sys.usb.config=bicr,adb
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2003
+ write /sys/class/android_usb/android0/functions mass_storage,adb
+ write /sys/class/android_usb/android0/f_mass_storage/bicr 1
+ write /sys/class/android_usb/android0/f_mass_storage/lun/file "/dev/block/loop0"
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#37.USB BICR configuration(mass_storage+adb+acm)
+on property:sys.usb.config=bicr,adb,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2006
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions mass_storage,adb,acm
+ write /sys/class/android_usb/android0/f_mass_storage/bicr 1
+ write /sys/class/android_usb/android0/f_mass_storage/lun/file "/dev/block/loop0"
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#38.USB BICR configuration(mass_storage+acm)
+on property:sys.usb.config=bicr,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 200F
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions mass_storage,acm
+ write /sys/class/android_usb/android0/f_mass_storage/bicr 1
+ write /sys/class/android_usb/android0/f_mass_storage/lun/file "/dev/block/loop0"
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#39.eem
+on property:sys.usb.config=eem
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2026
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/bDeviceClass 224
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#40.eem,acm
+on property:sys.usb.config=eem,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2027
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state ${sys.usb.config}
+
+#41.eem,adb
+on property:sys.usb.config=eem,adb
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2028
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+#42.eem,adb,acm
+on property:sys.usb.config=eem,adb,acm
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor ${sys.usb.vid}
+ write /sys/class/android_usb/android0/idProduct 2030
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions ${sys.usb.config}
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state ${sys.usb.config}
+
+on property:sys.usb.bicr=yes
+ write /sys/class/android_usb/android0/f_mass_storage/bicr 1
+ write /sys/class/android_usb/android0/f_mass_storage/lun/file "/dev/block/loop0"
+
+on property:sys.usb.bicr=no
+ write /sys/class/android_usb/android0/f_mass_storage/bicr 0
+ write /sys/class/android_usb/android0/f_mass_storage/lun/file "0"
+
+on property:mediatek.usb.port.mode=usb
+ write /sys/devices/platform/mt_usb/portmode 0
+
+on property:mediatek.usb.port.mode=uart
+ write /sys/devices/platform/mt_usb/portmode 1
--- /dev/null
+# MTK project .rc configure
+on post-fs-data
+
+#
+# Connectivity related device nodes & configuration (begin)
+#
+
+#/dev/ttyMT2 for Connectivity BT/FM/GPS usage
+ chmod 0660 /dev/ttyMT2
+ chown system system /dev/ttyMT2
+
+
+# STP, WMT, GPS, FM and BT Driver
+# insmod /system/lib/modules/mtk_hif_sdio.ko
+# insmod /system/lib/modules/mtk_stp_wmt.ko
+# insmod /system/lib/modules/mtk_stp_uart.ko
+# insmod /system/lib/modules/mtk_stp_gps.ko
+# insmod /system/lib/modules/mtk_stp_bt.ko
+# insmod /system/lib/modules/mtk_fm_drv.ko
+# insmod /system/lib/modules/mtk_wmt_wifi.ko
+
+ insmod /system/lib/modules/mtk_wmt_detect.ko
+
+# Create char device file for WMT, GPS, BT, FM, WIFI
+# mknod /dev/stpwmt c 190 0;
+# mknod /dev/stpgps c 191 0;
+# mknod /dev/stpbt c 192 0;
+
+# chmod 0660 /dev/stpwmt
+# chown system system /dev/stpwmt
+#
+# chmod 0660 /dev/wmtdetect
+# chown system system /dev/wmtdetect
+
+ mknod /dev/wmtWifi c 153 0
+ chmod 0660 /dev/wmtWifi
+ chown system system /dev/wmtWifi
+
+# BT
+# chmod 0660 /dev/stpbt
+# chown bluetooth radio /dev/stpbt
+
+# GPS
+# chown gps gps /dev/stpgps
+ chown gps gps /sys/class/gpsdrv/gps/pwrctl
+ chown gps gps /sys/class/gpsdrv/gps/suspend
+ chown gps gps /sys/class/gpsdrv/gps/state
+ chown gps gps /sys/class/gpsdrv/gps/pwrsave
+ chown gps gps /sys/class/gpsdrv/gps/status
+ chmod 0660 /dev/stpgps
+
+# WiFi
+ mkdir /data/misc/wifi 0770 wifi wifi
+ mkdir /data/misc/wifi/sockets 0770 wifi wifi
+ mkdir /data/misc/wpa_supplicant 0770 wifi wifi
+ chown wifi wifi /data/misc/wifi
+
+# FM Radio device node
+ chmod 0660 /dev/fm
+ chown system media /dev/fm
+
+#Disable for one Single loader
+# Load WiFi Driver
+# insmod /system/lib/modules/wlan.ko
+
+# Char device for BT 3.0 HS
+ mknod /dev/ampc0 c 151 0
+ chown bluetooth bluetooth /dev/ampc0
+ chmod 0660 /dev/ampc0
+
+#
+# Connectivity related device nodes & configuration (end)
+
+on boot
+ # Refer to http://source.android.com/devices/tech/storage/index.html
+ # It said, "Starting in Android 4.4, multiple external storage devices are surfaced to developers through
+ # Context.getExternalFilesDirs(), Context.getExternalCacheDirs(), and Context.getObbDirs().
+ # External storage devices surfaced through these APIs must be a semi-permanent part of the device (such as an SD card slot in a battery compartment).
+ # Developers expect data stored in these locations to be available over long periods of time."
+ # Therefore, if the target has the SD card slot in a battery compartment, we need to specify SECONDARY_STORAGE (*** UN-Comment the following command ***)
+ #
+ # export SECONDARY_STORAGE /storage/sdcard1
+
+service fuse_usbotg /system/bin/sdcard -u 1023 -g 1023 -w 1023 -d /mnt/media_rw/usbotg /storage/usbotg
+ class late_start
+ disabled
+
+#
+# Connectivity related services (Begin)
+#
+
+service wmtLoader /system/bin/wmt_loader
+ user root
+ group root
+ class main
+ oneshot
+
+
+service conn_launcher /system/bin/6620_launcher -p /system/etc/firmware/
+ user system
+ group system
+ class core
+#
+# Connectivity related services (End)
+#
+#[FEATURE]-Add-BEGIN by SCDTABLET.(meiqin),03/27/2015,928381,show version
+service getver /system/bin/logwrapper /system/bin/getver
+ class late_start
+ user root
+ group root
+ oneshot
+on property:sys.tct.curef=*
+ setprop ro.tct.curef ${sys.tct.curef}
+#[FEATURE]-Add-END by SCDTABLET.(meiqin)
--- /dev/null
+
+#connectivity related init script
+#import init.project.rc
+#import init.connectivity.rc
+import init.charging.rc
+#import init.mt8127usb.rc
+#import init.aee.rc
+#import init.ssd.rc
+#import init.no_ssd.rc
+#import init.ssd_nomuser.rc
+
+on init
+ export USBOTG_STORAGE /storage/usbotg
+ mount tmpfs tmpfs /mnt/media_rw/ mode=0755,uid=1000,gid=1000
+ mkdir /mnt/media_rw/usbotg 0700 media_rw media_rw
+ mkdir /storage/usbotg 0700 root root
+ mount tmpfs tmpfs /storage/usbotg mode=0755,uid=1000,gid=1000
+
+# Backward compatibility
+ symlink /system/etc /etc
+ symlink /sys/kernel/debug /d
+
+# Right now vendor lives on the same filesystem as system,
+# but someday that may change.
+ symlink /system/vendor /vendor
+
+# Create cgroup mount point for cpu accounting
+ mkdir /acct
+ mount cgroup none /acct cpuacct
+ mkdir /acct/uid
+
+
+ mkdir /system
+ mkdir /data 0771 system system
+ mkdir /cache 0770 system cache
+ mkdir /config 0500 root root
+
+ mkdir /mnt/cd-rom 0000 system system
+
+ # Directory for putting things only root should see.
+ mkdir /mnt/secure 0700 root root
+ # Create private mountpoint so we can MS_MOVE from staging
+ mount tmpfs tmpfs /mnt/secure mode=0700,uid=0,gid=0
+
+ # Directory for staging bindmounts
+ mkdir /mnt/secure/staging 0700 root root
+
+ # Directory-target for where the secure container
+ # imagefile directory will be bind-mounted
+ mkdir /mnt/secure/asec 0700 root root
+
+ # Secure container public mount points.
+ mkdir /mnt/asec 0700 root system
+ mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
+
+ # Filesystem image public mount points.
+ mkdir /mnt/obb 0700 root system
+ mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000
+
+ write /proc/sys/kernel/panic_on_oops 1
+ write /proc/sys/kernel/hung_task_timeout_secs 0
+ write /proc/cpu/alignment 4
+ write /proc/sys/kernel/sched_latency_ns 10000000
+ write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
+ write /proc/sys/kernel/sched_compat_yield 1
+ write /proc/sys/kernel/sched_child_runs_first 0
+ write /proc/sys/kernel/randomize_va_space 2
+ write /proc/sys/kernel/kptr_restrict 2
+ write /proc/sys/kernel/dmesg_restrict 1
+ write /proc/sys/vm/mmap_min_addr 32768
+ write /proc/sys/net/ipv4/ping_group_range "0 2147483647"
+ write /proc/sys/kernel/sched_rt_runtime_us 950000
+ write /proc/sys/kernel/sched_rt_period_us 1000000
+
+
+# Allow everybody to read the xt_qtaguid resource tracking misc dev.
+# This is needed by any process that uses socket tagging.
+ chmod 0644 /dev/xt_qtaguid
+
+#HWComposer fb0
+ chmod 0666 /dev/graphics/fb0
+ chown system graphics /dev/graphics/fb0
+
+#HWComposer Vsync
+ chmod 0666 /dev/mtkfb_vsync
+ chown system graphics /dev/mtkfb_vsync
+
+
+#HWComposer fence
+ chmod 0666 /dev/sw_sync
+ chown system graphics /dev/sw_sync
+
+# Change ION driver permission
+ chmod 0666 /dev/ion
+
+# Change BWC permission
+ chmod 0664 /sys/bus/platform/drivers/mem_bw_ctrl/concurrency_scenario
+ chown system media /sys/bus/platform/drivers/mem_bw_ctrl/concurrency_scenario
+
+# Change M4U driver permission
+# chmod 0444 /dev/M4U_device
+
+# Change SMI driver permission
+ chmod 0660 /dev/MTK_SMI
+ chown system media /dev/MTK_SMI
+
+ #Use uinput's default permission
+ chown system net_bt_admin /dev/uinput
+
+# Change SMI mtk_sched permission
+ chmod 0660 /dev/mtk_sched
+ chown system media /dev/mtk_sched
+
+# Change DISP permission
+ chmod 0666 /dev/mtk_disp
+ chown system system /dev/mtk_disp
+
+# Change Camera permission
+ chmod 0660 /dev/camera-sysram
+ chmod 0660 /dev/camera-isp
+ chmod 0660 /dev/camera-pipemgr
+ chmod 0660 /dev/kd_camera_hw
+ chmod 0660 /dev/kd_camera_flashlight
+ chmod 0660 /dev/kd_camera_hw_bus2
+ chmod 0660 /dev/FM50AF
+ chmod 0660 /dev/CAM_CAL_DRV
+
+ chown system camera /dev/camera-sysram
+ chown system camera /dev/camera-isp
+ chown system camera /dev/camera-pipemgr
+ chown system camera /dev/kd_camera_hw
+ chown system camera /dev/kd_camera_flashlight
+ chown system camera /dev/kd_camera_hw_bus2
+ chown system camera /dev/FM50AF
+ chown system camera /dev/CAM_CAL_DRV
+
+# Change OVL permission
+ chmod 0440 /dev/mtk_ovl
+ chown system system /dev/mtk_ovl
+
+# Change Jpeg permission
+ # chmod 0444 /dev/mtk_jpeg
+ # chmod 0444 /dev/mtk_gdma
+ # chmod 0444 /dev/mtk_gfmt
+ chmod 0440 /dev/mtk_almk
+
+# otg_test
+ chown root radio /dev/mt_otg_test
+ chmod 0660 /dev/mt_otg_test
+
+# Enable AAL
+ setprop ro.mediatek.aal 1
+
+ # mount debugfs for ftrace
+ mount debugfs none /sys/kernel/debug
+
+ # change owner
+ chown system system /proc/bootprof
+ chown root system /proc/mtprof/cputime
+ chown root system /proc/mtprof/reboot_pid
+
+on boot
+# start sensor services
+# start akmd8963
+
+# start nvram
+start NvRAMAgent
+
+ chown system system /sys/devices/system/cpu/cpufreq/hotplug/cpu_num_base
+ chmod 0660 /sys/devices/system/cpu/cpufreq/hotplug/cpu_num_base
+
+on fs
+
+# export EXTERNAL_STORAGE /mnt/sdcard
+# mkdir /mnt/sdcard 0000 system system
+# symlink /mnt/sdcard /sdcard
+
+
+# mount mtd partitions
+ # Mount /system rw first to give the filesystem a chance to save a checkpoint
+ #write /proc/bootprof "INIT:NAND:Mount_START"
+ #mount yaffs2 mtd@system /system
+
+# via: set ril and pppd
+ #chown root /system/bin/pppd
+ #chmod 4755 /system/bin/pppd
+ #chown root /system/etc/ppp/ip-up-cdma
+ #chmod 4755 /system/et/ppp/ip-up-cdma
+ #chown root /system/etc/ppp/ipv6-up-cdma
+ #chmod 4755 /system/etc/ppp/ipv6-up-cdma
+ #chown root /system/etc/ppp/link-down-cdma
+ #chmod 4755 /system/etc/ppp/link-down-cdma
+ #mount yaffs2 mtd@system /system ro remount
+ #mount yaffs2 mtd@userdata /data nosuid nodev
+ #mount yaffs2 mtd@cache /cache nosuid nodev
+ #write /proc/bootprof "INIT:NAND:Mount_END"
+
+#on fs_property:ro.mount.fs=EXT4
+ write /proc/bootprof "INIT:eMMC:Mount_START"
+ mount_all /fstab.mt8127
+ write /proc/bootprof "INIT:eMMC:Mount_END"
+ mount iso9660 loop@/system/etc/iAmCdRom.iso /mnt/cd-rom ro
+
+ #change partition permission
+ exec /system/etc/partition_permission.sh
+
+# RGX init
+service pvrsrvctl /system/vendor/bin/pvrsrvctl --start
+ class core
+ user root
+ group root
+ oneshot
+
+on post-fs-data
+ mkdir /data/nvram 2770 root system
+ mkdir /data/media 0770 media_rw media_rw
+ chmod 0660 /data/misc/wifi/p2p_supplicant.conf
+
+
+# dhcp server
+ mkdir /data/misc/dhcp 0770 dhcp wifi
+ chown dhcp wifi /data/misc/dhcp
+
+# dhcpv6 server
+ mkdir /data/misc/wide-dhcpv6 0770 dhcp wifi
+ chown dhcp wifi /data/misc/wide-dhcpv6
+
+ # GPS
+ mkdir /data/gps_mnl 0771 gps system
+
+ # remove /data/system/wpa_supplicant which was created in meta mode of JB version,
+ # wlan will be not able to enabled if this directory exists in L version.
+ rmdir /data/system/wpa_supplicant
+
+ # for ppp options file
+ mkdir /data/misc/ppp 0770 bluetooth net_bt
+ # bluetooth
+ mkdir /data/@btmtk 0770 bluetooth net_bt
+ chown bluetooth bluetooth /dev/hid-keyboard
+ chmod 0660 /dev/hid-keyboard
+
+ # NFC
+ mkdir /data/nfc_socket 0771 nfc radio
+
+#VideoCodec
+ insmod /system/lib/modules/vcodec_kernel_driver.ko
+
+# JPEG
+ chmod 0440 /dev/mtk_jpeg
+ chown system camera /dev/mtk_jpeg
+
+# UIBC
+ chown system media /dev/uibc
+ chmod 0660 /dev/uibc
+
+#HDMI
+ chmod 0664 /dev/hdmitx
+
+# Sensor
+ chmod 0660 /dev/hwmsensor
+ chmod 0660 /dev/msensor
+ chmod 0660 /dev/gsensor
+ chmod 0660 /dev/als_ps
+ chmod 0660 /dev/gyroscope
+ chmod 0660 /dev/aal_als
+
+ chmod 0660 /sys/devices/platform/msensor/driver/cpsopmode
+ chmod 0660 /sys/devices/platform/msensor/driver/cpsreptxy
+ chmod 0660 /sys/devices/platform/msensor/driver/cpsreptz
+ chmod 0660 /sys/devices/platform/gsensor/driver/cpsopmode
+ chmod 0660 /sys/devices/platform/gsensor/driver/cpsrange
+
+ chown system system /dev/hwmsensor
+ chown system system /dev/msensor
+ chown system system /dev/gsensor
+ chown radio system /dev/als_ps
+ chown system system /dev/gyroscope
+ chown system system /dev/aal_als
+
+ chmod 0660 /sys/class/misc/m_acc_misc/accenablenodata
+ chmod 0660 /sys/class/misc/m_acc_misc/accactive
+ chmod 0660 /sys/class/misc/m_acc_misc/accdelay
+ chmod 0660 /sys/class/misc/m_acc_misc/accbatch
+ chmod 0660 /sys/class/misc/m_acc_misc/accflush
+ chown system system /sys/class/misc/m_acc_misc/accenablenodata
+ chown system system /sys/class/misc/m_acc_misc/accactive
+ chown system system /sys/class/misc/m_acc_misc/accdelay
+ chown system system /sys/class/misc/m_acc_misc/accbatch
+ chown system system /sys/class/misc/m_acc_misc/accflush
+
+ chmod 0660 /sys/class/misc/m_mag_misc/magactive
+ chmod 0660 /sys/class/misc/m_mag_misc/magdelay
+ chmod 0660 /sys/class/misc/m_mag_misc/magbatch
+ chmod 0660 /sys/class/misc/m_mag_misc/magflush
+ chmod 0660 /sys/class/misc/m_mag_misc/magoactive
+ chmod 0660 /sys/class/misc/m_mag_misc/magodelay
+ chmod 0660 /sys/class/misc/m_mag_misc/magobatch
+ chmod 0660 /sys/class/misc/m_mag_misc/magoflush
+ chown system system /sys/class/misc/m_mag_misc/magactive
+ chown system system /sys/class/misc/m_mag_misc/magdelay
+ chown system system /sys/class/misc/m_mag_misc/magbatch
+ chown system system /sys/class/misc/m_mag_misc/magflush
+ chown system system /sys/class/misc/m_mag_misc/magoactive
+ chown system system /sys/class/misc/m_mag_misc/magodelay
+ chown system system /sys/class/misc/m_mag_misc/magobatch
+ chown system system /sys/class/misc/m_mag_misc/magoflush
+ chmod 0660 /sys/class/misc/m_batch_misc/batchactive
+ chmod 0660 /sys/class/misc/m_batch_misc/batchdelay
+ chmod 0660 /sys/class/misc/m_batch_misc/batchbatch
+ chmod 0660 /sys/class/misc/m_batch_misc/batchflush
+ chown system system /sys/class/misc/m_batch_misc/batchactive
+ chown system system /sys/class/misc/m_batch_misc/batchdelay
+ chown system system /sys/class/misc/m_batch_misc/batchbatch
+ chown system system /sys/class/misc/m_batch_misc/batchflush
+
+ chmod 0660 /sys/class/misc/m_gyro_misc/gyroenablenodata
+ chmod 0660 /sys/class/misc/m_gyro_misc/gyroactive
+ chmod 0660 /sys/class/misc/m_gyro_misc/gyrodelay
+ chmod 0660 /sys/class/misc/m_gyro_misc/gyrobatch
+ chmod 0660 /sys/class/misc/m_gyro_misc/gyroflush
+ chown system system /sys/class/misc/m_gyro_misc/gyroenablenodata
+ chown system system /sys/class/misc/m_gyro_misc/gyroactive
+ chown system system /sys/class/misc/m_gyro_misc/gyrodelay
+ chown system system /sys/class/misc/m_gyro_misc/gyrobatch
+ chown system system /sys/class/misc/m_gyro_misc/gyroflush
+
+ chmod 0660 /sys/class/misc/m_alsps_misc/alsactive
+ chmod 0660 /sys/class/misc/m_alsps_misc/alsdelay
+ chmod 0660 /sys/class/misc/m_alsps_misc/alsbatch
+ chmod 0660 /sys/class/misc/m_alsps_misc/alsflush
+ chmod 0660 /sys/class/misc/m_alsps_misc/psactive
+ chmod 0660 /sys/class/misc/m_alsps_misc/psdelay
+ chmod 0660 /sys/class/misc/m_alsps_misc/psbatch
+ chmod 0660 /sys/class/misc/m_alsps_misc/psflush
+ chown system system /sys/class/misc/m_alsps_misc/alsactive
+ chown system system /sys/class/misc/m_alsps_misc/alsdelay
+ chown system system /sys/class/misc/m_alsps_misc/alsbatch
+ chown system system /sys/class/misc/m_alsps_misc/alsflush
+ chown system system /sys/class/misc/m_alsps_misc/psactive
+ chown system system /sys/class/misc/m_alsps_misc/psdelay
+ chown system system /sys/class/misc/m_alsps_misc/psbatch
+ chown system system /sys/class/misc/m_alsps_misc/psflush
+
+ chmod 0660 /sys/class/misc/m_baro_misc/baroenablenodata
+ chmod 0660 /sys/class/misc/m_baro_misc/baroactive
+ chmod 0660 /sys/class/misc/m_baro_misc/barodelay
+ chmod 0660 /sys/class/misc/m_baro_misc/barobatch
+ chmod 0660 /sys/class/misc/m_baro_misc/baroflush
+ chown system system /sys/class/misc/m_baro_misc/baroenablenodata
+ chown system system /sys/class/misc/m_baro_misc/baroactive
+ chown system system /sys/class/misc/m_baro_misc/barodelay
+ chown system system /sys/class/misc/m_baro_misc/barobatch
+ chown system system /sys/class/misc/m_baro_misc/baroflush
+
+
+ mkdir /data/misc/sensors 0664 system system
+ mkdir /data/misc/akmd 0770 system system
+ mkdir /data/acdapi/ 0770 system system
+ chmod 0660 /data/misc/acdapi/calib.dat
+ chmod 0660 /data/misc/acdapi/param.dat
+ chmod 0660 /data/misc/acdapi/sensors.dat
+ chown system /sys/devices/platform/msensor/driver/cpsopmode
+ chown system /sys/devices/platform/msensor/driver/cpsreptxy
+ chown system /sys/devices/platform/msensor/driver/cpsreptz
+
+ chown system system /system/bin/sbchk
+ chmod 0771 /system/bin/sbchk
+
+ # change key_provisioning
+ mkdir /data/key_provisioning
+ chmod 0770 /data/key_provisioning
+ chown system system /data/key_provisioning
+ restorecon /data/key_provisioning
+
+ # encryption flow
+ setprop vold.post_fs_data_done 1
+
+ # Recycle stuffs
+ exec /system/bin/rm -f /cache/.ipoh.img
+
+on property:vold.decrypt=trigger_restart_framework
+ start msensord
+ start nvram_daemon
+ start permission_check
+
+#
+#sensor service (begin)
+service msensord /system/bin/msensord
+ class main
+ oneshot
+
+#
+#drm operation server
+service kisd /system/bin/kisd
+ class main
+
+service nvram_daemon /system/bin/nvram_daemon
+ class main
+ user root
+ group system
+ oneshot
+
+# write proc for test sim
+ on property:gsm.sim.ril.testsim=0
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 0
+ write /proc/sys/net/ipv4/tcp_rto_min 200
+ on property:gsm.sim.ril.testsim=1
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 1
+ write /proc/sys/net/ipv4/tcp_rto_min 400
+ on property:gsm.sim.ril.testsim.2=0
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 0
+ write /proc/sys/net/ipv4/tcp_rto_min 200
+ on property:gsm.sim.ril.testsim.2=1
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 1
+ write /proc/sys/net/ipv4/tcp_rto_min 400
+ on property:gsm.sim.ril.testsim.3=0
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 0
+ write /proc/sys/net/ipv4/tcp_rto_min 200
+ on property:gsm.sim.ril.testsim.3=1
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 1
+ write /proc/sys/net/ipv4/tcp_rto_min 400
+ on property:gsm.sim.ril.testsim.4=0
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 0
+ write /proc/sys/net/ipv4/tcp_rto_min 200
+ on property:gsm.sim.ril.testsim.4=1
+ write /proc/sys/net/netfilter/nf_conntrack_tcp_no_window_check 1
+ write /proc/sys/net/ipv4/tcp_rto_min 400
+service NvRAMAgent /system/bin/nvram_agent_binder
+ user system
+ group system
+
+service akmd8963 /system/bin/akmd8963
+ disabled
+ user system
+ group system
+ oneshot
+
+service akmd09911 /system/bin/akmd09911
+ disabled
+ user system
+ group system
+ class main
+
+service GoogleOtaAgent /system/bin/GoogleOtaBinder
+ class main
+ user system
+ group system
+
+# workaround: disable mtkbt to avoid NE
+service mtkbt /system/bin/mtkbt
+ class late_start
+ socket bt.int.adp dgram 660 bluetooth net_bt
+ socket bt.a2dp.stream dgram 660 bluetooth net_bt
+ user bluetooth
+ group system vpn net_admin inet net_raw net_bt bluetooth net_bt_admin net_bt_stack sdcard_r
+ oneshot
+
+service dhcpcd_bt-pan /system/bin/dhcpcd -BK -dd
+ class main
+ user dhcp
+ group net_admin net_raw
+ disabled
+ oneshot
+
+service dhcpcd_wlan0 /system/bin/dhcpcd -BK -dd
+ class main
+ user dhcp
+ group net_admin net_raw
+ disabled
+ oneshot
+
+service dhcpcd_p2p /system/bin/dhcpcd -BK -dd
+ class main
+ user dhcp
+ group net_admin net_raw
+ disabled
+ oneshot
+
+service iprenew_wlan0 /system/bin/dhcpcd -n
+ class main
+ user dhcp
+ group net_admin net_raw
+ disabled
+ oneshot
+
+service iprenew_p2p /system/bin/dhcpcd -n
+ class main
+ user dhcp
+ group net_admin net_raw
+ disabled
+ oneshot
+
+service dhcp6cDNS_wlan0 /system/bin/dhcp6c -c "/etc/wide-dhcpv6/dhcp6cDNS.conf" -Df wlan0
+ disabled
+ oneshot
+
+service dhcp6c_wlan0 /system/bin/dhcp6c -c "/etc/wide-dhcpv6/dhcp6c.conf" -Df wlan0
+ disabled
+ oneshot
+
+on property:service.dhcp6c_wlan0.enable=0
+ stop dhcp6c_wlan0
+
+on property:service.dhcp6c_wlan0.enable=1
+ start dhcp6c_wlan0
+
+service dhcp6c_PD /system/bin/dhcp6c -c "/etc/wide-dhcpv6/dhcp6cPD.conf" -Df
+ disabled
+ oneshot
+
+#
+#sensor service (end)
+#
+
+#thermal service
+service thermal_manager /system/bin/thermal_manager
+ class main
+ user root
+ oneshot
+
+service thermal /system/bin/thermal
+ class main
+ user system
+ group system
+
+service thermald /system/bin/thermald
+ class main
+ user system
+ group system
+
+service aal /system/bin/aal
+ class core
+ user system
+ group system graphics radio
+
+service pq /system/bin/pq
+ class main
+ user system
+ group system graphics
+ oneshot
+
+# FOTA upgrade
+service rbfota /system/bin/fota1
+ class main
+ disabled
+ oneshot
+
+#
+# MT6620 related services (Begin)
+#
+
+# monitor property and power on/off wlan
+on property:wlan.driver.status=ok
+ write /dev/wmtWifi "1"
+
+on property:wlan.driver.status=unloaded
+ write /dev/wmtWifi "0"
+
+#remove -puse_p2p_group_interface=1, our driver doesnot support this feature
+#
+service p2p_supplicant /system/bin/wpa_supplicant \
+ -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
+ -I/system/etc/wifi/wpa_supplicant_overlay.conf -N \
+ -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf -e/data/misc/wifi/entropy.bin -ddd \
+ -I/system/etc/wifi/p2p_supplicant_overlay.conf \
+ -O/data/misc/wifi/sockets -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 wpa_supplicant /system/bin/wpa_supplicant \
+ -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf -e/data/misc/wifi/entropy.bin -ddd \
+ -I/system/etc/wifi/wpa_supplicant_overlay.conf \
+ -O/data/misc/wifi/sockets -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 ap_daemon /system/bin/wpa_supplicant \
+ -iap0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf -e/data/misc/wifi/entropy.bin -puse_p2p_group_interface=1 -ddd
+ # 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
+ disabled
+ oneshot
+
+service mobile_log_d /system/bin/mobile_log_d
+ class main
+
+service netdiag /system/bin/netdiag
+ class main
+ socket netdiag stream 0660 root inet
+
+#
+# MT6620 related services (End)
+#
+
+## mtk printk uart controller
+on property:persist.uartconsole.enable=1
+ write /proc/mtprintk 1
+
+# Update the second boot logo
+service bootlogoupdater /system/bin/boot_logo_updater
+ class core
+ oneshot
+
+service auto_shutdown /system/bin/sh /auto_shutdown.sh
+ oneshot
+ disabled
+
+service audio-daemon /system/bin/audiocmdservice_atci
+ class main
+ socket atci-audio stream 660 media system
+ user root
+ group media system sdcard_rw
+ disabled
+ oneshot
+
+# OTA update backup partition
+service flash_tee2 /system/etc/install-tee2.sh
+ class main
+ oneshot
+
+# GuiExt Server init
+service guiext-server /system/bin/guiext-server
+ class main
+ user system
+ group system graphics
+
+#Define device for ATCID
+ chmod 660 /dev/ttyGS0
+ chown system /dev/ttyGS0
+ chmod 660 /dev/ttyGS1
+ chown system /dev/ttyGS1
+
+service atci_service /system/bin/atci_service
+ class core
+ socket atci-service stream 660 radio system
+ socket atci-serv-fw stream 660 radio system
+ user root
+ disabled
+ group radio system
+ oneshot
+
+service atcid-daemon-u /system/bin/atcid
+ class main
+ user system
+ group radio system media
+ disabled
+ oneshot
+
+service atcid-daemon-e /system/bin/atcid
+ class core
+ user root
+ group radio system
+ disabled
+ oneshot
+
+service sbchk /system/bin/sbchk
+ class main
+ user system
+ group system
+ oneshot
+
+on property:init.svc.servicemanager=restarting
+ restart aal
+ restart pq
+
+on property:init.svc.bootanim=running
+ write /proc/bootprof "BOOT_Animation:START"
+
+on property:init.svc.bootanim=stopped
+ write /proc/bootprof "BOOT_Animation:END"
+ start auto_shutdown
+
+on property:ro.build.type=eng
+ start atci_service
+ start atcid-daemon-e
+
+#emsvr service (start)
+#
+on property:ro.build.type=eng
+ start emsvr
+
+on property:ro.build.type=user
+ start emsvr_user
+
+on property:ro.build.type=userdebug
+ start emsvr_user
+
+service emsvr_user /system/bin/em_svr
+ disabled
+ user system
+ group system radio diag
+
+service emsvr /system/bin/em_svr
+ disabled
+ user root
+
+#
+#emsvr service (end)
+#
+
+
+#
+#ape codec service
+#
+
+service MtkCodecService /system/bin/MtkCodecService
+ class main
+ user system
+ group audio media sdcard_r
+
+#MNLD daemon
+service mnld /system/xbin/mnld
+ class main
+ user gps
+ group system gps inet misc sdcard_rw sdcard_r media_rw
+ socket mnld stream 660 gps system
+
+on boot
+# AGPS
+ mkdir /data/agps_supl 0771 gps system
+
+ ###########add for 3Gdongle
+
+on boot
+#
+# change the right of ip-up ip-down scripts(begin)
+#
+chmod 777 /etc/ppp/ip-up
+chmod 777 /etc/ppp/ip-down
+#
+# change the right of ip-up ip-down scripts(end)
+#
+
+#
+# change the right of ip-up-ppp0 ip-down-ppp0 scripts(begin)
+#
+chmod 777 /etc/ppp/ip-up-ppp0
+chmod 777 /etc/ppp/ip-down-ppp0
+#
+# change the right of ip-up ip-down scripts(end)
+#
+
+#set the property of persiste.radio.reset_on_switch
+setprop persist.radio.reset_on_switch true
+#end
+
+#set the property of rild.mark_switchuser
+setprop rild.mark_switchuser 0
+#end
+
+chmod 0644 /system/lib/libzteevdo-ril.so
+chomd 0644 /system/lib/zterilPara
+chown root /system/bin/pppd
+chmod 4755 /system/bin/pppd
+chown root /system/bin/chat
+chmod 4755 /system/bin/chat
+
+chmod 0664 /sys/class/leds/lcd-backlight/brightness
+chown system system /sys/class/leds/red/trigger
+chown system system /sys/class/leds/green/trigger
+chown system system /sys/class/leds/blue/trigger
+#
+#ril-daemon (begin)
+#
+service ril-3gddaemon /system/bin/rild_dongle
+ class main
+ socket rild-dongle stream 660 root radio
+ socket rild-dongle-debug stream 660 radio radio
+ user root
+ group radio cache inet misc audio log
+ disabled
+
+#
+#ril-daemon (end)
+#
+
+#
+#usbdongled(begin)
+#
+service usbdongled /system/bin/dongled
+ class main
+ user root
+ group radio cache inet misc
+ enabled
+
+#
+#usbdongled(end)
+#
+
+#
+# add the service for call pppd(begin)
+#
+service zpppd_gprs /system/bin/init.gprs-pppd
+ user root
+ group radio cache inet misc
+ disabled
+ oneshot
+#
+# add the service for call pppd(end)
+#
+
+#
+# ipo
+#
+service ipod /system/bin/ipod
+ user root
+ group root
+ disabled
+
+#
+# swap
+#
+service enableswap /system/bin/sh /enableswap.sh
+ class core
+ oneshot
+ seclabel u:r:enableswap:s0
+
+#monitor battery status
+service batterywarning /system/bin/batterywarning
+ class main
+ user shell
+ group shell
--- /dev/null
+# Copyright (C) 2012 The Android Open Source Project
+#
+# IMPORTANT: Do not create world writable files or directories.
+# This is a common source of Android security bugs.
+#
+
+#import /init.environ.rc
+#import /init.usb.rc
+import /init.tct.${ro.hardware}.rc
+#import /init.${ro.zygote}.rc
+#import /init.trace.rc
+
+on early-init
+ # Set init and its forked children's oom_adj.
+ write /proc/1/oom_score_adj -1000
+
+ # Apply strict SELinux checking of PROT_EXEC on mmap/mprotect calls.
+ #write /sys/fs/selinux/checkreqprot 0
+
+ # Set the security context for the init process.
+ # This should occur before anything else (e.g. ueventd) is started.
+ setcon u:r:init:s0
+
+ # Set the security context of /adb_keys if present.
+ restorecon /adb_keys
+
+ start ueventd
+
+ # create mountpoints
+ mkdir /mnt 0775 root system
+
+on init
+ sysclktz 0
+
+loglevel 6 ####
+ write /proc/bootprof "INIT: on init start" ####
+
+ # Backward compatibility
+ symlink /system/etc /etc
+ symlink /sys/kernel/debug /d
+
+ # Right now vendor lives on the same filesystem as system,
+ # but someday that may change.
+ symlink /system/vendor /vendor
+
+ # Create cgroup mount point for cpu accounting
+ mkdir /acct
+ mount cgroup none /acct cpuacct
+ mkdir /acct/uid
+
+ # Create cgroup mount point for memory
+ mount tmpfs none /sys/fs/cgroup mode=0750,uid=0,gid=1000
+ mkdir /sys/fs/cgroup/memory 0750 root system
+ mount cgroup none /sys/fs/cgroup/memory memory
+ write /sys/fs/cgroup/memory/memory.move_charge_at_immigrate 1
+ chown root system /sys/fs/cgroup/memory/tasks
+ chmod 0660 /sys/fs/cgroup/memory/tasks
+ mkdir /sys/fs/cgroup/memory/sw 0750 root system
+ write /sys/fs/cgroup/memory/sw/memory.swappiness 100
+ write /sys/fs/cgroup/memory/sw/memory.move_charge_at_immigrate 1
+ chown root system /sys/fs/cgroup/memory/sw/tasks
+ chmod 0660 /sys/fs/cgroup/memory/sw/tasks
+
+ ##bsp config enable
+ write /sys/class/misc/tp_cfg/cfg_load_enable 1
+
+ mkdir /system
+ mkdir /data 0771 system system
+ mkdir /cache 0770 system cache
+ mkdir /config 0500 root root
+
+ # See storage config details at http://source.android.com/tech/storage/
+ mkdir /mnt/shell 0700 shell shell
+ mkdir /mnt/media_rw 0700 media_rw media_rw
+ mkdir /storage 0751 root sdcard_r
+
+ # Directory for putting things only root should see.
+ mkdir /mnt/secure 0700 root root
+
+ # Directory for staging bindmounts
+ mkdir /mnt/secure/staging 0700 root root
+
+ # Directory-target for where the secure container
+ # imagefile directory will be bind-mounted
+ mkdir /mnt/secure/asec 0700 root root
+
+ # Secure container public mount points.
+ mkdir /mnt/asec 0700 root system
+ mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
+
+ # Filesystem image public mount points.
+ mkdir /mnt/obb 0700 root system
+ mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000
+
+ # memory control cgroup
+ mkdir /dev/memcg 0700 root system
+ mount cgroup none /dev/memcg memory
+
+ write /proc/sys/kernel/panic_on_oops 1
+ write /proc/sys/kernel/hung_task_timeout_secs 0
+ write /proc/cpu/alignment 4
+ write /proc/sys/kernel/sched_latency_ns 10000000
+ write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
+ write /proc/sys/kernel/sched_compat_yield 1
+ write /proc/sys/kernel/sched_child_runs_first 0
+ write /proc/sys/kernel/randomize_va_space 2
+ write /proc/sys/kernel/kptr_restrict 2
+ write /proc/sys/vm/mmap_min_addr 32768
+ write /proc/sys/net/ipv4/ping_group_range "0 2147483647"
+ write /proc/sys/net/unix/max_dgram_qlen 300
+ write /proc/sys/kernel/sched_rt_runtime_us 950000
+ write /proc/sys/kernel/sched_rt_period_us 1000000
+
+ # reflect fwmark from incoming packets onto generated replies
+ write /proc/sys/net/ipv4/fwmark_reflect 1
+ write /proc/sys/net/ipv6/fwmark_reflect 1
+
+ # set fwmark on accepted sockets
+ write /proc/sys/net/ipv4/tcp_fwmark_accept 1
+
+ # Create cgroup mount points for process groups
+ mkdir /dev/cpuctl
+ mount cgroup none /dev/cpuctl cpu
+ chown system system /dev/cpuctl
+ chown system system /dev/cpuctl/tasks
+ chmod 0660 /dev/cpuctl/tasks
+ write /dev/cpuctl/cpu.shares 1024
+ write /dev/cpuctl/cpu.rt_runtime_us 950000
+ write /dev/cpuctl/cpu.rt_period_us 1000000
+
+ mkdir /dev/cpuctl/apps
+ chown system system /dev/cpuctl/apps/tasks
+ chmod 0666 /dev/cpuctl/apps/tasks
+ write /dev/cpuctl/apps/cpu.shares 1024
+ write /dev/cpuctl/apps/cpu.rt_runtime_us 800000
+ write /dev/cpuctl/apps/cpu.rt_period_us 1000000
+
+ mkdir /dev/cpuctl/apps/bg_non_interactive
+ chown system system /dev/cpuctl/apps/bg_non_interactive/tasks
+ chmod 0666 /dev/cpuctl/apps/bg_non_interactive/tasks
+ # 5.0 %
+ write /dev/cpuctl/apps/bg_non_interactive/cpu.shares 52
+ write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_runtime_us 700000
+ write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_period_us 1000000
+
+ # qtaguid will limit access to specific data based on group memberships.
+ # net_bw_acct grants impersonation of socket owners.
+ # net_bw_stats grants access to other apps' detailed tagged-socket stats.
+ chown root net_bw_acct /proc/net/xt_qtaguid/ctrl
+ chown root net_bw_stats /proc/net/xt_qtaguid/stats
+
+ # Allow everybody to read the xt_qtaguid resource tracking misc dev.
+ # This is needed by any process that uses socket tagging.
+ chmod 0644 /dev/xt_qtaguid
+
+ # Create location for fs_mgr to store abbreviated output from filesystem
+ # checker programs.
+ mkdir /dev/fscklogs 0770 root system
+
+ # pstore/ramoops previous console log
+ mount pstore pstore /sys/fs/pstore
+ chown system log /sys/fs/pstore/console-ramoops
+ chmod 0440 /sys/fs/pstore/console-ramoops
+
+ # ion device
+ chmod 0666 /dev/ion
+
+# Healthd can trigger a full boot from charger mode by signaling this
+# property when the power button is held.
+on property:sys.boot_from_charger_mode=1
+ class_stop charger
+ trigger late-init
+
+# Load properties from /system/ + /factory after fs mount.
+on load_all_props_action
+ load_all_props
+
+# Indicate to fw loaders that the relevant mounts are up.
+on firmware_mounts_complete
+ rm /dev/.booting
+
+# Mount filesystems and start core system services.
+on late-init
+ trigger early-fs
+ trigger fs
+ trigger post-fs
+ trigger post-fs-data
+
+ # Load properties from /system/ + /factory after fs mount. Place
+ # this in another action so that the load will be scheduled after the prior
+ # issued fs triggers have completed.
+ trigger load_all_props_action
+
+ # Remove a file to wake up anything waiting for firmware.
+ trigger firmware_mounts_complete
+
+ trigger early-boot
+ trigger boot
+
+
+on post-fs
+ # once everything is setup, no need to modify /
+ mount rootfs rootfs / ro remount
+ # mount shared so changes propagate into child namespaces
+ mount rootfs rootfs / shared rec
+
+ # We chown/chmod /cache again so because mount is run as root + defaults
+ chown system cache /cache
+ chmod 0770 /cache
+ # We restorecon /cache in case the cache partition has been reset.
+ restorecon_recursive /cache
+
+ # This may have been created by the recovery system with odd permissions
+ chown system cache /cache/recovery
+ chmod 0770 /cache/recovery
+
+ #change permissions on vmallocinfo so we can grab it from bugreports
+ chown root log /proc/vmallocinfo
+ chmod 0440 /proc/vmallocinfo
+
+ chown root log /proc/slabinfo
+ chmod 0440 /proc/slabinfo
+
+ #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
+ chown root system /proc/kmsg
+ chmod 0440 /proc/kmsg
+ chown root system /proc/sysrq-trigger
+ chmod 0220 /proc/sysrq-trigger
+ chown system log /proc/last_kmsg
+ chmod 0440 /proc/last_kmsg
+
+ # make the selinux kernel policy world-readable
+ chmod 0444 /sys/fs/selinux/policy
+
+ # create the lost+found directories, so as to enforce our permissions
+ mkdir /cache/lost+found 0770 root root
+
+on post-fs-data
+ # We chown/chmod /data again so because mount is run as root + defaults
+ chown system system /data
+ chmod 0771 /data
+ # We restorecon /data in case the userdata partition has been reset.
+ restorecon /data
+
+ # Avoid predictable entropy pool. Carry over entropy from previous boot.
+ copy /data/system/entropy.dat /dev/urandom
+
+ # Create dump dir and collect dumps.
+ # Do this before we mount cache so eventually we can use cache for
+ # storing dumps on platforms which do not have a dedicated dump partition.
+ mkdir /data/dontpanic 0750 root log
+
+ # Collect apanic data, free resources and re-arm trigger
+ copy /proc/apanic_console /data/dontpanic/apanic_console
+ chown root log /data/dontpanic/apanic_console
+ chmod 0640 /data/dontpanic/apanic_console
+
+ copy /proc/apanic_threads /data/dontpanic/apanic_threads
+ chown root log /data/dontpanic/apanic_threads
+ chmod 0640 /data/dontpanic/apanic_threads
+
+ write /proc/apanic_console 1
+
+ # create basic filesystem structure
+ mkdir /data/misc 01771 system misc
+ mkdir /data/misc/adb 02750 system shell
+ mkdir /data/misc/bluedroid 0770 bluetooth net_bt_stack
+ mkdir /data/misc/bluetooth 0770 system system
+ mkdir /data/misc/keystore 0700 keystore keystore
+ mkdir /data/misc/keychain 0771 system system
+ mkdir /data/misc/net 0750 root shell
+ mkdir /data/misc/radio 0770 system radio
+ mkdir /data/misc/sms 0770 system radio
+ mkdir /data/misc/zoneinfo 0775 system system
+ mkdir /data/misc/vpn 0770 system vpn
+ mkdir /data/misc/shared_relro 0771 shared_relro shared_relro
+ mkdir /data/misc/systemkeys 0700 system system
+ 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/ethernet 0770 system system
+ mkdir /data/misc/dhcp 0770 dhcp dhcp
+ mkdir /data/misc/user 0771 root root
+ # give system access to wpa_supplicant.conf for backup and restore
+ chmod 0660 /data/misc/wifi/wpa_supplicant.conf
+ mkdir /data/local 0751 root root
+ mkdir /data/misc/media 0700 media media
+
+ # For security reasons, /data/local/tmp should always be empty.
+ # Do not place files or directories in /data/local/tmp
+ mkdir /data/local/tmp 0771 shell shell
+ mkdir /data/data 0771 system system
+ mkdir /data/app-private 0771 system system
+ mkdir /data/app-asec 0700 root root
+ mkdir /data/app-lib 0771 system system
+ mkdir /data/app 0771 system system
+ mkdir /data/property 0700 root root
+
+ # create dalvik-cache, so as to enforce our permissions
+ mkdir /data/dalvik-cache 0771 root root
+ mkdir /data/dalvik-cache/profiles 0711 system system
+
+ # create resource-cache and double-check the perms
+ mkdir /data/resource-cache 0771 system system
+ chown system system /data/resource-cache
+ chmod 0771 /data/resource-cache
+
+ # create the lost+found directories, so as to enforce our permissions
+ mkdir /data/lost+found 0770 root root
+
+ # create directory for DRM plug-ins - give drm the read/write access to
+ # the following directory.
+ mkdir /data/drm 0770 drm drm ####
+ # mkdir /data/drm 0774 drm system ####
+
+ # create directory for MediaDrm plug-ins - give drm the read/write access to
+ # the following directory.
+ mkdir /data/mediadrm 0770 mediadrm mediadrm
+
+ # symlink to bugreport storage location
+ symlink /data/data/com.android.shell/files/bugreports /data/bugreports
+
+ # Separate location for storing security policy files on data
+ mkdir /data/security 0711 system system
+
+ # add for mediaserver data
+ mkdir /data/mediaserver 0775 media media
+ restorecon /data/mediaserver
+
+ # Reload policy from /data/security if present.
+ setprop selinux.reload_policy 1
+
+ # Set SELinux security contexts on upgrade or policy update.
+ restorecon_recursive /data
+
+ # If there is no fs-post-data action in the init.<device>.rc file, you
+ # must uncomment this line, otherwise encrypted filesystems
+ # won't work.
+ # Set indication (checked by vold) that we have finished this action
+ #setprop vold.post_fs_data_done 1
+
+on boot
+ # basic network init
+ ifup lo
+ hostname localhost
+ domainname localdomain
+
+ # set RLIMIT_NICE to allow priorities from 19 to -20
+ setrlimit 13 40 40
+
+ # Memory management. Basic kernel parameters, and allow the high
+ # level system server to be able to adjust the kernel OOM driver
+ # parameters to match how it is managing things.
+ write /proc/sys/vm/overcommit_memory 1
+ write /proc/sys/vm/min_free_order_shift 4
+ chown root system /sys/module/lowmemorykiller/parameters/adj
+ chmod 0220 /sys/module/lowmemorykiller/parameters/adj
+ chown root system /sys/module/lowmemorykiller/parameters/minfree
+ chmod 0220 /sys/module/lowmemorykiller/parameters/minfree
+
+ # Tweak background writeout
+ write /proc/sys/vm/dirty_expire_centisecs 200
+ write /proc/sys/vm/dirty_background_ratio 5
+
+ # Permissions for System Server and daemons.
+ chown radio system /sys/android_power/state
+ chown radio system /sys/android_power/request_state
+ chown radio system /sys/android_power/acquire_full_wake_lock
+ chown radio system /sys/android_power/acquire_partial_wake_lock
+ chown radio system /sys/android_power/release_wake_lock
+ chown system system /sys/power/autosleep
+ chown system system /sys/power/state
+ chown system system /sys/power/wakeup_count
+ chown radio system /sys/power/wake_lock
+ chown radio system /sys/power/wake_unlock
+ chmod 0660 /sys/power/state
+ chmod 0660 /sys/power/wake_lock
+ chmod 0660 /sys/power/wake_unlock
+
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_rate
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_rate
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/timer_slack
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/timer_slack
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/min_sample_time
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/min_sample_time
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/target_loads
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/target_loads
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/boost
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boost
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/input_boost
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/input_boost
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration
+ chown system system /sys/devices/system/cpu/cpufreq/interactive/io_is_busy
+ chmod 0660 /sys/devices/system/cpu/cpufreq/interactive/io_is_busy
+
+ # Assume SMP uses shared cpufreq policy for all CPUs
+ chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
+ chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
+
+ chown system system /sys/class/timed_output/vibrator/enable
+ chown system system /sys/class/leds/keyboard-backlight/brightness
+ chown system system /sys/class/leds/lcd-backlight/brightness
+ chown system system /sys/class/leds/button-backlight/brightness
+ chown system system /sys/class/leds/jogball-backlight/brightness
+ chown system system /sys/class/leds/red/brightness
+ chown system system /sys/class/leds/green/brightness
+ chown system system /sys/class/leds/blue/brightness
+ chown system system /sys/class/leds/red/device/grpfreq
+ chown system system /sys/class/leds/red/device/grppwm
+ chown system system /sys/class/leds/red/device/blink
+ chown system system /sys/class/timed_output/vibrator/enable
+ chown system system /sys/module/sco/parameters/disable_esco
+ chown system system /sys/kernel/ipv4/tcp_wmem_min
+ chown system system /sys/kernel/ipv4/tcp_wmem_def
+ chown system system /sys/kernel/ipv4/tcp_wmem_max
+ chown system system /sys/kernel/ipv4/tcp_rmem_min
+ chown system system /sys/kernel/ipv4/tcp_rmem_def
+ chown system system /sys/kernel/ipv4/tcp_rmem_max
+ chown root radio /proc/cmdline
+
+ # Define default initial receive window size in segments.
+ setprop net.tcp.default_init_rwnd 60
+
+ class_start core
+
+on nonencrypted
+ class_start main
+ class_start late_start
+
+on property:vold.decrypt=trigger_default_encryption
+ start defaultcrypto
+
+on property:vold.decrypt=trigger_encryption
+ start surfaceflinger
+ start encrypt
+
+on property:sys.init_log_level=*
+ loglevel ${sys.init_log_level}
+
+on charger
+ class_start charger
+
+on property:vold.decrypt=trigger_reset_main
+ class_reset main
+
+on property:vold.decrypt=trigger_load_persist_props
+ load_persist_props
+
+on property:vold.decrypt=trigger_post_fs_data
+ trigger post-fs-data
+
+on property:vold.decrypt=trigger_restart_min_framework
+ class_start main
+
+on property:vold.decrypt=trigger_restart_framework
+ class_start main
+ class_start late_start
+
+on property:vold.decrypt=trigger_shutdown_framework
+ class_reset late_start
+ class_reset main
+
+on property:sys.powerctl=*
+ powerctl ${sys.powerctl}
+
+# system server cannot write to /proc/sys files,
+# and chown/chmod does not work for /proc/sys/ entries.
+# So proxy writes through init.
+on property:sys.sysctl.extra_free_kbytes=*
+ write /proc/sys/vm/extra_free_kbytes ${sys.sysctl.extra_free_kbytes}
+
+# "tcp_default_init_rwnd" Is too long!
+on property:sys.sysctl.tcp_def_init_rwnd=*
+ write /proc/sys/net/ipv4/tcp_default_init_rwnd ${sys.sysctl.tcp_def_init_rwnd}
+
+
+## Daemon processes to be run by init.
+##
+service ueventd /sbin/ueventd
+ class core
+ critical
+ seclabel u:r:ueventd:s0
+
+service logd /system/bin/logd
+ class core
+ socket logd stream 0666 logd logd
+ socket logdr seqpacket 0666 logd logd
+ socket logdw dgram 0222 logd logd
+ seclabel u:r:logd:s0
+
+service healthd /sbin/healthd
+ class core
+ critical
+ seclabel u:r:healthd:s0
+
+service console /system/bin/sh
+ class core
+ console
+ disabled
+ user shell
+ seclabel u:r:shell:s0
+
+on property:ro.debuggable=1
+ start console
+
+# adbd is controlled via property triggers in init.<platform>.usb.rc
+service adbd /sbin/adbd --root_seclabel=u:r:su:s0
+ class core
+ socket adbd stream 660 system system
+ disabled
+ seclabel u:r:adbd:s0
+
+# adbd on at boot in emulator
+on property:ro.kernel.qemu=1
+ start adbd
+
+#service lmkd /system/bin/lmkd
+# class core
+# critical
+# socket lmkd seqpacket 0660 system system
+
+#service servicemanager /system/bin/servicemanager
+# class core
+# user system
+# group system
+# critical
+# onrestart restart healthd
+# onrestart restart zygote
+# onrestart restart media
+# onrestart restart surfaceflinger
+# onrestart restart drm
+
+#service vold /system/bin/vold
+# class core
+# socket vold stream 0660 root mount
+# ioprio be 2
+
+#service netd /system/bin/netd
+# class main
+# socket netd stream 0660 root system
+# socket dnsproxyd stream 0660 root inet
+# socket mdns stream 0660 root system
+# socket fwmarkd stream 0660 root inet
+
+#service debuggerd /system/bin/debuggerd
+# class main
+
+#service debuggerd64 /system/bin/debuggerd64
+# class main
+
+# for using TK init.modem.rc rild-daemon setting
+#service ril-daemon /system/bin/rild
+# class main
+# socket rild stream 660 root radio
+# socket rild-debug stream 660 radio system
+# user root
+# group radio cache inet misc audio log
+
+#service surfaceflinger /system/bin/surfaceflinger
+# class core
+# user system
+# group graphics drmrpc
+# onrestart restart zygote
+
+#make sure drm server has rights to read and write sdcard ####
+#service drm /system/bin/drmserver
+# class main
+# user drm
+ # group drm system inet drmrpc ####
+# group drm system inet drmrpc sdcard_r ####
+
+#service media /system/bin/mediaserver
+# class main
+# user root ####
+# google default ####
+# user media ####
+# group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc mediadrm media sdcard_r system net_bt_stack ####
+# google default ####
+# group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc mediadrm ####
+
+# ioprio rt 4
+
+# One shot invocation to deal with encrypted volume.
+#service defaultcrypto /system/bin/vdc --wait cryptfs mountdefaultencrypted
+# disabled
+# oneshot
+ # vold will set vold.decrypt to trigger_restart_framework (default
+ # encryption) or trigger_restart_min_framework (other encryption)
+
+# One shot invocation to encrypt unencrypted volumes
+#service encrypt /system/bin/vdc --wait cryptfs enablecrypto inplace default
+# disabled
+# oneshot
+ # vold will set vold.decrypt to trigger_restart_framework (default
+ # encryption)
+
+#service bootanim /system/bin/bootanimation
+# class core
+# user graphics
+# group graphics audio ####
+# group graphics media audio ####
+# disabled
+# oneshot
+
+#service installd /system/bin/installd
+# class main
+# socket installd stream 600 system system
+
+#service flash_recovery /system/bin/install-recovery.sh
+# class main
+# seclabel u:r:install_recovery:s0
+# oneshot
+
+#service racoon /system/bin/racoon
+# class main
+# socket racoon stream 600 system system
+ # IKE uses UDP port 500. Racoon will setuid to vpn after binding the port.
+# group vpn net_admin inet
+# disabled
+# oneshot
+
+#service mtpd /system/bin/mtpd
+# class main
+# socket mtpd stream 600 system system
+# user vpn
+# group vpn net_admin inet net_raw
+# disabled
+# oneshot
+
+#service keystore /system/bin/keystore /data/misc/keystore
+# class main
+# user keystore
+# group keystore drmrpc
+
+#service dumpstate /system/bin/dumpstate -s
+# class main
+# socket dumpstate stream 0660 shell log
+# disabled
+# oneshot
+
+#service mdnsd /system/bin/mdnsd
+# class main
+# user mdnsr
+# group inet net_raw
+# socket mdnsd stream 0660 mdnsr inet
+# disabled
+# oneshot
+
+#service pre-recovery /system/bin/uncrypt
+# class main
+# disabled
+# oneshot
--- /dev/null
+on post-fs
+
+ # trustzone related interface
+ mknod /dev/trustzone c 197 0;
+ chmod 0666 /dev/trustzone
+ chown root media /dev/trustzone
+
+#
+# Connectivity related modules and character device nodes (Begin)
+#
+ #for 662x_launcher
+ chmod 0660 /dev/ttyMT2
+ chown system system /dev/ttyMT2
+
+ # STP, SDIO, WMT, GPS, FM and BT Driver
+# insmod /system/lib/modules/mtk_hif_sdio.ko
+# insmod /system/lib/modules/mtk_stp_wmt.ko
+# insmod /system/lib/modules/mtk_stp_uart.ko
+# insmod /system/lib/modules/mtk_stp_gps.ko
+# insmod /system/lib/modules/mtk_stp_bt.ko
+# insmod /system/lib/modules/mtk_fm_drv.ko
+# insmod /system/lib/modules/mtk_fm_priv.ko
+# insmod /system/lib/modules/mtk_wmt_wifi.ko
+
+ insmod /system/lib/modules/mtk_wmt_detect.ko
+
+ # Create char device file for WMT, GPS, BT, FM, WIFI
+ mknod /dev/stpwmt c 190 0;
+ mknod /dev/stpgps c 191 0;
+ mknod /dev/stpbt c 192 0;
+ mknod /dev/fm c 193 0;
+ chmod 0660 /dev/stpwmt
+ chown system system /dev/stpwmt
+ chmod 0660 /dev/wmtdetect
+ chown system system /dev/wmtdetect
+
+ # FM Radio device, FIXME: this is not a proper way to set permissions
+ chmod 0666 /dev/fm
+
+ mknod /dev/wmtWifi c 153 0
+ chmod 0666 /dev/wmtWifi
+ chmod 0660 /dev/stpgps
+ chmod 0660 /dev/stpbt
+ chown bluetooth radio /dev/stpbt
+
+ # Load WiFi Driver
+ #insmod /system/lib/modules/wlan.ko
+
+#
+# Connectivity related modules and character device nodes (Ends)
+#
+
+on boot
+
+
+#
+# Connectivity related services (Begin)
+#
+
+service wmtLoader /system/bin/wmt_loader
+ user root
+ group root
+ oneshot
+
+service conn_launcher /system/bin/6620_launcher -p /system/etc/firmware/
+ user system
+ group system
+
+
+#
+# Connectivity related services (End)
+#
+
--- /dev/null
+# Copyright (C) 2012 The Android Open Source Project
+#
+# IMPORTANT: Do not create world writable files or directories.
+# This is a common source of Android security bugs.
+#
+import /init.environ.rc
+import init.ssd.rc
+import init.no_ssd.rc
+import init.ssd_nomuser.rc
+import init.fon.rc
+import init.aee.rc
+
+on early-init
+ # Set init and its forked children's oom_adj.
+ write /proc/1/oom_score_adj -1000
+
+ # Apply strict SELinux checking of PROT_EXEC on mmap/mprotect calls.
+ #write /sys/fs/selinux/checkreqprot 0
+
+ # Set the security context for the init process.
+ # This should occur before anything else (e.g. ueventd) is started.
+ setcon u:r:init:s0
+
+ # Set the security context of /adb_keys if present.
+ restorecon /adb_keys
+
+ start ueventd
+
+# create mountpoints
+ mkdir /mnt 0775 root system
+
+on init
+
+sysclktz 0
+
+loglevel 5
+
+# Backward compatibility
+ symlink /system/etc /etc
+ symlink /sys/kernel/debug /d
+
+# Right now vendor lives on the same filesystem as system,
+# but someday that may change.
+ symlink /system/vendor /vendor
+
+# Create cgroup mount point for cpu accounting
+ mkdir /acct
+ mount cgroup none /acct cpuacct
+ mkdir /acct/uid
+
+ mkdir /system
+ mkdir /data 0771 system system
+ mkdir /cache 0770 system cache
+ mkdir /config 0500 root root
+
+ # See storage config details at http://source.android.com/tech/storage/
+ mkdir /mnt/shell 0700 shell shell
+ mkdir /mnt/media_rw 0700 media_rw media_rw
+ mkdir /storage 0751 root sdcard_r
+
+ mkdir /mnt/cd-rom 0000 system system
+
+ # Directory for putting things only root should see.
+ mkdir /mnt/secure 0700 root root
+
+ # Directory for staging bindmounts
+ mkdir /mnt/secure/staging 0700 root root
+
+ # Directory-target for where the secure container
+ # imagefile directory will be bind-mounted
+ mkdir /mnt/secure/asec 0700 root root
+
+ # Secure container public mount points.
+ mkdir /mnt/asec 0700 root system
+ mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
+
+ # Filesystem image public mount points.
+ mkdir /mnt/obb 0700 root system
+ mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000
+
+ write /proc/sys/kernel/panic_on_oops 1
+ write /proc/sys/kernel/hung_task_timeout_secs 0
+ write /proc/cpu/alignment 4
+ write /proc/sys/kernel/sched_latency_ns 10000000
+ write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
+ write /proc/sys/kernel/sched_compat_yield 1
+
+# Healthd can trigger a full boot from charger mode by signaling this
+# property when the power button is held.
+on property:sys.boot_from_charger_mode=1
+ class_stop charger
+ trigger late-init
+
+# Load properties from /system/ + /factory after fs mount.
+on load_all_props_action
+ load_all_props
+
+# Mount filesystems and start core system services.
+on late-init
+ trigger early-fs
+ trigger fs
+ trigger post-fs
+ trigger post-fs-data
+
+ # Load properties from /system/ + /factory after fs mount. Place
+ # this in another action so that the load will be scheduled after the prior
+ # issued fs triggers have completed.
+ trigger load_all_props_action
+
+ trigger early-boot
+ trigger boot
+
+on fs
+ write /proc/bootprof "INIT:eMMC:Mount_START"
+ mount_all /fstab.mt8127
+ write /proc/bootprof "INIT:eMMC:Mount_END"
+
+# mount secro partition
+# mount yaffs2 mtd@secstatic /system/secro ro
+# mount ext4 /dev/block/platform/mtk-msdc.0/by-name/SEC_RO /system/secro ro
+
+on post-fs
+ # once everything is setup, no need to modify /
+ mount rootfs rootfs / ro remount
+
+ # We chown/chmod /cache again so because mount is run as root + defaults
+ chown system cache /cache
+ chmod 0770 /cache
+ # We restorecon /cache in case the cache partition has been reset.
+ restorecon_recursive /cache
+
+ #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
+ chown root system /proc/kmsg
+ chmod 0440 /proc/kmsg
+
+ # make the selinux kernel policy world-readable
+ chmod 0444 /sys/fs/selinux/policy
+
+ # create the lost+found directories, so as to enforce our permissions
+ mkdir /cache/lost+found 0770 root root
+
+on post-fs-data
+ # We chown/chmod /data again so because mount is run as root + defaults
+ chown system system /data
+ chmod 0771 /data
+ # We restorecon /data in case the userdata partition has been reset.
+ restorecon /data
+
+
+# create basic filesystem structure
+ mkdir /data/nvram 2770 root system
+ mkdir /data/misc 01771 system misc
+ mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
+ mkdir /data/misc/bluetooth 0770 system system
+ mkdir /data/misc/keystore 0700 keystore keystore
+ mkdir /data/misc/keychain 0771 system system
+ mkdir /data/misc/vpn 0770 system vpn
+ mkdir /data/misc/systemkeys 0700 system system
+ # give system access to wpa_supplicant.conf for backup and restore
+ mkdir /data/misc/wifi 0770 wifi wifi
+ chmod 0660 /data/misc/wifi/wpa_supplicant.conf
+ chmod 0660 /data/misc/wifi/p2p_supplicant.conf
+ mkdir /data/local 0751 root root
+ # For security reasons, /data/local/tmp should always be empty.
+ # Do not place files or directories in /data/local/tmp
+ mkdir /data/local/tmp 0771 shell shell
+ mkdir /data/data 0771 system system
+ mkdir /data/app-private 0771 system system
+ mkdir /data/app-asec 0700 root root
+ mkdir /data/app 0771 system system
+ mkdir /data/property 0700 root root
+ mkdir /data/ssh 0750 root shell
+ mkdir /data/ssh/empty 0700 root root
+
+ # create the lost+found directories, so as to enforce our permissions
+ mkdir /data/lost+found 0770
+
+ # double check the perms, in case lost+found already exists, and set owner
+ chown root root /data/lost+found
+ chmod 0770 /data/lost+found
+
+ # H264 Decoder
+ chmod 777 /dev/MT6516_H264_DEC
+
+ # Internal SRAM Driver
+ chmod 777 /dev/MT6516_Int_SRAM
+
+ # MM QUEUE Driver
+ chmod 777 /dev/MT6516_MM_QUEUE
+
+ # MPEG4 Decoder
+ chmod 777 /dev/MT6516_MP4_DEC
+
+ # MPEG4 Encoder
+ chmod 777 /dev/MT6516_MP4_ENC
+
+ # OpenCORE proxy config
+ chmod 0666 /data/http-proxy-cfg
+
+ # OpenCORE player config
+ chmod 0666 /etc/player.cfg
+
+start NvRAMAgent
+
+ # WiFi
+ mkdir /data/misc/wifi 0770 system wifi
+ mkdir /data/misc/wifi/sockets 0770 system wifi
+ mkdir /data/misc/dhcp 0770 dhcp dhcp
+ chown dhcp dhcp /data/misc/dhcp
+ chmod 0660 /sys/class/rfkill/rfkill1/state
+ chown system system /sys/class/rfkill/rfkill1/state
+ # Turn off wifi by default
+ write /sys/class/rfkill/rfkill1/state 0
+
+
+
+ # Set this property so surfaceflinger is not started by system_init
+ setprop system_init.startsurfaceflinger 0
+
+ #otp
+ chmod 0660 /dev/otp
+ chown root system /dev/otp
+
+ # Touch Panel
+ chown system system /sys/touchpanel/calibration
+ chmod 0660 /sys/touchpanel/calibration
+
+ chmod 0777 /dev/pmem_multimedia
+ chmod 0777 /dev/mt6516-isp
+ chmod 0777 /dev/mt6516-IDP
+ chmod 0777 /dev/mt9p012
+ chmod 0777 /dev/mt6516_jpeg
+ chmod 0777 /dev/FM50AF
+
+
+
+ # RTC
+ mkdir /data/misc/rtc 0770 system system
+
+ # M4U
+ #insmod /system/lib/modules/m4u.ko
+ #mknod /dev/M4U_device c 188 0
+ chmod 0444 /dev/M4U_device
+
+ # Sensor
+ chmod 0666 /dev/sensor
+
+ # GPIO
+ chmod 0666 /dev/mtgpio
+
+ # Android SEC related device nodes
+ insmod /system/lib/modules/sec.ko
+ mknod /dev/sec c 182 0
+ chmod 0660 /dev/sec
+ chown root system /dev/sec
+
+ # device info interface
+ #insmod /system/lib/modules/devinfo.ko
+ #mknod /dev/devmap c 196 0;
+ chmod 0440 /dev/devmap
+ chown root system /dev/devmap
+
+ # change key_provisioning
+ mkdir /data/key_provisioning
+ chmod 0770 /data/key_provisioning
+ chown system system /data/key_provisioning
+
+ # Separate location for storing security policy files on data
+ mkdir /data/security 0711 system system
+
+ # Reload policy from /data/security if present.
+ setprop selinux.reload_policy 1
+
+ # Set SELinux security contexts on upgrade or policy update.
+ restorecon_recursive /data
+
+ # If there is no fs-post-data action in the init.<device>.rc file, you
+ # must uncomment this line, otherwise encrypted filesystems
+ # won't work.
+ # Set indication (checked by vold) that we have finished this action
+ setprop vold.post_fs_data_done 1
+
+on boot
+ chown root /remount.sh
+ chmod 700 /remount.sh
+ exec /remount.sh
+
+start drvbd
+
+# basic network init
+ ifup lo
+ hostname localhost
+ domainname localdomain
+
+ class_start default
+ class_start core
+
+on nonencrypted
+ class_start main
+ class_start late_start
+
+on property:vold.decrypt=trigger_default_encryption
+ start defaultcrypto
+
+on property:vold.decrypt=trigger_encryption
+ start surfaceflinger
+ start encrypt
+
+on property:vold.decrypt=trigger_reset_main
+ class_reset main
+
+on property:vold.decrypt=trigger_load_persist_props
+ load_persist_props
+
+on property:vold.decrypt=trigger_post_fs_data
+ trigger post-fs-data
+
+on property:vold.decrypt=trigger_restart_min_framework
+ class_start main
+
+on property:vold.decrypt=trigger_restart_framework
+ start nvram_daemon
+ class_start main
+ class_start late_start
+ start permission_check
+
+on property:vold.decrypt=trigger_shutdown_framework
+ class_reset late_start
+ class_reset main
+
+service ueventd /sbin/ueventd
+ class core
+ critical
+ seclabel u:r:ueventd:s0
+
+service logd /system/bin/logd
+ class core
+ socket logd stream 0666 logd logd
+ socket logdr seqpacket 0666 logd logd
+ socket logdw dgram 0222 logd logd
+ seclabel u:r:logd:s0
+
+service console /system/bin/sh
+ class core
+ console
+ disabled
+ user shell
+ group shell log
+ seclabel u:r:shell:s0
+
+on property:sys.powerctl=*
+ powerctl ${sys.powerctl}
+
+on property:ro.debuggable=1
+ start console
+
+# adbd is controlled via property triggers in init.<platform>.usb.rc
+service adbd /sbin/adbd --root_seclabel=u:r:su:s0
+ class core
+ socket adbd stream 660 system system
+ disabled
+ seclabel u:r:adbd:s0
+
+service vold /system/bin/vold
+ class core
+ socket vold stream 0660 root mount
+ ioprio be 2
+
+# One shot invocation to deal with encrypted volume.
+service defaultcrypto /system/bin/vdc --wait cryptfs mountdefaultencrypted
+ disabled
+ oneshot
+ # vold will set vold.decrypt to trigger_restart_framework (default
+ # encryption) or trigger_restart_min_framework (other encryption)
+
+# One shot invocation to encrypt unencrypted volumes
+service encrypt /system/bin/vdc --wait cryptfs enablecrypto inplace default
+ disabled
+ oneshot
+ # vold will set vold.decrypt to trigger_restart_framework (default
+ # encryption)
+
+service meta_tst /system/bin/meta_tst
+
+#drm operation server
+service kisd /system/bin/kisd
+
+service servicemanager /system/bin/servicemanager
+ class core
+ user system
+ group system
+ critical
+service nvram_daemon /system/bin/nvram_daemon
+ class main
+ user root
+ group system
+ oneshot
+
+service NvRAMAgent /system/bin/nvram_agent_binder
+ user system
+ group system
+
+service drvbd /system/bin/drvbd
+ class main
+ user system
+ group system
+
+service debuggerd /system/bin/debuggerd
+ class main
+
+service debuggerd64 /system/bin/debuggerd64
+ class main
+
+
+service mobile_log_d /system/bin/mobile_log_d
+ class main
+
+on property:ro.boot.mblogenable=0
+ stop mobile_log_d
+
+on property:ro.boot.mblogenable=1
+ start mobile_log_d
+
+#mass_storage,adb,acm
+on property:ro.boot.usbconfig=0
+ write /sys/class/android_usb/android0/iSerial $ro.serialno
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor 0e8d
+ write /sys/class/android_usb/android0/idProduct 2006
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions mass_storage,adb,acm
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+
+#acm
+on property:ro.boot.usbconfig=1
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/iSerial " "
+ write /sys/class/android_usb/android0/idVendor 0e8d
+ write /sys/class/android_usb/android0/idProduct 2007
+ write /sys/class/android_usb/android0/f_acm/instances 1
+ write /sys/class/android_usb/android0/functions acm
+ write /sys/class/android_usb/android0/bDeviceClass 02
+ write /sys/class/android_usb/android0/enable 1
--- /dev/null
+/dev/pvrsrvkm 0766 root root
+/dev/pvr_sync 0766 root root
+/dev/stpwmt 0660 system system
+/dev/stpbt 0660 bluetooth radio
+/dev/stpgps 0660 gps gps
+/dev/Vcodec 0660 media system
+/dev/wmtWifi 0660 system system
+/dev/sec 0660 root system
+/dev/preloader 0640 root system
+/dev/misc-sd 0640 root system
+/dev/sec_ro 0640 root system
+/dev/recovery 0640 root system
+/dev/seccfg 0660 root system
+/dev/block/mmcblk0 0660 root system
+/dev/trustzone 0660 root drmrpc
+/dev/devmap 0440 root system
+/dev/mali0 0666 system graphics
+/dev/gps 0660 gps system
+
+#change partition permission
+/dev/preloader 0640 root system
+/dev/bootimg 0640 root system
+/dev/recovery 0660 root system
+/dev/sec_ro 0640 root system
+/dev/kb 0660 root system
+/dev/dkb 0660 root system
+/dev/seccfg 0660 root system
+/dev/pro_info 0660 root system
+/dev/otp 0660 root system
+/dev/nvram 0660 root system
+/dev/misc 0660 root system
+/dev/misc2 0660 root system
+/dev/block/platform/mtk-msdc.0/by-name/misc2 0660 root system
+/dev/block/mmcblk0 0660 root system
+/dev/block/mmcblk0boot0 0660 root system
+/dev/misc-sd 0660 root system
+
+#connectivity
+/dev/stpwmt 0660 system system
+/dev/wmtdetect 0660 system system
+/dev/stpbt 0660 bluetooth radio
+/dev/stpgps 0660 gps gps
+/dev/stpant 0660 system system
+
+# WIFI
+/dev/wmtWifi 0660 system system
+
+# FMRadio
+/dev/fm 0660 system media
+
+# add the read write right of ttyUSB*
+/dev/bus/usb/* 0660 root usb
+/dev/ttyUSB0 0660 radio radio
+/dev/ttyUSB1 0660 radio radio
+/dev/ttyUSB2 0660 radio radio
+/dev/ttyUSB3 0660 radio radio
+/dev/ttyUSB4 0660 radio radio
+
+# Anyone can read the logs, but if they're not in the "logs"
+# group, then they'll only see log entries for their UID.
+/dev/xLog 0600 root root
+/dev/log/* 0666 root log
+/dev/log/ksystem 0600 root log
+
+/dev/ccci* 0660 radio radio
+/dev/ttyC* 0660 radio radio
+/sys/kernel/ccci modem_info 0644 radio radio
+/sys/kernel/ccci md1_postfix 0644 radio radio
+/sys/kernel/ccci md2_postfix 0644 radio radio
+/dev/eemcs* 0660 radio radio
+/dev/ccci_pcm_rx 0660 media media
+/dev/ccci_pcm_tx 0660 media media
+/dev/ccci_aud 0660 media media
+/dev/ccci2_aud 0660 media media
+/dev/eemcs_aud 0660 media media
+
+# SGX device node
+/dev/pvrsrvkm 0666 root root
+/dev/pvr_sync 0666 root root
+
+# sysfs properties
+/sys/devices/platform/leds-mt65xx/leds/green delay_on 0664 system system
+/sys/devices/platform/leds-mt65xx/leds/green delay_off 0664 system system
+/sys/devices/platform/leds-mt65xx/leds/red delay_on 0664 system system
+/sys/devices/platform/leds-mt65xx/leds/red delay_off 0664 system system
+/sys/devices/platform/leds-mt65xx/leds/blue delay_on 0664 system system
+/sys/devices/platform/leds-mt65xx/leds/blue delay_off 0664 system system
+
+NFC device
+/dev/msr3110 0666 root root
+/dev/mt6605 0660 nfc radio
+
+#GPS
+/dev/gps 0660 gps system
+
+#GPIO
+/dev/mtgpio 0600 radio root
+
+#MTK BTIF driver
+/dev/btif 0600 system system
+
+#FOR VIA MODEM
+/dev/ttySDIO* 0660 radio sdcard_rw
+/dev/ttyRB* 0660 radio radio
+
+# Mali node
+/dev/mali 0666 system graphics
+
+#touch
+/dev/touch 0660 root system
+/dev/hotknot 0660 root system
+
+#hang_detect
+/dev/RT_Monitor 0600 system system
+/dev/kick_powerkey 0600 system system
--- /dev/null
+/dev/bootimg /boot emmc defaults defaults
+/dev/logo /logo emmc defaults defaults
+/dev/misc /misc emmc defaults defaults
+/dev/nvram /nvram emmc defaults defaults
+/dev/recovery /recovery emmc defaults defaults
+/dev/uboot /uboot emmc defaults defaults
+/dev/block/mmcblk0p6 /system ext4 defaults defaults
+/dev/block/mmcblk0p7 /cache ext4 defaults defaults
+/dev/block/mmcblk0p8 /data ext4 defaults defaults
+/dev/block/mmcblk1p1 /extsdcard vfat defaults defaults
+/dev/block/mmcblk0p2 /sd-ext ext4 defaults defaults
+/dev/block/sda1 usbotg auto defaults defaults
--- /dev/null
+#!/bin/bash
+
+VENDOR=alcatel
+DEVICE=ttab
+OUTDIR=vendor/$VENDOR/$DEVICE
+MAKEFILE=../../../$OUTDIR/$DEVICE-vendor-blobs.mk
+
+(cat << EOF) > $MAKEFILE
+# Copyright (C) 2013-2016, The CyanogenMod Project
+# Copyright (C) 2017, The LineageOS 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 generated by device/$VENDOR/$DEVICE/setup-makefiles.sh
+
+LOCAL_PATH := vendor/$VENDOR/$DEVICE
+
+PRODUCT_COPY_FILES += \\
+EOF
+
+LINEEND=" \\"
+COUNT=`wc -l proprietary-files.txt | awk {'print $1'}`
+DISM=`egrep -c '(^#|^$)' proprietary-files.txt`
+COUNT=`expr $COUNT - $DISM`
+for FILE in `egrep -v '(^#|^$)' ../$DEVICE/proprietary-files.txt`; do
+ COUNT=`expr $COUNT - 1`
+ if [ $COUNT = "0" ]; then
+ LINEEND=""
+ fi
+ # Split the file from the destination (format is "file[:destination]")
+ OLDIFS=$IFS IFS=":" PARSING_ARRAY=($FILE) IFS=$OLDIFS
+ FILE=${PARSING_ARRAY[0]}
+ DEST=${PARSING_ARRAY[1]}
+ if [ -n "$DEST" ]; then
+ FILE=$DEST
+ fi
+ echo " \$(LOCAL_PATH)/proprietary/$FILE:system/$FILE$LINEEND" >> $MAKEFILE
+done
+
+(cat << EOF) > ../../../$OUTDIR/$DEVICE-vendor.mk
+# Copyright (C) 2013-2016, The CyanogenMod Project
+# Copyright (C) 2017, The LineageOS 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 generated by device/$VENDOR/$DEVICE/setup-makefiles.sh
+
+# Pick up overlay for features that depend on non-open-source files
+DEVICE_PACKAGE_OVERLAYS := vendor/$VENDOR/$DEVICE/overlay
+
+\$(call inherit-product, vendor/$VENDOR/$DEVICE/$DEVICE-vendor-blobs.mk)
+EOF
+
+(cat << EOF) > ../../../$OUTDIR/BoardConfigVendor.mk
+# Copyright (C) 2013-2016, The CyanogenMod Project
+# Copyright (C) 2017, The LineageOS 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 generated by device/$VENDOR/$DEVICE/setup-makefiles.sh
+
+EOF
\ No newline at end of file
--- /dev/null
+#
+# system.prop for ttab
+#
+ro.sf.lcd_density=213
+debug.hwui.render_dirty_regions=false
+ro.opengles.version=131072
+ro.audio.silent=0
+wifi.interface=wlan0
+ro.mediatek.wlan.wsc=1
+ro.mediatek.wlan.p2p=1
+mediatek.wlan.ctia=0
+wifi.tethering.interface=wlan0
+wifi.direct.interface=p2p0
+ro.sys.usb.storage.type=mtp,mass_storage
+ro.sys.usb.bicr=yes
+ro.sys.usb.charging.only=yes
+drm.service.enabled=true
+persist.radio.combo.chipid=-1
+mediatek.wlan.chip=
+mediatek.wlan.module.postfix=_
+ro.egl.destroy_after_detach=true
+
+# Factory Reset Protection
+#ro.frp.pst=/dev/block/platform/mtk-msdc.0/mmcblk0p3
+
+persist.sys.strictmode.visual=0
+persist.sys.strictmode.disable=1
+
+ro.enable_boot_charger_mode=1
+
+ro.radio.noril=1
+ro.carrier=wifi-only
+
+dalvik.vm.heapstartsize=5m
+dalvik.vm.heapgrowthlimit=128m
+dalvik.vm.heapsize=256m
+dalvik.vm.heaptargetutilization=0.75
+dalvik.vm.heapminfree=512k
+dalvik.vm.heapmaxfree=2m
--- /dev/null
+add_lunch_combo cm_ttab-eng
--- /dev/null
+# Copyright (C) 2011 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)
+
+# Make the HAL library
+# ============================================================
+include $(CLEAR_VARS)
+
+LOCAL_REQUIRED_MODULES :=
+
+LOCAL_CFLAGS += -Wno-unused-parameter -Wno-int-to-pointer-cast
+LOCAL_CFLAGS += -Wno-maybe-uninitialized -Wno-parentheses
+LOCAL_CPPFLAGS += -Wno-conversion-null
+
+ifeq ($(MTK_TC7_FEATURE), yes)
+LOCAL_CFLAGS += -DCONFIG_PNO_SUPPORT
+endif
+
+LOCAL_C_INCLUDES += \
+ external/libnl/include \
+ $(call include-path-for, libhardware_legacy)/hardware_legacy \
+ external/wpa_supplicant_8/src/drivers
+
+LOCAL_SRC_FILES := \
+ wifi_hal.cpp \
+ rtt.cpp \
+ common.cpp \
+ cpp_bindings.cpp \
+ gscan.cpp \
+ wifi_offload.cpp
+
+LOCAL_MODULE := libwifi-hal-mt66xx
+LOCAL_PROPRIETARY_MODULE := true
+LOCAL_MODULE_OWNER := mtk
+
+include $(BUILD_STATIC_LIBRARY)
+
--- /dev/null
+Copyright (c) <YEAR>, <OWNER>
+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 <ORGANIZATION> 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 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.
+
+
+
--- /dev/null
+This directory contains WIFI_HAL interface and function
+
+
+WHAT IT DOES?
+=============
+It provide another method for WIFI HAL to access WIFI driver which is different from wpa_supplicant.
+
+
+HOW IT WAS BUILT?
+==================
+It needs the following libs from AOSP:
+
+
+and the following libs from MediaTek:
+
+
+All source/dependency modules of this module are already put in
+'hardware/mediatek/wlan/wifi_hal' folder.
+
+
+HOW TO USE IT?
+==============
+Files in this directory is used for WIFI HAL interface and function
+
+
+
+
--- /dev/null
+#include <stdint.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/rtnetlink.h>
+#include <netpacket/packet.h>
+#include <linux/filter.h>
+#include <linux/errqueue.h>
+
+#include <linux/pkt_sched.h>
+#include <netlink/object-api.h>
+#include <netlink/netlink.h>
+#include <netlink/socket.h>
+#include <netlink/handlers.h>
+
+#include "wifi_hal.h"
+#include "common.h"
+#include "cpp_bindings.h"
+
+interface_info *getIfaceInfo(wifi_interface_handle handle)
+{
+ return (interface_info *)handle;
+}
+
+wifi_handle getWifiHandle(wifi_interface_handle handle)
+{
+ return getIfaceInfo(handle)->handle;
+}
+
+hal_info *getHalInfo(wifi_handle handle)
+{
+ return (hal_info *)handle;
+}
+
+hal_info *getHalInfo(wifi_interface_handle handle)
+{
+ return getHalInfo(getWifiHandle(handle));
+}
+
+wifi_handle getWifiHandle(hal_info *info)
+{
+ return (wifi_handle)info;
+}
+
+wifi_interface_handle getIfaceHandle(interface_info *info)
+{
+ return (wifi_interface_handle)info;
+}
+
+wifi_error wifi_register_handler(wifi_handle handle, int cmd, nl_recvmsg_msg_cb_t func, void *arg)
+{
+ hal_info *info = (hal_info *)handle;
+
+ /* TODO: check for multiple handlers? */
+ pthread_mutex_lock(&info->cb_lock);
+
+ wifi_error result = WIFI_ERROR_OUT_OF_MEMORY;
+
+ if (info->num_event_cb < info->alloc_event_cb) {
+ info->event_cb[info->num_event_cb].nl_cmd = cmd;
+ info->event_cb[info->num_event_cb].vendor_id = 0;
+ info->event_cb[info->num_event_cb].vendor_subcmd = 0;
+ info->event_cb[info->num_event_cb].cb_func = func;
+ info->event_cb[info->num_event_cb].cb_arg = arg;
+ ALOGV("Successfully added event handler %p:%p for command %d at %d",
+ arg, func, cmd, info->num_event_cb);
+ info->num_event_cb++;
+ result = WIFI_SUCCESS;
+ }
+
+ pthread_mutex_unlock(&info->cb_lock);
+ return result;
+}
+
+wifi_error wifi_register_vendor_handler(wifi_handle handle,
+ uint32_t id, int subcmd, nl_recvmsg_msg_cb_t func, void *arg)
+{
+ hal_info *info = (hal_info *)handle;
+
+ /* TODO: check for multiple handlers? */
+ pthread_mutex_lock(&info->cb_lock);
+
+ wifi_error result = WIFI_ERROR_OUT_OF_MEMORY;
+
+ if (info->num_event_cb < info->alloc_event_cb) {
+ info->event_cb[info->num_event_cb].nl_cmd = NL80211_CMD_VENDOR;
+ info->event_cb[info->num_event_cb].vendor_id = id;
+ info->event_cb[info->num_event_cb].vendor_subcmd = subcmd;
+ info->event_cb[info->num_event_cb].cb_func = func;
+ info->event_cb[info->num_event_cb].cb_arg = arg;
+ ALOGV("Added event handler %p:%p for vendor 0x%0x and subcmd 0x%0x at %d",
+ arg, func, id, subcmd, info->num_event_cb);
+ info->num_event_cb++;
+ result = WIFI_SUCCESS;
+ }
+
+ pthread_mutex_unlock(&info->cb_lock);
+ return result;
+}
+
+void wifi_unregister_handler(wifi_handle handle, int cmd)
+{
+ hal_info *info = (hal_info *)handle;
+
+ if (cmd == NL80211_CMD_VENDOR) {
+ ALOGE("Must use wifi_unregister_vendor_handler to remove vendor handlers");
+ return;
+ }
+
+ pthread_mutex_lock(&info->cb_lock);
+
+ for (int i = 0; i < info->num_event_cb; i++) {
+ if (info->event_cb[i].nl_cmd == cmd) {
+ ALOGV("Successfully removed event handler %p:%p for cmd = 0x%0x from %d",
+ info->event_cb[i].cb_arg, info->event_cb[i].cb_func, cmd, i);
+
+ memmove(&info->event_cb[i], &info->event_cb[i+1],
+ (info->num_event_cb - i - 1) * sizeof(cb_info));
+ info->num_event_cb--;
+ break;
+ }
+ }
+
+ pthread_mutex_unlock(&info->cb_lock);
+}
+
+void wifi_unregister_vendor_handler(wifi_handle handle, uint32_t id, int subcmd)
+{
+ hal_info *info = (hal_info *)handle;
+
+ pthread_mutex_lock(&info->cb_lock);
+
+ for (int i = 0; i < info->num_event_cb; i++) {
+
+ if (info->event_cb[i].nl_cmd == NL80211_CMD_VENDOR
+ && info->event_cb[i].vendor_id == id
+ && info->event_cb[i].vendor_subcmd == subcmd) {
+ ALOGV("Successfully removed event handler %p:%p for vendor 0x%0x, subcmd 0x%0x from %d",
+ info->event_cb[i].cb_arg, info->event_cb[i].cb_func, id, subcmd, i);
+ memmove(&info->event_cb[i], &info->event_cb[i+1],
+ (info->num_event_cb - i - 1) * sizeof(cb_info));
+ info->num_event_cb--;
+ break;
+ }
+ }
+
+ pthread_mutex_unlock(&info->cb_lock);
+}
+
+
+wifi_error wifi_register_cmd(wifi_handle handle, int id, WifiCommand *cmd)
+{
+ hal_info *info = (hal_info *)handle;
+
+ ALOGV("registering command %d", id);
+
+ wifi_error result = WIFI_ERROR_OUT_OF_MEMORY;
+
+ if (info->num_cmd < info->alloc_cmd) {
+ info->cmd[info->num_cmd].id = id;
+ info->cmd[info->num_cmd].cmd = cmd;
+ ALOGV("Successfully added command %d: %p at %d", id, cmd, info->num_cmd);
+ info->num_cmd++;
+ result = WIFI_SUCCESS;
+ } else {
+ ALOGE("Failed to add command %d: %p at %d, reached max limit %d",
+ id, cmd, info->num_cmd, info->alloc_cmd);
+ }
+
+ return result;
+}
+
+WifiCommand *wifi_unregister_cmd(wifi_handle handle, int id)
+{
+ hal_info *info = (hal_info *)handle;
+
+ ALOGV("un-registering command %d", id);
+
+ WifiCommand *cmd = NULL;
+
+ for (int i = 0; i < info->num_cmd; i++) {
+ if (info->cmd[i].id == id) {
+ cmd = info->cmd[i].cmd;
+ memmove(&info->cmd[i], &info->cmd[i+1], (info->num_cmd - i - 1) * sizeof(cmd_info));
+ info->num_cmd--;
+ ALOGV("Successfully removed command %d: %p from %d", id, cmd, i);
+ break;
+ }
+ }
+
+ if (!cmd) {
+ ALOGI("Failed to remove command %d: %p", id, cmd);
+ }
+
+ return cmd;
+}
+
+WifiCommand *wifi_get_cmd(wifi_handle handle, int id)
+{
+ hal_info *info = (hal_info *)handle;
+
+ WifiCommand *cmd = NULL;
+
+ for (int i = 0; i < info->num_cmd; i++) {
+ if (info->cmd[i].id == id) {
+ cmd = info->cmd[i].cmd;
+ break;
+ }
+ }
+
+ return cmd;
+}
+
+void wifi_unregister_cmd(wifi_handle handle, WifiCommand *cmd)
+{
+ hal_info *info = (hal_info *)handle;
+
+ for (int i = 0; i < info->num_cmd; i++) {
+ if (info->cmd[i].cmd == cmd) {
+ int id = info->cmd[i].id;
+ memmove(&info->cmd[i], &info->cmd[i+1], (info->num_cmd - i - 1) * sizeof(cmd_info));
+ info->num_cmd--;
+ ALOGV("Successfully removed command %d: %p from %d", id, cmd, i);
+ break;
+ }
+ }
+}
+
+wifi_error wifi_cancel_cmd(wifi_request_id id, wifi_interface_handle iface)
+{
+ wifi_handle handle = getWifiHandle(iface);
+
+ WifiCommand *cmd = wifi_unregister_cmd(handle, id);
+ ALOGV("Cancel WifiCommand = %p", cmd);
+ if (cmd) {
+ cmd->cancel();
+ cmd->releaseRef();
+ return WIFI_SUCCESS;
+ }
+
+ return WIFI_ERROR_INVALID_ARGS;
+}
+
--- /dev/null
+
+#include "wifi_hal.h"
+
+#ifndef __WIFI_HAL_COMMON_H__
+#define __WIFI_HAL_COMMON_H__
+
+#define LOG_TAG "WifiHAL"
+
+#include <utils/Log.h>
+#include "nl80211_copy.h"
+#include "sync.h"
+
+#define SOCKET_BUFFER_SIZE (32768U)
+#define RECV_BUF_SIZE (4096)
+#define DEFAULT_EVENT_CB_SIZE (64)
+#define DEFAULT_CMD_SIZE (64)
+#define DOT11_OUI_LEN 3
+#define DOT11_MAX_SSID_LEN 32
+
+#define MAX_PROBE_RESP_IE_LEN 2048
+/*
+ Vendor OUI - This is a unique identifier that identifies organization. Lets
+ code Android specific functions with Google OUI; although vendors can do more
+ with their own OUI's as well.
+ */
+
+const uint32_t GOOGLE_OUI = 0x001A11;
+/* TODO: define vendor OUI here */
+
+#ifndef MAC2STR
+#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
+#endif
+
+/*
+ This enum defines ranges for various commands; commands themselves
+ can be defined in respective feature headers; i.e. find gscan command
+ definitions in gscan.cpp
+ */
+
+typedef enum {
+ /* Don't use 0 as a valid subcommand */
+ ANDROID_NL80211_SUBCMD_UNSPECIFIED,
+
+ /* Define all vendor startup commands between 0x0 and 0x0FFF */
+ ANDROID_NL80211_SUBCMD_WIFI_RANGE_START = 0x0001,
+ ANDROID_NL80211_SUBCMD_WIFI_RANGE_END = 0x0FFF,
+
+ /* Define all GScan related commands between 0x1000 and 0x10FF */
+ ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START = 0x1000,
+ ANDROID_NL80211_SUBCMD_GSCAN_RANGE_END = 0x10FF,
+
+ /* Define all RTT related commands between 0x1100 and 0x11FF */
+ ANDROID_NL80211_SUBCMD_RTT_RANGE_START = 0x1100,
+ ANDROID_NL80211_SUBCMD_RTT_RANGE_END = 0x11FF,
+
+ ANDROID_NL80211_SUBCMD_LSTATS_RANGE_START = 0x1200,
+ ANDROID_NL80211_SUBCMD_LSTATS_RANGE_END = 0x12FF,
+
+ /* Define all Logger related commands between 0x1400 and 0x14FF */
+ ANDROID_NL80211_SUBCMD_DEBUG_RANGE_START = 0x1400,
+ ANDROID_NL80211_SUBCMD_DEBUG_RANGE_END = 0x14FF,
+
+ /* Define all wifi offload related commands between 0x1600 and 0x16FF */
+ ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_START = 0x1600,
+ ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_END = 0x16FF,
+
+ /* This is reserved for future usage */
+
+} ANDROID_VENDOR_SUB_COMMAND;
+
+typedef enum {
+ WIFI_SUBCMD_GET_CHANNEL_LIST = ANDROID_NL80211_SUBCMD_WIFI_RANGE_START,
+
+ WIFI_SUBCMD_GET_FEATURE_SET, /* 0x0002 */
+ WIFI_SUBCMD_GET_FEATURE_SET_MATRIX, /* 0x0003 */
+ WIFI_SUBCMD_SET_PNO_RANDOM_MAC_OUI, /* 0x0004 */
+ WIFI_SUBCMD_NODFS_SET, /* 0x0005 */
+ WIFI_SUBCMD_SET_COUNTRY_CODE, /* 0x0006 */
+
+ WIFI_SUBCMD_SET_RSSI_MONITOR, /* 0x0007 */
+ /* Add more sub commands here */
+} WIFI_SUB_COMMAND;
+
+typedef enum {
+ GSCAN_SUBCMD_GET_CAPABILITIES = ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START,
+
+ GSCAN_SUBCMD_SET_CONFIG, /* 0x1001 */
+ GSCAN_SUBCMD_SET_SCAN_CONFIG, /* 0x1002 */
+ GSCAN_SUBCMD_ENABLE_GSCAN, /* 0x1003 */
+ GSCAN_SUBCMD_GET_SCAN_RESULTS, /* 0x1004 */
+ GSCAN_SUBCMD_SCAN_RESULTS, /* 0x1005 */
+
+ GSCAN_SUBCMD_SET_HOTLIST, /* 0x1006 */
+
+ GSCAN_SUBCMD_SET_SIGNIFICANT_CHANGE_CONFIG, /* 0x1007 */
+ GSCAN_SUBCMD_ENABLE_FULL_SCAN_RESULTS, /* 0x1008 */
+
+ GSCAN_SUBCMD_SET_EPNO_SSID = 0x100F, /* 0x100F */
+
+ GSCAN_SUBCMD_SET_SSID_WHITE_LIST, /* 0x1010 */
+ GSCAN_SUBCMD_SET_ROAM_PARAMS, /* 0x1011 */
+ GSCAN_SUBCMD_ENABLE_LAZY_ROAM, /* 0x1012 */
+ GSCAN_SUBCMD_SET_BSSID_PREF, /* 0x1013 */
+ GSCAN_SUBCMD_SET_BSSID_BLACKLIST, /* 0x1014 */
+
+ GSCAN_SUBCMD_ANQPO_CONFIG, /* 0x1015 */
+ /* Add more sub commands here */
+
+} GSCAN_SUB_COMMAND;
+
+typedef enum {
+ WIFI_ATTRIBUTE_BAND = 1,
+ WIFI_ATTRIBUTE_NUM_CHANNELS,
+ WIFI_ATTRIBUTE_CHANNEL_LIST,
+
+ WIFI_ATTRIBUTE_NUM_FEATURE_SET,
+ WIFI_ATTRIBUTE_FEATURE_SET,
+ WIFI_ATTRIBUTE_PNO_RANDOM_MAC_OUI,
+ WIFI_ATTRIBUTE_NODFS_VALUE,
+ WIFI_ATTRIBUTE_COUNTRY_CODE,
+
+ WIFI_ATTRIBUTE_MAX_RSSI,
+ WIFI_ATTRIBUTE_MIN_RSSI,
+ WIFI_ATTRIBUTE_RSSI_MONITOR_START,
+} WIFI_ATTRIBUTE;
+
+typedef enum {
+ GSCAN_EVENT_SIGNIFICANT_CHANGE_RESULTS,
+ GSCAN_EVENT_HOTLIST_RESULTS_FOUND,
+ GSCAN_EVENT_SCAN_RESULTS_AVAILABLE,
+ GSCAN_EVENT_FULL_SCAN_RESULTS,
+ RTT_EVENT_COMPLETE,
+ GSCAN_EVENT_COMPLETE_SCAN,
+ GSCAN_EVENT_HOTLIST_RESULTS_LOST,
+ WIFI_EVENT_RSSI_MONITOR,
+ GSCAN_EVENT_EPNO_EVENT,
+ GSCAN_EVENT_ANQPO_HOTSPOT_MATCH,
+} WIFI_VENDOR_EVENT;
+
+typedef void (*wifi_internal_event_handler) (wifi_handle handle, int events);
+
+class WifiCommand;
+
+typedef struct {
+ int nl_cmd;
+ uint32_t vendor_id;
+ int vendor_subcmd;
+ nl_recvmsg_msg_cb_t cb_func;
+ void *cb_arg;
+} cb_info;
+
+typedef struct {
+ wifi_request_id id;
+ WifiCommand *cmd;
+} cmd_info;
+
+typedef struct {
+ wifi_handle handle; // handle to wifi data
+ char name[8+1]; // interface name + trailing null
+ int id; // id to use when talking to driver
+} interface_info;
+
+typedef struct {
+
+ struct nl_sock *cmd_sock; // command socket object
+ struct nl_sock *event_sock; // event socket object
+ int nl80211_family_id; // family id for 80211 driver
+ int cleanup_socks[2]; // sockets used to implement wifi_cleanup
+
+ bool in_event_loop; // Indicates that event loop is active
+ bool clean_up; // Indication to exit since cleanup has started
+
+ wifi_internal_event_handler event_handler; // default event handler
+ wifi_cleaned_up_handler cleaned_up_handler; // socket cleaned up handler
+
+ cb_info *event_cb; // event callbacks
+ int num_event_cb; // number of event callbacks
+ int alloc_event_cb; // number of allocated callback objects
+ pthread_mutex_t cb_lock; // mutex for the event_cb access
+
+ cmd_info *cmd; // Outstanding commands
+ int num_cmd; // number of commands
+ int alloc_cmd; // number of commands allocated
+
+ interface_info **interfaces; // array of interfaces
+ int num_interfaces; // number of interfaces
+
+
+ // add other details
+} hal_info;
+
+#define PNO_SSID_FOUND 0x1
+#define PNO_SSID_LOST 0x2
+
+typedef struct wifi_pno_result {
+ unsigned char ssid[DOT11_MAX_SSID_LEN];
+ unsigned char ssid_len;
+ signed char rssi;
+ u16 channel;
+ u16 flags;
+ mac_addr bssid;
+} wifi_pno_result_t;
+
+typedef struct wifi_gscan_result {
+ u64 ts; // Time of discovery
+ u8 ssid[DOT11_MAX_SSID_LEN+1]; // null terminated
+ mac_addr bssid; // BSSID
+ u32 channel; // channel frequency in MHz
+ s32 rssi; // in db
+ u64 rtt; // in nanoseconds
+ u64 rtt_sd; // standard deviation in rtt
+ u16 beacon_period; // units are Kusec
+ u16 capability; // Capability information
+ u32 ie_length;
+ char ie_data[1];
+} wifi_gscan_result_t;
+
+typedef struct wifi_gscan_full_result {
+ wifi_gscan_result_t fixed;
+ u32 scan_ch_bucket; // scan chbucket bitmask
+ u32 ie_length; // byte length of Information Elements
+ u8 ie_data[1]; // IE data to follow
+} wifi_gscan_full_result_t;
+
+wifi_error wifi_register_handler(wifi_handle handle, int cmd, nl_recvmsg_msg_cb_t func, void *arg);
+wifi_error wifi_register_vendor_handler(wifi_handle handle,
+ uint32_t id, int subcmd, nl_recvmsg_msg_cb_t func, void *arg);
+
+void wifi_unregister_handler(wifi_handle handle, int cmd);
+void wifi_unregister_vendor_handler(wifi_handle handle, uint32_t id, int subcmd);
+
+wifi_error wifi_register_cmd(wifi_handle handle, int id, WifiCommand *cmd);
+WifiCommand *wifi_unregister_cmd(wifi_handle handle, int id);
+WifiCommand *wifi_get_cmd(wifi_handle handle, int id);
+void wifi_unregister_cmd(wifi_handle handle, WifiCommand *cmd);
+
+interface_info *getIfaceInfo(wifi_interface_handle);
+wifi_handle getWifiHandle(wifi_interface_handle handle);
+hal_info *getHalInfo(wifi_handle handle);
+hal_info *getHalInfo(wifi_interface_handle handle);
+wifi_handle getWifiHandle(hal_info *info);
+wifi_interface_handle getIfaceHandle(interface_info *info);
+wifi_error wifi_cancel_cmd(wifi_request_id id, wifi_interface_handle iface);
+
+// some common macros
+
+#define min(x, y) ((x) < (y) ? (x) : (y))
+#define max(x, y) ((x) > (y) ? (x) : (y))
+
+#define NULL_CHECK_RETURN(ptr, str, ret) \
+ do { \
+ if (!(ptr)) { \
+ ALOGE("%s(): null pointer - #ptr (%s)\n", __FUNCTION__, str); \
+ return ret; \
+ } \
+ } while (0)
+
+#endif
+
--- /dev/null
+
+#include <stdint.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/rtnetlink.h>
+#include <netpacket/packet.h>
+#include <linux/filter.h>
+#include <linux/errqueue.h>
+
+#include <linux/pkt_sched.h>
+#include <netlink/object-api.h>
+#include <netlink/netlink.h>
+#include <netlink/socket.h>
+#include <netlink/handlers.h>
+
+#include <ctype.h>
+
+#include "wifi_hal.h"
+#include "common.h"
+#include "cpp_bindings.h"
+
+void appendFmt(char *buf, int &offset, const char *fmt, ...)
+{
+ va_list params;
+ va_start(params, fmt);
+ offset += vsprintf(buf + offset, fmt, params);
+ va_end(params);
+}
+
+#define C2S(x) case x: return #x;
+
+static const char *cmdToString(int cmd)
+{
+ switch (cmd) {
+ C2S(NL80211_CMD_UNSPEC)
+ C2S(NL80211_CMD_GET_WIPHY)
+ C2S(NL80211_CMD_SET_WIPHY)
+ C2S(NL80211_CMD_NEW_WIPHY)
+ C2S(NL80211_CMD_DEL_WIPHY)
+ C2S(NL80211_CMD_GET_INTERFACE)
+ C2S(NL80211_CMD_SET_INTERFACE)
+ C2S(NL80211_CMD_NEW_INTERFACE)
+ C2S(NL80211_CMD_DEL_INTERFACE)
+ C2S(NL80211_CMD_GET_KEY)
+ C2S(NL80211_CMD_SET_KEY)
+ C2S(NL80211_CMD_NEW_KEY)
+ C2S(NL80211_CMD_DEL_KEY)
+ C2S(NL80211_CMD_GET_BEACON)
+ C2S(NL80211_CMD_SET_BEACON)
+ C2S(NL80211_CMD_START_AP)
+ C2S(NL80211_CMD_STOP_AP)
+ C2S(NL80211_CMD_GET_STATION)
+ C2S(NL80211_CMD_SET_STATION)
+ C2S(NL80211_CMD_NEW_STATION)
+ C2S(NL80211_CMD_DEL_STATION)
+ C2S(NL80211_CMD_GET_MPATH)
+ C2S(NL80211_CMD_SET_MPATH)
+ C2S(NL80211_CMD_NEW_MPATH)
+ C2S(NL80211_CMD_DEL_MPATH)
+ C2S(NL80211_CMD_SET_BSS)
+ C2S(NL80211_CMD_SET_REG)
+ C2S(NL80211_CMD_REQ_SET_REG)
+ C2S(NL80211_CMD_GET_MESH_CONFIG)
+ C2S(NL80211_CMD_SET_MESH_CONFIG)
+ C2S(NL80211_CMD_SET_MGMT_EXTRA_IE)
+ C2S(NL80211_CMD_GET_REG)
+ C2S(NL80211_CMD_GET_SCAN)
+ C2S(NL80211_CMD_TRIGGER_SCAN)
+ C2S(NL80211_CMD_NEW_SCAN_RESULTS)
+ C2S(NL80211_CMD_SCAN_ABORTED)
+ C2S(NL80211_CMD_REG_CHANGE)
+ C2S(NL80211_CMD_AUTHENTICATE)
+ C2S(NL80211_CMD_ASSOCIATE)
+ C2S(NL80211_CMD_DEAUTHENTICATE)
+ C2S(NL80211_CMD_DISASSOCIATE)
+ C2S(NL80211_CMD_MICHAEL_MIC_FAILURE)
+ C2S(NL80211_CMD_REG_BEACON_HINT)
+ C2S(NL80211_CMD_JOIN_IBSS)
+ C2S(NL80211_CMD_LEAVE_IBSS)
+ C2S(NL80211_CMD_TESTMODE)
+ C2S(NL80211_CMD_CONNECT)
+ C2S(NL80211_CMD_ROAM)
+ C2S(NL80211_CMD_DISCONNECT)
+ C2S(NL80211_CMD_SET_WIPHY_NETNS)
+ C2S(NL80211_CMD_GET_SURVEY)
+ C2S(NL80211_CMD_NEW_SURVEY_RESULTS)
+ C2S(NL80211_CMD_SET_PMKSA)
+ C2S(NL80211_CMD_DEL_PMKSA)
+ C2S(NL80211_CMD_FLUSH_PMKSA)
+ C2S(NL80211_CMD_REMAIN_ON_CHANNEL)
+ C2S(NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL)
+ C2S(NL80211_CMD_SET_TX_BITRATE_MASK)
+ C2S(NL80211_CMD_REGISTER_FRAME)
+ C2S(NL80211_CMD_FRAME)
+ C2S(NL80211_CMD_FRAME_TX_STATUS)
+ C2S(NL80211_CMD_SET_POWER_SAVE)
+ C2S(NL80211_CMD_GET_POWER_SAVE)
+ C2S(NL80211_CMD_SET_CQM)
+ C2S(NL80211_CMD_NOTIFY_CQM)
+ C2S(NL80211_CMD_SET_CHANNEL)
+ C2S(NL80211_CMD_SET_WDS_PEER)
+ C2S(NL80211_CMD_FRAME_WAIT_CANCEL)
+ C2S(NL80211_CMD_JOIN_MESH)
+ C2S(NL80211_CMD_LEAVE_MESH)
+ C2S(NL80211_CMD_UNPROT_DEAUTHENTICATE)
+ C2S(NL80211_CMD_UNPROT_DISASSOCIATE)
+ C2S(NL80211_CMD_NEW_PEER_CANDIDATE)
+ C2S(NL80211_CMD_GET_WOWLAN)
+ C2S(NL80211_CMD_SET_WOWLAN)
+ C2S(NL80211_CMD_START_SCHED_SCAN)
+ C2S(NL80211_CMD_STOP_SCHED_SCAN)
+ C2S(NL80211_CMD_SCHED_SCAN_RESULTS)
+ C2S(NL80211_CMD_SCHED_SCAN_STOPPED)
+ C2S(NL80211_CMD_SET_REKEY_OFFLOAD)
+ C2S(NL80211_CMD_PMKSA_CANDIDATE)
+ C2S(NL80211_CMD_TDLS_OPER)
+ C2S(NL80211_CMD_TDLS_MGMT)
+ C2S(NL80211_CMD_UNEXPECTED_FRAME)
+ C2S(NL80211_CMD_PROBE_CLIENT)
+ C2S(NL80211_CMD_REGISTER_BEACONS)
+ C2S(NL80211_CMD_UNEXPECTED_4ADDR_FRAME)
+ C2S(NL80211_CMD_SET_NOACK_MAP)
+ C2S(NL80211_CMD_CH_SWITCH_NOTIFY)
+ C2S(NL80211_CMD_START_P2P_DEVICE)
+ C2S(NL80211_CMD_STOP_P2P_DEVICE)
+ C2S(NL80211_CMD_CONN_FAILED)
+ C2S(NL80211_CMD_SET_MCAST_RATE)
+ C2S(NL80211_CMD_SET_MAC_ACL)
+ C2S(NL80211_CMD_RADAR_DETECT)
+ C2S(NL80211_CMD_GET_PROTOCOL_FEATURES)
+ C2S(NL80211_CMD_UPDATE_FT_IES)
+ C2S(NL80211_CMD_FT_EVENT)
+ C2S(NL80211_CMD_CRIT_PROTOCOL_START)
+ C2S(NL80211_CMD_CRIT_PROTOCOL_STOP)
+ C2S(NL80211_CMD_GET_COALESCE)
+ C2S(NL80211_CMD_SET_COALESCE)
+ C2S(NL80211_CMD_CHANNEL_SWITCH)
+ C2S(NL80211_CMD_VENDOR)
+ C2S(NL80211_CMD_SET_QOS_MAP)
+ default:
+ return "NL80211_CMD_UNKNOWN";
+ }
+}
+
+const char *attributeToString(int attribute)
+{
+ switch (attribute) {
+ C2S(NL80211_ATTR_UNSPEC)
+
+ C2S(NL80211_ATTR_WIPHY)
+ C2S(NL80211_ATTR_WIPHY_NAME)
+
+ C2S(NL80211_ATTR_IFINDEX)
+ C2S(NL80211_ATTR_IFNAME)
+ C2S(NL80211_ATTR_IFTYPE)
+
+ C2S(NL80211_ATTR_MAC)
+
+ C2S(NL80211_ATTR_KEY_DATA)
+ C2S(NL80211_ATTR_KEY_IDX)
+ C2S(NL80211_ATTR_KEY_CIPHER)
+ C2S(NL80211_ATTR_KEY_SEQ)
+ C2S(NL80211_ATTR_KEY_DEFAULT)
+
+ C2S(NL80211_ATTR_BEACON_INTERVAL)
+ C2S(NL80211_ATTR_DTIM_PERIOD)
+ C2S(NL80211_ATTR_BEACON_HEAD)
+ C2S(NL80211_ATTR_BEACON_TAIL)
+
+ C2S(NL80211_ATTR_STA_AID)
+ C2S(NL80211_ATTR_STA_FLAGS)
+ C2S(NL80211_ATTR_STA_LISTEN_INTERVAL)
+ C2S(NL80211_ATTR_STA_SUPPORTED_RATES)
+ C2S(NL80211_ATTR_STA_VLAN)
+ C2S(NL80211_ATTR_STA_INFO)
+
+ C2S(NL80211_ATTR_WIPHY_BANDS)
+
+ C2S(NL80211_ATTR_MNTR_FLAGS)
+
+ C2S(NL80211_ATTR_MESH_ID)
+ C2S(NL80211_ATTR_STA_PLINK_ACTION)
+ C2S(NL80211_ATTR_MPATH_NEXT_HOP)
+ C2S(NL80211_ATTR_MPATH_INFO)
+
+ C2S(NL80211_ATTR_BSS_CTS_PROT)
+ C2S(NL80211_ATTR_BSS_SHORT_PREAMBLE)
+ C2S(NL80211_ATTR_BSS_SHORT_SLOT_TIME)
+
+ C2S(NL80211_ATTR_HT_CAPABILITY)
+
+ C2S(NL80211_ATTR_SUPPORTED_IFTYPES)
+
+ C2S(NL80211_ATTR_REG_ALPHA2)
+ C2S(NL80211_ATTR_REG_RULES)
+
+ C2S(NL80211_ATTR_MESH_CONFIG)
+
+ C2S(NL80211_ATTR_BSS_BASIC_RATES)
+
+ C2S(NL80211_ATTR_WIPHY_TXQ_PARAMS)
+ C2S(NL80211_ATTR_WIPHY_FREQ)
+ C2S(NL80211_ATTR_WIPHY_CHANNEL_TYPE)
+
+ C2S(NL80211_ATTR_KEY_DEFAULT_MGMT)
+
+ C2S(NL80211_ATTR_MGMT_SUBTYPE)
+ C2S(NL80211_ATTR_IE)
+
+ C2S(NL80211_ATTR_MAX_NUM_SCAN_SSIDS)
+
+ C2S(NL80211_ATTR_SCAN_FREQUENCIES)
+ C2S(NL80211_ATTR_SCAN_SSIDS)
+ C2S(NL80211_ATTR_GENERATION) /* replaces old SCAN_GENERATION */
+ C2S(NL80211_ATTR_BSS)
+
+ C2S(NL80211_ATTR_REG_INITIATOR)
+ C2S(NL80211_ATTR_REG_TYPE)
+
+ C2S(NL80211_ATTR_SUPPORTED_COMMANDS)
+
+ C2S(NL80211_ATTR_FRAME)
+ C2S(NL80211_ATTR_SSID)
+ C2S(NL80211_ATTR_AUTH_TYPE)
+ C2S(NL80211_ATTR_REASON_CODE)
+
+ C2S(NL80211_ATTR_KEY_TYPE)
+
+ C2S(NL80211_ATTR_MAX_SCAN_IE_LEN)
+ C2S(NL80211_ATTR_CIPHER_SUITES)
+
+ C2S(NL80211_ATTR_FREQ_BEFORE)
+ C2S(NL80211_ATTR_FREQ_AFTER)
+
+ C2S(NL80211_ATTR_FREQ_FIXED)
+
+
+ C2S(NL80211_ATTR_WIPHY_RETRY_SHORT)
+ C2S(NL80211_ATTR_WIPHY_RETRY_LONG)
+ C2S(NL80211_ATTR_WIPHY_FRAG_THRESHOLD)
+ C2S(NL80211_ATTR_WIPHY_RTS_THRESHOLD)
+
+ C2S(NL80211_ATTR_TIMED_OUT)
+
+ C2S(NL80211_ATTR_USE_MFP)
+
+ C2S(NL80211_ATTR_STA_FLAGS2)
+
+ C2S(NL80211_ATTR_CONTROL_PORT)
+
+ C2S(NL80211_ATTR_TESTDATA)
+
+ C2S(NL80211_ATTR_PRIVACY)
+
+ C2S(NL80211_ATTR_DISCONNECTED_BY_AP)
+ C2S(NL80211_ATTR_STATUS_CODE)
+
+ C2S(NL80211_ATTR_CIPHER_SUITES_PAIRWISE)
+ C2S(NL80211_ATTR_CIPHER_SUITE_GROUP)
+ C2S(NL80211_ATTR_WPA_VERSIONS)
+ C2S(NL80211_ATTR_AKM_SUITES)
+
+ C2S(NL80211_ATTR_REQ_IE)
+ C2S(NL80211_ATTR_RESP_IE)
+
+ C2S(NL80211_ATTR_PREV_BSSID)
+
+ C2S(NL80211_ATTR_KEY)
+ C2S(NL80211_ATTR_KEYS)
+
+ C2S(NL80211_ATTR_PID)
+
+ C2S(NL80211_ATTR_4ADDR)
+
+ C2S(NL80211_ATTR_SURVEY_INFO)
+
+ C2S(NL80211_ATTR_PMKID)
+ C2S(NL80211_ATTR_MAX_NUM_PMKIDS)
+
+ C2S(NL80211_ATTR_DURATION)
+
+ C2S(NL80211_ATTR_COOKIE)
+
+ C2S(NL80211_ATTR_WIPHY_COVERAGE_CLASS)
+
+ C2S(NL80211_ATTR_TX_RATES)
+
+ C2S(NL80211_ATTR_FRAME_MATCH)
+
+ C2S(NL80211_ATTR_ACK)
+
+ C2S(NL80211_ATTR_PS_STATE)
+
+ C2S(NL80211_ATTR_CQM)
+
+ C2S(NL80211_ATTR_LOCAL_STATE_CHANGE)
+
+ C2S(NL80211_ATTR_AP_ISOLATE)
+
+ C2S(NL80211_ATTR_WIPHY_TX_POWER_SETTING)
+ C2S(NL80211_ATTR_WIPHY_TX_POWER_LEVEL)
+
+ C2S(NL80211_ATTR_TX_FRAME_TYPES)
+ C2S(NL80211_ATTR_RX_FRAME_TYPES)
+ C2S(NL80211_ATTR_FRAME_TYPE)
+
+ C2S(NL80211_ATTR_CONTROL_PORT_ETHERTYPE)
+ C2S(NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT)
+
+ C2S(NL80211_ATTR_SUPPORT_IBSS_RSN)
+
+ C2S(NL80211_ATTR_WIPHY_ANTENNA_TX)
+ C2S(NL80211_ATTR_WIPHY_ANTENNA_RX)
+
+ C2S(NL80211_ATTR_MCAST_RATE)
+
+ C2S(NL80211_ATTR_OFFCHANNEL_TX_OK)
+
+ C2S(NL80211_ATTR_BSS_HT_OPMODE)
+
+ C2S(NL80211_ATTR_KEY_DEFAULT_TYPES)
+
+ C2S(NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION)
+
+ C2S(NL80211_ATTR_MESH_SETUP)
+
+ C2S(NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX)
+ C2S(NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX)
+
+ C2S(NL80211_ATTR_SUPPORT_MESH_AUTH)
+ C2S(NL80211_ATTR_STA_PLINK_STATE)
+
+ C2S(NL80211_ATTR_WOWLAN_TRIGGERS)
+ C2S(NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED)
+
+ C2S(NL80211_ATTR_SCHED_SCAN_INTERVAL)
+
+ C2S(NL80211_ATTR_INTERFACE_COMBINATIONS)
+ C2S(NL80211_ATTR_SOFTWARE_IFTYPES)
+
+ C2S(NL80211_ATTR_REKEY_DATA)
+
+ C2S(NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS)
+ C2S(NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN)
+
+ C2S(NL80211_ATTR_SCAN_SUPP_RATES)
+
+ C2S(NL80211_ATTR_HIDDEN_SSID)
+
+ C2S(NL80211_ATTR_IE_PROBE_RESP)
+ C2S(NL80211_ATTR_IE_ASSOC_RESP)
+
+ C2S(NL80211_ATTR_STA_WME)
+ C2S(NL80211_ATTR_SUPPORT_AP_UAPSD)
+
+ C2S(NL80211_ATTR_ROAM_SUPPORT)
+
+ C2S(NL80211_ATTR_SCHED_SCAN_MATCH)
+ C2S(NL80211_ATTR_MAX_MATCH_SETS)
+
+ C2S(NL80211_ATTR_PMKSA_CANDIDATE)
+
+ C2S(NL80211_ATTR_TX_NO_CCK_RATE)
+
+ C2S(NL80211_ATTR_TDLS_ACTION)
+ C2S(NL80211_ATTR_TDLS_DIALOG_TOKEN)
+ C2S(NL80211_ATTR_TDLS_OPERATION)
+ C2S(NL80211_ATTR_TDLS_SUPPORT)
+ C2S(NL80211_ATTR_TDLS_EXTERNAL_SETUP)
+
+ C2S(NL80211_ATTR_DEVICE_AP_SME)
+
+ C2S(NL80211_ATTR_DONT_WAIT_FOR_ACK)
+
+ C2S(NL80211_ATTR_FEATURE_FLAGS)
+
+ C2S(NL80211_ATTR_PROBE_RESP_OFFLOAD)
+
+ C2S(NL80211_ATTR_PROBE_RESP)
+
+ C2S(NL80211_ATTR_DFS_REGION)
+
+ C2S(NL80211_ATTR_DISABLE_HT)
+ C2S(NL80211_ATTR_HT_CAPABILITY_MASK)
+
+ C2S(NL80211_ATTR_NOACK_MAP)
+
+ C2S(NL80211_ATTR_INACTIVITY_TIMEOUT)
+
+ C2S(NL80211_ATTR_RX_SIGNAL_DBM)
+
+ C2S(NL80211_ATTR_BG_SCAN_PERIOD)
+
+ C2S(NL80211_ATTR_WDEV)
+
+ C2S(NL80211_ATTR_USER_REG_HINT_TYPE)
+
+ C2S(NL80211_ATTR_CONN_FAILED_REASON)
+
+ C2S(NL80211_ATTR_SAE_DATA)
+
+ C2S(NL80211_ATTR_VHT_CAPABILITY)
+
+ C2S(NL80211_ATTR_SCAN_FLAGS)
+
+ C2S(NL80211_ATTR_CHANNEL_WIDTH)
+ C2S(NL80211_ATTR_CENTER_FREQ1)
+ C2S(NL80211_ATTR_CENTER_FREQ2)
+
+ C2S(NL80211_ATTR_P2P_CTWINDOW)
+ C2S(NL80211_ATTR_P2P_OPPPS)
+
+ C2S(NL80211_ATTR_LOCAL_MESH_POWER_MODE)
+
+ C2S(NL80211_ATTR_ACL_POLICY)
+
+ C2S(NL80211_ATTR_MAC_ADDRS)
+
+ C2S(NL80211_ATTR_MAC_ACL_MAX)
+
+ C2S(NL80211_ATTR_RADAR_EVENT)
+
+ C2S(NL80211_ATTR_EXT_CAPA)
+ C2S(NL80211_ATTR_EXT_CAPA_MASK)
+
+ C2S(NL80211_ATTR_STA_CAPABILITY)
+ C2S(NL80211_ATTR_STA_EXT_CAPABILITY)
+
+ C2S(NL80211_ATTR_PROTOCOL_FEATURES)
+ C2S(NL80211_ATTR_SPLIT_WIPHY_DUMP)
+
+ C2S(NL80211_ATTR_DISABLE_VHT)
+ C2S(NL80211_ATTR_VHT_CAPABILITY_MASK)
+
+ C2S(NL80211_ATTR_MDID)
+ C2S(NL80211_ATTR_IE_RIC)
+
+ C2S(NL80211_ATTR_CRIT_PROT_ID)
+ C2S(NL80211_ATTR_MAX_CRIT_PROT_DURATION)
+
+ C2S(NL80211_ATTR_PEER_AID)
+
+ C2S(NL80211_ATTR_COALESCE_RULE)
+
+ C2S(NL80211_ATTR_CH_SWITCH_COUNT)
+ C2S(NL80211_ATTR_CH_SWITCH_BLOCK_TX)
+ C2S(NL80211_ATTR_CSA_IES)
+ C2S(NL80211_ATTR_CSA_C_OFF_BEACON)
+ C2S(NL80211_ATTR_CSA_C_OFF_PRESP)
+
+ C2S(NL80211_ATTR_RXMGMT_FLAGS)
+
+ C2S(NL80211_ATTR_STA_SUPPORTED_CHANNELS)
+
+ C2S(NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES)
+
+ C2S(NL80211_ATTR_HANDLE_DFS)
+
+ C2S(NL80211_ATTR_SUPPORT_5_MHZ)
+ C2S(NL80211_ATTR_SUPPORT_10_MHZ)
+
+ C2S(NL80211_ATTR_OPMODE_NOTIF)
+
+ C2S(NL80211_ATTR_VENDOR_ID)
+ C2S(NL80211_ATTR_VENDOR_SUBCMD)
+ C2S(NL80211_ATTR_VENDOR_DATA)
+ C2S(NL80211_ATTR_VENDOR_EVENTS)
+
+ C2S(NL80211_ATTR_QOS_MAP)
+ default:
+ return "NL80211_ATTR_UNKNOWN";
+ }
+}
+
+void WifiEvent::log() {
+ parse();
+
+ byte *data = (byte *)genlmsg_attrdata(mHeader, 0);
+ int len = genlmsg_attrlen(mHeader, 0);
+ ALOGD("cmd = %s, len = %d", get_cmdString(), len);
+ ALOGD("vendor_id = %04x, vendor_subcmd = %d", get_vendor_id(), get_vendor_subcmd());
+
+ for (int i = 0; i < len; i += 16) {
+ char line[81];
+ int linelen = min(16, len - i);
+ int offset = 0;
+ appendFmt(line, offset, "%02x", data[i]);
+ for (int j = 1; j < linelen; j++) {
+ appendFmt(line, offset, " %02x", data[i+j]);
+ }
+
+ for (int j = linelen; j < 16; j++) {
+ appendFmt(line, offset, " ");
+ }
+
+ line[23] = '-';
+
+ appendFmt(line, offset, " ");
+
+ for (int j = 0; j < linelen; j++) {
+ if (isprint(data[i+j])) {
+ appendFmt(line, offset, "%c", data[i+j]);
+ } else {
+ appendFmt(line, offset, "-");
+ }
+ }
+
+ ALOGD("%s", line);
+ }
+
+ for (unsigned i = 0; i < NL80211_ATTR_MAX_INTERNAL; i++) {
+ if (mAttributes[i] != NULL) {
+ ALOGD("found attribute %s", attributeToString(i));
+ }
+ }
+
+ ALOGD("-- End of message --");
+}
+
+const char *WifiEvent::get_cmdString() {
+ return cmdToString(get_cmd());
+}
+
+
+int WifiEvent::parse() {
+ if (mHeader != NULL) {
+ return WIFI_SUCCESS;
+ }
+ mHeader = (genlmsghdr *)nlmsg_data(nlmsg_hdr(mMsg));
+ int result = nla_parse(mAttributes, NL80211_ATTR_MAX_INTERNAL, genlmsg_attrdata(mHeader, 0),
+ genlmsg_attrlen(mHeader, 0), NULL);
+
+ // ALOGD("event len = %d", nlmsg_hdr(mMsg)->nlmsg_len);
+ return result;
+}
+
+int WifiRequest::create(int family, uint8_t cmd, int flags, int hdrlen) {
+
+ destroy();
+
+ mMsg = nlmsg_alloc();
+ if (mMsg != NULL) {
+ genlmsg_put(mMsg, /* pid = */ 0, /* seq = */ 0, family,
+ hdrlen, flags, cmd, /* version = */ 0);
+ return WIFI_SUCCESS;
+ } else {
+ return WIFI_ERROR_OUT_OF_MEMORY;
+ }
+}
+
+int WifiRequest::create(uint32_t id, int subcmd) {
+ int res = create(NL80211_CMD_VENDOR);
+ if (res < 0) {
+ return res;
+ }
+
+ res = put_u32(NL80211_ATTR_VENDOR_ID, id);
+ if (res < 0) {
+ return res;
+ }
+
+ res = put_u32(NL80211_ATTR_VENDOR_SUBCMD, subcmd);
+ if (res < 0) {
+ return res;
+ }
+
+ if (mIface != -1) {
+ res = set_iface_id(mIface);
+ ALOGD("WifiRequest::create vendor command to iface %d, vendor_id=0x%x, subcmd=0x%04x, res=%d",
+ mIface, id, subcmd, res);
+ }
+
+ return res;
+}
+
+
+static int no_seq_check(struct nl_msg *msg, void *arg)
+{
+ return NL_OK;
+}
+
+int WifiCommand::requestResponse() {
+ int err = create();
+ if (err < 0) {
+ return err;
+ }
+
+ return requestResponse(mMsg);
+}
+
+int WifiCommand::requestResponse(WifiRequest& request) {
+ int err = 0;
+
+ struct nl_cb *cb = nl_cb_alloc(NL_CB_DEFAULT);
+ if (!cb)
+ goto out;
+
+ /* send message */
+ err = nl_send_auto_complete(mInfo->cmd_sock, request.getMessage());
+ if (err < 0)
+ goto out;
+
+ err = 1;
+
+ nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL);
+ nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &err);
+ nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &err);
+ nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err);
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, response_handler, this);
+
+ /* wait for reply */
+ while (err > 0) {
+ int res = nl_recvmsgs(mInfo->cmd_sock, cb);
+ if (res) {
+ ALOGE("WifiCommand::requestResponse nl_recvmsgs failed: %d", res);
+ }
+ }
+ if (err)
+ ALOGD("WifiCommand::requestResponse err=%d", err);
+out:
+ nl_cb_put(cb);
+ return err;
+}
+
+int WifiCommand::requestEvent(int cmd) {
+
+ ALOGD("WifiCommand::requestEvent for cmd %d", cmd);
+
+ int res = wifi_register_handler(wifiHandle(), cmd, event_handler, this);
+ if (res < 0) {
+ return res;
+ }
+
+ res = create();
+ if (res < 0)
+ goto out;
+
+ ALOGD("WifiCommand::requestEvent waiting for response %d", cmd);
+
+ res = nl_send_auto_complete(mInfo->cmd_sock, mMsg.getMessage());
+ if (res < 0)
+ goto out;
+
+ ALOGD("WifiCommand::requestEvent waiting for event");
+ res = mCondition.wait();
+ if (res < 0)
+ goto out;
+
+out:
+ wifi_unregister_handler(wifiHandle(), cmd);
+ return res;
+}
+
+int WifiCommand::requestVendorEvent(uint32_t id, int subcmd) {
+
+ int res = wifi_register_vendor_handler(wifiHandle(), id, subcmd, event_handler, this);
+ if (res < 0) {
+ return res;
+ }
+
+ res = create();
+ if (res < 0)
+ goto out;
+
+ res = nl_send_auto_complete(mInfo->cmd_sock, mMsg.getMessage());
+ if (res < 0)
+ goto out;
+
+ res = mCondition.wait();
+ if (res < 0)
+ goto out;
+
+out:
+ wifi_unregister_vendor_handler(wifiHandle(), id, subcmd);
+ return res;
+}
+
+/* Event handlers */
+int WifiCommand::response_handler(struct nl_msg *msg, void *arg) {
+ // ALOGD("response_handler called");
+ WifiCommand *cmd = (WifiCommand *)arg;
+ WifiEvent reply(msg);
+ int res = reply.parse();
+ if (res < 0) {
+ ALOGE("Failed to parse reply message = %d", res);
+ return NL_SKIP;
+ } else {
+ // reply.log();
+ return cmd->handleResponse(reply);
+ }
+}
+
+int WifiCommand::event_handler(struct nl_msg *msg, void *arg) {
+ WifiCommand *cmd = (WifiCommand *)arg;
+ WifiEvent event(msg);
+ int res = event.parse();
+ if (res < 0) {
+ ALOGE("Failed to parse event = %d", res);
+ res = NL_SKIP;
+ } else {
+ res = cmd->handleEvent(event);
+ }
+
+ cmd->mCondition.signal();
+ return res;
+}
+
+/* Other event handlers */
+int WifiCommand::valid_handler(struct nl_msg *msg, void *arg) {
+ // ALOGD("valid_handler called");
+ int *err = (int *)arg;
+ *err = 0;
+ return NL_SKIP;
+}
+
+int WifiCommand::ack_handler(struct nl_msg *msg, void *arg) {
+ // ALOGD("ack_handler called");
+ int *err = (int *)arg;
+ *err = 0;
+ return NL_STOP;
+}
+
+int WifiCommand::finish_handler(struct nl_msg *msg, void *arg) {
+ // ALOGD("finish_handler called");
+ int *ret = (int *)arg;
+ *ret = 0;
+ return NL_SKIP;
+}
+
+int WifiCommand::error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg) {
+ int *ret = (int *)arg;
+ *ret = err->error;
+
+ // ALOGD("error_handler received : %d", err->error);
+ return NL_SKIP;
+}
--- /dev/null
+
+#include "wifi_hal.h"
+#include "common.h"
+#include "sync.h"
+
+class WifiEvent
+{
+ /* TODO: remove this when nl headers are updated */
+ static const unsigned NL80211_ATTR_MAX_INTERNAL = 256;
+private:
+ struct nl_msg *mMsg;
+ struct genlmsghdr *mHeader;
+ struct nlattr *mAttributes[NL80211_ATTR_MAX_INTERNAL + 1];
+
+public:
+ WifiEvent(nl_msg *msg) {
+ mMsg = msg;
+ mHeader = NULL;
+ memset(mAttributes, 0, sizeof(mAttributes));
+ }
+ ~WifiEvent() {
+ /* don't destroy mMsg; it doesn't belong to us */
+ }
+
+ void log();
+
+ int parse();
+
+ genlmsghdr *header() {
+ return mHeader;
+ }
+
+ int get_cmd() {
+ return mHeader->cmd;
+ }
+
+ int get_vendor_id() {
+ return get_u32(NL80211_ATTR_VENDOR_ID);
+ }
+
+ int get_vendor_subcmd() {
+ return get_u32(NL80211_ATTR_VENDOR_SUBCMD);
+ }
+
+ void *get_vendor_data() {
+ return get_data(NL80211_ATTR_VENDOR_DATA);
+ }
+
+ int get_vendor_data_len() {
+ return get_len(NL80211_ATTR_VENDOR_DATA);
+ }
+
+ const char *get_cmdString();
+
+ nlattr ** attributes() {
+ return mAttributes;
+ }
+
+ nlattr *get_attribute(int attribute) {
+ return mAttributes[attribute];
+ }
+
+ uint8_t get_u8(int attribute) {
+ return mAttributes[attribute] ? nla_get_u8(mAttributes[attribute]) : 0;
+ }
+
+ uint16_t get_u16(int attribute) {
+ return mAttributes[attribute] ? nla_get_u16(mAttributes[attribute]) : 0;
+ }
+
+ uint32_t get_u32(int attribute) {
+ return mAttributes[attribute] ? nla_get_u32(mAttributes[attribute]) : 0;
+ }
+
+ uint64_t get_u64(int attribute) {
+ return mAttributes[attribute] ? nla_get_u64(mAttributes[attribute]) : 0;
+ }
+
+ int get_len(int attribute) {
+ return mAttributes[attribute] ? nla_len(mAttributes[attribute]) : 0;
+ }
+
+ void *get_data(int attribute) {
+ return mAttributes[attribute] ? nla_data(mAttributes[attribute]) : NULL;
+ }
+
+private:
+ WifiEvent(const WifiEvent&); // hide copy constructor to prevent copies
+};
+
+class nl_iterator {
+ struct nlattr *pos;
+ int rem;
+public:
+ nl_iterator(struct nlattr *attr) {
+ pos = (struct nlattr *)nla_data(attr);
+ rem = nla_len(attr);
+ }
+ bool has_next() {
+ return nla_ok(pos, rem);
+ }
+ void next() {
+ pos = (struct nlattr *)nla_next(pos, &(rem));
+ }
+ struct nlattr *get() {
+ return pos;
+ }
+ uint16_t get_type() {
+ return pos->nla_type;
+ }
+ uint8_t get_u8() {
+ return nla_get_u8(pos);
+ }
+ uint16_t get_u16() {
+ return nla_get_u16(pos);
+ }
+ uint32_t get_u32() {
+ return nla_get_u32(pos);
+ }
+ uint64_t get_u64() {
+ return nla_get_u64(pos);
+ }
+ void* get_data() {
+ return nla_data(pos);
+ }
+ int get_len() {
+ return nla_len(pos);
+ }
+private:
+ nl_iterator(const nl_iterator&); // hide copy constructor to prevent copies
+};
+
+class WifiRequest
+{
+private:
+ int mFamily;
+ int mIface;
+ struct nl_msg *mMsg;
+
+public:
+ WifiRequest(int family) {
+ mMsg = NULL;
+ mFamily = family;
+ mIface = -1;
+ }
+
+ WifiRequest(int family, int iface) {
+ mMsg = NULL;
+ mFamily = family;
+ mIface = iface;
+ }
+
+ ~WifiRequest() {
+ destroy();
+ }
+
+ void destroy() {
+ if (mMsg) {
+ nlmsg_free(mMsg);
+ mMsg = NULL;
+ }
+ }
+
+ nl_msg *getMessage() {
+ return mMsg;
+ }
+
+ /* Command assembly helpers */
+ int create(int family, uint8_t cmd, int flags, int hdrlen);
+ int create(uint8_t cmd) {
+ return create(mFamily, cmd, 0, 0);
+ }
+
+ int create(uint32_t id, int subcmd);
+
+ int put(int attribute, void *ptr, unsigned len) {
+ return nla_put(mMsg, attribute, len, ptr);
+ }
+ int put_u8(int attribute, uint8_t value) {
+ return nla_put(mMsg, attribute, sizeof(value), &value);
+ }
+ int put_u16(int attribute, uint16_t value) {
+ return nla_put(mMsg, attribute, sizeof(value), &value);
+ }
+ int put_u32(int attribute, uint32_t value) {
+ return nla_put(mMsg, attribute, sizeof(value), &value);
+ }
+ int put_u64(int attribute, uint64_t value) {
+ return nla_put(mMsg, attribute, sizeof(value), &value);
+ }
+ int put_string(int attribute, const char *value) {
+ return nla_put(mMsg, attribute, strlen(value) + 1, value);
+ }
+ int put_addr(int attribute, mac_addr value) {
+ return nla_put(mMsg, attribute, sizeof(mac_addr), value);
+ }
+
+ struct nlattr * attr_start(int attribute) {
+ return nla_nest_start(mMsg, attribute);
+ }
+ void attr_end(struct nlattr *attr) {
+ nla_nest_end(mMsg, attr);
+ }
+
+ int set_iface_id(int ifindex) {
+ return put_u32(NL80211_ATTR_IFINDEX, ifindex);
+ }
+private:
+ WifiRequest(const WifiRequest&); // hide copy constructor to prevent copies
+
+};
+
+class WifiCommand
+{
+protected:
+ const char *mType;
+ hal_info *mInfo;
+ WifiRequest mMsg;
+ Condition mCondition;
+ wifi_request_id mId;
+ interface_info *mIfaceInfo;
+ int mRefs;
+public:
+ WifiCommand(const char *type, wifi_handle handle, wifi_request_id id)
+ : mType(type), mMsg(getHalInfo(handle)->nl80211_family_id), mId(id), mRefs(1)
+ {
+ mIfaceInfo = NULL;
+ mInfo = getHalInfo(handle);
+ // ALOGD("WifiCommand %p created, mInfo = %p, mIfaceInfo = %p", this, mInfo, mIfaceInfo);
+ }
+
+ WifiCommand(const char *type, wifi_interface_handle iface, wifi_request_id id)
+ : mType(type), mMsg(getHalInfo(iface)->nl80211_family_id, getIfaceInfo(iface)->id),
+ mId(id), mRefs(1)
+ {
+ mIfaceInfo = getIfaceInfo(iface);
+ mInfo = getHalInfo(iface);
+ // ALOGD("WifiCommand2 %p created, mInfo=%p, mIfaceInfo=%p, id=%d", this, mInfo, mIfaceInfo, mIfaceInfo->id);
+ }
+
+ virtual ~WifiCommand() {
+ // ALOGD("WifiCommand %p destroyed", this);
+ }
+
+ wifi_request_id id() {
+ return mId;
+ }
+
+ const char *getType() {
+ return mType;
+ }
+
+ virtual void addRef() {
+ int refs = __sync_add_and_fetch(&mRefs, 1);
+ // ALOGD("addRef: WifiCommand %p has %d references", this, refs);
+ }
+
+ virtual void releaseRef() {
+ int refs = __sync_sub_and_fetch(&mRefs, 1);
+ if (refs == 0) {
+ delete this;
+ } else {
+ // ALOGD("releaseRef: WifiCommand %p has %d references", this, refs);
+ }
+ }
+
+ virtual int create() {
+ /* by default there is no way to cancel */
+ ALOGD("WifiCommand %p can't be created", this);
+ return WIFI_ERROR_NOT_SUPPORTED;
+ }
+
+ virtual int cancel() {
+ /* by default there is no way to cancel */
+ return WIFI_ERROR_NOT_SUPPORTED;
+ }
+
+ int requestResponse();
+ int requestEvent(int cmd);
+ int requestVendorEvent(uint32_t id, int subcmd);
+ int requestResponse(WifiRequest& request);
+
+protected:
+ wifi_handle wifiHandle() {
+ return getWifiHandle(mInfo);
+ }
+
+ wifi_interface_handle ifaceHandle() {
+ return getIfaceHandle(mIfaceInfo);
+ }
+
+ int familyId() {
+ return mInfo->nl80211_family_id;
+ }
+
+ int ifaceId() {
+ return mIfaceInfo->id;
+ }
+
+ /* Override this method to parse reply and dig out data; save it in the object */
+ virtual int handleResponse(WifiEvent& reply) {
+ ALOGI("skipping a response");
+ return NL_SKIP;
+ }
+
+ /* Override this method to parse event and dig out data; save it in the object */
+ virtual int handleEvent(WifiEvent& event) {
+ ALOGI("skipping an event");
+ return NL_SKIP;
+ }
+
+ int registerHandler(int cmd) {
+ return wifi_register_handler(wifiHandle(), cmd, &event_handler, this);
+ }
+
+ void unregisterHandler(int cmd) {
+ wifi_unregister_handler(wifiHandle(), cmd);
+ }
+
+ int registerVendorHandler(uint32_t id, int subcmd) {
+ return wifi_register_vendor_handler(wifiHandle(), id, subcmd, &event_handler, this);
+ }
+
+ void unregisterVendorHandler(uint32_t id, int subcmd) {
+ wifi_unregister_vendor_handler(wifiHandle(), id, subcmd);
+ }
+
+private:
+ WifiCommand(const WifiCommand& ); // hide copy constructor to prevent copies
+
+ /* Event handling */
+ static int response_handler(struct nl_msg *msg, void *arg);
+
+ static int event_handler(struct nl_msg *msg, void *arg);
+
+ /* Other event handlers */
+ static int valid_handler(struct nl_msg *msg, void *arg);
+
+ static int ack_handler(struct nl_msg *msg, void *arg);
+
+ static int finish_handler(struct nl_msg *msg, void *arg);
+
+ static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg);
+};
+
+/* nl message processing macros (required to pass C++ type checks) */
+
+#define for_each_attr(pos, nla, rem) \
+ for (pos = (nlattr *)nla_data(nla), rem = nla_len(nla); \
+ nla_ok(pos, rem); \
+ pos = (nlattr *)nla_next(pos, &(rem)))
+
--- /dev/null
+
+#include <stdint.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/rtnetlink.h>
+#include <netpacket/packet.h>
+#include <linux/filter.h>
+#include <linux/errqueue.h>
+
+#include <linux/pkt_sched.h>
+#include <netlink/object-api.h>
+#include <netlink/netlink.h>
+#include <netlink/socket.h>
+#include <netlink/handlers.h>
+
+#include "sync.h"
+
+#define LOG_TAG "WifiHAL"
+
+#include <utils/Log.h>
+
+#include "wifi_hal.h"
+#include "common.h"
+#include "cpp_bindings.h"
+
+typedef enum {
+ GSCAN_ATTRIBUTE_CAPABILITIES = 1,
+
+ GSCAN_ATTRIBUTE_NUM_BUCKETS = 10,
+ GSCAN_ATTRIBUTE_BASE_PERIOD,
+ GSCAN_ATTRIBUTE_BUCKETS_BAND,
+ GSCAN_ATTRIBUTE_BUCKET_ID,
+ GSCAN_ATTRIBUTE_BUCKET_PERIOD,
+ GSCAN_ATTRIBUTE_BUCKET_NUM_CHANNELS,
+ GSCAN_ATTRIBUTE_BUCKET_CHANNELS,
+ GSCAN_ATTRIBUTE_NUM_AP_PER_SCAN,
+ GSCAN_ATTRIBUTE_REPORT_THRESHOLD,
+ GSCAN_ATTRIBUTE_NUM_SCANS_TO_CACHE,
+
+ GSCAN_ATTRIBUTE_ENABLE_FEATURE = 20,
+ GSCAN_ATTRIBUTE_SCAN_RESULTS_COMPLETE, /* indicates no more results */
+ GSCAN_ATTRIBUTE_FLUSH_FEATURE, /* Flush all the configs */
+ GSCAN_ENABLE_FULL_SCAN_RESULTS,
+ GSCAN_ATTRIBUTE_REPORT_EVENTS,
+ /* Adaptive scan attributes */
+ GSCAN_ATTRIBUTE_BUCKET_STEP_COUNT,
+ GSCAN_ATTRIBUTE_BUCKET_MAX_PERIOD,
+
+ GSCAN_ATTRIBUTE_NUM_OF_RESULTS = 30,
+ GSCAN_ATTRIBUTE_FLUSH_RESULTS,
+ GSCAN_ATTRIBUTE_SCAN_RESULTS, /* flat array of wifi_scan_result */
+ GSCAN_ATTRIBUTE_SCAN_ID, /* indicates scan number */
+ GSCAN_ATTRIBUTE_SCAN_FLAGS, /* indicates if scan was aborted */
+ GSCAN_ATTRIBUTE_AP_FLAGS, /* flags on significant change event */
+ GSCAN_ATTRIBUTE_CH_BUCKET_BITMASK,
+
+ GSCAN_ATTRIBUTE_SSID = 40,
+ GSCAN_ATTRIBUTE_BSSID,
+ GSCAN_ATTRIBUTE_CHANNEL,
+ GSCAN_ATTRIBUTE_RSSI,
+ GSCAN_ATTRIBUTE_TIMESTAMP,
+ GSCAN_ATTRIBUTE_RTT,
+ GSCAN_ATTRIBUTE_RTTSD,
+
+ GSCAN_ATTRIBUTE_HOTLIST_BSSIDS = 50,
+ GSCAN_ATTRIBUTE_RSSI_LOW,
+ GSCAN_ATTRIBUTE_RSSI_HIGH,
+ GSCAN_ATTRIBUTE_HOTLIST_ELEM,
+ GSCAN_ATTRIBUTE_HOTLIST_FLUSH,
+
+ GSCAN_ATTRIBUTE_RSSI_SAMPLE_SIZE = 60,
+ GSCAN_ATTRIBUTE_LOST_AP_SAMPLE_SIZE,
+ GSCAN_ATTRIBUTE_MIN_BREACHING,
+ GSCAN_ATTRIBUTE_NUM_AP, /* TBD */
+ GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_BSSIDS,
+ GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH,
+
+ /* EPNO */
+ GSCAN_ATTRIBUTE_EPNO_SSID_LIST = 70,
+ GSCAN_ATTRIBUTE_EPNO_SSID,
+ GSCAN_ATTRIBUTE_EPNO_SSID_LEN,
+ GSCAN_ATTRIBUTE_EPNO_RSSI,
+ GSCAN_ATTRIBUTE_EPNO_FLAGS,
+ GSCAN_ATTRIBUTE_EPNO_AUTH,
+ GSCAN_ATTRIBUTE_EPNO_SSID_NUM,
+ GSCAN_ATTRIBUTE_EPNO_FLUSH,
+
+ GSCAN_ATTRIBUTE_WHITELIST_SSID = 80,
+ GSCAN_ATTRIBUTE_NUM_WL_SSID,
+ GSCAN_ATTRIBUTE_WL_SSID_LEN,
+ GSCAN_ATTRIBUTE_WL_SSID_FLUSH,
+ GSCAN_ATTRIBUTE_WHITELIST_SSID_ELEM,
+ GSCAN_ATTRIBUTE_NUM_BSSID,
+ GSCAN_ATTRIBUTE_BSSID_PREF_LIST,
+ GSCAN_ATTRIBUTE_BSSID_PREF_FLUSH,
+ GSCAN_ATTRIBUTE_BSSID_PREF,
+ GSCAN_ATTRIBUTE_RSSI_MODIFIER,
+
+ GSCAN_ATTRIBUTE_A_BAND_BOOST_THRESHOLD = 90,
+ GSCAN_ATTRIBUTE_A_BAND_PENALTY_THRESHOLD,
+ GSCAN_ATTRIBUTE_A_BAND_BOOST_FACTOR,
+ GSCAN_ATTRIBUTE_A_BAND_PENALTY_FACTOR,
+ GSCAN_ATTRIBUTE_A_BAND_MAX_BOOST,
+ GSCAN_ATTRIBUTE_LAZY_ROAM_HYSTERESIS,
+ GSCAN_ATTRIBUTE_ALERT_ROAM_RSSI_TRIGGER,
+ GSCAN_ATTRIBUTE_LAZY_ROAM_ENABLE,
+
+ /* BSSID blacklist */
+ GSCAN_ATTRIBUTE_BSSID_BLACKLIST_FLUSH = 100,
+ GSCAN_ATTRIBUTE_BLACKLIST_BSSID,
+
+ /* ANQPO */
+ GSCAN_ATTRIBUTE_ANQPO_HS_LIST = 110,
+ GSCAN_ATTRIBUTE_ANQPO_HS_LIST_SIZE,
+ GSCAN_ATTRIBUTE_ANQPO_HS_NETWORK_ID,
+ GSCAN_ATTRIBUTE_ANQPO_HS_NAI_REALM,
+ GSCAN_ATTRIBUTE_ANQPO_HS_ROAM_CONSORTIUM_ID,
+ GSCAN_ATTRIBUTE_ANQPO_HS_PLMN,
+
+ /* ePNO cfg */
+ GSCAN_ATTRIBUTE_EPNO_5G_RSSI_THR = 130,
+ GSCAN_ATTRIBUTE_EPNO_2G_RSSI_THR,
+ GSCAN_ATTRIBUTE_EPNO_INIT_SCORE_MAX,
+ GSCAN_ATTRIBUTE_EPNO_CUR_CONN_BONUS,
+ GSCAN_ATTRIBUTE_EPNO_SAME_NETWORK_BONUS,
+ GSCAN_ATTRIBUTE_EPNO_SECURE_BONUS,
+ GSCAN_ATTRIBUTE_EPNO_5G_BONUS,
+
+ GSCAN_ATTRIBUTE_MAX
+
+} GSCAN_ATTRIBUTE;
+
+// helper methods
+wifi_error wifi_enable_full_scan_results(wifi_request_id id, wifi_interface_handle iface,
+ wifi_scan_result_handler handler);
+wifi_error wifi_disable_full_scan_results(wifi_request_id id, wifi_interface_handle iface);
+int wifi_handle_full_scan_event(wifi_request_id id, WifiEvent& event,
+ wifi_scan_result_handler handler);
+void convert_to_hal_result(wifi_scan_result *to, wifi_gscan_result_t *from);
+
+
+void convert_to_hal_result(wifi_scan_result *to, wifi_gscan_result_t *from)
+{
+ to->ts = from->ts;
+ to->channel = from->channel;
+ to->rssi = from->rssi;
+ to->rtt = from->rtt;
+ to->rtt_sd = from->rtt_sd;
+ to->beacon_period = from->beacon_period;
+ to->capability = from->capability;
+ memcpy(to->ssid, from->ssid, (DOT11_MAX_SSID_LEN+1));
+ memcpy(&to->bssid, &from->bssid, sizeof(mac_addr));
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+class GetCapabilitiesCommand : public WifiCommand
+{
+ wifi_gscan_capabilities *mCapabilities;
+public:
+ GetCapabilitiesCommand(wifi_interface_handle iface, wifi_gscan_capabilities *capabitlites)
+ : WifiCommand("GetCapabilitiesCommand", iface, 0), mCapabilities(capabitlites)
+ {
+ memset(mCapabilities, 0, sizeof(*mCapabilities));
+ }
+
+ virtual int create() {
+ ALOGD("[WIFI HAL]Creating message to get gscan capablities; handle=%p, iface=%d, ifname=%s",
+ mIfaceInfo->handle, mIfaceInfo->id, mIfaceInfo->name);
+
+ int ret = mMsg.create(GOOGLE_OUI, GSCAN_SUBCMD_GET_CAPABILITIES);
+ if (ret < 0) {
+ return ret;
+ }
+
+ return ret;
+ }
+
+protected:
+ virtual int handleResponse(WifiEvent& reply) {
+
+ ALOGV("In GetCapabilities::handleResponse");
+
+ if (reply.get_cmd() != NL80211_CMD_VENDOR) {
+ ALOGE("Ignoring reply with cmd = %d", reply.get_cmd());
+ return NL_SKIP;
+ }
+
+ int id = reply.get_vendor_id();
+ int subcmd = reply.get_vendor_subcmd();
+ int wiphy_id = reply.get_u32(NL80211_ATTR_WIPHY);
+ int if_id = reply.get_u32(NL80211_ATTR_IFINDEX);
+
+ struct nlattr *vendor_data = (struct nlattr *)reply.get_vendor_data();
+ int len = reply.get_vendor_data_len();
+ void *payload = NULL;
+ if (vendor_data->nla_type == GSCAN_ATTRIBUTE_CAPABILITIES) {
+ payload = nla_data(vendor_data);
+ len -= NLA_HDRLEN;
+ }
+
+ ALOGD("wiphy_id=%d, if_id=%d, Id=%0x, subcmd=%d, len=%d, expected len=%d",
+ wiphy_id, if_id, id, subcmd, len, sizeof(*mCapabilities));
+ if (payload)
+ memcpy(mCapabilities, payload, min(len, (int) sizeof(*mCapabilities)));
+
+ ALOGI("max_scan_cache_size=%d, %d, %d, %d, %d, %d, %d, %d, max_bssid_history_entries=%d",
+ mCapabilities->max_scan_cache_size, mCapabilities->max_scan_buckets,
+ mCapabilities->max_ap_cache_per_scan,
+ mCapabilities->max_rssi_sample_size,
+ mCapabilities->max_scan_reporting_threshold,
+ mCapabilities->max_hotlist_bssids,
+ mCapabilities->max_hotlist_ssids,
+ mCapabilities->max_significant_wifi_change_aps,
+ mCapabilities->max_bssid_history_entries);
+
+ /* this case wifi driver don't support GScan */
+ if (!(mCapabilities->max_scan_cache_size || mCapabilities->max_scan_buckets
+ || mCapabilities->max_ap_cache_per_scan))
+ return NL_STOP;
+
+ return NL_OK;
+ }
+};
+
+wifi_error wifi_get_gscan_capabilities(wifi_interface_handle handle,
+ wifi_gscan_capabilities *capabilities)
+{
+ GetCapabilitiesCommand command(handle, capabilities);
+ return (wifi_error) command.requestResponse();
+}
+
+class GetChannelListCommand : public WifiCommand
+{
+private:
+ wifi_channel *mChannels;
+ int mMaxChannels;
+ int *mNumOfChannel;
+ int mBand;
+
+public:
+ GetChannelListCommand(wifi_interface_handle handle, int band, int max_channels,
+ wifi_channel *channels, int *num_channels)
+ : WifiCommand("GetChannelListCommand", handle, 0)
+ {
+ mBand = band;
+ mMaxChannels = max_channels;
+ mChannels = channels;
+ mNumOfChannel = num_channels;
+ memset(mChannels, 0, sizeof(wifi_channel) * mMaxChannels);
+ }
+
+ virtual int create() {
+ ALOGV("Creating message to get channel list; iface = %d", mIfaceInfo->id);
+
+ int ret = mMsg.create(GOOGLE_OUI, WIFI_SUBCMD_GET_CHANNEL_LIST);
+ if (ret < 0) {
+ return ret;
+ }
+
+ ALOGI("In GetChannelList::mBand=%d", mBand);
+
+ nlattr *data = mMsg.attr_start(NL80211_ATTR_VENDOR_DATA);
+ ret = mMsg.put_u32(WIFI_ATTRIBUTE_BAND, mBand);
+ if (ret < 0) {
+ return ret;
+ }
+
+ mMsg.attr_end(data);
+ return ret;
+ }
+
+protected:
+ virtual int handleResponse(WifiEvent& reply) {
+
+ ALOGV("In GetChannelList::handleResponse");
+
+ if (reply.get_cmd() != NL80211_CMD_VENDOR) {
+ ALOGE("Ignore reply with cmd 0x%x", reply.get_cmd());
+ return NL_SKIP;
+ }
+
+ int vendor_id = reply.get_vendor_id();
+ int subcmd = reply.get_vendor_subcmd();
+ ALOGV("vendor_id = 0x%x, subcmd = 0x%x", vendor_id, subcmd);
+
+ nlattr *vendor = reply.get_attribute(NL80211_ATTR_VENDOR_DATA);
+ int len = reply.get_vendor_data_len();
+ if (vendor == NULL || len == 0) {
+ ALOGE("No vendor data in GetChannelList response, ignore it");
+ return NL_SKIP;
+ }
+
+ int num_channels = 0;
+ for (nl_iterator it(vendor); it.has_next(); it.next()) {
+ if (it.get_type() == WIFI_ATTRIBUTE_NUM_CHANNELS) {
+ num_channels = it.get_u32();
+ ALOGI("Get channel list with %d channels", num_channels);
+ if (num_channels > mMaxChannels)
+ num_channels = mMaxChannels;
+ *mNumOfChannel = num_channels;
+ } else if (it.get_type() == WIFI_ATTRIBUTE_CHANNEL_LIST && num_channels) {
+ memcpy(mChannels, it.get_data(), sizeof(wifi_channel) * num_channels);
+ } else {
+ ALOGW("Ignore invalid attribute type = %d, size = %d",
+ it.get_type(), it.get_len());
+ }
+ }
+
+ ALOGD("mChannels[0]=%d mChannels[1]=%d", *mChannels, *(mChannels + 1));
+
+ return NL_OK;
+ }
+};
+
+wifi_error wifi_get_valid_channels(wifi_interface_handle handle,
+ int band, int max_channels, wifi_channel *channels, int *num_channels)
+{
+ GetChannelListCommand command(handle, band, max_channels, channels, num_channels);
+ return (wifi_error) command.requestResponse();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+/* helper functions */
+
+static int parseScanResults(wifi_scan_result *results, int num, nlattr *attr)
+{
+ memset(results, 0, sizeof(wifi_scan_result) * num);
+
+ int i = 0;
+ for (nl_iterator it(attr); it.has_next() && i < num; it.next(), i++) {
+
+ int index = it.get_type();
+ ALOGI("retrieved scan result %d", index);
+ nlattr *sc_data = (nlattr *) it.get_data();
+ wifi_scan_result *result = results + i;
+
+ for (nl_iterator it2(sc_data); it2.has_next(); it2.next()) {
+ int type = it2.get_type();
+ if (type == GSCAN_ATTRIBUTE_SSID) {
+ strncpy(result->ssid, (char *) it2.get_data(), it2.get_len());
+ result->ssid[it2.get_len()] = 0;
+ } else if (type == GSCAN_ATTRIBUTE_BSSID) {
+ memcpy(result->bssid, (byte *) it2.get_data(), sizeof(mac_addr));
+ } else if (type == GSCAN_ATTRIBUTE_TIMESTAMP) {
+ result->ts = it2.get_u64();
+ } else if (type == GSCAN_ATTRIBUTE_CHANNEL) {
+ result->ts = it2.get_u16();
+ } else if (type == GSCAN_ATTRIBUTE_RSSI) {
+ result->rssi = it2.get_u8();
+ } else if (type == GSCAN_ATTRIBUTE_RTT) {
+ result->rtt = it2.get_u64();
+ } else if (type == GSCAN_ATTRIBUTE_RTTSD) {
+ result->rtt_sd = it2.get_u64();
+ }
+ }
+
+ }
+
+ if (i >= num) {
+ ALOGE("Got too many results; skipping some");
+ }
+
+ return i;
+}
+
+int createFeatureRequest(WifiRequest& request, int subcmd, int enable) {
+
+ int result = request.create(GOOGLE_OUI, subcmd);
+ if (result < 0) {
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+ result = request.put_u32(GSCAN_ATTRIBUTE_ENABLE_FEATURE, enable);
+ if (result < 0) {
+ return result;
+ }
+
+ request.attr_end(data);
+ return WIFI_SUCCESS;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+class FullScanResultsCommand : public WifiCommand
+{
+ int *mParams;
+ wifi_scan_result_handler mHandler;
+public:
+ FullScanResultsCommand(wifi_interface_handle iface, int id, int *params,
+ wifi_scan_result_handler handler)
+ : WifiCommand("FullScanResultsCommand", iface, id), mParams(params), mHandler(handler)
+ { }
+
+ int createRequest(WifiRequest& request, int subcmd, int enable) {
+ int result = request.create(GOOGLE_OUI, subcmd);
+ if (result < 0) {
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+ result = request.put_u32(GSCAN_ENABLE_FULL_SCAN_RESULTS, enable);
+ if (result < 0) {
+ return result;
+ }
+
+ request.attr_end(data);
+ return WIFI_SUCCESS;
+
+ }
+
+ int start() {
+ ALOGD("Enabling Full scan results");
+ WifiRequest request(familyId(), ifaceId());
+ int result = createRequest(request, GSCAN_SUBCMD_ENABLE_FULL_SCAN_RESULTS, 1);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to create request; result = %d", result);
+ return result;
+ }
+
+ registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_FULL_SCAN_RESULTS);
+
+ result = requestResponse(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to enable full scan results; result = %d", result);
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_FULL_SCAN_RESULTS);
+ return result;
+ }
+
+ return result;
+ }
+
+ virtual int cancel() {
+ ALOGD("Disabling Full scan results");
+
+ WifiRequest request(familyId(), ifaceId());
+ int result = createRequest(request, GSCAN_SUBCMD_ENABLE_FULL_SCAN_RESULTS, 0);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to create request; result = %d", result);
+ } else {
+ result = requestResponse(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to disable full scan results;result = %d", result);
+ }
+ }
+
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_FULL_SCAN_RESULTS);
+ return WIFI_SUCCESS;
+ }
+
+ virtual int handleResponse(WifiEvent& reply) {
+ ALOGD("Request complete!");
+ /* Nothing to do on response! */
+ return NL_SKIP;
+ }
+
+ virtual int handleEvent(WifiEvent& event) {
+ ALOGV("Full scan results: Got an event");
+ return wifi_handle_full_scan_event(id(), event, mHandler);
+ }
+
+};
+/////////////////////////////////////////////////////////////////////////////
+
+class ScanCommand : public WifiCommand
+{
+ wifi_scan_cmd_params *mParams;
+ wifi_scan_result_handler mHandler;
+public:
+ ScanCommand(wifi_interface_handle iface, int id, wifi_scan_cmd_params *params,
+ wifi_scan_result_handler handler)
+ : WifiCommand("ScanCommand", iface, id), mParams(params), mHandler(handler)
+ { }
+
+ int createSetupRequest(WifiRequest& request) {
+ int result = request.create(GOOGLE_OUI, GSCAN_SUBCMD_SET_CONFIG);
+ if (result < 0) {
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+ result = request.put_u32(GSCAN_ATTRIBUTE_BASE_PERIOD, mParams->base_period);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u32(GSCAN_ATTRIBUTE_NUM_BUCKETS, mParams->num_buckets);
+ if (result < 0) {
+ return result;
+ }
+
+ for (int i = 0; i < mParams->num_buckets; i++) {
+ nlattr * bucket = request.attr_start(i); // next bucket
+ result = request.put_u32(GSCAN_ATTRIBUTE_BUCKET_ID, mParams->buckets[i].bucket);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u32(GSCAN_ATTRIBUTE_BUCKET_PERIOD, mParams->buckets[i].period);
+ if (result < 0) {
+ return result;
+ }
+
+ /* parameter validity check */
+ if (mParams->buckets[i].band < WIFI_BAND_UNSPECIFIED
+ || mParams->buckets[i].band > WIFI_BAND_ABG_WITH_DFS)
+ mParams->buckets[i].band = WIFI_BAND_ABG; /* default 2.4G + 5G */
+ result = request.put_u32(GSCAN_ATTRIBUTE_BUCKETS_BAND,
+ mParams->buckets[i].band);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u32(GSCAN_ATTRIBUTE_BUCKET_STEP_COUNT,
+ mParams->buckets[i].step_count);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u32(GSCAN_ATTRIBUTE_BUCKET_MAX_PERIOD,
+ mParams->buckets[i].max_period);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u32(GSCAN_ATTRIBUTE_REPORT_EVENTS,
+ mParams->buckets[i].report_events);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u32(GSCAN_ATTRIBUTE_BUCKET_NUM_CHANNELS,
+ mParams->buckets[i].num_channels);
+ if (result < 0) {
+ return result;
+ }
+
+ if (mParams->buckets[i].num_channels) {
+ nlattr *channels = request.attr_start(GSCAN_ATTRIBUTE_BUCKET_CHANNELS);
+ ALOGV(" channels: ");
+ for (int j = 0; j < mParams->buckets[i].num_channels; j++) {
+ result = request.put_u32(j, mParams->buckets[i].channels[j].channel);
+ ALOGV(" %u", mParams->buckets[i].channels[j].channel);
+
+ if (result < 0) {
+ return result;
+ }
+ }
+ request.attr_end(channels);
+ }
+
+ request.attr_end(bucket);
+ }
+
+ request.attr_end(data);
+ return WIFI_SUCCESS;
+ }
+
+ int createScanConfigRequest(WifiRequest& request) {
+ int result = request.create(GOOGLE_OUI, GSCAN_SUBCMD_SET_SCAN_CONFIG);
+ if (result < 0) {
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+ result = request.put_u32(GSCAN_ATTRIBUTE_NUM_AP_PER_SCAN, mParams->max_ap_per_scan);
+ if (result < 0) {
+ return result;
+ }
+
+ /* parameter validity check */
+ if (mParams->report_threshold_percent < 0 || mParams->report_threshold_percent > 100)
+ mParams->report_threshold_percent = 100;
+ result = request.put_u32(GSCAN_ATTRIBUTE_REPORT_THRESHOLD,
+ mParams->report_threshold_percent);
+ if (result < 0) {
+ return result;
+ }
+
+ int num_scans = mParams->report_threshold_num_scans;
+
+ result = request.put_u32(GSCAN_ATTRIBUTE_NUM_SCANS_TO_CACHE, num_scans);
+ if (result < 0) {
+ return result;
+ }
+
+ request.attr_end(data);
+ return WIFI_SUCCESS;
+ }
+
+ int createStartRequest(WifiRequest& request) {
+ return createFeatureRequest(request, GSCAN_SUBCMD_ENABLE_GSCAN, 1);
+ }
+
+ int createStopRequest(WifiRequest& request) {
+ return createFeatureRequest(request, GSCAN_SUBCMD_ENABLE_GSCAN, 0);
+ }
+
+ int start() {
+ ALOGI("1) GScan Setting configuration: ");
+ WifiRequest request(familyId(), ifaceId());
+ int result = createSetupRequest(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to create setup request; result = %d", result);
+ return result;
+ }
+
+ result = requestResponse(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to configure setup; result = %d", result);
+ return result;
+ }
+
+ request.destroy();
+
+ result = createScanConfigRequest(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to create scan config request; result = %d", result);
+ return result;
+ }
+
+ result = requestResponse(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to configure scan; result = %d", result);
+ return result;
+ }
+
+ ALOGI("2) Enable GScan: ");
+
+ result = createStartRequest(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to create start request; result = %d", result);
+ return result;
+ }
+
+ registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SCAN_RESULTS_AVAILABLE);
+ registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_COMPLETE_SCAN);
+ registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_FULL_SCAN_RESULTS);
+
+ result = requestResponse(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to start scan; result = %d", result);
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_COMPLETE_SCAN);
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SCAN_RESULTS_AVAILABLE);
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_FULL_SCAN_RESULTS);
+ return result;
+ }
+ return result;
+ }
+
+ virtual int cancel() {
+ ALOGI("Stopping GScan");
+
+ WifiRequest request(familyId(), ifaceId());
+ int result = createStopRequest(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to create stop request; result = %d", result);
+ } else {
+ result = requestResponse(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to stop scan; result = %d", result);
+ }
+ }
+
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_COMPLETE_SCAN);
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SCAN_RESULTS_AVAILABLE);
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_FULL_SCAN_RESULTS);
+ return WIFI_SUCCESS;
+ }
+
+ virtual int handleResponse(WifiEvent& reply) {
+ /* Nothing to do on response! */
+ return NL_SKIP;
+ }
+
+ virtual int handleEvent(WifiEvent& event) {
+ ALOGV("[WIFI HAL]Got a GScan results event");
+
+ // event.log();
+
+ struct nlattr *vendor_data = (struct nlattr *)event.get_vendor_data();
+ int len = event.get_vendor_data_len();
+ int event_id = event.get_vendor_subcmd();
+
+ if (vendor_data)
+ ALOGV("vendor_data->nla_type=%d nla_len=%d, len=%d, event_id=%d",
+ vendor_data->nla_type, vendor_data->nla_len, len, event_id);
+
+ if ((event_id == GSCAN_EVENT_COMPLETE_SCAN) ||
+ (event_id == GSCAN_EVENT_SCAN_RESULTS_AVAILABLE)) {
+ if (vendor_data == NULL || vendor_data->nla_len != 8) {
+ ALOGE("Bad event data!");
+ return NL_SKIP;
+ }
+ wifi_scan_event evt_type;
+ evt_type = (wifi_scan_event) nla_get_u32(vendor_data);
+ ALOGI("Received event_id=%d, event type=%d", event_id, evt_type);
+ if (*mHandler.on_scan_event)
+ (*mHandler.on_scan_event)(id(), evt_type);
+ } else if (event_id == GSCAN_EVENT_FULL_SCAN_RESULTS) {
+ wifi_handle_full_scan_event(id(), event, mHandler);
+ }
+ return NL_SKIP;
+ }
+};
+
+wifi_error wifi_start_gscan(
+ wifi_request_id id,
+ wifi_interface_handle iface,
+ wifi_scan_cmd_params params,
+ wifi_scan_result_handler handler)
+{
+ wifi_handle handle = getWifiHandle(iface);
+
+ ALOGD("[WIFI HAL]Starting GScan, halHandle = %p", handle);
+
+ ScanCommand *cmd = new ScanCommand(iface, id, ¶ms, handler);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ wifi_error result = wifi_register_cmd(handle, id, cmd);
+ if (result != WIFI_SUCCESS) {
+ cmd->releaseRef();
+ return result;
+ }
+ result = (wifi_error)cmd->start();
+ if (result != WIFI_SUCCESS) {
+ wifi_unregister_cmd(handle, id);
+ cmd->releaseRef();
+ return result;
+ }
+ return result;
+}
+
+wifi_error wifi_stop_gscan(wifi_request_id id, wifi_interface_handle iface)
+{
+ ALOGD("[WIFI HAL]Stopping GScan");
+ wifi_handle handle = getWifiHandle(iface);
+
+ if (id == -1) {
+ wifi_scan_result_handler handler;
+ wifi_scan_cmd_params dummy_params;
+ memset(&handler, 0, sizeof(handler));
+
+ ScanCommand *cmd = new ScanCommand(iface, id, &dummy_params, handler);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ cmd->cancel();
+ cmd->releaseRef();
+ return WIFI_SUCCESS;
+ }
+
+ return wifi_cancel_cmd(id, iface);
+}
+
+
+wifi_error wifi_enable_full_scan_results(
+ wifi_request_id id,
+ wifi_interface_handle iface,
+ wifi_scan_result_handler handler)
+{
+ wifi_handle handle = getWifiHandle(iface);
+ int params_dummy;
+ ALOGD("[WIFI HAL]Enabling full scan results, halHandle = %p", handle);
+
+ FullScanResultsCommand *cmd = new FullScanResultsCommand(iface, id, ¶ms_dummy, handler);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ wifi_error result = wifi_register_cmd(handle, id, cmd);
+ if (result != WIFI_SUCCESS) {
+ cmd->releaseRef();
+ return result;
+ }
+ result = (wifi_error)cmd->start();
+ if (result != WIFI_SUCCESS) {
+ wifi_unregister_cmd(handle, id);
+ cmd->releaseRef();
+ return result;
+ }
+ return result;
+}
+
+int wifi_handle_full_scan_event(
+ wifi_request_id id,
+ WifiEvent& event,
+ wifi_scan_result_handler handler)
+{
+ //nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
+ struct nlattr *vendor_data = (struct nlattr *)event.get_vendor_data();
+ unsigned int len = event.get_vendor_data_len();
+ int event_id = event.get_vendor_subcmd();
+
+ if (vendor_data == NULL || len < sizeof(wifi_gscan_full_result_t)) {
+ ALOGE("Full scan results: No scan results found");
+ return NL_SKIP;
+ }
+
+ wifi_gscan_full_result_t *drv_res = NULL;
+ if (event_id == GSCAN_EVENT_FULL_SCAN_RESULTS)
+ drv_res = (wifi_gscan_full_result_t *)nla_data(vendor_data);
+ if (!drv_res) {
+ ALOGE("cannot get vendor_data of GSCAN_EVENT_FULL_SCAN_RESULTS\n");
+ return NL_SKIP;
+ }
+ /* To protect against corrupted data, put a ceiling */
+ int ie_len = min(MAX_PROBE_RESP_IE_LEN, drv_res->ie_length);
+ wifi_scan_result *full_scan_result;
+ wifi_gscan_result_t *fixed = &drv_res->fixed;
+
+ if ((ie_len + offsetof(wifi_gscan_full_result_t, ie_data)) > len) {
+ ALOGE("BAD event data, len %d ie_len %d fixed length %lu!\n", len,
+ ie_len, offsetof(wifi_gscan_full_result_t, ie_data));
+ return NL_SKIP;
+ }
+ full_scan_result = (wifi_scan_result *) malloc((ie_len + offsetof(wifi_scan_result, ie_data)));
+ if (!full_scan_result) {
+ ALOGE("Full scan results: Can't malloc!\n");
+ return NL_SKIP;
+ }
+ convert_to_hal_result(full_scan_result, fixed);
+ full_scan_result->ie_length = ie_len;
+ memcpy(full_scan_result->ie_data, drv_res->ie_data, ie_len);
+ if(handler.on_full_scan_result)
+ handler.on_full_scan_result(id, full_scan_result, drv_res->scan_ch_bucket);
+
+ ALOGI("Full scan result: %-32s %02x:%02x:%02x:%02x:%02x:%02x %d %d %llu %llu %llu 0x%x %x %d\n",
+ fixed->ssid, fixed->bssid[0], fixed->bssid[1], fixed->bssid[2], fixed->bssid[3],
+ fixed->bssid[4], fixed->bssid[5], fixed->rssi, fixed->channel, fixed->ts,
+ fixed->rtt, fixed->rtt_sd, fixed->capability, drv_res->scan_ch_bucket, drv_res->ie_length);
+ free(full_scan_result);
+ return NL_SKIP;
+}
+
+wifi_error wifi_disable_full_scan_results(wifi_request_id id, wifi_interface_handle iface)
+{
+ ALOGD("[WIFI HAL]Disabling full scan results");
+ wifi_handle handle = getWifiHandle(iface);
+
+ if(id == -1) {
+ wifi_scan_result_handler handler;
+ wifi_handle handle = getWifiHandle(iface);
+ int params_dummy;
+
+ memset(&handler, 0, sizeof(handler));
+ FullScanResultsCommand *cmd = new FullScanResultsCommand(iface, 0, ¶ms_dummy, handler);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ cmd->cancel();
+ cmd->releaseRef();
+ return WIFI_SUCCESS;
+ }
+
+ return wifi_cancel_cmd(id, iface);
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+class GetScanResultsCommand : public WifiCommand {
+ wifi_cached_scan_results *mScans;
+ int mMax;
+ int *mNum;
+ int mRetrieved;
+ byte mFlush;
+ int mCompleted;
+public:
+ GetScanResultsCommand(wifi_interface_handle iface, byte flush,
+ wifi_cached_scan_results *results, int max, int *num)
+ : WifiCommand("GetScanResultsCommand", iface, -1), mScans(results), mMax(max), mNum(num),
+ mRetrieved(0), mFlush(flush), mCompleted(0)
+ { }
+
+ int createRequest(WifiRequest& request, int num, byte flush) {
+ int result = request.create(GOOGLE_OUI, GSCAN_SUBCMD_GET_SCAN_RESULTS);
+ if (result < 0) {
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+ result = request.put_u32(GSCAN_ATTRIBUTE_NUM_OF_RESULTS, num);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u8(GSCAN_ATTRIBUTE_FLUSH_RESULTS, flush);
+ if (result < 0) {
+ return result;
+ }
+
+ request.attr_end(data);
+ return WIFI_SUCCESS;
+ }
+
+ int execute() {
+ WifiRequest request(familyId(), ifaceId());
+ ALOGD("retrieving mMax=%d scan results", mMax);
+
+ for (int i = 0; i < 10 && mRetrieved < mMax; i++) {
+ int num_to_retrieve = mMax - mRetrieved;
+ ALOGI("retrieving %d:%d cached gscan results in one shot", mRetrieved, num_to_retrieve);
+ int result = createRequest(request, num_to_retrieve, mFlush);
+ if (result < 0) {
+ ALOGE("failed to create request");
+ return result;
+ }
+
+ int prev_retrieved = mRetrieved;
+
+ result = requestResponse(request);
+
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to retrieve scan results; result = %d", result);
+ return result;
+ }
+
+ ALOGD("mRetrieved=%d, prev_retrieved=%d, mCompleted=%d", mRetrieved, prev_retrieved, mCompleted);
+
+ if (mRetrieved == prev_retrieved || mCompleted) {
+ /* no more items left to retrieve */
+ break;
+ }
+
+ request.destroy();
+ }
+
+ ALOGI("GetScanResults total read %d results", mRetrieved);
+ *mNum = mRetrieved;
+ return WIFI_SUCCESS;
+ }
+
+ virtual int handleResponse(WifiEvent& reply) {
+ ALOGV("In GetScanResultsCommand::handleResponse");
+
+ if (reply.get_cmd() != NL80211_CMD_VENDOR) {
+ ALOGE("Ignoring reply with cmd = %d", reply.get_cmd());
+ return NL_SKIP;
+ }
+
+ int id = reply.get_vendor_id();
+ int subcmd = reply.get_vendor_subcmd();
+
+ /*
+ if (subcmd != GSCAN_SUBCMD_SCAN_RESULTS) {
+ ALOGE("Invalid response to GetScanResultsCommand; ignoring it");
+ return NL_SKIP;
+ }
+ */
+
+ //nlattr *vendor = reply.get_attribute(NL80211_ATTR_VENDOR_DATA);
+ struct nlattr *vendor_data = (struct nlattr *)reply.get_vendor_data();
+ int len = reply.get_vendor_data_len();
+ if (vendor_data == NULL || len == 0) {
+ ALOGE("no vendor data in GetScanResults response; ignoring it");
+ return NL_SKIP;
+ }
+ ALOGD("Id = %0x, subcmd = %d, vendor=%p, get_vendor_data()=%p vendor->nla_type=%d len=%d",
+ id, subcmd, vendor_data, reply.get_vendor_data(), vendor_data->nla_type, len);
+
+ for (nl_iterator it(vendor_data); it.has_next(); it.next()) {
+ if (it.get_type() == GSCAN_ATTRIBUTE_SCAN_RESULTS_COMPLETE) {
+ mCompleted = it.get_u8();
+ ALOGI("retrieved mCompleted flag : %d", mCompleted);
+ } else if (it.get_type() >= GSCAN_ATTRIBUTE_NUM_OF_RESULTS
+ && it.get_type() <= GSCAN_ATTRIBUTE_CH_BUCKET_BITMASK) {
+ int scan_id = 0, flags = 0, num = 0, scan_ch_bucket_mask = 0;
+ for (nl_iterator it2(it.get()); it2.has_next(); it2.next()) {
+ if (it2.get_type() == GSCAN_ATTRIBUTE_SCAN_ID) {
+ scan_id = it2.get_u32();
+ ALOGD("retrieved scan_id : %d", scan_id);
+ } else if (it2.get_type() == GSCAN_ATTRIBUTE_SCAN_FLAGS) {
+ flags = it2.get_u8();
+ ALOGD("retrieved scan_flags : 0x%0x", flags);
+ } else if (it2.get_type() == GSCAN_ATTRIBUTE_NUM_OF_RESULTS) {
+ num = it2.get_u32();
+ ALOGD("retrieved num_results: %d", num);
+ } else if (it2.get_type() == GSCAN_ATTRIBUTE_CH_BUCKET_BITMASK) {
+ scan_ch_bucket_mask = it2.get_u32();
+ ALOGD("retrieved scan_ch_bucket_mask: 0x%0x", scan_ch_bucket_mask);
+ } else if (it2.get_type() == GSCAN_ATTRIBUTE_SCAN_RESULTS && num) {
+ if (mRetrieved >= mMax) {
+ ALOGW("Stored %d scans, ignoring excess results", mRetrieved);
+ break;
+ }
+ num = min(num, (int)(it2.get_len()/sizeof(wifi_scan_result)));
+ num = min(num, (int)MAX_AP_CACHE_PER_SCAN);
+ ALOGI("Copying %d scan results, mRetrieved=%d, scan_id=%d, flag=0x%x, bktMask=0x%04x",
+ num, mRetrieved, scan_id, flags, scan_ch_bucket_mask);
+ wifi_gscan_result_t *results = (wifi_gscan_result_t *)it2.get_data();
+ wifi_scan_result *mScanResults = mScans[mRetrieved].results;
+
+ for (int i = 0; i < num; i++) {
+ wifi_gscan_result_t *result = &results[i];
+ convert_to_hal_result(&mScanResults[i], result);
+ mScanResults[i].ie_length = result->ie_length;
+ //mScanResults[i].ie_data = result->ie_data;
+ ALOGD("%02d %-32s " MACSTR " %ddB channel=%d, capa=0x%04x, ie_len=%d", i,
+ result->ssid, MAC2STR(result->bssid),
+ result->rssi, result->channel, mScanResults[i].capability, mScanResults[i].ie_length);
+ }
+ mScans[mRetrieved].scan_id = scan_id;
+ mScans[mRetrieved].flags = flags;
+ mScans[mRetrieved].num_results = num;
+ mScans[mRetrieved].buckets_scanned = scan_ch_bucket_mask;
+ ALOGV("Setting result of scan_id : 0x%0x", mScans[mRetrieved].scan_id);
+ mRetrieved++;
+ } else {
+ ALOGW("Ignoring invalid attribute type = %d, size = %d",
+ it.get_type(), it.get_len());
+ }
+ }
+ } else {
+ ALOGW("Ignoring invalid attribute type = %d, size = %d",
+ it.get_type(), it.get_len());
+ }
+ }
+ ALOGD("GetScanResults read %dth results", mRetrieved);
+ return NL_OK;
+ }
+};
+
+wifi_error wifi_get_cached_gscan_results(wifi_interface_handle iface, byte flush,
+ int max, wifi_cached_scan_results *results, int *num) {
+
+ ALOGI("[WIFI HAL]Getting cached gscan results, flush=%d, max=%d, num=%d", flush, max, *num);
+
+ GetScanResultsCommand *cmd = new GetScanResultsCommand(iface, flush, results, max, num);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ wifi_error err = (wifi_error) cmd->execute();
+ cmd->releaseRef();
+ return err;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+class BssidHotlistCommand : public WifiCommand
+{
+private:
+ wifi_bssid_hotlist_params mParams;
+ wifi_hotlist_ap_found_handler mHandler;
+ static const int MAX_RESULTS = 64;
+ wifi_scan_result mResults[MAX_RESULTS];
+public:
+ BssidHotlistCommand(wifi_interface_handle handle, int id,
+ wifi_bssid_hotlist_params params, wifi_hotlist_ap_found_handler handler)
+ : WifiCommand("BssidHotlistCommand", handle, id), mParams(params), mHandler(handler)
+ { }
+
+ int createSetupRequest(WifiRequest& request) {
+ int result = request.create(GOOGLE_OUI, GSCAN_SUBCMD_SET_HOTLIST);
+ if (result < 0) {
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+ result = request.put_u8(GSCAN_ATTRIBUTE_HOTLIST_FLUSH, 1);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u32(GSCAN_ATTRIBUTE_LOST_AP_SAMPLE_SIZE, mParams.lost_ap_sample_size);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u16(GSCAN_ATTRIBUTE_NUM_AP, mParams.num_bssid);
+ if (result < 0) {
+ return result;
+ }
+
+ struct nlattr * attr = request.attr_start(GSCAN_ATTRIBUTE_HOTLIST_BSSIDS);
+ for (int i = 0; i < mParams.num_bssid; i++) {
+ nlattr *attr2 = request.attr_start(GSCAN_ATTRIBUTE_HOTLIST_ELEM);
+ if (attr2 == NULL) {
+ return WIFI_ERROR_OUT_OF_MEMORY;
+ }
+ result = request.put_addr(GSCAN_ATTRIBUTE_BSSID, mParams.ap[i].bssid);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u32(GSCAN_ATTRIBUTE_RSSI_HIGH, mParams.ap[i].high);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u32(GSCAN_ATTRIBUTE_RSSI_LOW, mParams.ap[i].low);
+ if (result < 0) {
+ return result;
+ }
+ request.attr_end(attr2);
+ }
+
+ request.attr_end(attr);
+ request.attr_end(data);
+ return result;
+ }
+
+ int createTeardownRequest(WifiRequest& request) {
+ int result = request.create(GOOGLE_OUI, GSCAN_SUBCMD_SET_HOTLIST);
+ if (result < 0) {
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+ result = request.put_u8(GSCAN_ATTRIBUTE_HOTLIST_FLUSH, 1);
+ if (result < 0) {
+ return result;
+ }
+
+ struct nlattr * attr = request.attr_start(GSCAN_ATTRIBUTE_HOTLIST_BSSIDS);
+ request.attr_end(attr);
+ request.attr_end(data);
+ return result;
+ }
+
+ int start() {
+ ALOGD("[WIFI HAL]Executing hotlist setup request, num = %d", mParams.num_bssid);
+ WifiRequest request(familyId(), ifaceId());
+ int result = createSetupRequest(request);
+ if (result < 0) {
+ return result;
+ }
+
+ result = requestResponse(request);
+ if (result < 0) {
+ ALOGI("Failed to execute hotlist setup request, result = %d", result);
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_FOUND);
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_LOST);
+ return result;
+ }
+
+ ALOGI("Successfully set %d APs in the hotlist", mParams.num_bssid);
+ result = createFeatureRequest(request, GSCAN_SUBCMD_ENABLE_GSCAN, 1);
+ if (result < 0) {
+ return result;
+ }
+
+ registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_FOUND);
+ registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_LOST);
+
+ result = requestResponse(request);
+ if (result < 0) {
+ ALOGE("failed to start scan; result = %d", result);
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_FOUND);
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_LOST);
+ return result;
+ }
+
+ ALOGI("successfully restarted the scan");
+ return result;
+ }
+
+ virtual int cancel() {
+ /* unregister event handler */
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_FOUND);
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_LOST);
+ /* create set hotlist message with empty hotlist */
+ WifiRequest request(familyId(), ifaceId());
+ int result = createTeardownRequest(request);
+ if (result < 0) {
+ return result;
+ }
+
+ result = requestResponse(request);
+ if (result < 0) {
+ return result;
+ }
+
+ ALOGI("Successfully reset APs in current hotlist");
+ return result;
+ }
+
+ virtual int handleResponse(WifiEvent& reply) {
+ /* Nothing to do on response! */
+ return NL_SKIP;
+ }
+
+ virtual int handleEvent(WifiEvent& event) {
+ ALOGD("[WIFI HAL]Hotlist AP event");
+ int event_id = event.get_vendor_subcmd();
+ // event.log();
+
+ struct nlattr *vendor_data = (struct nlattr *)event.get_vendor_data();
+ int len = event.get_vendor_data_len();
+
+ if (vendor_data == NULL || len == 0) {
+ ALOGI("No scan results found");
+ return NL_SKIP;
+ }
+
+ memset(mResults, 0, sizeof(wifi_scan_result) * MAX_RESULTS);
+
+ int num = len / sizeof(wifi_scan_result);
+ num = min(MAX_RESULTS, num);
+ ALOGD("hotlist APs num=%d, vendor len=%d, nla_len=%d nla_type=%d",
+ num, len, vendor_data->nla_len, vendor_data->nla_type);
+ if(vendor_data->nla_type == GSCAN_EVENT_HOTLIST_RESULTS_LOST
+ || vendor_data->nla_type == GSCAN_EVENT_HOTLIST_RESULTS_FOUND)
+ memcpy(mResults, nla_data(vendor_data), num * sizeof(wifi_scan_result));
+
+ if (event_id == GSCAN_EVENT_HOTLIST_RESULTS_FOUND) {
+ ALOGI("FOUND %d hotlist APs", num);
+ if (*mHandler.on_hotlist_ap_found)
+ (*mHandler.on_hotlist_ap_found)(id(), num, mResults);
+ } else if (event_id == GSCAN_EVENT_HOTLIST_RESULTS_LOST) {
+ ALOGI("LOST %d hotlist APs", num);
+ if (*mHandler.on_hotlist_ap_lost)
+ (*mHandler.on_hotlist_ap_lost)(id(), num, mResults);
+ }
+ return NL_SKIP;
+ }
+};
+
+class ePNOCommand : public WifiCommand
+{
+private:
+ wifi_epno_params epno_params;
+ wifi_epno_handler mHandler;
+ wifi_scan_result mResults[MAX_EPNO_NETWORKS];
+public:
+ ePNOCommand(wifi_interface_handle handle, int id,
+ const wifi_epno_params *params, wifi_epno_handler handler)
+ : WifiCommand("ePNOCommand", handle, id), mHandler(handler)
+ {
+ if (params != NULL) {
+ memcpy(&epno_params, params, sizeof(wifi_epno_params));
+ } else {
+ memset(&epno_params, 0, sizeof(wifi_epno_params));
+ }
+ }
+
+ int createSetupRequest(WifiRequest& request) {
+ if (epno_params.num_networks > MAX_EPNO_NETWORKS) {
+ ALOGE("wrong epno num_networks:%d", epno_params.num_networks);
+ return WIFI_ERROR_INVALID_ARGS;
+ }
+ int result = request.create(GOOGLE_OUI, GSCAN_SUBCMD_SET_EPNO_SSID);
+ if (result < 0) {
+ return result;
+ }
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+ result = request.put_u8(GSCAN_ATTRIBUTE_EPNO_FLUSH, 1);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u8(GSCAN_ATTRIBUTE_EPNO_5G_RSSI_THR,
+ (u8)epno_params.min5GHz_rssi);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u8(GSCAN_ATTRIBUTE_EPNO_2G_RSSI_THR,
+ (u8)epno_params.min24GHz_rssi);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u16(GSCAN_ATTRIBUTE_EPNO_INIT_SCORE_MAX,
+ epno_params.initial_score_max);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u16(GSCAN_ATTRIBUTE_EPNO_CUR_CONN_BONUS,
+ epno_params.current_connection_bonus);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u16(GSCAN_ATTRIBUTE_EPNO_SAME_NETWORK_BONUS,
+ epno_params.same_network_bonus);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u16(GSCAN_ATTRIBUTE_EPNO_SECURE_BONUS,
+ epno_params.secure_bonus);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u16(GSCAN_ATTRIBUTE_EPNO_5G_BONUS,
+ epno_params.band5GHz_bonus);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u8(GSCAN_ATTRIBUTE_EPNO_SSID_NUM,
+ epno_params.num_networks);
+ if (result < 0) {
+ return result;
+ }
+ struct nlattr * attr = request.attr_start(GSCAN_ATTRIBUTE_EPNO_SSID_LIST);
+ wifi_epno_network *ssid_list = epno_params.networks;
+ for (int i = 0; i < epno_params.num_networks; i++) {
+ nlattr *attr2 = request.attr_start(i);
+ if (attr2 == NULL) {
+ return WIFI_ERROR_OUT_OF_MEMORY;
+ }
+ result = request.put(GSCAN_ATTRIBUTE_EPNO_SSID, ssid_list[i].ssid, DOT11_MAX_SSID_LEN);
+ ALOGI("PNO network: SSID %s flags %x auth %x", ssid_list[i].ssid,
+ ssid_list[i].flags,
+ ssid_list[i].auth_bit_field);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u32(GSCAN_ATTRIBUTE_EPNO_SSID_LEN, strlen(ssid_list[i].ssid));
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u32(GSCAN_ATTRIBUTE_EPNO_FLAGS, ssid_list[i].flags);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u32(GSCAN_ATTRIBUTE_EPNO_AUTH, ssid_list[i].auth_bit_field);
+ if (result < 0) {
+ return result;
+ }
+ request.attr_end(attr2);
+ }
+ request.attr_end(attr);
+ request.attr_end(data);
+ return result;
+ }
+
+ int createTeardownRequest(WifiRequest& request) {
+ int result = request.create(GOOGLE_OUI, GSCAN_SUBCMD_SET_EPNO_SSID);
+ if (result < 0) {
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+ result = request.put_u8(GSCAN_ATTRIBUTE_EPNO_FLUSH, 1);
+ if (result < 0) {
+ return result;
+ }
+ request.attr_end(data);
+ return result;
+ }
+
+ int start() {
+ ALOGI("Executing ePNO setup request, num = %d", epno_params.num_networks);
+ WifiRequest request(familyId(), ifaceId());
+ int result = createSetupRequest(request);
+ if (result < 0) {
+ return result;
+ }
+
+ result = requestResponse(request);
+ if (result < 0) {
+ ALOGI("Failed to execute ePNO setup request, result = %d", result);
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_EPNO_EVENT);
+ return result;
+ }
+
+ ALOGI("Successfully set %d SSIDs for ePNO", epno_params.num_networks);
+ registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_EPNO_EVENT);
+ ALOGI("successfully restarted the scan");
+ return result;
+ }
+
+ virtual int cancel() {
+ /* unregister event handler */
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_EPNO_EVENT);
+ /* create set hotlist message with empty hotlist */
+ WifiRequest request(familyId(), ifaceId());
+ int result = createTeardownRequest(request);
+ if (result < 0) {
+ return result;
+ }
+
+ result = requestResponse(request);
+ if (result < 0) {
+ return result;
+ }
+
+ ALOGI("Successfully reset APs in current hotlist");
+ return result;
+ }
+
+ virtual int handleResponse(WifiEvent& reply) {
+ /* Nothing to do on response! */
+ return NL_SKIP;
+ }
+
+ virtual int handleEvent(WifiEvent& event) {
+ ALOGI("ePNO event");
+ int event_id = event.get_vendor_subcmd();
+ // event.log();
+
+ nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
+ int len = event.get_vendor_data_len();
+
+ if (vendor_data == NULL || len == 0) {
+ ALOGI("No scan results found");
+ return NL_SKIP;
+ }
+
+ memset(mResults, 0, sizeof(wifi_scan_result) * MAX_EPNO_NETWORKS);
+
+ unsigned int num = len / sizeof(wifi_pno_result_t);
+ unsigned int i;
+ num = min(MAX_EPNO_NETWORKS, num);
+ wifi_pno_result_t *res = (wifi_pno_result_t *) event.get_vendor_data();
+ for (i = 0; i < num; i++) {
+ if (res[i].flags == PNO_SSID_FOUND) {
+ memcpy(mResults[i].ssid, res[i].ssid, res[i].ssid_len);
+ memcpy(mResults[i].bssid, res[i].bssid, sizeof(mac_addr));
+
+ mResults[i].ssid[res[i].ssid_len] = '\0';
+ mResults[i].channel = res[i].channel;
+ mResults[i].rssi = res[i].rssi;
+ }
+ }
+ if (*mHandler.on_network_found)
+ (*mHandler.on_network_found)(id(), num, mResults);
+ return NL_SKIP;
+ }
+};
+
+wifi_error wifi_set_bssid_hotlist(wifi_request_id id, wifi_interface_handle iface,
+ wifi_bssid_hotlist_params params, wifi_hotlist_ap_found_handler handler)
+{
+ wifi_handle handle = getWifiHandle(iface);
+
+ BssidHotlistCommand *cmd = new BssidHotlistCommand(iface, id, params, handler);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ wifi_error result = wifi_register_cmd(handle, id, cmd);
+ if (result != WIFI_SUCCESS) {
+ cmd->releaseRef();
+ return result;
+ }
+ result = (wifi_error)cmd->start();
+ if (result != WIFI_SUCCESS) {
+ wifi_unregister_cmd(handle, id);
+ cmd->releaseRef();
+ return result;
+ }
+ return result;
+}
+
+wifi_error wifi_reset_bssid_hotlist(wifi_request_id id, wifi_interface_handle iface)
+{
+ return wifi_cancel_cmd(id, iface);
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+class SignificantWifiChangeCommand : public WifiCommand
+{
+ typedef struct {
+ mac_addr bssid; // BSSID
+ wifi_channel channel; // channel frequency in MHz
+ int num_rssi; // number of rssi samples
+ wifi_rssi rssi[8]; // RSSI history in db
+ } wifi_significant_change_result_internal;
+
+private:
+ wifi_significant_change_params mParams;
+ wifi_significant_change_handler mHandler;
+ static const int MAX_RESULTS = 64;
+ wifi_significant_change_result_internal mResultsBuffer[MAX_RESULTS];
+ wifi_significant_change_result *mResults[MAX_RESULTS];
+public:
+ SignificantWifiChangeCommand(wifi_interface_handle handle, int id,
+ wifi_significant_change_params params, wifi_significant_change_handler handler)
+ : WifiCommand("SignificantWifiChangeCommand", handle, id), mParams(params),
+ mHandler(handler)
+ { }
+
+ int createSetupRequest(WifiRequest& request) {
+ int result = request.create(GOOGLE_OUI, GSCAN_SUBCMD_SET_SIGNIFICANT_CHANGE_CONFIG);
+ if (result < 0) {
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+ result = request.put_u8(GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH, 1);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u16(GSCAN_ATTRIBUTE_RSSI_SAMPLE_SIZE, mParams.rssi_sample_size);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u16(GSCAN_ATTRIBUTE_LOST_AP_SAMPLE_SIZE, mParams.lost_ap_sample_size);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u16(GSCAN_ATTRIBUTE_MIN_BREACHING, mParams.min_breaching);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u16(GSCAN_ATTRIBUTE_NUM_AP, mParams.num_bssid);
+ if (result < 0) {
+ return result;
+ }
+
+ struct nlattr * attr = request.attr_start(GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_BSSIDS);
+
+ for (int i = 0; i < mParams.num_bssid; i++) {
+ nlattr *attr2 = request.attr_start(i);
+ if (attr2 == NULL) {
+ return WIFI_ERROR_OUT_OF_MEMORY;
+ }
+ result = request.put_addr(GSCAN_ATTRIBUTE_BSSID, mParams.ap[i].bssid);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u32(GSCAN_ATTRIBUTE_RSSI_HIGH, mParams.ap[i].high);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u32(GSCAN_ATTRIBUTE_RSSI_LOW, mParams.ap[i].low);
+ if (result < 0) {
+ return result;
+ }
+ request.attr_end(attr2);
+ }
+
+ request.attr_end(attr);
+ request.attr_end(data);
+
+ return result;
+ }
+
+ int createTeardownRequest(WifiRequest& request) {
+ int result = request.create(GOOGLE_OUI, GSCAN_SUBCMD_SET_SIGNIFICANT_CHANGE_CONFIG);
+ if (result < 0) {
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+ result = request.put_u16(GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH, 1);
+ if (result < 0) {
+ return result;
+ }
+
+ request.attr_end(data);
+ return result;
+ }
+
+ int start() {
+ ALOGD("[WIFI HAL]Set significant wifi change config");
+ WifiRequest request(familyId(), ifaceId());
+
+ int result = createSetupRequest(request);
+ if (result < 0) {
+ return result;
+ }
+
+ result = requestResponse(request);
+ if (result < 0) {
+ ALOGE("failed to set significant wifi change config %d", result);
+ return result;
+ }
+
+ ALOGI("successfully set significant wifi change config");
+
+ result = createFeatureRequest(request, GSCAN_SUBCMD_ENABLE_GSCAN, 1);
+ if (result < 0) {
+ return result;
+ }
+
+ registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SIGNIFICANT_CHANGE_RESULTS);
+
+ result = requestResponse(request);
+ if (result < 0) {
+ ALOGE("failed to start scan; result = %d", result);
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SIGNIFICANT_CHANGE_RESULTS);
+ return result;
+ }
+
+ ALOGI("successfully restarted the scan");
+ return result;
+ }
+
+ virtual int cancel() {
+ /* unregister event handler */
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SIGNIFICANT_CHANGE_RESULTS);
+
+ /* create set significant change monitor message with empty hotlist */
+ WifiRequest request(familyId(), ifaceId());
+
+ int result = createTeardownRequest(request);
+ if (result < 0) {
+ return result;
+ }
+
+ result = requestResponse(request);
+ if (result < 0) {
+ return result;
+ }
+
+ ALOGI("successfully reset significant wifi change config");
+ return result;
+ }
+
+ virtual int handleResponse(WifiEvent& reply) {
+ /* Nothing to do on response! */
+ return NL_SKIP;
+ }
+
+ virtual int handleEvent(WifiEvent& event) {
+ ALOGD("[WIFI HAL]Got a significant wifi change event");
+
+ struct nlattr *vendor_data = (struct nlattr *)event.get_vendor_data();
+ int len = event.get_vendor_data_len();
+
+ if (vendor_data == NULL || len == 0) {
+ ALOGI("No scan results found");
+ return NL_SKIP;
+ }
+
+ typedef struct {
+ uint16_t flags;
+ uint16_t channel;
+ mac_addr bssid;
+ s8 rssi_history[8];
+ } ChangeInfo;
+
+ int num = min(len / sizeof(ChangeInfo), MAX_RESULTS);
+ ChangeInfo *ci;
+ if (vendor_data->nla_type == GSCAN_EVENT_SIGNIFICANT_CHANGE_RESULTS)
+ ci = (ChangeInfo *)nla_data(vendor_data);
+ else
+ return NL_SKIP;
+
+ for (int i = 0; i < num; i++) {
+ memcpy(mResultsBuffer[i].bssid, ci[i].bssid, sizeof(mac_addr));
+ mResultsBuffer[i].channel = ci[i].channel;
+ mResultsBuffer[i].num_rssi = 8;
+ for (int j = 0; j < mResultsBuffer[i].num_rssi; j++)
+ mResultsBuffer[i].rssi[j] = (int) ci[i].rssi_history[j];
+ mResults[i] = reinterpret_cast<wifi_significant_change_result *>(&(mResultsBuffer[i]));
+ }
+
+ ALOGI("Retrieved %d scan results, vendor len=%d nla_type=%d", num, len, vendor_data->nla_type);
+
+ if (num != 0) {
+ (*mHandler.on_significant_change)(id(), num, mResults);
+ } else {
+ ALOGW("No significant change reported");
+ }
+
+ return NL_SKIP;
+ }
+};
+
+wifi_error wifi_set_significant_change_handler(wifi_request_id id, wifi_interface_handle iface,
+ wifi_significant_change_params params, wifi_significant_change_handler handler)
+{
+ wifi_handle handle = getWifiHandle(iface);
+
+ SignificantWifiChangeCommand *cmd = new SignificantWifiChangeCommand(
+ iface, id, params, handler);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ wifi_error result = wifi_register_cmd(handle, id, cmd);
+ if (result != WIFI_SUCCESS) {
+ cmd->releaseRef();
+ return result;
+ }
+ result = (wifi_error)cmd->start();
+ if (result != WIFI_SUCCESS) {
+ wifi_unregister_cmd(handle, id);
+ cmd->releaseRef();
+ return result;
+ }
+ return result;
+}
+
+wifi_error wifi_reset_significant_change_handler(wifi_request_id id, wifi_interface_handle iface)
+{
+ return wifi_cancel_cmd(id, iface);
+}
+
+wifi_error wifi_reset_epno_list(wifi_request_id id, wifi_interface_handle iface)
+{
+ if (id == -1) {
+ wifi_epno_handler handler;
+ wifi_handle handle = getWifiHandle(iface);
+
+ memset(&handler, 0, sizeof(handler));
+ ePNOCommand *cmd = new ePNOCommand(iface, id, NULL, handler);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ cmd->cancel();
+ cmd->releaseRef();
+ return WIFI_SUCCESS;
+ }
+ return wifi_cancel_cmd(id, iface);
+}
+
+wifi_error wifi_set_epno_list(wifi_request_id id, wifi_interface_handle iface,
+ const wifi_epno_params *params, wifi_epno_handler handler)
+{
+ wifi_handle handle = getWifiHandle(iface);
+
+ ePNOCommand *cmd = new ePNOCommand(iface, id, params, handler);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ wifi_error result = wifi_register_cmd(handle, id, cmd);
+ if (result != WIFI_SUCCESS) {
+ cmd->releaseRef();
+ return result;
+ }
+ result = (wifi_error)cmd->start();
+ if (result != WIFI_SUCCESS) {
+ wifi_unregister_cmd(handle, id);
+ cmd->releaseRef();
+ return result;
+ }
+ return result;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+
+class AnqpoConfigureCommand : public WifiCommand
+{
+ int num_hs;
+ wifi_passpoint_network *mNetworks;
+ wifi_passpoint_event_handler mHandler;
+ wifi_scan_result *mResult;
+public:
+ AnqpoConfigureCommand(wifi_request_id id, wifi_interface_handle iface,
+ int num, wifi_passpoint_network *hs_list, wifi_passpoint_event_handler handler)
+ : WifiCommand("AnqpoConfigureCommand", iface, id), num_hs(num), mNetworks(hs_list),
+ mHandler(handler)
+ {
+ mResult = NULL;
+ }
+
+ int createRequest(WifiRequest& request, int val) {
+
+ int result = request.create(GOOGLE_OUI, GSCAN_SUBCMD_ANQPO_CONFIG);
+ result = request.put_u32(GSCAN_ATTRIBUTE_ANQPO_HS_LIST_SIZE, num_hs);
+ if (result < 0) {
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+
+ struct nlattr * attr = request.attr_start(GSCAN_ATTRIBUTE_ANQPO_HS_LIST);
+ for (int i = 0; i < num_hs; i++) {
+ nlattr *attr2 = request.attr_start(i);
+ if (attr2 == NULL) {
+ return WIFI_ERROR_OUT_OF_MEMORY;
+ }
+ result = request.put_u32(GSCAN_ATTRIBUTE_ANQPO_HS_NETWORK_ID, mNetworks[i].id);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put(GSCAN_ATTRIBUTE_ANQPO_HS_NAI_REALM, mNetworks[i].realm, 256);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put(GSCAN_ATTRIBUTE_ANQPO_HS_ROAM_CONSORTIUM_ID,
+ mNetworks[i].roamingConsortiumIds, 128);
+ if (result < 0) {
+ return result;
+ }
+ result = request.put(GSCAN_ATTRIBUTE_ANQPO_HS_PLMN, mNetworks[i].plmn, 3);
+ if (result < 0) {
+ return result;
+ }
+
+ request.attr_end(attr2);
+ }
+
+ request.attr_end(attr);
+ request.attr_end(data);
+
+ return WIFI_SUCCESS;
+ }
+
+ int start() {
+
+ WifiRequest request(familyId(), ifaceId());
+ int result = createRequest(request, num_hs);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to create request; result = %d", result);
+ return result;
+ }
+
+ registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_ANQPO_HOTSPOT_MATCH);
+
+ result = requestResponse(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to set ANQPO networks; result = %d", result);
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_ANQPO_HOTSPOT_MATCH);
+ return result;
+ }
+
+ return result;
+ }
+
+ virtual int cancel() {
+
+ WifiRequest request(familyId(), ifaceId());
+ int result = createRequest(request, 0);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to create request; result = %d", result);
+ } else {
+ result = requestResponse(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to reset ANQPO networks;result = %d", result);
+ }
+ }
+
+ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_ANQPO_HOTSPOT_MATCH);
+ return WIFI_SUCCESS;
+ }
+
+ virtual int handleResponse(WifiEvent& reply) {
+ ALOGD("Request complete!");
+ /* Nothing to do on response! */
+ return NL_SKIP;
+ }
+
+ virtual int handleEvent(WifiEvent& event) {
+ typedef struct {
+ u16 channel; /* channel of GAS protocol */
+ u8 dialog_token; /* GAS dialog token */
+ u8 fragment_id; /* fragment id */
+ u16 status_code; /* status code on GAS completion */
+ u16 data_len; /* length of data to follow */
+ u8 data[1]; /* variable length specified by data_len */
+ } wifi_anqp_gas_resp;
+
+ ALOGI("ANQPO hotspot matched event!");
+
+ nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
+ unsigned int len = event.get_vendor_data_len();
+
+ if (vendor_data == NULL || len < sizeof(wifi_scan_result)) {
+ ALOGI("No scan results found");
+ return NL_SKIP;
+ }
+ mResult = (wifi_scan_result *)malloc(sizeof(wifi_scan_result));
+ if (!mResult) {
+ return NL_SKIP;
+ }
+ wifi_gscan_full_result_t *drv_res = (wifi_gscan_full_result_t *)event.get_vendor_data();
+ wifi_gscan_result_t *fixed = &drv_res->fixed;
+ convert_to_hal_result(mResult, fixed);
+
+ byte *anqp = (byte *)drv_res + offsetof(wifi_gscan_full_result_t, ie_data) + drv_res->ie_length;
+ wifi_anqp_gas_resp *gas = (wifi_anqp_gas_resp *)anqp;
+ int anqp_len = offsetof(wifi_anqp_gas_resp, data) + gas->data_len;
+ int networkId = *(int *)((byte *)anqp + anqp_len);
+
+ ALOGI("%-32s\t", mResult->ssid);
+
+ ALOGI("%02x:%02x:%02x:%02x:%02x:%02x ", mResult->bssid[0], mResult->bssid[1],
+ mResult->bssid[2], mResult->bssid[3], mResult->bssid[4], mResult->bssid[5]);
+
+ ALOGI("%d\t", mResult->rssi);
+ ALOGI("%d\t", mResult->channel);
+ ALOGI("%lld\t", mResult->ts);
+ ALOGI("%lld\t", mResult->rtt);
+ ALOGI("%lld\n", mResult->rtt_sd);
+
+ if(*mHandler.on_passpoint_network_found)
+ (*mHandler.on_passpoint_network_found)(id(), networkId, mResult, anqp_len, anqp);
+ free(mResult);
+ return NL_SKIP;
+ }
+};
+
+wifi_error wifi_set_passpoint_list(wifi_request_id id, wifi_interface_handle iface, int num,
+ wifi_passpoint_network *networks, wifi_passpoint_event_handler handler)
+{
+ wifi_handle handle = getWifiHandle(iface);
+
+ AnqpoConfigureCommand *cmd = new AnqpoConfigureCommand(id, iface, num, networks, handler);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ wifi_error result = wifi_register_cmd(handle, id, cmd);
+ if (result != WIFI_SUCCESS) {
+ cmd->releaseRef();
+ return result;
+ }
+ result = (wifi_error)cmd->start();
+ if (result != WIFI_SUCCESS) {
+ wifi_unregister_cmd(handle, id);
+ cmd->releaseRef();
+ return result;
+ }
+ return result;
+}
+
+wifi_error wifi_reset_passpoint_list(wifi_request_id id, wifi_interface_handle iface)
+{
+ return wifi_cancel_cmd(id, iface);
+}
+
--- /dev/null
+#include <stdint.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/rtnetlink.h>
+#include <netpacket/packet.h>
+#include <linux/filter.h>
+#include <linux/errqueue.h>
+
+#include <linux/pkt_sched.h>
+#include <netlink/object-api.h>
+#include <netlink/netlink.h>
+#include <netlink/socket.h>
+
+#include "nl80211_copy.h"
+
+#include "sync.h"
+
+#define LOG_TAG "WifiHAL"
+
+#include <utils/Log.h>
+#include <utils/String8.h>
+
+#include "wifi_hal.h"
+#include "common.h"
+#include "cpp_bindings.h"
+
+using namespace android;
+#define RTT_RESULT_SIZE (sizeof(wifi_rtt_result));
+
+typedef enum {
+ RTT_SUBCMD_SET_CONFIG = ANDROID_NL80211_SUBCMD_RTT_RANGE_START,
+ RTT_SUBCMD_CANCEL_CONFIG,
+ RTT_SUBCMD_GETCAPABILITY,
+ RTT_SUBCMD_GETAVAILCHANNEL,
+ RTT_SUBCMD_SET_RESPONDER,
+ RTT_SUBCMD_CANCEL_RESPONDER,
+} RTT_SUB_COMMAND;
+
+typedef enum {
+ RTT_ATTRIBUTE_CAPABILITIES = 1,
+
+ RTT_ATTRIBUTE_TARGET_CNT = 10,
+ RTT_ATTRIBUTE_TARGET_INFO,
+ RTT_ATTRIBUTE_TARGET_MAC,
+ RTT_ATTRIBUTE_TARGET_TYPE,
+ RTT_ATTRIBUTE_TARGET_PEER,
+ RTT_ATTRIBUTE_TARGET_CHAN,
+ RTT_ATTRIBUTE_TARGET_PERIOD,
+ RTT_ATTRIBUTE_TARGET_NUM_BURST,
+ RTT_ATTRIBUTE_TARGET_NUM_FTM_BURST,
+ RTT_ATTRIBUTE_TARGET_NUM_RETRY_FTM,
+ RTT_ATTRIBUTE_TARGET_NUM_RETRY_FTMR,
+ RTT_ATTRIBUTE_TARGET_LCI,
+ RTT_ATTRIBUTE_TARGET_LCR,
+ RTT_ATTRIBUTE_TARGET_BURST_DURATION,
+ RTT_ATTRIBUTE_TARGET_PREAMBLE,
+ RTT_ATTRIBUTE_TARGET_BW,
+ RTT_ATTRIBUTE_RESULTS_COMPLETE = 30,
+ RTT_ATTRIBUTE_RESULTS_PER_TARGET,
+ RTT_ATTRIBUTE_RESULT_CNT,
+ RTT_ATTRIBUTE_RESULT
+} RTT_ATTRIBUTE;
+
+typedef struct strmap_entry {
+ int id;
+ String8 text;
+} strmap_entry_t;
+
+struct dot11_rm_ie {
+ u8 id;
+ u8 len;
+ u8 token;
+ u8 mode;
+ u8 type;
+} __attribute__ ((packed));
+
+typedef struct dot11_rm_ie dot11_rm_ie_t;
+#define DOT11_HDR_LEN 2
+#define DOT11_RM_IE_LEN 5
+#define DOT11_MNG_MEASURE_REQUEST_ID 38 /* 11H MeasurementRequest */
+#define DOT11_MEASURE_TYPE_LCI 8 /* d11 measurement LCI type */
+#define DOT11_MEASURE_TYPE_CIVICLOC 11 /* d11 measurement location civic */
+
+static const strmap_entry_t err_info[] = {
+ {RTT_STATUS_SUCCESS, String8("Success")},
+ {RTT_STATUS_FAILURE, String8("Failure")},
+ {RTT_STATUS_FAIL_NO_RSP, String8("No reponse")},
+ {RTT_STATUS_FAIL_INVALID_TS, String8("Invalid Timestamp")},
+ {RTT_STATUS_FAIL_PROTOCOL, String8("Protocol error")},
+ {RTT_STATUS_FAIL_REJECTED, String8("Rejected")},
+ {RTT_STATUS_FAIL_NOT_SCHEDULED_YET, String8("not scheduled")},
+ {RTT_STATUS_FAIL_SCHEDULE, String8("schedule failed")},
+ {RTT_STATUS_FAIL_TM_TIMEOUT, String8("timeout")},
+ {RTT_STATUS_FAIL_AP_ON_DIFF_CHANNEL, String8("AP is on difference channel")},
+ {RTT_STATUS_FAIL_NO_CAPABILITY, String8("no capability")},
+ {RTT_STATUS_FAIL_BUSY_TRY_LATER, String8("busy and try later")},
+ {RTT_STATUS_ABORTED, String8("aborted")}
+};
+
+static const char* get_err_info(int status)
+{
+ int i;
+ const strmap_entry_t *p_entry;
+ int num_entries = sizeof(err_info)/ sizeof(err_info[0]);
+ /* scan thru the table till end */
+ p_entry = err_info;
+ for (i = 0; i < (int) num_entries; i++)
+ {
+ if (p_entry->id == status)
+ return p_entry->text;
+ p_entry++; /* next entry */
+ }
+ return "unknown error"; /* not found */
+}
+
+class GetRttCapabilitiesCommand : public WifiCommand
+{
+ wifi_rtt_capabilities *mCapabilities;
+public:
+ GetRttCapabilitiesCommand(wifi_interface_handle iface, wifi_rtt_capabilities *capabitlites)
+ : WifiCommand("GetRttCapabilitiesCommand", iface, 0), mCapabilities(capabitlites)
+ {
+ memset(mCapabilities, 0, sizeof(*mCapabilities));
+ }
+
+ virtual int create() {
+ ALOGD("[WIFI HAL]Creating message to get Rtt capablities; iface = %d", mIfaceInfo->id);
+
+ int ret = mMsg.create(GOOGLE_OUI, RTT_SUBCMD_GETCAPABILITY);
+ if (ret < 0) {
+ return ret;
+ }
+
+ return ret;
+ }
+
+protected:
+ virtual int handleResponse(WifiEvent& reply) {
+
+ ALOGD("In GetRttCapabilitiesCommand::handleResponse");
+
+ if (reply.get_cmd() != NL80211_CMD_VENDOR) {
+ ALOGD("Ignoring reply with cmd = %d", reply.get_cmd());
+ return NL_SKIP;
+ }
+
+ int id = reply.get_vendor_id();
+ int subcmd = reply.get_vendor_subcmd();
+ int wiphy_id = reply.get_u32(NL80211_ATTR_WIPHY);
+ int if_id = reply.get_u32(NL80211_ATTR_IFINDEX);
+
+ struct nlattr *vendor_data = (struct nlattr *)reply.get_vendor_data();
+ int len = reply.get_vendor_data_len();
+ void *payload = NULL;
+ if(vendor_data->nla_type == RTT_ATTRIBUTE_CAPABILITIES) {
+ payload = nla_data(vendor_data);
+ len -= NLA_HDRLEN;
+ }
+
+ ALOGD("wiphy_id=%d, if_id=%d, Id=%0x, subcmd=%d, len=%d, expected len=%d", wiphy_id, if_id, id, subcmd, len,
+ sizeof(*mCapabilities));
+ if (payload)
+ memcpy(mCapabilities, payload, min(len, (int) sizeof(*mCapabilities)));
+
+ ALOGI("RTT capability: %d, %d, %d, %d, %d, %d",
+ mCapabilities->rtt_one_sided_supported, mCapabilities->rtt_ftm_supported,
+ mCapabilities->lci_support, mCapabilities->lcr_support,
+ mCapabilities->preamble_support, mCapabilities->bw_support);
+
+ return NL_OK;
+ }
+};
+
+
+class GetRttResponderInfoCommand : public WifiCommand
+{
+ wifi_rtt_responder* mResponderInfo;
+public:
+ GetRttResponderInfoCommand(wifi_interface_handle iface, wifi_rtt_responder *responderInfo)
+ : WifiCommand("GetRttResponderInfoCommand", iface, 0), mResponderInfo(responderInfo)
+ {
+ memset(mResponderInfo, 0 , sizeof(*mResponderInfo));
+
+ }
+
+ virtual int create() {
+ ALOGD("Creating message to get responder info ; iface = %d", mIfaceInfo->id);
+
+ int ret = mMsg.create(GOOGLE_OUI, RTT_SUBCMD_GETAVAILCHANNEL);
+ if (ret < 0) {
+ return ret;
+ }
+
+ return ret;
+ }
+
+protected:
+ virtual int handleResponse(WifiEvent& reply) {
+
+ ALOGD("In GetRttResponderInfoCommand::handleResponse");
+
+ if (reply.get_cmd() != NL80211_CMD_VENDOR) {
+ ALOGD("Ignoring reply with cmd = %d", reply.get_cmd());
+ return NL_SKIP;
+ }
+
+ int id = reply.get_vendor_id();
+ int subcmd = reply.get_vendor_subcmd();
+
+ void *data = reply.get_vendor_data();
+ int len = reply.get_vendor_data_len();
+
+ ALOGD("Id = %0x, subcmd = %d, len = %d, expected len = %d", id, subcmd, len,
+ sizeof(*mResponderInfo));
+
+ memcpy(mResponderInfo, data, min(len, (int) sizeof(*mResponderInfo)));
+
+ return NL_OK;
+ }
+};
+
+
+class EnableResponderCommand : public WifiCommand
+{
+ wifi_channel_info mChannelInfo;
+ unsigned m_max_duration_sec;
+ wifi_rtt_responder* mResponderInfo;
+public:
+ EnableResponderCommand(wifi_interface_handle iface, int id, wifi_channel_info channel_hint,
+ unsigned max_duration_seconds, wifi_rtt_responder *responderInfo)
+ : WifiCommand("EnableResponderCommand", iface, 0), mChannelInfo(channel_hint),
+ m_max_duration_sec(max_duration_seconds), mResponderInfo(responderInfo)
+ {
+ memset(mResponderInfo, 0, sizeof(*mResponderInfo));
+ }
+
+ virtual int create() {
+ ALOGD("Creating message to set responder ; iface = %d", mIfaceInfo->id);
+
+ int ret = mMsg.create(GOOGLE_OUI, RTT_SUBCMD_SET_RESPONDER);
+ if (ret < 0) {
+ return ret;
+ }
+
+ return ret;
+ }
+
+protected:
+ virtual int handleResponse(WifiEvent& reply) {
+
+ ALOGD("In EnableResponderCommand::handleResponse");
+
+ if (reply.get_cmd() != NL80211_CMD_VENDOR) {
+ ALOGD("Ignoring reply with cmd = %d", reply.get_cmd());
+ return NL_SKIP;
+ }
+
+ int id = reply.get_vendor_id();
+ int subcmd = reply.get_vendor_subcmd();
+
+ void *data = reply.get_vendor_data();
+ int len = reply.get_vendor_data_len();
+
+ ALOGD("Id = %0x, subcmd = %d, len = %d, expected len = %d", id, subcmd, len,
+ sizeof(*mResponderInfo));
+
+ memcpy(mResponderInfo, data, min(len, (int) sizeof(*mResponderInfo)));
+
+ return NL_OK;
+ }
+};
+
+
+class CancelResponderCommand : public WifiCommand
+{
+
+public:
+ CancelResponderCommand(wifi_interface_handle iface, int id)
+ : WifiCommand("CancelResponderCommand", iface, 0)/*, mChannelInfo(channel)*/
+ {
+
+ }
+
+ virtual int create() {
+ ALOGD("Creating message to cancel responder ; iface = %d", mIfaceInfo->id);
+
+ int ret = mMsg.create(GOOGLE_OUI, RTT_SUBCMD_CANCEL_RESPONDER);
+ if (ret < 0) {
+ return ret;
+ }
+
+ return ret;
+ }
+
+protected:
+ virtual int handleResponse(WifiEvent& reply) {
+ /* Nothing to do on response! */
+ return NL_SKIP;
+ }
+
+};
+
+
+class RttCommand : public WifiCommand
+{
+ unsigned numRttParams;
+ int mCompleted;
+ int currentIdx;
+ int totalCnt;
+ static const int MAX_RESULTS = 1024;
+ wifi_rtt_result *rttResults[MAX_RESULTS];
+ wifi_rtt_config *rttParams;
+ wifi_rtt_event_handler rttHandler;
+public:
+ RttCommand(wifi_interface_handle iface, int id, unsigned num_rtt_config,
+ wifi_rtt_config rtt_config[], wifi_rtt_event_handler handler)
+ : WifiCommand("RttCommand", iface, id), numRttParams(num_rtt_config), rttParams(rtt_config),
+ rttHandler(handler)
+ {
+ memset(rttResults, 0, sizeof(rttResults));
+ currentIdx = 0;
+ mCompleted = 0;
+ totalCnt = 0;
+ }
+
+ RttCommand(wifi_interface_handle iface, int id)
+ : WifiCommand("RttCommand", iface, id)
+ {
+ currentIdx = 0;
+ mCompleted = 0;
+ totalCnt = 0;
+ numRttParams = 0;
+ }
+
+ int createSetupRequest(WifiRequest& request) {
+ int result = request.create(GOOGLE_OUI, RTT_SUBCMD_SET_CONFIG);
+ if (result < 0) {
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+ result = request.put_u8(RTT_ATTRIBUTE_TARGET_CNT, numRttParams);
+ if (result < 0) {
+ return result;
+ }
+ nlattr *rtt_config = request.attr_start(RTT_ATTRIBUTE_TARGET_INFO);
+ for (unsigned i = 0; i < numRttParams; i++) {
+ nlattr *attr2 = request.attr_start(i);
+ if (attr2 == NULL) {
+ return WIFI_ERROR_OUT_OF_MEMORY;
+ }
+
+ result = request.put_addr(RTT_ATTRIBUTE_TARGET_MAC, rttParams[i].addr);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u8(RTT_ATTRIBUTE_TARGET_TYPE, rttParams[i].type);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u8(RTT_ATTRIBUTE_TARGET_PEER, rttParams[i].peer);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put(RTT_ATTRIBUTE_TARGET_CHAN, &rttParams[i].channel,
+ sizeof(wifi_channel_info));
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u32(RTT_ATTRIBUTE_TARGET_NUM_BURST, rttParams[i].num_burst);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u32(RTT_ATTRIBUTE_TARGET_NUM_FTM_BURST,
+ rttParams[i].num_frames_per_burst);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u32(RTT_ATTRIBUTE_TARGET_NUM_RETRY_FTM,
+ rttParams[i].num_retries_per_rtt_frame);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u32(RTT_ATTRIBUTE_TARGET_NUM_RETRY_FTMR,
+ rttParams[i].num_retries_per_ftmr);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u32(RTT_ATTRIBUTE_TARGET_PERIOD,
+ rttParams[i].burst_period);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u32(RTT_ATTRIBUTE_TARGET_BURST_DURATION,
+ rttParams[i].burst_duration);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u8(RTT_ATTRIBUTE_TARGET_LCI,
+ rttParams[i].LCI_request);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u8(RTT_ATTRIBUTE_TARGET_LCR,
+ rttParams[i].LCR_request);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u8(RTT_ATTRIBUTE_TARGET_BW,
+ rttParams[i].bw);
+ if (result < 0) {
+ return result;
+ }
+
+ result = request.put_u8(RTT_ATTRIBUTE_TARGET_PREAMBLE,
+ rttParams[i].preamble);
+ if (result < 0) {
+ return result;
+ }
+ request.attr_end(attr2);
+ }
+
+ request.attr_end(rtt_config);
+ request.attr_end(data);
+ return WIFI_SUCCESS;
+ }
+
+ int createTeardownRequest(WifiRequest& request, unsigned num_devices, mac_addr addr[]) {
+ int result = request.create(GOOGLE_OUI, RTT_SUBCMD_CANCEL_CONFIG);
+ if (result < 0) {
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+ request.put_u8(RTT_ATTRIBUTE_TARGET_CNT, num_devices);
+ for(unsigned i = 0; i < num_devices; i++) {
+ result = request.put_addr(RTT_ATTRIBUTE_TARGET_MAC, addr[i]);
+ if (result < 0) {
+ return result;
+ }
+ }
+ request.attr_end(data);
+ return result;
+ }
+ int start() {
+ ALOGD("Setting RTT configuration");
+ WifiRequest request(familyId(), ifaceId());
+ int result = createSetupRequest(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to create setup request; result = %d", result);
+ return result;
+ }
+
+ result = requestResponse(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to configure RTT setup; result = %d", result);
+ return result;
+ }
+
+ registerVendorHandler(GOOGLE_OUI, RTT_EVENT_COMPLETE);
+ ALOGI("Successfully started RTT operation");
+ return result;
+ }
+
+ virtual int cancel() {
+ ALOGD("Stopping RTT");
+
+ WifiRequest request(familyId(), ifaceId());
+ int result = createTeardownRequest(request, 0, NULL);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to create stop request; result = %d", result);
+ } else {
+ result = requestResponse(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to stop scan; result = %d", result);
+ }
+ }
+
+ unregisterVendorHandler(GOOGLE_OUI, RTT_EVENT_COMPLETE);
+ return WIFI_SUCCESS;
+ }
+
+ int cancel_specific(unsigned num_devices, mac_addr addr[]) {
+ ALOGE("Stopping RTT");
+
+ WifiRequest request(familyId(), ifaceId());
+ int result = createTeardownRequest(request, num_devices, addr);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to create stop request; result = %d", result);
+ } else {
+ result = requestResponse(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("failed to stop RTT; result = %d", result);
+ }
+ }
+
+ unregisterVendorHandler(GOOGLE_OUI, RTT_EVENT_COMPLETE);
+ return WIFI_SUCCESS;
+ }
+
+ virtual int handleResponse(WifiEvent& reply) {
+ /* Nothing to do on response! */
+ return NL_SKIP;
+ }
+
+ virtual int handleEvent(WifiEvent& event) {
+ ALOGI("Got an RTT event");
+ nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);
+ int len = event.get_vendor_data_len();
+ if (vendor_data == NULL || len == 0) {
+ ALOGI("No rtt results found");
+ }
+ for (nl_iterator it(vendor_data); it.has_next(); it.next()) {
+ if (it.get_type() == RTT_ATTRIBUTE_RESULTS_COMPLETE) {
+ mCompleted = it.get_u32();
+ ALOGI("retrieved completed flag : %d\n", mCompleted);
+ } else if (it.get_type() == RTT_ATTRIBUTE_RESULTS_PER_TARGET) {
+ int result_cnt = 0;
+ mac_addr bssid;
+ for (nl_iterator it2(it.get()); it2.has_next(); it2.next()) {
+ if (it2.get_type() == RTT_ATTRIBUTE_TARGET_MAC) {
+ memcpy(bssid, it2.get_data(), sizeof(mac_addr));
+ ALOGI("retrived target mac : %02x:%02x:%02x:%02x:%02x:%02x\n",
+ bssid[0],
+ bssid[1],
+ bssid[2],
+ bssid[3],
+ bssid[4],
+ bssid[5]);
+ } else if (it2.get_type() == RTT_ATTRIBUTE_RESULT_CNT) {
+ result_cnt = it2.get_u32();
+ ALOGI("retrieved result_cnt : %d\n", result_cnt);
+ } else if (it2.get_type() == RTT_ATTRIBUTE_RESULT) {
+ int result_len = it2.get_len();
+ rttResults[currentIdx] = (wifi_rtt_result *)malloc(it2.get_len());
+ wifi_rtt_result *rtt_result = rttResults[currentIdx];
+ if (rtt_result == NULL) {
+ mCompleted = 1;
+ ALOGE("failed to allocate the wifi_rtt_result\n");
+ break;
+ }
+ memcpy(rtt_result, it2.get_data(), it2.get_len());
+ result_len -= sizeof(wifi_rtt_result);
+ if (result_len > 0) {
+ result_len -= sizeof(wifi_rtt_result);
+ dot11_rm_ie_t *ele_1;
+ dot11_rm_ie_t *ele_2;
+ /* The result has LCI or LCR element */
+ ele_1 = (dot11_rm_ie_t *)(rtt_result + 1);
+ if (ele_1->id == DOT11_MNG_MEASURE_REQUEST_ID) {
+ if (ele_1->type == DOT11_MEASURE_TYPE_LCI) {
+ rtt_result->LCI = (wifi_information_element *)ele_1;
+ result_len -= (ele_1->len + DOT11_HDR_LEN);
+ /* get a next rm ie */
+ if (result_len > 0) {
+ ele_2 = (dot11_rm_ie_t *)((char *)ele_1 + (ele_1->len + DOT11_HDR_LEN));
+ if ((ele_2->id == DOT11_MNG_MEASURE_REQUEST_ID) &&
+ (ele_2->type == DOT11_MEASURE_TYPE_CIVICLOC)) {
+ rtt_result->LCR = (wifi_information_element *)ele_2;
+ }
+ }
+ } else if (ele_1->type == DOT11_MEASURE_TYPE_CIVICLOC){
+ rtt_result->LCR = (wifi_information_element *)ele_1;
+ result_len -= (ele_1->len + DOT11_HDR_LEN);
+ /* get a next rm ie */
+ if (result_len > 0) {
+ ele_2 = (dot11_rm_ie_t *)((char *)ele_1 + (ele_1->len + DOT11_HDR_LEN));
+ if ((ele_2->id == DOT11_MNG_MEASURE_REQUEST_ID) &&
+ (ele_2->type == DOT11_MEASURE_TYPE_LCI)) {
+ rtt_result->LCI = (wifi_information_element *)ele_2;
+ }
+ }
+ }
+ }
+ }
+ totalCnt++;
+ ALOGI("retrived rtt_result : \n\tburst_num :%d, measurement_number : %d, success_number : %d\n"
+ "\tnumber_per_burst_peer : %d, status : %s, retry_after_duration : %d s\n"
+ "\trssi : %d dbm, rx_rate : %d Kbps, rtt : %llu ns, rtt_sd : %llu\n"
+ "\tdistance : %d, burst_duration : %d ms, negotiated_burst_num : %d\n",
+ rtt_result->burst_num, rtt_result->measurement_number,
+ rtt_result->success_number, rtt_result->number_per_burst_peer,
+ get_err_info(rtt_result->status), rtt_result->retry_after_duration,
+ rtt_result->rssi, rtt_result->rx_rate.bitrate * 100,
+ rtt_result->rtt/10, rtt_result->rtt_sd, rtt_result->distance_mm / 10,
+ rtt_result->burst_duration, rtt_result->negotiated_burst_num);
+ currentIdx++;
+ }
+ }
+ }
+
+ }
+ if (mCompleted) {
+ unregisterVendorHandler(GOOGLE_OUI, RTT_EVENT_COMPLETE);
+ (*rttHandler.on_rtt_results)(id(), totalCnt, rttResults);
+ for (int i = 0; i < currentIdx; i++) {
+ free(rttResults[i]);
+ rttResults[i] = NULL;
+ }
+ totalCnt = currentIdx = 0;
+ WifiCommand *cmd = wifi_unregister_cmd(wifiHandle(), id());
+ if (cmd)
+ cmd->releaseRef();
+ }
+ return NL_SKIP;
+ }
+};
+
+
+/* API to request RTT measurement */
+wifi_error wifi_rtt_range_request(wifi_request_id id, wifi_interface_handle iface,
+ unsigned num_rtt_config, wifi_rtt_config rtt_config[], wifi_rtt_event_handler handler)
+{
+ wifi_handle handle = getWifiHandle(iface);
+ RttCommand *cmd = new RttCommand(iface, id, num_rtt_config, rtt_config, handler);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ wifi_error result = wifi_register_cmd(handle, id, cmd);
+ if (result != WIFI_SUCCESS) {
+ cmd->releaseRef();
+ return result;
+ }
+ result = (wifi_error)cmd->start();
+ if (result != WIFI_SUCCESS) {
+ wifi_unregister_cmd(handle, id);
+ cmd->releaseRef();
+ return result;
+ }
+ return result;
+}
+
+/* API to cancel RTT measurements */
+wifi_error wifi_rtt_range_cancel(wifi_request_id id, wifi_interface_handle iface,
+ unsigned num_devices, mac_addr addr[])
+{
+ wifi_handle handle = getWifiHandle(iface);
+ RttCommand *cmd = new RttCommand(iface, id);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ cmd->cancel_specific(num_devices, addr);
+ cmd->releaseRef();
+ return WIFI_SUCCESS;
+}
+
+/* API to get RTT capability */
+wifi_error wifi_get_rtt_capabilities(wifi_interface_handle iface,
+ wifi_rtt_capabilities *capabilities)
+{
+ GetRttCapabilitiesCommand command(iface, capabilities);
+ return (wifi_error) command.requestResponse();
+}
+
+/* API to get the responder information */
+wifi_error wifi_rtt_get_responder_info(wifi_interface_handle iface,
+ wifi_rtt_responder* responderInfo)
+{
+ GetRttResponderInfoCommand command(iface, responderInfo);
+ return (wifi_error) command.requestResponse();
+
+}
+
+/**
+ * Enable RTT responder mode.
+ * channel_hint - hint of the channel information where RTT responder should be enabled on.
+ * max_duration_seconds - timeout of responder mode.
+ * wifi_rtt_responder - information for RTT responder e.g. channel used and preamble supported.
+ */
+wifi_error wifi_enable_responder(wifi_request_id id, wifi_interface_handle iface,
+ wifi_channel_info channel_hint, unsigned max_duration_seconds,
+ wifi_rtt_responder* responderInfo)
+{
+ EnableResponderCommand command(iface, id, channel_hint, max_duration_seconds, responderInfo);
+ return (wifi_error) command.requestResponse();
+}
+
+/**
+ * Disable RTT responder mode.
+ */
+wifi_error wifi_disable_responder(wifi_request_id id, wifi_interface_handle iface)
+{
+ CancelResponderCommand command(iface, id);
+ return (wifi_error) command.requestResponse();
+}
+
--- /dev/null
+
+#include <pthread.h>
+
+#ifndef __WIFI_HAL_SYNC_H__
+#define __WIFI_HAL_SYNC_H__
+
+class Mutex
+{
+private:
+ pthread_mutex_t mMutex;
+public:
+ Mutex() {
+ pthread_mutex_init(&mMutex, NULL);
+ }
+ ~Mutex() {
+ pthread_mutex_destroy(&mMutex);
+ }
+ int tryLock() {
+ return pthread_mutex_trylock(&mMutex);
+ }
+ int lock() {
+ return pthread_mutex_lock(&mMutex);
+ }
+ void unlock() {
+ pthread_mutex_unlock(&mMutex);
+ }
+};
+
+class Condition
+{
+private:
+ pthread_cond_t mCondition;
+ pthread_mutex_t mMutex;
+
+public:
+ Condition() {
+ pthread_mutex_init(&mMutex, NULL);
+ pthread_cond_init(&mCondition, NULL);
+ }
+ ~Condition() {
+ pthread_cond_destroy(&mCondition);
+ pthread_mutex_destroy(&mMutex);
+ }
+
+ int wait() {
+ return pthread_cond_wait(&mCondition, &mMutex);
+ }
+
+ void signal() {
+ pthread_cond_signal(&mCondition);
+ }
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+#include <stdint.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/rtnetlink.h>
+#include <netpacket/packet.h>
+#include <linux/filter.h>
+#include <linux/errqueue.h>
+#include <errno.h>
+#include <string.h>
+
+#include <linux/pkt_sched.h>
+#include <netlink/object-api.h>
+#include <netlink/netlink.h>
+#include <netlink/socket.h>
+#include <netlink/attr.h>
+#include <netlink/handlers.h>
+#include <netlink/msg.h>
+
+#include <dirent.h>
+#include <net/if.h>
+
+#include "sync.h"
+
+#define LOG_TAG "WifiHAL"
+
+#include <utils/Log.h>
+
+#include "wifi_hal.h"
+#include "common.h"
+#include "cpp_bindings.h"
+#include "cutils/properties.h"
+
+/*
+ BUGBUG: normally, libnl allocates ports for all connections it makes; but
+ being a static library, it doesn't really know how many other netlink connections
+ are made by the same process, if connections come from different shared libraries.
+ These port assignments exist to solve that problem - temporarily. We need to fix
+ libnl to try and allocate ports across the entire process.
+ */
+
+#define WIFI_HAL_CMD_SOCK_PORT 644
+#define WIFI_HAL_EVENT_SOCK_PORT 645
+
+static void internal_event_handler(wifi_handle handle, int events);
+static int internal_no_seq_check(nl_msg *msg, void *arg);
+static int internal_valid_message_handler(nl_msg *msg, void *arg);
+static int wifi_get_multicast_id(wifi_handle handle, const char *name, const char *group);
+static int wifi_add_membership(wifi_handle handle, const char *group);
+static wifi_error wifi_init_interfaces(wifi_handle handle);
+static wifi_error wifi_start_rssi_monitoring(wifi_request_id id, wifi_interface_handle
+ iface, s8 max_rssi, s8 min_rssi, wifi_rssi_event_handler eh);
+static wifi_error wifi_stop_rssi_monitoring(wifi_request_id id, wifi_interface_handle iface);
+
+static wifi_error wifi_reset_log_handler_dummy(wifi_request_id id, wifi_interface_handle iface);
+static wifi_error wifi_get_wake_reason_stats_dummy(wifi_interface_handle iface,
+ WLAN_DRIVER_WAKE_REASON_CNT *wifi_wake_reason_cnt);
+static wifi_error wifi_get_packet_filter_capabilities_dummy(
+ wifi_interface_handle handle, u32 *version, u32 *max_len);
+static wifi_error wifi_configure_nd_offload_dummy(wifi_interface_handle iface, u8 enable);
+static wifi_error wifi_get_firmware_version_dummy(
+ wifi_interface_handle iface, char *buffer, int buffer_size);
+static wifi_error wifi_get_driver_version_dummy(
+ wifi_interface_handle iface, char *buffer, int buffer_size);
+static wifi_error wifi_get_ring_data_dummy(wifi_interface_handle iface, char *ring_name);
+static wifi_error wifi_get_ring_buffers_status_dummy(wifi_interface_handle iface,
+ u32 *num_rings, wifi_ring_buffer_status *status);
+static wifi_error wifi_get_logger_supported_feature_set_dummy(wifi_interface_handle iface,
+ unsigned int *support);
+static wifi_error wifi_start_logging_dummy(wifi_interface_handle iface, u32 verbose_level,
+ u32 flags, u32 max_interval_sec, u32 min_data_size, char *ring_name);
+static wifi_error wifi_start_pkt_fate_monitoring_dummy(wifi_interface_handle iface);
+static wifi_error wifi_get_tx_pkt_fates_dummy(wifi_interface_handle handle,
+ wifi_tx_report *tx_report_bufs, size_t n_requested_fates, size_t *n_provided_fates);
+static wifi_error wifi_get_rx_pkt_fates_dummy(wifi_interface_handle handle,
+ wifi_rx_report *rx_report_bufs, size_t n_requested_fates, size_t *n_provided_fates);
+static wifi_error wifi_get_driver_memory_dump_dummy(wifi_interface_handle iface,
+ wifi_driver_memory_dump_callbacks callbacks);
+static wifi_error wifi_set_log_handler_dummy(wifi_request_id id, wifi_interface_handle iface,
+ wifi_ring_buffer_data_handler handler);
+static wifi_error wifi_set_scanning_mac_oui_dummy(wifi_interface_handle handle, oui scan_oui);
+
+
+/* Initialize/Cleanup */
+
+void wifi_socket_set_local_port(struct nl_sock *sock, uint32_t port)
+{
+ uint32_t pid = getpid() & 0x3FFFFF;
+ nl_socket_set_local_port(sock, pid + (port << 22));
+}
+
+static nl_sock *wifi_create_nl_socket(int port)
+{
+
+ // ALOGD("Creating netlink socket, local port[%d]", port);
+ struct nl_sock *sock = nl_socket_alloc();
+ if (sock == NULL) {
+ ALOGE("Could not create netlink socket: %s(%d)", strerror(errno), errno);
+ return NULL;
+ }
+
+ wifi_socket_set_local_port(sock, port);
+
+ // ALOGD("Connecting to socket");
+ if (nl_connect(sock, NETLINK_GENERIC)) {
+ ALOGE("Could not connect to netlink socket: %s(%d)", strerror(errno), errno);
+ nl_socket_free(sock);
+ return NULL;
+ }
+
+ return sock;
+}
+/* Initialize vendor function pointer table with MTK HAL API */
+wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn)
+{
+ if (fn == NULL) {
+ return WIFI_ERROR_UNKNOWN;
+ }
+ fn->wifi_initialize = wifi_initialize;
+ fn->wifi_cleanup = wifi_cleanup;
+ fn->wifi_event_loop = wifi_event_loop;
+ fn->wifi_get_supported_feature_set = wifi_get_supported_feature_set;
+ fn->wifi_get_concurrency_matrix = wifi_get_concurrency_matrix;
+ fn->wifi_set_scanning_mac_oui = wifi_set_scanning_mac_oui_dummy;
+ fn->wifi_get_ifaces = wifi_get_ifaces;
+ fn->wifi_get_iface_name = wifi_get_iface_name;
+ fn->wifi_start_gscan = wifi_start_gscan;
+ fn->wifi_stop_gscan = wifi_stop_gscan;
+ fn->wifi_get_cached_gscan_results = wifi_get_cached_gscan_results;
+ fn->wifi_set_bssid_hotlist = wifi_set_bssid_hotlist;
+ fn->wifi_reset_bssid_hotlist = wifi_reset_bssid_hotlist;
+ fn->wifi_set_significant_change_handler = wifi_set_significant_change_handler;
+ fn->wifi_reset_significant_change_handler = wifi_reset_significant_change_handler;
+ /*fn->wifi_get_gscan_capabilities = wifi_get_gscan_capabilities;
+ fn->wifi_get_link_stats = wifi_get_link_stats;
+ fn->wifi_set_link_stats = wifi_set_link_stats;
+ fn->wifi_clear_link_stats = wifi_clear_link_stats;*/
+ fn->wifi_get_valid_channels = wifi_get_valid_channels;
+ fn->wifi_rtt_range_request = wifi_rtt_range_request;
+ fn->wifi_rtt_range_cancel = wifi_rtt_range_cancel;
+ fn->wifi_get_rtt_capabilities = wifi_get_rtt_capabilities;
+ /*fn->wifi_rtt_get_responder_info = wifi_rtt_get_responder_info;
+ fn->wifi_enable_responder = wifi_enable_responder;
+ fn->wifi_disable_responder = wifi_disable_responder;
+ fn->wifi_set_nodfs_flag = wifi_set_nodfs_flag;*/
+ fn->wifi_start_logging = wifi_start_logging_dummy;
+ fn->wifi_set_epno_list = wifi_set_epno_list;
+ fn->wifi_reset_epno_list = wifi_reset_epno_list;
+ fn->wifi_set_country_code = wifi_set_country_code;
+ /*fn->wifi_get_firmware_memory_dump = wifi_get_firmware_memory_dump;*/
+ fn->wifi_set_log_handler = wifi_set_log_handler_dummy;
+ fn->wifi_reset_log_handler = wifi_reset_log_handler_dummy;
+ /*fn->wifi_set_alert_handler = wifi_set_alert_handler;
+ fn->wifi_reset_alert_handler = wifi_reset_alert_handler;*/
+ fn->wifi_get_firmware_version = wifi_get_firmware_version_dummy;
+ fn->wifi_get_ring_buffers_status = wifi_get_ring_buffers_status_dummy;
+ fn->wifi_get_logger_supported_feature_set = wifi_get_logger_supported_feature_set_dummy;
+ fn->wifi_get_ring_data = wifi_get_ring_data_dummy;
+ fn->wifi_get_driver_version = wifi_get_driver_version_dummy;
+ fn->wifi_start_rssi_monitoring = wifi_start_rssi_monitoring;
+ fn->wifi_stop_rssi_monitoring = wifi_stop_rssi_monitoring;
+ fn->wifi_configure_nd_offload = wifi_configure_nd_offload_dummy;
+ fn->wifi_start_sending_offloaded_packet = wifi_start_sending_offloaded_packet;
+ fn->wifi_stop_sending_offloaded_packet = wifi_stop_sending_offloaded_packet;
+ fn->wifi_start_pkt_fate_monitoring = wifi_start_pkt_fate_monitoring_dummy;
+ fn->wifi_get_tx_pkt_fates = wifi_get_tx_pkt_fates_dummy;
+ fn->wifi_get_rx_pkt_fates = wifi_get_rx_pkt_fates_dummy;
+ fn->wifi_get_packet_filter_capabilities = wifi_get_packet_filter_capabilities_dummy;
+
+ fn->wifi_get_driver_memory_dump = wifi_get_driver_memory_dump_dummy;
+ fn->wifi_get_wake_reason_stats = wifi_get_wake_reason_stats_dummy;
+ fn->wifi_get_packet_filter_capabilities = wifi_get_packet_filter_capabilities_dummy;
+
+ return WIFI_SUCCESS;
+}
+
+wifi_error wifi_initialize(wifi_handle *handle)
+{
+ ALOGI("Wifi HAL initializing");
+
+ hal_info *info = (hal_info *)malloc(sizeof(hal_info));
+ if (info == NULL) {
+ ALOGE("Could not allocate hal_info");
+ return WIFI_ERROR_OUT_OF_MEMORY;
+ }
+
+ memset(info, 0, sizeof(*info));
+
+ ALOGI("Creating socket");
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, info->cleanup_socks) < 0) {
+ ALOGE("Could not create cleanup sockets");
+ free(info);
+ return WIFI_ERROR_UNKNOWN;
+ }
+
+ struct nl_sock *cmd_sock = wifi_create_nl_socket(WIFI_HAL_CMD_SOCK_PORT);
+ if (cmd_sock == NULL) {
+ ALOGE("Could not create handle");
+ free(info);
+ return WIFI_ERROR_UNKNOWN;
+ }
+
+ struct nl_sock *event_sock = wifi_create_nl_socket(WIFI_HAL_EVENT_SOCK_PORT);
+ if (event_sock == NULL) {
+ ALOGE("Could not create handle");
+ nl_socket_free(cmd_sock);
+ free(info);
+ return WIFI_ERROR_UNKNOWN;
+ }
+
+ struct nl_cb *cb = nl_socket_get_cb(event_sock);
+ if (cb == NULL) {
+ ALOGE("Could not create handle");
+ nl_socket_free(cmd_sock);
+ nl_socket_free(event_sock);
+ free(info);
+ return WIFI_ERROR_UNKNOWN;
+ }
+
+ // ALOGI("cb->refcnt = %d", cb->cb_refcnt);
+ nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, internal_no_seq_check, info);
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, internal_valid_message_handler, info);
+ nl_cb_put(cb);
+
+ info->cmd_sock = cmd_sock;
+ info->event_sock = event_sock;
+ info->clean_up = false;
+ info->in_event_loop = false;
+
+ info->event_cb = (cb_info *)malloc(sizeof(cb_info) * DEFAULT_EVENT_CB_SIZE);
+ info->alloc_event_cb = DEFAULT_EVENT_CB_SIZE;
+ info->num_event_cb = 0;
+ if (info->event_cb == NULL) {
+ ALOGE("Could not allocate cb_info array");
+ nl_socket_free(cmd_sock);
+ nl_socket_free(event_sock);
+ free(info);
+ return WIFI_ERROR_OUT_OF_MEMORY;
+ }
+
+ info->cmd = (cmd_info *)malloc(sizeof(cmd_info) * DEFAULT_CMD_SIZE);
+ info->alloc_cmd = DEFAULT_CMD_SIZE;
+ info->num_cmd = 0;
+ if (info->cmd == NULL) {
+ ALOGE("Could not allocate cmd_info array");
+ nl_socket_free(cmd_sock);
+ nl_socket_free(event_sock);
+ free(info->event_cb);
+ free(info);
+ return WIFI_ERROR_OUT_OF_MEMORY;
+ }
+
+ ALOGI("Get nl80211_family_id");
+ info->nl80211_family_id = genl_ctrl_resolve(cmd_sock, "nl80211");
+ if (info->nl80211_family_id < 0) {
+ ALOGE("Could not resolve nl80211 familty id");
+ nl_socket_free(cmd_sock);
+ nl_socket_free(event_sock);
+ free(info->event_cb);
+ free(info->cmd);
+ free(info);
+ return WIFI_ERROR_UNKNOWN;
+ }
+
+ pthread_mutex_init(&info->cb_lock, NULL);
+
+ if (wifi_init_interfaces((wifi_handle) info) != WIFI_SUCCESS) {
+ ALOGE("No wifi interface found");
+ nl_socket_free(cmd_sock);
+ nl_socket_free(event_sock);
+ free(info->event_cb);
+ free(info->cmd);
+ pthread_mutex_destroy(&info->cb_lock);
+ free(info);
+ return WIFI_ERROR_NOT_AVAILABLE;
+ }
+
+ if ((wifi_add_membership((wifi_handle) info, "scan") < 0) ||
+ (wifi_add_membership((wifi_handle) info, "mlme") < 0) ||
+ (wifi_add_membership((wifi_handle) info, "regulatory") < 0) ||
+ (wifi_add_membership((wifi_handle) info, "vendor") < 0)) {
+ ALOGE("Add membership failed");
+ nl_socket_free(cmd_sock);
+ nl_socket_free(event_sock);
+ free(info->event_cb);
+ free(info->cmd);
+ pthread_mutex_destroy(&info->cb_lock);
+ free(info);
+ return WIFI_ERROR_NOT_AVAILABLE;
+ }
+
+ *handle = (wifi_handle) info;
+
+ ALOGD("Wifi HAL initialized successfully: nl80211_family_id=%d, found %d interfaces",
+ info->nl80211_family_id, info->num_interfaces);
+ return WIFI_SUCCESS;
+}
+
+static int wifi_add_membership(wifi_handle handle, const char *group)
+{
+ hal_info *info = getHalInfo(handle);
+
+ int id = wifi_get_multicast_id(handle, "nl80211", group);
+ if (id < 0) {
+ ALOGE("Could not find group %s", group);
+ return id;
+ }
+
+ int ret = nl_socket_add_membership(info->event_sock, id);
+ if (ret < 0) {
+ ALOGE("Could not add membership to group %s", group);
+ }
+
+ ALOGD("Add membership for group %s successfully", group);
+ return ret;
+}
+
+static void internal_cleaned_up_handler(wifi_handle handle)
+{
+ hal_info *info = getHalInfo(handle);
+ wifi_cleaned_up_handler cleaned_up_handler = info->cleaned_up_handler;
+
+ if (info->cmd_sock != 0) {
+ close(info->cleanup_socks[0]);
+ close(info->cleanup_socks[1]);
+ nl_socket_free(info->cmd_sock);
+ nl_socket_free(info->event_sock);
+ info->cmd_sock = NULL;
+ info->event_sock = NULL;
+ }
+
+ (*cleaned_up_handler)(handle);
+ pthread_mutex_destroy(&info->cb_lock);
+ free(info);
+
+ ALOGI("Internal cleanup completed");
+}
+
+void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler)
+{
+ hal_info *info = getHalInfo(handle);
+ char buf[64];
+
+ info->cleaned_up_handler = handler;
+ if (TEMP_FAILURE_RETRY(write(info->cleanup_socks[0], "Exit", 4)) < 1) {
+ // As a fallback set the cleanup flag to TRUE
+ ALOGE("could not write to the cleanup socket");
+ } else {
+ // Listen to the response
+ // Hopefully we dont get errors or get hung up
+ // Not much can be done in that case, but assume that
+ // it has rx'ed the Exit message to exit the thread.
+ // As a fallback set the cleanup flag to TRUE
+ memset(buf, 0, sizeof(buf));
+ ssize_t result = TEMP_FAILURE_RETRY(read(info->cleanup_socks[0], buf, sizeof(buf)));
+ ALOGE("%s: Read after POLL returned %zd, error no = %d (%s)", __FUNCTION__,
+ result, errno, strerror(errno));
+ if (strncmp(buf, "Done", 4) == 0) {
+ ALOGE("Event processing terminated");
+ } else {
+ ALOGD("Rx'ed %s", buf);
+ }
+ }
+ info->clean_up = true;
+ pthread_mutex_lock(&info->cb_lock);
+
+ int bad_commands = 0;
+
+ for (int i = 0; i < info->num_event_cb; i++) {
+ cb_info *cbi = &(info->event_cb[i]);
+ WifiCommand *cmd = (WifiCommand *)cbi->cb_arg;
+ ALOGI("Command left in event_cb %p:%s", cmd, (cmd ? cmd->getType(): ""));
+ }
+
+ while (info->num_cmd > bad_commands) {
+ int num_cmd = info->num_cmd;
+ cmd_info *cmdi = &(info->cmd[bad_commands]);
+ WifiCommand *cmd = cmdi->cmd;
+ if (cmd != NULL) {
+ ALOGI("Cancelling command %p:%s", cmd, cmd->getType());
+ pthread_mutex_unlock(&info->cb_lock);
+ cmd->cancel();
+ pthread_mutex_lock(&info->cb_lock);
+ if (num_cmd == info->num_cmd) {
+ ALOGI("Cancelling command %p:%s did not work", cmd, (cmd ? cmd->getType(): ""));
+ bad_commands++;
+ }
+ /* release reference added when command is saved */
+ cmd->releaseRef();
+ }
+ }
+
+ for (int i = 0; i < info->num_event_cb; i++) {
+ cb_info *cbi = &(info->event_cb[i]);
+ WifiCommand *cmd = (WifiCommand *)cbi->cb_arg;
+ ALOGE("Leaked command %p", cmd);
+ }
+ pthread_mutex_unlock(&info->cb_lock);
+ internal_cleaned_up_handler(handle);
+}
+
+static int internal_pollin_handler(wifi_handle handle)
+{
+ hal_info *info = getHalInfo(handle);
+ struct nl_cb *cb = nl_socket_get_cb(info->event_sock);
+ int res = nl_recvmsgs(info->event_sock, cb);
+ // ALOGD("nl_recvmsgs returned %d", res);
+ nl_cb_put(cb);
+ return res;
+}
+
+/* Run event handler */
+void wifi_event_loop(wifi_handle handle)
+{
+ hal_info *info = getHalInfo(handle);
+ if (info->in_event_loop) {
+ return;
+ } else {
+ info->in_event_loop = true;
+ }
+
+ pollfd pfd[2];
+ memset(&pfd[0], 0, sizeof(pollfd) * 2);
+
+ pfd[0].fd = nl_socket_get_fd(info->event_sock);
+ pfd[0].events = POLLIN;
+ pfd[1].fd = info->cleanup_socks[1];
+ pfd[1].events = POLLIN;
+
+ char buf[2048];
+ /* TODO: Add support for timeouts */
+
+ do {
+ int timeout = -1; /* Infinite timeout */
+ pfd[0].revents = 0;
+ pfd[1].revents = 0;
+ // ALOGI("Polling socket");
+ int result = TEMP_FAILURE_RETRY(poll(pfd, 2, timeout));
+ if (result < 0) {
+ // ALOGE("Error polling socket");
+ } else if (pfd[0].revents & POLLERR) {
+ ALOGE("POLL Error; error no = %d (%s)", errno, strerror(errno));
+ ssize_t result2 = TEMP_FAILURE_RETRY(read(pfd[0].fd, buf, sizeof(buf)));
+ ALOGE("Read after POLL returned %zd, error no = %d (%s)", result2,
+ errno, strerror(errno));
+ } else if (pfd[0].revents & POLLHUP) {
+ ALOGE("Remote side hung up");
+ break;
+ } else if (pfd[0].revents & POLLIN) {
+ // ALOGI("Found some events!!!");
+ internal_pollin_handler(handle);
+ } else if (pfd[1].revents & POLLIN) {
+ memset(buf, 0, sizeof(buf));
+ ssize_t result2 = TEMP_FAILURE_RETRY(read(pfd[1].fd, buf, sizeof(buf)));
+ ALOGE("%s: Read after POLL returned %zd, error no = %d (%s)", __FUNCTION__,
+ result2, errno, strerror(errno));
+ if (strncmp(buf, "Exit", 4) == 0) {
+ ALOGD("Got a signal to exit!!!");
+ if (TEMP_FAILURE_RETRY(write(pfd[1].fd, "Done", 4)) < 1) {
+ ALOGE("could not write to the cleanup socket");
+ }
+ break;
+ } else {
+ ALOGD("Rx'ed %s on the cleanup socket\n", buf);
+ }
+ } else {
+ ALOGE("Unknown event - %0x, %0x", pfd[0].revents, pfd[1].revents);
+ }
+ } while (!info->clean_up);
+ ALOGI("Exit %s", __FUNCTION__);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////
+static int internal_no_seq_check(struct nl_msg *msg, void *arg)
+{
+ return NL_OK;
+}
+
+static int internal_valid_message_handler(nl_msg *msg, void *arg)
+{
+ wifi_handle handle = (wifi_handle)arg;
+ hal_info *info = getHalInfo(handle);
+
+ WifiEvent event(msg);
+ int res = event.parse();
+ if (res < 0) {
+ ALOGE("Failed to parse event: %d", res);
+ return NL_SKIP;
+ }
+
+ int cmd = event.get_cmd();
+ uint32_t vendor_id = 0;
+ int subcmd = 0;
+
+ if (cmd == NL80211_CMD_VENDOR) {
+ vendor_id = event.get_u32(NL80211_ATTR_VENDOR_ID);
+ subcmd = event.get_u32(NL80211_ATTR_VENDOR_SUBCMD);
+ ALOGV("event received %s, vendor_id = 0x%0x, subcmd = 0x%0x",
+ event.get_cmdString(), vendor_id, subcmd);
+ } else {
+ ALOGV("event received %s", event.get_cmdString());
+ }
+
+ bool dispatched = false;
+
+ pthread_mutex_lock(&info->cb_lock);
+
+ for (int i = 0; i < info->num_event_cb; i++) {
+ if (cmd == info->event_cb[i].nl_cmd) {
+ if (cmd == NL80211_CMD_VENDOR
+ && ((vendor_id != info->event_cb[i].vendor_id)
+ || (subcmd != info->event_cb[i].vendor_subcmd)))
+ {
+ /* event for a different vendor, ignore it */
+ continue;
+ }
+
+ cb_info *cbi = &(info->event_cb[i]);
+ nl_recvmsg_msg_cb_t cb_func = cbi->cb_func;
+ void *cb_arg = cbi->cb_arg;
+ WifiCommand *cmd = (WifiCommand *)cbi->cb_arg;
+ if (cmd != NULL) {
+ cmd->addRef();
+ }
+
+ pthread_mutex_unlock(&info->cb_lock);
+ if (cb_func)
+ (*cb_func)(msg, cb_arg);
+ if (cmd != NULL) {
+ cmd->releaseRef();
+ }
+
+ return NL_OK;
+ }
+ }
+
+ pthread_mutex_unlock(&info->cb_lock);
+ return NL_OK;
+}
+
+///////////////////////////////////////////////////////////////////////////////////
+
+class GetMulticastIdCommand : public WifiCommand
+{
+private:
+ const char *mName;
+ const char *mGroup;
+ int mId;
+
+public:
+ GetMulticastIdCommand(wifi_handle handle, const char *name, const char *group)
+ : WifiCommand("GetMulticastIdCommand", handle, 0)
+ {
+ mName = name;
+ mGroup = group;
+ mId = -1;
+ }
+
+ int getId() {
+ return mId;
+ }
+
+ virtual int create() {
+ int nlctrlFamily = genl_ctrl_resolve(mInfo->cmd_sock, "nlctrl");
+ // ALOGD("ctrl family = %d", nlctrlFamily);
+ int ret = mMsg.create(nlctrlFamily, CTRL_CMD_GETFAMILY, 0, 0);
+ if (ret < 0) {
+ return ret;
+ }
+ ret = mMsg.put_string(CTRL_ATTR_FAMILY_NAME, mName);
+ return ret;
+ }
+
+ virtual int handleResponse(WifiEvent& reply) {
+
+ // ALOGD("handling reponse in %s", __func__);
+
+ struct nlattr **tb = reply.attributes();
+ struct genlmsghdr *gnlh = reply.header();
+ struct nlattr *mcgrp = NULL;
+ int i;
+
+ if (!tb[CTRL_ATTR_MCAST_GROUPS]) {
+ ALOGD("No multicast groups found");
+ return NL_SKIP;
+ } else {
+ // ALOGD("Multicast groups attr size = %d", nla_len(tb[CTRL_ATTR_MCAST_GROUPS]));
+ }
+
+ for_each_attr(mcgrp, tb[CTRL_ATTR_MCAST_GROUPS], i) {
+
+ // ALOGD("Processing group");
+ struct nlattr *tb2[CTRL_ATTR_MCAST_GRP_MAX + 1];
+ nla_parse(tb2, CTRL_ATTR_MCAST_GRP_MAX, (nlattr *)nla_data(mcgrp),
+ nla_len(mcgrp), NULL);
+ if (!tb2[CTRL_ATTR_MCAST_GRP_NAME] || !tb2[CTRL_ATTR_MCAST_GRP_ID]) {
+ continue;
+ }
+
+ char *grpName = (char *)nla_data(tb2[CTRL_ATTR_MCAST_GRP_NAME]);
+ int grpNameLen = nla_len(tb2[CTRL_ATTR_MCAST_GRP_NAME]);
+
+ // ALOGD("Found group name %s", grpName);
+
+ if (strncmp(grpName, mGroup, grpNameLen) != 0)
+ continue;
+
+ mId = nla_get_u32(tb2[CTRL_ATTR_MCAST_GRP_ID]);
+ break;
+ }
+
+ return NL_SKIP;
+ }
+
+};
+
+class SetCountryCodeCommand : public WifiCommand {
+private:
+ const char *mCountryCode;
+public:
+ SetCountryCodeCommand(wifi_interface_handle handle, const char *country_code)
+ : WifiCommand("SetCountryCodeCommand", handle, 0) {
+ mCountryCode = country_code;
+ }
+ virtual int create() {
+ int ret;
+
+ ret = mMsg.create(GOOGLE_OUI, WIFI_SUBCMD_SET_COUNTRY_CODE);
+ if (ret < 0) {
+ ALOGE("Can't create message to send to driver - %d", ret);
+ return ret;
+ }
+
+ nlattr *data = mMsg.attr_start(NL80211_ATTR_VENDOR_DATA);
+ ret = mMsg.put_string(WIFI_ATTRIBUTE_COUNTRY_CODE, mCountryCode);
+ if (ret < 0) {
+ return ret;
+ }
+
+ mMsg.attr_end(data);
+ return WIFI_SUCCESS;
+ }
+};
+
+class SetRSSIMonitorCommand : public WifiCommand
+{
+private:
+ s8 mMax_rssi;
+ s8 mMin_rssi;
+ wifi_rssi_event_handler mHandler;
+
+public:
+ SetRSSIMonitorCommand(wifi_request_id id, wifi_interface_handle handle,
+ s8 max_rssi, s8 min_rssi, wifi_rssi_event_handler eh)
+ : WifiCommand("SetRSSIMonitorCommand", handle, id), mMax_rssi(max_rssi), mMin_rssi
+ (min_rssi), mHandler(eh)
+ {
+ }
+
+ int createRequest(WifiRequest& request, int enable) {
+ int result = request.create(GOOGLE_OUI, WIFI_SUBCMD_SET_RSSI_MONITOR);
+ if (result < 0) {
+ return result;
+ }
+
+ ALOGI("set RSSI Monitor, mMax_rssi=%d, mMin_rssi=%d, enable=%d", mMax_rssi, mMin_rssi, enable);
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+ result = request.put_u32(WIFI_ATTRIBUTE_MAX_RSSI, (enable? mMax_rssi: 0));
+ if (result < 0) {
+ return result;
+ }
+ ALOGD("create request");
+ result = request.put_u32(WIFI_ATTRIBUTE_MIN_RSSI, (enable? mMin_rssi: 0));
+ if (result < 0) {
+ return result;
+ }
+ result = request.put_u32(WIFI_ATTRIBUTE_RSSI_MONITOR_START, enable);
+ if (result < 0) {
+ return result;
+ }
+
+ request.attr_end(data);
+ return result;
+ }
+
+ int start() {
+ WifiRequest request(familyId(), ifaceId());
+ int result = createRequest(request, 1);
+ if (result < 0) {
+ return result;
+ }
+ result = requestResponse(request);
+ if (result < 0) {
+ ALOGE("Failed to set RSSI Monitor, result=%d", result);
+ return result;
+ }
+ ALOGD("Successfully set RSSI monitoring");
+ registerVendorHandler(GOOGLE_OUI, WIFI_EVENT_RSSI_MONITOR);
+
+
+ if (result < 0) {
+ unregisterVendorHandler(GOOGLE_OUI, WIFI_EVENT_RSSI_MONITOR);
+ return result;
+ }
+ ALOGI("Done!");
+ return result;
+ }
+
+ virtual int cancel() {
+ WifiRequest request(familyId(), ifaceId());
+ int result = createRequest(request, 0);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("Failed to create request, result=%d", result);
+ } else {
+ result = requestResponse(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("Failed to stop RSSI monitoring, result=%d", result);
+ }
+ }
+ unregisterVendorHandler(GOOGLE_OUI, WIFI_EVENT_RSSI_MONITOR);
+ return WIFI_SUCCESS;
+ }
+
+ virtual int handleResponse(WifiEvent& reply) {
+ /* Nothing to do on response! */
+ return NL_SKIP;
+ }
+
+ virtual int handleEvent(WifiEvent& event) {
+ ALOGD("Got a RSSI monitor event");
+
+ struct nlattr *vendor_data = (struct nlattr *)event.get_vendor_data();
+ int len = event.get_vendor_data_len();
+
+ if (vendor_data == NULL || len == 0) {
+ ALOGE("RSSI monitor: No data");
+ return NL_SKIP;
+ }
+ /* driver<->HAL event structure */
+ #define RSSI_MONITOR_EVT_VERSION 1
+ typedef struct {
+ u8 version;
+ s8 cur_rssi;
+ mac_addr BSSID;
+ } rssi_monitor_evt;
+
+ rssi_monitor_evt *data = NULL;
+ if (vendor_data->nla_type == WIFI_EVENT_RSSI_MONITOR)
+ data = (rssi_monitor_evt *)nla_data(vendor_data);
+ else
+ return NL_SKIP;
+
+ ALOGI("data: version=%d, cur_rssi=%d BSSID=" MACSTR "\r\n",
+ data->version, data->cur_rssi, MAC2STR(data->BSSID));
+
+ if (data->version != RSSI_MONITOR_EVT_VERSION) {
+ ALOGE("Event version mismatch %d, expected %d", data->version, RSSI_MONITOR_EVT_VERSION);
+ return NL_SKIP;
+ }
+
+ if (*mHandler.on_rssi_threshold_breached) {
+ (*mHandler.on_rssi_threshold_breached)(id(), data->BSSID, data->cur_rssi);
+ } else {
+ ALOGW("No RSSI monitor handler registered");
+ }
+
+ return NL_SKIP;
+ }
+};
+
+class GetFeatureSetCommand : public WifiCommand
+{
+private:
+ int feature_type;
+ feature_set *fset;
+ feature_set *feature_matrix;
+ int *fm_size;
+ int set_size_max;
+
+public:
+ GetFeatureSetCommand(wifi_interface_handle handle, int feature, feature_set *set,
+ feature_set set_matrix[], int *size, int max_size)
+ : WifiCommand("GetFeatureSetCommand", handle, 0)
+ {
+ feature_type = feature;
+ fset = set;
+ feature_matrix = set_matrix;
+ fm_size = size;
+ set_size_max = max_size;
+ }
+
+ virtual int create() {
+ int ret;
+
+ if(feature_type == WIFI_ATTRIBUTE_FEATURE_SET) {
+ ret = mMsg.create(GOOGLE_OUI, WIFI_SUBCMD_GET_FEATURE_SET);
+ } else if (feature_type == WIFI_ATTRIBUTE_NUM_FEATURE_SET) {
+ ret = mMsg.create(GOOGLE_OUI, WIFI_SUBCMD_GET_FEATURE_SET_MATRIX);
+ } else {
+ ALOGE("Unknown feature type %d", feature_type);
+ return -1;
+ }
+
+ if (ret < 0) {
+ ALOGE("Can't create subcmd message to driver, ret=%d", ret);
+ }
+
+ return ret;
+ }
+
+protected:
+ virtual int handleResponse(WifiEvent& reply) {
+
+ ALOGD("In GetFeatureSetCommand::handleResponse");
+
+ if (reply.get_cmd() != NL80211_CMD_VENDOR) {
+ ALOGD("Ignore reply with cmd 0x%x", reply.get_cmd());
+ return NL_SKIP;
+ }
+
+ int vendor_id = reply.get_vendor_id();
+ int subcmd = reply.get_vendor_subcmd();
+ ALOGD("vendor_id = 0x%x, subcmd = 0x%x", vendor_id, subcmd);
+
+ nlattr *vendor_data = reply.get_attribute(NL80211_ATTR_VENDOR_DATA);
+ int len = reply.get_vendor_data_len();
+ if (vendor_data == NULL || len == 0) {
+ ALOGE("No vendor data in GetFeatureSetCommand response, ignore it");
+ return NL_SKIP;
+ }
+
+ if (feature_type == WIFI_ATTRIBUTE_FEATURE_SET) {
+ void *data = reply.get_vendor_data();
+ if (!fset) {
+ ALOGE("feature_set pointer is not set");
+ return NL_SKIP;
+ }
+ memcpy(fset, data, min(len, (int) sizeof(*fset)));
+ }
+ else if (feature_type == WIFI_ATTRIBUTE_NUM_FEATURE_SET) {
+ int num_features_set = 0;
+ int i = 0;
+
+ if(!feature_matrix || !fm_size) {
+ ALOGE("feature_set pointer is not set");
+ return NL_SKIP;
+ }
+
+ for (nl_iterator it(vendor_data); it.has_next(); it.next()) {
+ if (it.get_type() == WIFI_ATTRIBUTE_NUM_FEATURE_SET) {
+ num_features_set = it.get_u32();
+ ALOGI("Get feature list with %d concurrent sets", num_features_set);
+ if(set_size_max && (num_features_set > set_size_max))
+ num_features_set = set_size_max;
+ *fm_size = num_features_set;
+ } else if ((it.get_type() == WIFI_ATTRIBUTE_FEATURE_SET) &&
+ i < num_features_set) {
+ feature_matrix[i] = it.get_u32();
+ i++;
+ } else {
+ ALOGW("Ignore invalid attribute type = %d, size = %d",
+ it.get_type(), it.get_len());
+ }
+ }
+ }
+
+ return NL_OK;
+ }
+
+};
+
+static int wifi_get_multicast_id(wifi_handle handle, const char *name, const char *group)
+{
+ GetMulticastIdCommand cmd(handle, name, group);
+ int res = cmd.requestResponse();
+ if (res < 0)
+ return res;
+ else
+ return cmd.getId();
+}
+
+/////////////////////////////////////////////////////////////////////////
+
+static bool is_wifi_interface(const char *name)
+{
+ if (strncmp(name, "wlan", 4) != 0 && strncmp(name, "p2p", 3) != 0) {
+ /* Not a wifi interface; ignore it */
+ return false;
+ } else {
+ return true;
+ }
+}
+
+int get_interface(const char *name, interface_info *info)
+{
+ strncpy(info->name, name, sizeof(info->name));
+ info->name[sizeof(info->name) - 1] = '\0';
+ info->id = if_nametoindex(name);
+ ALOGD("found an interface : %s, id = %d", name, info->id);
+ return WIFI_SUCCESS;
+}
+
+wifi_error wifi_init_interfaces(wifi_handle handle)
+{
+ ALOGI("init wifi interfaces");
+ hal_info *info = (hal_info *)handle;
+ struct dirent *de;
+
+ DIR *d = opendir("/sys/class/net");
+ if (d == 0)
+ return WIFI_ERROR_UNKNOWN;
+
+ int n = 0;
+ while ((de = readdir(d))) {
+ if (de->d_name[0] == '.')
+ continue;
+ if (is_wifi_interface(de->d_name) ) {
+ n++;
+ }
+ }
+
+ closedir(d);
+
+ if (n == 0)
+ return WIFI_ERROR_NOT_AVAILABLE;
+
+ d = opendir("/sys/class/net");
+ if (d == 0)
+ return WIFI_ERROR_UNKNOWN;
+
+ info->interfaces = (interface_info **)malloc(sizeof(interface_info *) * n);
+ if (!info->interfaces) {
+ closedir(d);
+ return WIFI_ERROR_OUT_OF_MEMORY;
+ }
+
+ int i = 0;
+ while ((de = readdir(d))) {
+ if (de->d_name[0] == '.')
+ continue;
+ if (is_wifi_interface(de->d_name)) {
+ interface_info *ifinfo = (interface_info *)malloc(sizeof(interface_info));
+ if (get_interface(de->d_name, ifinfo) != WIFI_SUCCESS) {
+ free(ifinfo);
+ continue;
+ }
+ ifinfo->handle = handle;
+ info->interfaces[i] = ifinfo;
+ i++;
+ }
+ }
+
+ closedir(d);
+
+ info->num_interfaces = n;
+ return WIFI_SUCCESS;
+}
+
+wifi_error wifi_get_ifaces(wifi_handle handle, int *num, wifi_interface_handle **interfaces)
+{
+ hal_info *info = (hal_info *)handle;
+
+ *interfaces = (wifi_interface_handle *)info->interfaces;
+ *num = info->num_interfaces;
+
+ return WIFI_SUCCESS;
+}
+
+wifi_error wifi_get_iface_name(wifi_interface_handle handle, char *name, size_t size)
+{
+ interface_info *info = (interface_info *)handle;
+ strncpy(name, info->name, size);
+ return WIFI_SUCCESS;
+}
+
+wifi_error wifi_get_supported_feature_set(wifi_interface_handle handle, feature_set *pset)
+{
+#if 0
+ GetFeatureSetCommand command(handle, WIFI_ATTRIBUTE_FEATURE_SET, set, NULL, NULL, 1);
+ return (wifi_error)command.requestResponse();
+#else
+ feature_set set = 0;
+ char prop_buf[PROPERTY_VALUE_MAX];
+
+ property_get("ro.wlan.mtk.wifi.5g", prop_buf, NULL);
+ if (!strcmp(prop_buf, "1"))
+ set |= WIFI_FEATURE_INFRA_5G;
+
+ set |= WIFI_FEATURE_P2P;
+ set |= WIFI_FEATURE_SOFT_AP;
+ set |= WIFI_FEATURE_TDLS;
+
+#ifdef CONFIG_PNO_SUPPORT
+ set |= WIFI_FEATURE_PNO;
+#endif
+
+
+ memcpy(pset, &set, sizeof(feature_set));
+
+ ALOGI("[WIFI HAL]wifi_get_supported_feature_set: handle=%p, feature_set=0x%x", handle, *pset);
+ return WIFI_SUCCESS;
+#endif
+}
+
+wifi_error wifi_get_concurrency_matrix(wifi_interface_handle handle, int set_size_max,
+ feature_set set[], int *set_size)
+{
+ GetFeatureSetCommand command(handle, WIFI_ATTRIBUTE_NUM_FEATURE_SET, NULL, set, set_size, set_size_max);
+ return (wifi_error)command.requestResponse();
+}
+
+
+wifi_error wifi_set_country_code(wifi_interface_handle handle, const char *country_code)
+{
+ SetCountryCodeCommand command(handle, country_code);
+ return (wifi_error) command.requestResponse();
+}
+
+static wifi_error wifi_start_rssi_monitoring(wifi_request_id id, wifi_interface_handle
+ iface, s8 max_rssi, s8 min_rssi, wifi_rssi_event_handler eh)
+{
+ ALOGI("Start RSSI monitoring %d", id);
+ wifi_handle handle = getWifiHandle(iface);
+ SetRSSIMonitorCommand *cmd = new SetRSSIMonitorCommand(id, iface, max_rssi, min_rssi, eh);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ wifi_error result = wifi_register_cmd(handle, id, cmd);
+ if (result != WIFI_SUCCESS) {
+ cmd->releaseRef();
+ return result;
+ }
+ result = (wifi_error)cmd->start();
+ if (result != WIFI_SUCCESS) {
+ wifi_unregister_cmd(handle, id);
+ cmd->releaseRef();
+ return result;
+ }
+ return result;
+}
+
+static wifi_error wifi_stop_rssi_monitoring(wifi_request_id id, wifi_interface_handle iface)
+{
+ ALOGI("Stopping RSSI monitoring %d", id);
+
+ if (id == -1) {
+ wifi_rssi_event_handler handler;
+ s8 max_rssi = 0, min_rssi = 0;
+ wifi_handle handle = getWifiHandle(iface);
+ memset(&handler, 0, sizeof(handler));
+ SetRSSIMonitorCommand *cmd = new SetRSSIMonitorCommand(id, iface, max_rssi, min_rssi, handler);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ cmd->cancel();
+ cmd->releaseRef();
+ return WIFI_SUCCESS;
+ }
+ return wifi_cancel_cmd(id, iface);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+static wifi_error wifi_set_scanning_mac_oui_dummy(wifi_interface_handle handle, oui scan_oui)
+{
+ return WIFI_SUCCESS;
+}
+
+static wifi_error wifi_set_log_handler_dummy(wifi_request_id id, wifi_interface_handle iface,
+ wifi_ring_buffer_data_handler handler)
+{
+ return WIFI_SUCCESS;
+}
+
+static wifi_error wifi_get_wake_reason_stats_dummy(wifi_interface_handle iface,
+ WLAN_DRIVER_WAKE_REASON_CNT *wifi_wake_reason_cnt)
+{
+ if (wifi_wake_reason_cnt) {
+ memset(wifi_wake_reason_cnt, 0, sizeof(*wifi_wake_reason_cnt));
+ return WIFI_SUCCESS;
+ }
+ return WIFI_ERROR_INVALID_ARGS;
+}
+
+static wifi_error wifi_get_packet_filter_capabilities_dummy(wifi_interface_handle handle,
+ u32 *version, u32 *max_len)
+{
+ if (version && max_len) {
+ *version = 0;
+ *max_len = 0;
+ return WIFI_SUCCESS;
+ }
+ return WIFI_ERROR_INVALID_ARGS;
+}
+
+static wifi_error wifi_configure_nd_offload_dummy(wifi_interface_handle iface, u8 enable)
+{
+ return WIFI_SUCCESS;
+}
+
+static wifi_error wifi_start_pkt_fate_monitoring_dummy(wifi_interface_handle iface)
+{
+ return WIFI_SUCCESS;
+}
+
+static wifi_error wifi_get_tx_pkt_fates_dummy(wifi_interface_handle handle,
+ wifi_tx_report *tx_report_bufs, size_t n_requested_fates, size_t *n_provided_fates)
+{
+ if (n_provided_fates) {
+ *n_provided_fates = 0;
+ return WIFI_SUCCESS;
+ }
+ return WIFI_ERROR_INVALID_ARGS;
+}
+
+static wifi_error wifi_get_rx_pkt_fates_dummy(wifi_interface_handle handle,
+ wifi_rx_report *rx_report_bufs, size_t n_requested_fates, size_t *n_provided_fates)
+{
+ if (n_provided_fates) {
+ *n_provided_fates = 0;
+ return WIFI_SUCCESS;
+ }
+ return WIFI_ERROR_INVALID_ARGS;
+}
+
+static wifi_error wifi_get_driver_memory_dump_dummy(wifi_interface_handle iface,
+ wifi_driver_memory_dump_callbacks callbacks)
+{
+ return WIFI_SUCCESS;
+}
+
+static wifi_error wifi_reset_log_handler_dummy(wifi_request_id id, wifi_interface_handle iface)
+{
+ return WIFI_SUCCESS;
+}
+
+static wifi_error wifi_get_firmware_version_dummy(wifi_interface_handle iface, char *buffer,
+ int buffer_size)
+{
+ if (buffer && buffer_size > 0) {
+ strncpy(buffer, "0", buffer_size);
+ return WIFI_SUCCESS;
+ }
+ return WIFI_ERROR_INVALID_ARGS;
+}
+
+static wifi_error wifi_get_driver_version_dummy(wifi_interface_handle iface,
+ char *buffer, int buffer_size)
+{
+ if (buffer && buffer_size > 0) {
+ strncpy(buffer, "0", buffer_size);
+ return WIFI_SUCCESS;
+ }
+ return WIFI_ERROR_INVALID_ARGS;
+}
+
+static wifi_error wifi_get_ring_data_dummy(wifi_interface_handle iface, char *ring_name)
+{
+ if (ring_name) {
+ return WIFI_SUCCESS;
+ }
+ return WIFI_ERROR_INVALID_ARGS;
+}
+
+static wifi_error wifi_get_ring_buffers_status_dummy(wifi_interface_handle iface,
+ u32 *num_rings, wifi_ring_buffer_status *status)
+{
+ if (num_rings && status) {
+ *num_rings = 1;
+ memset(status, 0, sizeof(*status));
+ strncpy((char*)status->name, "dummy", sizeof(*status->name));
+ return WIFI_SUCCESS;
+ }
+ return WIFI_ERROR_INVALID_ARGS;
+}
+
+static wifi_error wifi_get_logger_supported_feature_set_dummy(wifi_interface_handle iface,
+ unsigned int *support)
+{
+ if (support) {
+ *support = 0;
+ return WIFI_SUCCESS;
+ }
+ return WIFI_ERROR_INVALID_ARGS;
+}
+
+static wifi_error wifi_start_logging_dummy(wifi_interface_handle iface, u32 verbose_level,
+ u32 flags, u32 max_interval_sec, u32 min_data_size, char *ring_name)
+{
+ if (ring_name) {
+ return WIFI_SUCCESS;
+ }
+ return WIFI_ERROR_INVALID_ARGS;
+}
+
--- /dev/null
+#include <stdint.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
+#include <netlink/genl/ctrl.h>
+#include <linux/rtnetlink.h>
+#include <netpacket/packet.h>
+#include <linux/filter.h>
+#include <linux/errqueue.h>
+
+#include <linux/pkt_sched.h>
+#include <netlink/object-api.h>
+#include <netlink/netlink.h>
+#include <netlink/socket.h>
+
+#include "nl80211_copy.h"
+#include "sync.h"
+
+#define LOG_TAG "WifiHAL"
+
+#include <utils/Log.h>
+
+#include "wifi_hal.h"
+#include "common.h"
+#include "cpp_bindings.h"
+
+using namespace android;
+
+typedef enum {
+ WIFI_OFFLOAD_START_MKEEP_ALIVE = ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_START,
+ WIFI_OFFLOAD_STOP_MKEEP_ALIVE,
+} WIFI_OFFLOAD_SUB_COMMAND;
+
+typedef enum {
+ MKEEP_ALIVE_ATTRIBUTE_ID = 1,
+ MKEEP_ALIVE_ATTRIBUTE_IP_PKT_LEN,
+ MKEEP_ALIVE_ATTRIBUTE_IP_PKT,
+ MKEEP_ALIVE_ATTRIBUTE_SRC_MAC_ADDR,
+ MKEEP_ALIVE_ATTRIBUTE_DST_MAC_ADDR,
+ MKEEP_ALIVE_ATTRIBUTE_PERIOD_MSEC
+} WIFI_MKEEP_ALIVE_ATTRIBUTE;
+
+typedef enum {
+ START_MKEEP_ALIVE,
+ STOP_MKEEP_ALIVE,
+} GetCmdType;
+
+///////////////////////////////////////////////////////////////////////////////
+class MKeepAliveCommand : public WifiCommand
+{
+ u8 mIndex;
+ u8 *mIpPkt;
+ u16 mIpPktLen;
+ u8 *mSrcMacAddr;
+ u8 *mDstMacAddr;
+ u32 mPeriodMsec;
+ GetCmdType mType;
+
+public:
+
+ // constructor for start sending
+ MKeepAliveCommand(wifi_interface_handle iface, u8 index, u8 *ip_packet, u16 ip_packet_len,
+ u8 *src_mac_addr, u8 *dst_mac_addr, u32 period_msec, GetCmdType cmdType)
+ : WifiCommand("MKeepAliveCommand", iface, 0), mIndex(index), mIpPkt(ip_packet),
+ mIpPktLen(ip_packet_len), mSrcMacAddr(src_mac_addr), mDstMacAddr(dst_mac_addr),
+ mPeriodMsec(period_msec), mType(cmdType)
+ { }
+
+ // constructor for stop sending
+ MKeepAliveCommand(wifi_interface_handle iface, u8 index, GetCmdType cmdType)
+ : WifiCommand("MKeepAliveCommand", iface, 0), mIndex(index), mType(cmdType)
+ { }
+
+ int createRequest(WifiRequest &request) {
+ int result;
+
+ switch (mType) {
+ case START_MKEEP_ALIVE:
+ {
+ result = request.create(GOOGLE_OUI, WIFI_OFFLOAD_START_MKEEP_ALIVE);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("Failed to create start keep alive request; result = %d", result);
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+
+ result = request.put_u8(MKEEP_ALIVE_ATTRIBUTE_ID, mIndex);
+ if (result < 0) {
+ ALOGE("Failed to put id request; result = %d", result);
+ return result;
+ }
+
+ result = request.put_u16(MKEEP_ALIVE_ATTRIBUTE_IP_PKT_LEN, mIpPktLen);
+ if (result < 0) {
+ ALOGE("Failed to put ip pkt len request; result = %d", result);
+ return result;
+ }
+
+ result = request.put(MKEEP_ALIVE_ATTRIBUTE_IP_PKT, (u8*)mIpPkt, mIpPktLen);
+ if (result < 0) {
+ ALOGE("Failed to put ip pkt request; result = %d", result);
+ return result;
+ }
+
+ result = request.put_addr(MKEEP_ALIVE_ATTRIBUTE_SRC_MAC_ADDR, mSrcMacAddr);
+ if (result < 0) {
+ ALOGE("Failed to put src mac address request; result = %d", result);
+ return result;
+ }
+
+ result = request.put_addr(MKEEP_ALIVE_ATTRIBUTE_DST_MAC_ADDR, mDstMacAddr);
+ if (result < 0) {
+ ALOGE("Failed to put dst mac address request; result = %d", result);
+ return result;
+ }
+
+ result = request.put_u32(MKEEP_ALIVE_ATTRIBUTE_PERIOD_MSEC, mPeriodMsec);
+ if (result < 0) {
+ ALOGE("Failed to put period request; result = %d", result);
+ return result;
+ }
+
+ request.attr_end(data);
+ break;
+ }
+
+ case STOP_MKEEP_ALIVE:
+ {
+ result = request.create(GOOGLE_OUI, WIFI_OFFLOAD_STOP_MKEEP_ALIVE);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("Failed to create stop keep alive request; result = %d", result);
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+
+ result = request.put_u8(MKEEP_ALIVE_ATTRIBUTE_ID, mIndex);
+ if (result < 0) {
+ ALOGE("Failed to put id request; result = %d", result);
+ return result;
+ }
+
+ request.attr_end(data);
+ break;
+ }
+
+ default:
+ ALOGE("Unknown wifi keep alive command");
+ result = WIFI_ERROR_UNKNOWN;
+ }
+ return result;
+ }
+
+ int start() {
+ ALOGD("Start mkeep_alive command");
+ WifiRequest request(familyId(), ifaceId());
+ int result = createRequest(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("Failed to create keep alive request; result = %d", result);
+ return result;
+ }
+
+ result = requestResponse(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("Failed to register keep alive response; result = %d", result);
+ }
+ return result;
+ }
+
+ virtual int handleResponse(WifiEvent& reply) {
+ ALOGD("In MKeepAliveCommand::handleResponse");
+
+ if (reply.get_cmd() != NL80211_CMD_VENDOR) {
+ ALOGD("Ignoring reply with cmd = %d", reply.get_cmd());
+ return NL_SKIP;
+ }
+
+ switch (mType) {
+ case START_MKEEP_ALIVE:
+ case STOP_MKEEP_ALIVE:
+ break;
+
+ default:
+ ALOGW("Unknown mkeep_alive command");
+ }
+ return NL_OK;
+ }
+
+ virtual int handleEvent(WifiEvent& event) {
+ /* NO events! */
+ return NL_SKIP;
+ }
+};
+
+
+/* API to send specified mkeep_alive packet periodically. */
+wifi_error wifi_start_sending_offloaded_packet(wifi_request_id index, wifi_interface_handle iface,
+ u8 *ip_packet, u16 ip_packet_len, u8 *src_mac_addr, u8 *dst_mac_addr, u32 period_msec)
+{
+ if ((index > 0 && index <= N_AVAIL_ID) && (ip_packet != NULL) && (src_mac_addr != NULL)
+ && (dst_mac_addr != NULL) && (period_msec > 0)
+ && (ip_packet_len <= MKEEP_ALIVE_IP_PKT_MAX)) {
+ MKeepAliveCommand *cmd = new MKeepAliveCommand(iface, index, ip_packet, ip_packet_len,
+ src_mac_addr, dst_mac_addr, period_msec, START_MKEEP_ALIVE);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ wifi_error result = (wifi_error)cmd->start();
+ cmd->releaseRef();
+ return result;
+ } else {
+ ALOGE("Invalid mkeep_alive parameters");
+ return WIFI_ERROR_INVALID_ARGS;
+ }
+}
+
+/* API to stop sending mkeep_alive packet. */
+wifi_error wifi_stop_sending_offloaded_packet(wifi_request_id index, wifi_interface_handle iface)
+{
+ if (index > 0 && index <= N_AVAIL_ID) {
+ MKeepAliveCommand *cmd = new MKeepAliveCommand(iface, index, STOP_MKEEP_ALIVE);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+ wifi_error result = (wifi_error)cmd->start();
+ cmd->releaseRef();
+ return result;
+ } else {
+ ALOGE("Invalid mkeep_alive parameters");
+ return WIFI_ERROR_INVALID_ARGS;
+ }
+}
--- /dev/null
+#
+# 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.
+# 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)
+
+##### For Google SUPPLICANT #####
+ifeq ($(MTKPATH),)
+ $(warning build BASIC wpa_supplicant)
+ WPA_SUPPL_DIR = external/wpa_supplicant_8
+ WPA_SRC_FILE :=
+
+ifneq ($(BOARD_WPA_SUPPLICANT_DRIVER),)
+ CONFIG_DRIVER_$(BOARD_WPA_SUPPLICANT_DRIVER) := y
+endif
+ifneq ($(BOARD_HOSTAPD_DRIVER),)
+ CONFIG_DRIVER_$(BOARD_HOSTAPD_DRIVER) := y
+endif
+
+include $(WPA_SUPPL_DIR)/wpa_supplicant/android.config
+
+WPA_SUPPL_DIR_INCLUDE = $(WPA_SUPPL_DIR)/src \
+ $(WPA_SUPPL_DIR)/src/common \
+ $(WPA_SUPPL_DIR)/src/drivers \
+ $(WPA_SUPPL_DIR)/src/l2_packet \
+ $(WPA_SUPPL_DIR)/src/utils \
+ $(WPA_SUPPL_DIR)/src/wps \
+ $(WPA_SUPPL_DIR)/wpa_supplicant
+
+ifdef CONFIG_DRIVER_NL80211
+WPA_SUPPL_DIR_INCLUDE += external/libnl/include
+WPA_SRC_FILE += mediatek_driver_cmd_nl80211.c
+endif
+
+ifdef CONFIG_DRIVER_WEXT
+#error doesn't support CONFIG_DRIVER_WEXT
+endif
+
+# To force sizeof(enum) = 4
+ifeq ($(TARGET_ARCH),arm)
+L_CFLAGS += -mabi=aapcs-linux
+endif
+
+ifdef CONFIG_ANDROID_LOG
+L_CFLAGS += -DCONFIG_ANDROID_LOG
+endif
+
+########################
+include $(CLEAR_VARS)
+LOCAL_MODULE := lib_driver_cmd_mt66xx
+LOCAL_SHARED_LIBRARIES := libc libcutils
+LOCAL_CFLAGS := $(L_CFLAGS)
+LOCAL_SRC_FILES := $(WPA_SRC_FILE)
+LOCAL_C_INCLUDES := $(WPA_SUPPL_DIR_INCLUDE)
+include $(BUILD_STATIC_LIBRARY)
+########################
+endif
--- /dev/null
+/*
+ * Driver interaction with extended Linux CFG8021
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ */
+#include "includes.h"
+#include <linux/wireless.h>
+#include "netlink/genl/genl.h"
+
+#include "common.h"
+#include "driver_nl80211.h"
+#include "linux_ioctl.h"
+#include "wpa_supplicant_i.h"
+#include "config.h"
+#ifdef ANDROID
+#include "android_drv.h"
+#endif
+
+#include "driver_i.h"
+
+#include "eloop.h"
+
+/**********************************************************************
+* OVERLAPPED functins, previous defination is in driver_nl80211.c,
+* it will be modified
+***********************************************************************/
+
+/**********************************************************************/
+static int wpa_driver_mediatek_set_country(void *priv, const char *alpha2_arg)
+{
+ struct i802_bss *bss = priv;
+ struct wpa_driver_nl80211_data *drv = bss->drv;
+ int ioctl_sock = -1;
+ struct iwreq iwr;
+ int ret = -1;
+ char buf[11];
+#ifdef MTK_TC1_FEATURE
+ char replace_ifname[IFNAMSIZ+1];
+
+ memset(replace_ifname, 0, IFNAMSIZ+1);
+ os_strlcpy(replace_ifname, "wlan0", os_strlen("wlan0")+1);
+#endif
+
+ wpa_printf(MSG_DEBUG, "wpa_driver_nl80211_set_country");
+ ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
+ if (ioctl_sock < 0) {
+ wpa_printf(MSG_ERROR, "%s: socket(PF_INET,SOCK_DGRAM)", __func__);
+ return -1;
+ }
+ os_memset(&iwr, 0, sizeof(iwr));
+#ifdef MTK_TC1_FEATURE
+ // convert 'p2p0' -> 'wlan0' :
+ // when iface name is p2p0, COUNTRY driver command doesn't support in MTK solution.
+ if (os_strncmp(drv->first_bss->ifname, "p2p0", os_strlen("p2p0")) == 0) {
+ wpa_printf(MSG_DEBUG, "Change interface name : p2p0->wlan0");
+ os_strlcpy(iwr.ifr_name, replace_ifname, IFNAMSIZ );
+ } else {
+ os_strlcpy(iwr.ifr_name, drv->first_bss->ifname, IFNAMSIZ);
+ }
+#else
+ os_strlcpy(iwr.ifr_name, drv->first_bss->ifname, IFNAMSIZ);
+#endif
+ sprintf(buf, "COUNTRY %s", alpha2_arg);
+ iwr.u.data.pointer = buf;
+ iwr.u.data.length = strlen(buf);
+ if ((ret = ioctl(ioctl_sock, 0x8B0C, &iwr)) < 0) { // SIOCSIWPRIV
+ wpa_printf(MSG_DEBUG, "ioctl[SIOCSIWPRIV]: %s", buf);
+ close(ioctl_sock);
+ return ret;
+ }
+ else {
+ close(ioctl_sock);
+ return 0;
+ }
+
+}
+
+/*
+* update channel list in wpa_supplicant
+* if coutry code chanaged
+*/
+static void wpa_driver_notify_country_change(void *ctx, char *cmd)
+{
+ if (os_strncasecmp(cmd, "COUNTRY", 7) == 0) {
+ union wpa_event_data event;
+
+ os_memset(&event, 0, sizeof(event));
+ event.channel_list_changed.initiator = REGDOM_SET_BY_USER;
+ if (os_strncasecmp(cmd, "COUNTRY", 7) == 0) {
+ event.channel_list_changed.type = REGDOM_TYPE_COUNTRY;
+ if (os_strlen(cmd) > 9) {
+ event.channel_list_changed.alpha2[0] = cmd[8];
+ event.channel_list_changed.alpha2[1] = cmd[9];
+ }
+ } else
+ event.channel_list_changed.type = REGDOM_TYPE_UNKNOWN;
+ wpa_supplicant_event(ctx, EVENT_CHANNEL_LIST_CHANGED, &event);
+ }
+}
+
+int wpa_driver_nl80211_driver_cmd(void *priv, char *cmd, char *buf,
+ size_t buf_len )
+{
+ struct i802_bss *bss = priv;
+ struct wpa_driver_nl80211_data *drv = bss->drv;
+ struct ifreq ifr;
+ struct wpa_supplicant *wpa_s;
+ struct hostapd_data *hapd;
+ int handled = 0;
+ int cmd_len = 0;
+ union wpa_event_data event;
+ static int user_force_band = 0;
+ int ret = -1;
+
+ if (drv == NULL) {
+ wpa_printf(MSG_ERROR, "%s: drv is NULL. Exiting", __func__);
+ return -1;
+ }
+ if (drv->ctx == NULL) {
+ wpa_printf(MSG_ERROR, "%s: drv->ctx is NULL. Exiting", __func__);
+ return -1;
+ }
+
+ if (os_strcmp(bss->ifname, "ap0") == 0) {
+ hapd = (struct hostapd_data *)(drv->ctx);
+ }
+ else {
+ wpa_s = (struct wpa_supplicant *)(drv->ctx);
+ if (wpa_s->conf == NULL) {
+ wpa_printf(MSG_ERROR, "%s: wpa_s->conf is NULL. Exiting", __func__);
+ return -1;
+ }
+ }
+
+ wpa_printf(MSG_DEBUG, "iface %s recv cmd %s", bss->ifname, cmd);
+ handled = 1;
+
+ if (os_strncasecmp(cmd, "POWERMODE ", 10) == 0) {
+ int state;
+ state = atoi(cmd + 10);
+ wpa_printf(MSG_DEBUG, "POWERMODE=%d", state);
+ } else if (os_strncmp(cmd, "MACADDR", os_strlen("MACADDR")) == 0) {
+ u8 macaddr[ETH_ALEN] = {};
+ os_memcpy(&macaddr, wpa_s->own_addr, ETH_ALEN);
+ ret = snprintf(buf, buf_len, "Macaddr = " MACSTR "\n", MAC2STR(macaddr));
+ wpa_printf(MSG_DEBUG, "%s", buf);
+ } else if(os_strncasecmp(cmd, "COUNTRY", os_strlen("COUNTRY"))==0) {
+ if (os_strlen(cmd) != os_strlen("COUNTRY") + 3) {
+ wpa_printf(MSG_DEBUG, "Ignore COUNTRY cmd %s", cmd);
+ ret = 0;
+ } else {
+ wpa_printf(MSG_INFO, "set country: %s", cmd+8);
+ // ret = wpa_drv_set_country(wpa_s, cmd+8);
+ ret = wpa_driver_mediatek_set_country(priv, cmd+8);
+ if (ret == 0) {
+ wpa_printf(MSG_DEBUG, "Update channel list after country code changed");
+ wpa_driver_notify_country_change(wpa_s, cmd);
+ }
+ }
+ } else if (os_strcasecmp(cmd, "start") == 0) {
+ if (ret = linux_set_iface_flags(drv->global->ioctl_sock,
+ drv->first_bss->ifname, 1)) {
+ wpa_printf(MSG_INFO, "nl80211: Could not set interface UP, ret=%d \n", ret);
+ } else {
+ wpa_msg(drv->ctx, MSG_INFO, "CTRL-EVENT-DRIVER-STATE STARTED");
+ }
+ } else if (os_strcasecmp(cmd, "stop") == 0) {
+ if (drv->associated) {
+ ret = wpa_drv_deauthenticate(wpa_s, drv->bssid, WLAN_REASON_DEAUTH_LEAVING);
+ if (ret != 0)
+ wpa_printf(MSG_DEBUG, "DRIVER-STOP error, ret=%d", ret);
+ } else {
+ wpa_printf(MSG_INFO, "nl80211: not associated, no need to deauthenticate \n");
+ }
+
+ if (ret = linux_set_iface_flags(drv->global->ioctl_sock,
+ drv->first_bss->ifname, 0)) {
+ wpa_printf(MSG_INFO, "nl80211: Could not set interface Down, ret=%d \n", ret);
+ } else {
+ wpa_msg(drv->ctx, MSG_INFO, "CTRL-EVENT-DRIVER-STATE STOPPED");
+ }
+ } else if (os_strncasecmp(cmd, "getpower", 8) == 0) {
+ u32 mode;
+ // ret = wpa_driver_wext_driver_get_power(drv, &mode);
+ if (ret == 0) {
+ ret = snprintf(buf, buf_len, "powermode = %u\n", mode);
+ wpa_printf(MSG_DEBUG, "%s", buf);
+ if (ret < (int)buf_len)
+ return ret;
+ }
+ } else if (os_strncasecmp(cmd, "get-rts-threshold", 17) == 0) {
+ u32 thd;
+ // ret = wpa_driver_wext_driver_get_rts(drv, &thd);
+ if (ret == 0) {
+ ret = snprintf(buf, buf_len, "rts-threshold = %u\n", thd);
+ wpa_printf(MSG_DEBUG, "%s", buf);
+ if (ret < (int)buf_len)
+ return ret;
+ }
+ } else if (os_strncasecmp(cmd, "set-rts-threshold", 17) == 0) {
+ u32 thd = 0;
+ char *cp = cmd + 17;
+ char *endp;
+ if (*cp != '\0') {
+ thd = (u32)strtol(cp, &endp, 0);
+ // if (endp != cp)
+ // ret = wpa_driver_wext_driver_set_rts(drv, thd);
+ }
+ } else if (os_strcasecmp(cmd, "btcoexscan-start") == 0) {
+ ret = 0; /* mt5921 linux driver not implement yet */
+ } else if (os_strcasecmp(cmd, "btcoexscan-stop") == 0) {
+ ret = 0; /* mt5921 linux driver not implement yet */
+ } else if (os_strncasecmp(cmd, "btcoexmode", 10) == 0) {
+ ret = 0; /* mt5921 linux driver not implement yet */
+ } else {
+ handled = 0;
+ wpa_printf(MSG_INFO, "Unsupported command");
+ }
+
+ return ret;
+}
+
+int wpa_driver_set_p2p_noa(void *priv, u8 count, int start, int duration)
+{
+ struct i802_bss *bss = priv;
+ struct wpa_driver_nl80211_data *drv = bss->drv;
+
+ wpa_printf(MSG_DEBUG, "iface %s P2P_SET_NOA %d %d %d, ignored", bss->ifname, count, start, duration);
+ return -1;
+}
+
+int wpa_driver_get_p2p_noa(void *priv, u8 *buf, size_t len)
+{
+ struct i802_bss *bss = priv;
+ struct wpa_driver_nl80211_data *drv = bss->drv;
+
+ wpa_printf(MSG_DEBUG, "iface %s P2P_GET_NOA, ignored", bss->ifname);
+ return -1;
+}
+
+int wpa_driver_set_p2p_ps(void *priv, int legacy_ps, int opp_ps, int ctwindow)
+{
+ struct i802_bss *bss = priv;
+ struct wpa_driver_nl80211_data *drv = bss->drv;
+
+ wpa_printf(MSG_DEBUG, "iface %s P2P_SET_PS, ignored", bss->ifname);
+ return -1;
+}
+
+int wpa_driver_set_ap_wps_p2p_ie(void *priv, const struct wpabuf *beacon,
+ const struct wpabuf *proberesp,
+ const struct wpabuf *assocresp)
+{
+ struct i802_bss *bss = priv;
+ struct wpa_driver_nl80211_data *drv = bss->drv;
+
+ wpa_printf(MSG_DEBUG, "iface %s set_ap_wps_p2p_ie, ignored", bss->ifname);
+ return 0;
+}
+