Board Bringup changes

Desc: Basic board bringup on AOSP_R_48 source code, the build
contains only aosp changes.

Issue: FP2P-100
Change-Id: I6dc0e5fb585671ffae5b24cee055d01d7d91fdfa
diff --git a/Android.mk b/Android.mk
index 962ad2d..d4b8e72 100644
--- a/Android.mk
+++ b/Android.mk
@@ -2,6 +2,10 @@
 # This empty Android.mk file exists to prevent the build system from
 # automatically including any other Android.mk files under this directory.
 #
+ifneq ($(filter FP2, $(TARGET_DEVICE)),)
 
-include $(call all-subdir-makefiles,$(LOCAL_PATH))
+LOCAL_PATH := $(call my-dir)
 
+include $(call all-makefiles-under,$(LOCAL_PATH))
+
+endif
diff --git a/AndroidBoard.mk b/AndroidBoard.mk
index 79164be..b81b7d8 100644
--- a/AndroidBoard.mk
+++ b/AndroidBoard.mk
@@ -1,3 +1,77 @@
 LOCAL_PATH := $(call my-dir)
+
+#----------------------------------------------------------------------
+# Compile Linux Kernel
+#----------------------------------------------------------------------
+ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
+ifeq ($(KERNEL_DEFCONFIG),)
+	KERNEL_DEFCONFIG := fairphone_defconfig
+endif
+else
+ifeq ($(KERNEL_DEFCONFIG),)
+	KERNEL_DEFCONFIG := fairphone-perf_defconfig
+endif
+endif
+
+include kernel/msm8974/AndroidKernel.mk
+
+$(INSTALLED_KERNEL_TARGET): $(TARGET_PREBUILT_KERNEL) | $(ACP)
+	$(transform-prebuilt-to-target)
+
+#----------------------------------------------------------------------
+# Copy additional target-specific files
+#----------------------------------------------------------------------
 include $(CLEAR_VARS)
+LOCAL_MODULE       := vold.fstab
+LOCAL_MODULE_TAGS  := optional
+LOCAL_MODULE_CLASS := ETC
+LOCAL_SRC_FILES    := $(LOCAL_MODULE)
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE       := init.target.rc
+LOCAL_MODULE_TAGS  := optional
+LOCAL_MODULE_CLASS := ETC
+LOCAL_SRC_FILES    := $(LOCAL_MODULE)
+LOCAL_MODULE_PATH  := $(TARGET_ROOT_OUT)
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE       := gpio-keys.kl
+LOCAL_MODULE_TAGS  := optional
+LOCAL_MODULE_CLASS := ETC
+LOCAL_SRC_FILES    := configs/$(LOCAL_MODULE)
+LOCAL_MODULE_PATH  := $(TARGET_OUT_KEYLAYOUT)
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE       := atmel_mxt_ts.kl
+LOCAL_MODULE_TAGS  := optional
+LOCAL_MODULE_CLASS := ETC
+LOCAL_SRC_FILES    := configs/$(LOCAL_MODULE)
+LOCAL_MODULE_PATH  := $(TARGET_OUT_KEYLAYOUT)
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE       := synaptics_rmi4_i2c.kl
+LOCAL_MODULE_TAGS  := optional
+LOCAL_MODULE_CLASS := ETC
+LOCAL_SRC_FILES    := configs/$(LOCAL_MODULE)
+LOCAL_MODULE_PATH  := $(TARGET_OUT_KEYLAYOUT)
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE       := fstab.qcom
+LOCAL_MODULE_TAGS  := optional
+LOCAL_MODULE_CLASS := ETC
+LOCAL_SRC_FILES    := $(LOCAL_MODULE)
+LOCAL_MODULE_PATH  := $(TARGET_ROOT_OUT)
+include $(BUILD_PREBUILT)
+
+#----------------------------------------------------------------------
+# extra images
+#----------------------------------------------------------------------
+ifeq (, $(wildcard vendor/qcom/build/tasks/generate_extra_images.mk))
+include device/qcom/common/generate_extra_images.mk
+endif
 
diff --git a/AndroidProducts.mk b/AndroidProducts.mk
deleted file mode 100644
index 82e5c88..0000000
--- a/AndroidProducts.mk
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# This file should set PRODUCT_MAKEFILES to a list of product makefiles
-# to expose to the build system.  LOCAL_DIR will already be set to
-# the directory containing this file.
-#
-# This file may not rely on the value of any variable other than
-# LOCAL_DIR; do not use any conditionals, and do not look up the
-# value of any variable that isn't set in this file or in a file that
-# it includes.
-#
-
-PRODUCT_MAKEFILES := \
-    $(LOCAL_DIR)/fp2.mk \
diff --git a/BoardConfig.mk b/BoardConfig.mk
index 7a0ab25..10e820a 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -1,72 +1,22 @@
-#device specific changes
-
-# architecture
+# config.mk
+#
+# Product-specific compile-time definitions.
+#
 ifeq ($(TARGET_ARCH),)
 TARGET_ARCH := arm
 endif
-TARGET_ARCH_VARIANT := armv7-a-neon
-TARGET_CPU_ABI := armeabi-v7a
-TARGET_BOARD_PLATFORM := msm8974
-
-# linux kernel
-#
-# set TARGET_NO_KERNEL true if kernel is prebuilt
-#
-TARGET_NO_KERNEL := false
-TARGET_KERNEL_ARCH := $(TARGET_ARCH)
-BOARD_KERNEL_BASE := 0x00000000
-BOARD_KERNEL_PAGESIZE := 2048
-BOARD_KERNEL_TAGS_OFFSET := 0x01E00000
-BOARD_RAMDISK_OFFSET := 0x02000000
-TARGET_KERNEL_SOURCE := kernel/msm8974
-TARGET_KERNEL_CONFIG := fairphone_defconfig
-BOARD_KERNEL_SEPARATED_DT := true
-BOARD_KERNEL_IMAGE_NAME := zImage
-TARGET_USERIMAGES_USE_EXT4 := true
-BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
-BOARD_PERSISTIMAGE_FILE_SYSTEM_TYPE := ext4
-BOARD_MKBOOTIMG_ARGS:= --ramdisk_offset $(BOARD_RAMDISK_OFFSET) --tags_offset $(BOARD_KERNEL_TAGS_OFFSET)
-
-ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
-        BOARD_KERNEL_CMDLINE := console=ttyHSL0,115200,n8 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x3b7 ehci-hcd.park=3 androidboot.bootdevice=msm_sdcc.1 androidboot.selinux=permissive
-else
-        BOARD_KERNEL_CMDLINE := androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x3b7 ehci-hcd.park=3 androidboot.bootdevice=msm_sdcc.1
-endif
-
-BOARD_KERNEL_SEPARATED_DT := true
-
-# SELinux
-#include device/qcom/sepolicy-legacy/sepolicy.mk
-BOARD_SEPOLICY_DIRS += \
-    device/fairphone/FP2/sepolicy
-
-# Filesystem
-BOARD_BOOTIMAGE_PARTITION_SIZE := 0x01000000
-BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
-BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := f2fs
-BOARD_CACHEIMAGE_PARTITION_SIZE := 671088640
-BOARD_FLASH_BLOCK_SIZE := 131072 # (BOARD_KERNEL_PAGESIZE * 64)
-BOARD_PERSISTIMAGE_FILE_SYSTEM_TYPE := ext4
-BOARD_PERSISTIMAGE_PARTITION_SIZE := 5242880
-BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x01000000
-BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648
-BOARD_TOMBSTONESIMAGE_PARTITION_SIZE := 73400320
-BOARD_USERDATAIMAGE_PARTITION_SIZE := 27358941675
-TARGET_USERIMAGES_USE_EXT4 := true
-
-TARGET_COPY_OUT_VENDOR := system/vendor
-PRODUCT_HARDWARE := fp2
-
-# Recent Changes Started
-
+TARGET_KERNEL_ARCH := arm
 BOARD_USES_GENERIC_AUDIO := true
 USE_CAMERA_STUB := false
+
 TARGET_KERNEL_APPEND_DTB := false
+
 TARGET_USES_AOSP := false
 
 # Compile with msm kernel
 TARGET_COMPILE_WITH_MSM_KERNEL := true
 TARGET_HAS_QC_KERNEL_SOURCE := true
+
 #TODO: Fix-me: Setting TARGET_HAVE_HDMI_OUT to false
 # to get rid of compilation error.
 TARGET_HAVE_HDMI_OUT := false
@@ -74,14 +24,24 @@
 NUM_FRAMEBUFFER_SURFACE_BUFFERS := 3
 TARGET_NO_BOOTLOADER := false
 TARGET_NO_KERNEL := false
-TARGET_NO_RADIOIMAGE := true
 TARGET_NO_RPC := true
+
+TARGET_CPU_ABI  := armeabi-v7a
+TARGET_CPU_ABI2 := armeabi
+TARGET_ARCH_VARIANT := armv7-a-neon
 TARGET_CPU_VARIANT := krait
 TARGET_CPU_SMP := true
 ARCH_ARM_HAVE_TLS_REGISTER := true
-TARGET_BOOTLOADER_BOARD_NAME := FP2
-#BOARD_KERNEL_OFFSET	 := 0x00080000
 
+TARGET_HARDWARE_3D := false
+TARGET_BOARD_PLATFORM := msm8974
+TARGET_BOOTLOADER_BOARD_NAME := FP2
+
+BOARD_KERNEL_BASE        := 0x00000000
+BOARD_KERNEL_PAGESIZE    := 2048
+BOARD_KERNEL_TAGS_OFFSET := 0x01E00000
+BOARD_RAMDISK_OFFSET     := 0x02000000
+BOARD_KERNEL_OFFSET	 := 0x00080000
 # Enables Adreno RS driver
 OVERRIDE_RS_DRIVER := libRSDriver_adreno.so
 
@@ -98,8 +58,30 @@
 # Use signed boot and recovery image
 TARGET_BOOTIMG_SIGNED := true
 
-# Add NON-HLOS files for ota upgrade
-ADD_RADIO_FILES ?= true
+TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_PERSISTIMAGE_FILE_SYSTEM_TYPE := ext4
+
+BOARD_MKBOOTIMG_ARGS:= --kernel_offset $(BOARD_KERNEL_OFFSET) --ramdisk_offset $(BOARD_RAMDISK_OFFSET) --tags_offset $(BOARD_KERNEL_TAGS_OFFSET)
+
+ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
+BOARD_KERNEL_CMDLINE := console=ttyHSL0,115200,n8 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x3b7 ehci-hcd.park=3 androidboot.bootdevice=msm_sdcc.1 androidboot.selinux=permissive
+else
+BOARD_KERNEL_CMDLINE := androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x3b7 ehci-hcd.park=3 androidboot.bootdevice=msm_sdcc.1 androidboot.selinux=permissive
+endif
+BOARD_KERNEL_SEPARATED_DT := true
+
+BOARD_EGL_CFG := device/fairphone/FP2/egl.cfg
+
+BOARD_BOOTIMAGE_PARTITION_SIZE := 0x01000000
+BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x01000000
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 27358941675
+BOARD_CACHEIMAGE_PARTITION_SIZE := 671088640
+BOARD_PERSISTIMAGE_PARTITION_SIZE := 5242880
+BOARD_TOMBSTONESIMAGE_PARTITION_SIZE := 73400320
+BOARD_FLASH_BLOCK_SIZE := 131072 # (BOARD_KERNEL_PAGESIZE * 64)
+
 
 # Added to indicate that protobuf-c is supported in this build
 PROTOBUF_SUPPORTED := true
@@ -115,12 +97,8 @@
 
 TARGET_HW_DISK_ENCRYPTION := false
 
-# Workaround framework bluetooth dependency
-#BOARD_HAVE_BLUETOOTH := true
-#BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/qcom/common
-#OVERRIDE_RS_DRIVER := libRSDriver_adreno.so
-
-TARGET_LDPRELOAD := libNimsWrap.so
+TARGET_INIT_VENDOR_LIB := libinit_msm
+TARGET_RECOVERY_UPDATER_LIBS := librecovery_updater_msm
 
 USE_OPENGL_RENDERER := true
 
@@ -131,7 +109,60 @@
 BOARD_WIDEVINE_OEMCRYPTO_LEVEL := 3
 
 # Charger
-#BOARD_HAL_STATIC_LIBRARIES := libhealthd.FP2
+BOARD_HAL_STATIC_LIBRARIES := libhealthd.FP2
 
-# Recent Changes ended here
--include vendor/fairphone/FP2/BoardConfigVendor.mk
+# Lights
+TARGET_PROVIDES_LIBLIGHT := true
+
+# QCOM hardware
+BOARD_USES_QCOM_HARDWARE := true
+
+# Audio
+AUDIO_FEATURE_ENABLED_COMPRESS_VOIP := false
+AUDIO_FEATURE_ENABLED_EXTN_FORMATS := true
+AUDIO_FEATURE_ENABLED_EXTN_POST_PROC := true
+AUDIO_FEATURE_ENABLED_FLUENCE := true
+AUDIO_FEATURE_ENABLED_FM_POWER_OPT := true
+AUDIO_FEATURE_ENABLED_HFP := true
+AUDIO_FEATURE_ENABLED_HWDEP_CAL := true
+AUDIO_FEATURE_ENABLED_LOW_LATENCY_CAPTURE := true
+AUDIO_FEATURE_ENABLED_MULTI_VOICE_SESSIONS := true
+AUDIO_FEATURE_ENABLED_NEW_SAMPLE_RATE := true
+AUDIO_FEATURE_ENABLED_PROXY_DEVICE := true
+AUDIO_FEATURE_LOW_LATENCY_PRIMARY := true
+BOARD_USES_ALSA_AUDIO := true
+USE_CUSTOM_AUDIO_POLICY := 0
+
+
+# Camera
+TARGET_USES_MEDIA_EXTENSIONS := true
+USE_DEVICE_SPECIFIC_CAMERA := true
+
+# Graphics
+MAX_EGL_CACHE_KEY_SIZE := 12*1024
+MAX_EGL_CACHE_SIZE := 2048*1024
+OVERRIDE_RS_DRIVER := libRSDriver_adreno.so
+TARGET_ADDITIONAL_GRALLOC_10_USAGE_BITS := 0x02000000U
+TARGET_USES_ION := true
+TARGET_USES_NEW_ION_API := true
+USE_OPENGL_RENDERER := true
+
+TARGET_RELEASETOOLS_EXTENSIONS := device/fairphone/FP2
+
+#Need to add this in Boardconfig.mk
+# HIDL
+DEVICE_MANIFEST_FILE := device/fairphone/FP2/manifest.xml
+
+#SELinux
+include device/qcom/sepolicy/sepolicy.mk
+BOARD_SEPOLICY_DIRS += \
+    $(DEVICE_PATH)/sepolicy
+
+# QCOM Power
+TARGET_HAS_LEGACY_POWER_STATS := true
+TARGET_HAS_NO_WLAN_STATS := true
+TARGET_USES_INTERACTION_BOOST := true
+
+
+# Vendor-specific definitions
+include vendor/fairphone/fp2/BoardConfigVendor.mk
diff --git a/configs/atmel_mxt_ts.kl b/configs/atmel_mxt_ts.kl
new file mode 100644
index 0000000..eda99fb
--- /dev/null
+++ b/configs/atmel_mxt_ts.kl
@@ -0,0 +1,31 @@
+# Copyright (c) 2012, The Linux Foundation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+#       copyright notice, this list of conditions and the following
+#       disclaimer in the documentation and/or other materials provided
+#       with the distribution.
+#     * Neither the name of The Linux Foundation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+key 139    MENU
+key 102    HOME
+key 158    BACK
+key 217    SEARCH
diff --git a/configs/config.fs b/configs/config.fs
new file mode 100644
index 0000000..e3b8c03
--- /dev/null
+++ b/configs/config.fs
@@ -0,0 +1,28 @@
+# Copyright (C) 2018 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This file is used to define the properties of the filesystem
+# images generated by build tools (mkbootfs and mkyaffs2image) and
+# by the device side of adb.
+
+[AID_VENDOR_QCOM_DIAG]
+value:2950
+
+[AID_VENDOR_RFS]
+value:2951
+
+[AID_VENDOR_RFS_SHARED]
+value:2952
+
diff --git a/configs/egl.cfg b/configs/egl.cfg
new file mode 100644
index 0000000..2a11ba2
--- /dev/null
+++ b/configs/egl.cfg
@@ -0,0 +1,2 @@
+0 0 android
+0 1 adreno
diff --git a/configs/gpio-keys.kl b/configs/gpio-keys.kl
new file mode 100644
index 0000000..d7b70cf
--- /dev/null
+++ b/configs/gpio-keys.kl
@@ -0,0 +1,32 @@
+# Copyright (c) 2012, The Linux Foundation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+#       copyright notice, this list of conditions and the following
+#       disclaimer in the documentation and/or other materials provided
+#       with the distribution.
+#     * Neither the name of The Linux Foundation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+key 115   VOLUME_UP
+key 114   VOLUME_DOWN
+key 102   HOME
+key 528   FOCUS
+key 766   CAMERA
diff --git a/configs/synaptics_rmi4_i2c.kl b/configs/synaptics_rmi4_i2c.kl
new file mode 100644
index 0000000..eda99fb
--- /dev/null
+++ b/configs/synaptics_rmi4_i2c.kl
@@ -0,0 +1,31 @@
+# Copyright (c) 2012, The Linux Foundation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+#       copyright notice, this list of conditions and the following
+#       disclaimer in the documentation and/or other materials provided
+#       with the distribution.
+#     * Neither the name of The Linux Foundation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+key 139    MENU
+key 102    HOME
+key 158    BACK
+key 217    SEARCH
diff --git a/fp2.mk b/fp2.mk
index 7e96fe1..26c79f3 100644
--- a/fp2.mk
+++ b/fp2.mk
@@ -6,69 +6,60 @@
 PRODUCT_HARDWARE := fp2
 
 ifeq ($(TARGET_PREBUILT_KERNEL), true)
-    LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL)
+	LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL)
 
 PRODUCT_COPY_FILES += \
-    $(LOCAL_KERNEL):kernel
+	$(LOCAL_KERNEL):kernel
 endif
 
 PRODUCT_COPY_FILES += \
-    $(LOCAL_PATH)/init.recovery.hardware.rc:recovery/root/init.recovery.$(PRODUCT_HARDWARE).rc \
-    $(LOCAL_PATH)/init.hardware.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.$(PRODUCT_HARDWARE).rc \
-    $(LOCAL_PATH)/ueventd.hardware.rc:$(TARGET_COPY_OUT_VENDOR)/ueventd.rc
+	$(LOCAL_PATH)/init.recovery.hardware.rc:recovery/root/init.recovery.$(PRODUCT_HARDWARE).rc \
+	$(LOCAL_PATH)/init.hardware.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.$(PRODUCT_HARDWARE).rc \
+	$(LOCAL_PATH)/ueventd.hardware.rc:$(TARGET_COPY_OUT_VENDOR)/ueventd.rc
 
 PRODUCT_COPY_FILES += \
-    $(LOCAL_PATH)/fstab.hardware:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.$(PRODUCT_HARDWARE)
+	$(LOCAL_PATH)/fstab.hardware:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.$(PRODUCT_HARDWARE)
 
 PRODUCT_PACKAGES += \
-    android.hardware.graphics.allocator@2.0-impl \
-    android.hardware.graphics.allocator@2.0-service \
-    android.hardware.graphics.composer@2.1-impl \
-    android.hardware.graphics.mapper@2.0-impl
+	android.hardware.graphics.allocator@2.0-impl \
+	android.hardware.graphics.allocator@2.0-service \
+	android.hardware.graphics.composer@2.1-impl \
+	android.hardware.graphics.mapper@2.0-impl
 
 #audio
 PRODUCT_PACKAGES += \
-    android.hardware.audio@2.0-impl \
-    android.hardware.audio@2.0-service \
-    android.hardware.audio.effect@2.0-impl
-
-# Bluetooth
-PRODUCT_PACKAGES += \
-    android.hardware.bluetooth@1.0-impl \
-    android.hardware.bluetooth@1.0-service \
-    libbt-vendor
+	android.hardware.audio@2.0-impl \
+	android.hardware.audio@2.0-service \
+	android.hardware.audio.effect@2.0-impl
 
 # RenderScript
 PRODUCT_PACKAGES += \
-    android.hardware.renderscript@1.0-impl
+	android.hardware.renderscript@1.0-impl
 
 # GPS
 PRODUCT_PACKAGES += \
-    android.hardware.gnss@1.0-impl \
-    android.hardware.gnss@1.0-service
+	android.hardware.gnss@1.0-impl \
+	android.hardware.gnss@1.0-service
 
 # Keystore
 PRODUCT_PACKAGES += \
-    android.hardware.keymaster@3.0-impl \
-    android.hardware.keymaster@3.0-service
+	android.hardware.keymaster@3.0-impl \
+	android.hardware.keymaster@3.0-service
 
 # Camera
 PRODUCT_PACKAGES += \
-    android.hardware.camera.provider@2.4-impl
+	android.hardware.camera.provider@2.4-impl
 
 # Sensors
 PRODUCT_PACKAGES += \
-    android.hardware.sensors@1.0-impl
+	android.hardware.sensors@1.0-impl
 
 # DRM
 PRODUCT_PACKAGES += \
-    android.hardware.drm@1.0-impl \
-    android.hardware.drm@1.0-service
+	android.hardware.drm@1.0-impl \
+	android.hardware.drm@1.0-service
 
 # Vibrator
 PRODUCT_PACKAGES += \
-    android.hardware.vibrator@1.0-impl \
-    android.hardware.vibrator@1.0-service
-
-
-
+	android.hardware.vibrator@1.0-impl \
+	android.hardware.vibrator@1.0-service
diff --git a/fstab.qcom b/fstab.qcom
new file mode 100644
index 0000000..b128a0b
--- /dev/null
+++ b/fstab.qcom
@@ -0,0 +1,13 @@
+# Android fstab file.
+# 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
+
+#TODO: Add 'check' as fs_mgr_flags with data partition.
+# Currently we dont have e2fsck compiled. So fs check would failed.
+
+#<src>                                                <mnt_point>  <type>  <mnt_flags and options>                     <fs_mgr_flags>
+/dev/block/platform/msm_sdcc.1/by-name/system         /system      ext4    ro,barrier=1,discard                                wait,recoveryonly
+/dev/block/platform/msm_sdcc.1/by-name/userdata       /data        ext4    nosuid,nodev,barrier=1,noauto_da_alloc,discard      wait,check,encryptable=footer
+/devices/msm_sdcc.2/mmc_host*                          /storage/sdcard1   vfat    nosuid,nodev         wait,voldmanaged=sdcard1:auto,encryptable=footer
+/dev/block/bootdevice/by-name/pad                  /frp        emmc    defaults             defaults
+/devices/platform/xhci-hcd/usb*                       /storage/usbotg    vfat    nosuid,nodev  wait,voldmanaged=usbotg:auto 
diff --git a/init.hardware.rc b/init.hardware.rc
index 8c56370..c50a53d 100644
--- a/init.hardware.rc
+++ b/init.hardware.rc
@@ -287,25 +287,12 @@
     chown radio radio /data/vendor/ipa
 
     # Create the directories used by the Wireless subsystem
-    mkdir /data/misc/wifi 0770 wifi wifi
-    mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi
-    mkdir /data/vendor/wifi 0771 wifi wifi
-    mkdir /data/vendor/wifi/wpa 0770 wifi wifi
-    mkdir /data/vendor/wifi/wpa/sockets 0770 wifi wifi
-    mkdir /data/misc/dhcp 0770 dhcp dhcp
     chown dhcp dhcp /data/misc/dhcp
 
     # Mounting of persist is moved to 'on emmc-fs' and 'on fs' sections
     # We chown/chmod /persist again so because mount is run as root + defaults
     chown root system /persist
     chmod 0771 /persist
-    chown system system /persist/WCNSS_qcom_wlan_nv.bin
-
-    # Create directory for hostapd
-    mkdir /data/hostapd 0770 system wifi
-
-    # Trigger WLAN driver load
-    write /sys/kernel/boot_wlan/boot_wlan 1
 
     #create port-bridge log dir
     mkdir /data/misc/port_bridge 0770 radio radio
@@ -381,14 +368,6 @@
     chown radio radio /data/vendor/radio/db_check_done
     chmod 0660 /data/vendor/radio/db_check_done
 
-    # Create directories for Location services
-    mkdir /data/vendor/location 0770 gps gps
-    mkdir /data/vendor/location/mq 0770 gps gps
-    mkdir /data/vendor/location/xtwifi 0770 gps gps
-
-    # NFC local data and nfcee xml storage
-    mkdir /data/vendor/nfc 0770 nfc nfc
-
     # b/62837579 elabel directory
     mkdir /data/misc/elabel 0700 system system
 
@@ -447,16 +426,10 @@
     chmod 2770 /dev/socket/qmux_radio
     mkdir /dev/socket/qmux_audio 0770 media audio
     chmod 2770 /dev/socket/qmux_audio
-    mkdir /dev/socket/qmux_bluetooth 0770 bluetooth bluetooth
-    chmod 2770 /dev/socket/qmux_bluetooth
-    mkdir /dev/socket/qmux_gps 0770 gps gps
-    chmod 2770 /dev/socket/qmux_gps
 
     # Create NETMGR daemon socket area
     mkdir /dev/socket/netmgr 0750 radio radio
 
-    setprop wifi.interface wlan0
-
     # Assign TCP buffer thresholds to be ceiling value of technology maximums
     # Increased technology maximums should be reflected here.
     write /proc/sys/net/core/rmem_max  8388608
@@ -473,19 +446,6 @@
     write /dev/cpuset/application/background/cpus 0-7
     write /dev/cpuset/application/cpus 0-7
 
-    # Bluetooth
-    chown bluetooth net_bt /sys/class/rfkill/rfkill0/type
-    chown bluetooth net_bt /sys/class/rfkill/rfkill0/state
-    chmod 0660 /sys/class/rfkill/rfkill0/state
-    chown bluetooth net_bt /sys/class/rfkill/rfkill0/device/extldo
-    chmod 0660 /sys/class/rfkill/rfkill0/device/extldo
-
-    # Wifi firmware reload path
-    chown wifi wifi /sys/module/wlan/parameters/fwpath
-
-    # default country code
-    setprop ro.boot.wificountrycode 00
-
     # Encrypted ramoops
     umount /sys/fs/pstore
     chmod 770 /dev/access-ramoops
@@ -688,20 +648,6 @@
    user root
    group root system
 
-service wpa_supplicant /vendor/bin/hw/wpa_supplicant \
-    -O/data/vendor/wifi/wpa/sockets -puse_p2p_group_interface=1 -dd \
-    -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
-    interface android.hardware.wifi.supplicant@1.0::ISupplicant default
-    interface android.hardware.wifi.supplicant@1.1::ISupplicant default
-    class main
-    socket wpa_wlan0 dgram 660 wifi wifi
-    disabled
-    oneshot
-
 service vendor.cnss-daemon /vendor/bin/cnss-daemon -n -l
    class late_start
    user system
@@ -770,18 +716,6 @@
     user radio
     group radio net_raw diag usb net_admin
 
-on property:wc_transport.start_hci=true
-    start vendor.hci_filter
-
-on property:wc_transport.start_hci=false
-    stop vendor.hci_filter
-
-service vendor.hci_filter /vendor/bin/wcnss_filter
-    class late_start
-    user bluetooth
-    group bluetooth diag system wakelock
-    disabled
-
 service vendor.loc_launcher /vendor/bin/loc_launcher
     class late_start
     group gps inet diag wifi
@@ -880,9 +814,9 @@
 on property:sys.vdso=32
    write /sys/module/vdso/parameters/enable_64 0
 
-on property:wlan.driver.status=ok
+#on property:wlan.driver.status=ok
    # Get the wlan driver/fw version
-   start vendor.wlan_sh
+#   start vendor.wlan_sh
 
 # charger driver exposes now finer grain control, map demo mode to those properties
 # demo mode can only be exit wipping data which will also reset the persist properties
diff --git a/init.target.rc b/init.target.rc
new file mode 100644
index 0000000..51a2d72
--- /dev/null
+++ b/init.target.rc
@@ -0,0 +1,251 @@
+# Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+#       copyright notice, this list of conditions and the following
+#       disclaimer in the documentation and/or other materials provided
+#       with the distribution.
+#     * Neither the name of The Linux Foundation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#
+
+on early-init
+    mkdir /firmware 0771 system system
+    symlink /data/tombstones /tombstones
+
+on init
+    # Set the property to indicate type of virtual display to 0
+    # 0 indicates that virtual display is not a Wifi display and that the
+    # session is not exercised through RemoteDisplay in the android framework
+    setprop persist.sys.wfd.virtual 0
+on post-fs
+    #export LD_PRELOAD libNimsWrap.so
+
+on fs
+    mount_all fstab.qcom
+
+    # Keeping following partitions outside fstab file. As user may not have
+    # these partition flashed on the device. Failure to mount any partition in fstab file
+    # results in failure to launch late-start class.
+
+    wait /dev/block/platform/msm_sdcc.1/by-name/cache
+    mount ext4 /dev/block/platform/msm_sdcc.1/by-name/cache /cache nosuid nodev barrier=1
+
+    wait /dev/block/platform/msm_sdcc.1/by-name/persist
+    mount ext4 /dev/block/platform/msm_sdcc.1/by-name/persist /persist nosuid nodev barrier=1
+    restorecon_recursive   /persist
+    mkdir /persist/data 0700 system system
+    mkdir /persist/data/sfs 0700 system system
+    mkdir /persist/data/tz 0700 system system
+
+    wait /dev/block/platform/msm_sdcc.1/by-name/modem
+    mount vfat /dev/block/platform/msm_sdcc.1/by-name/modem /firmware ro context=u:object_r:firmware_file:s0,shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337
+
+on post-fs-data
+    mkdir /data/tombstones 0771 system system
+    mkdir /tombstones/modem 0771 system system
+    mkdir /tombstones/lpass 0771 system system
+    mkdir /tombstones/wcnss 0771 system system
+    mkdir /tombstones/dsps 0771 system system
+    mkdir /data/usf 0700 system system
+
+on boot
+    insmod /system/lib/modules/adsprpc.ko
+# access permission for secure touch
+    chmod 0660 /sys/devices/f9923000.i2c/i2c-1/1-004a/secure_touch_enable
+    chmod 0440 /sys/devices/f9923000.i2c/i2c-1/1-004a/secure_touch
+    chown system drmrpc /sys/devices/f9923000.i2c/i2c-1/1-004a/secure_touch_enable
+    chown system drmrpc /sys/devices/f9923000.i2c/i2c-1/1-004a/secure_touch
+    chmod 0660 /sys/devices/f9924000.i2c/i2c-2/2-004a/secure_touch_enable
+    chmod 0440 /sys/devices/f9924000.i2c/i2c-2/2-004a/secure_touch
+    chown system drmrpc /sys/devices/f9924000.i2c/i2c-2/2-004a/secure_touch_enable
+    chown system drmrpc /sys/devices/f9924000.i2c/i2c-2/2-004a/secure_touch
+    chmod 0775 /persist
+    chmod 0444 /persist/board_date.bin
+    chmod 0444 /persist/phoneid.bin
+    chown system root /persist/sns.reg
+    chmod 770  /persist/sns.reg
+
+    # Added by Arvind
+    # add a cpuset for the camera daemon
+    # we want all cores for camera
+    mkdir /dev/cpuset/camera-daemon
+    write /dev/cpuset/camera-daemon/cpus 0-3
+    write /dev/cpuset/camera-daemon/mems 0
+    chown system system /dev/cpuset/camera-daemon
+    chown system system /dev/cpuset/camera-daemon/tasks
+    chmod 0664 /dev/cpuset/camera-daemon/tasks
+
+# Allow usb charging to be disabled persistently
+on property:persist.usb.chgdisabled=1
+    write /sys/class/power_supply/battery/charging_enabled 0
+
+on property:persist.usb.chgdisabled=0
+    write /sys/class/power_supply/battery/charging_enabled 1
+
+#start camera server as daemon
+service qcamerasvr /system/vendor/bin/mm-qcamera-daemon
+    class late_start
+    user camera
+    group camera system inet input graphics
+
+service qseecomd /system/vendor/bin/qseecomd
+   class core
+   user root
+   group root
+
+service mpdecision /system/bin/mpdecision --avg_comp
+   class main
+   user root
+   disabled
+
+service qosmgrd /system/bin/qosmgr /system/etc/qosmgr_rules.xml
+   user system
+   group system
+   disabled
+
+service thermal-engine /system/vendor/bin/thermal-engine
+   class main
+   user root
+   socket thermal-send-client stream 0666 system system
+   socket thermal-recv-client stream 0660 system system
+   socket thermal-recv-passive-client stream 0666 system system
+   group root
+
+service security-check1 /sbin/security_boot_check system
+    class core
+    oneshot
+
+service security-check2 /sbin/security_boot_check recovery
+    class core
+    oneshot
+
+service time_daemon /system/vendor/bin/time_daemon
+   class late_start
+   user root
+   group root
+
+service adsprpcd /system/vendor/bin/adsprpcd
+   class main
+   user media
+   group media
+
+service audiod /system/bin/audiod
+   class late_start
+   user system
+   group system
+
+service usf_tester /system/bin/usf_tester
+    user system
+    group system inet
+    disabled
+
+service usf_epos /system/bin/usf_epos
+    class main
+    user system
+    group system inet
+    disabled
+
+service usf_gesture /system/bin/usf_gesture
+    user system
+    group system inet
+    disabled
+
+service usf_sync_gesture /system/bin/usf_sync_gesture
+    user system
+    group system inet
+    disabled
+
+service usf_p2p /system/bin/usf_p2p
+    user system
+    group system inet
+    disabled
+
+service usf_hovering /system/bin/usf_hovering
+    user system
+    group system inet
+    disabled
+
+service usf_proximity /system/bin/usf_proximity
+    user system
+    group system inet
+    disabled
+
+service usf_pairing /system/bin/usf_pairing
+    user system
+    group system inet
+    disabled
+
+service usf_sw_calib /system/bin/usf_sw_calib
+    user system
+    group system inet
+    disabled
+
+service imsqmidaemon /system/bin/imsqmidaemon
+    class main
+    user system
+    socket ims_qmid stream 0660 system radio
+    group radio net_raw log qcom_diag
+
+service imsdatadaemon /system/bin/imsdatadaemon
+    class main
+    user system
+    socket ims_datad stream 0660 system radio
+    group system wifi radio inet net_raw log qcom_diag net_admin
+    disabled
+
+on property:sys.ims.QMI_DAEMON_STATUS=1
+    start imsdatadaemon
+
+service ims_rtp_daemon /system/bin/ims_rtp_daemon
+   class main
+   user system
+   socket ims_rtpd stream 0660 system radio
+   group radio net_raw diag qcom_diag log inet
+   disabled
+
+service imscmservice /system/bin/imscmservice
+   class main
+   user system
+   group radio net_raw diag qcom_diag log
+   disabled
+
+on property:sys.ims.DATA_DAEMON_STATUS=1
+   start ims_rtp_daemon
+   start imscmservice
+
+service ppd /system/bin/mm-pp-daemon
+    class late_start
+    disabled
+    user system
+    socket pps stream 0660 system system
+    group system graphics
+
+on property:init.svc.surfaceflinger=stopped
+    stop ppd
+
+on property:init.svc.surfaceflinger=running
+    start ppd
+
+service TCMDServer /system/bin/TCMDServer
+    class main
+    group root
+    user root
diff --git a/libhealthd/Android.mk b/libhealthd/Android.mk
new file mode 100644
index 0000000..2a0d849
--- /dev/null
+++ b/libhealthd/Android.mk
@@ -0,0 +1,11 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := healthd_board_FP2.cpp
+LOCAL_MODULE := libhealthd.FP2
+LOCAL_CFLAGS := -Werror
+LOCAL_C_INCLUDES := \
+	system/core/healthd/include \
+	system/core/base/include \
+	bootable/recovery
+include $(BUILD_STATIC_LIBRARY)
diff --git a/libhealthd/healthd_board_FP2.cpp b/libhealthd/healthd_board_FP2.cpp
new file mode 100644
index 0000000..c2be31c
--- /dev/null
+++ b/libhealthd/healthd_board_FP2.cpp
@@ -0,0 +1,269 @@
+
+/*
+* Copyright (C) 2013 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <fcntl.h>
+#include <healthd/healthd.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <cutils/android_reboot.h>
+#include <cutils/klog.h>
+
+#define BACKLIGHT_ON_LEVEL    100
+#define BACKLIGHT_OFF_LEVEL    0
+
+#define RED_LED_PATH            "/sys/class/leds/red/brightness"
+#define GREEN_LED_PATH          "/sys/class/leds/green/brightness"
+#define BLUE_LED_PATH           "/sys/class/leds/blue/brightness"
+#define BACKLIGHT_PATH          "/sys/class/leds/lcd-backlight/brightness"
+#define CHARGING_ENABLED_PATH   "/sys/class/power_supply/battery/charging_enabled"
+
+#define ARRAY_SIZE(x)           (sizeof(x)/sizeof(x[0]))
+
+#define LOGE(x...) do { KLOG_ERROR("charger", x); } while (0)
+#define LOGW(x...) do { KLOG_WARNING("charger", x); } while (0)
+#define LOGV(x...) do { KLOG_DEBUG("charger", x); } while (0)
+
+enum {
+  RED_LED = 0x01 << 0,
+  GREEN_LED = 0x01 << 1,
+  BLUE_LED = 0x01 << 2,
+};
+
+struct led_ctl {
+  int color;
+  const char *path;
+};
+
+struct led_ctl leds[3] =
+{{RED_LED, RED_LED_PATH},
+{GREEN_LED, GREEN_LED_PATH},
+{BLUE_LED, BLUE_LED_PATH}};
+
+struct soc_led_color_mapping {
+  int soc;
+  int color;
+};
+
+/* Increasing battery charge percentage vs LED color mapping */
+struct soc_led_color_mapping soc_leds[3] = {
+  {15, RED_LED},
+  {95, RED_LED | GREEN_LED},
+  {100, GREEN_LED},
+};
+
+static int set_tricolor_led(int on, int color)
+{
+  int fd, i;
+  char buffer[10];
+  
+  for (i = 0; i < (int)ARRAY_SIZE(leds); i++) {
+    if ((color & leds[i].color) && (access(leds[i].path, R_OK | W_OK) == 0)) {
+      fd = open(leds[i].path, O_RDWR);
+      if (fd < 0) {
+        LOGE("Could not open red led node\n");
+        goto cleanup;
+      }
+      if (on)
+      snprintf(buffer, sizeof(int), "%d\n", 255);
+      else
+      snprintf(buffer, sizeof(int), "%d\n", 0);
+      
+      if (write(fd, buffer, strlen(buffer)) < 0)
+      LOGE("Could not write to led node\n");
+      cleanup:
+      if (fd >= 0)
+      close(fd);
+    }
+  }
+  
+  return 0;
+}
+
+static int set_battery_soc_leds(int soc)
+{
+  int i, color;
+  static int old_color = -1;
+  int range_max = ARRAY_SIZE(soc_leds) - 1;
+  
+  if (range_max < 0)
+  return 0;
+  
+  color = soc_leds[range_max].color;
+  for (i = 0; i <= range_max ; i++) {
+    if (soc < soc_leds[i].soc) {
+      color = soc_leds[i].color;
+      break;
+    }
+  }
+  if (old_color != color) {
+    if (old_color >= 0)
+    set_tricolor_led(0, old_color);
+    set_tricolor_led(1, color);
+    old_color = color;
+  }
+  
+  return 0;
+}
+
+static int is_usb_charger_valid()
+{
+  const char *usb_charger_path = "/sys/kernel/debug/msm_otg/chg_type";
+  char buf[32] = {'\0'};
+  int fd = 0;
+  int open_count = 3;
+  int sleep_count = 0;
+  
+  while ((fd <= 0) && (open_count-- > 0)) {
+    fd = open(usb_charger_path, O_RDONLY);
+    if (fd > 0) {
+      break;
+    }
+    usleep(100000);
+  }
+  if (fd > 0) {
+    while (!strstr(buf, "USB")  && (sleep_count <= 20)) {
+      read(fd, buf, 32);
+      if (strstr(buf, "USB")) {
+        close(fd);
+        return 1;
+      } else {
+        usleep(100000);
+      }
+      sleep_count++;
+    }
+  } else {
+    sleep(2);
+  }
+  return 0;
+}
+
+static void wait_for_usb_ps_ok()
+{
+  const char *usb_ps_online = "/sys/class/power_supply/usb/online";
+  char buf[8] = {'\0'};
+  int fd = 0;
+  int open_count = 3;
+  int sleep_count = 0;
+  
+  while ((fd <= 0) && (open_count-- > 0)) {
+    fd = open(usb_ps_online, O_RDONLY);
+    if (fd > 0) {
+      break;
+    }
+    usleep(100000);
+  }
+  if (fd > 0) {
+    while ((buf[0] != '1') && (sleep_count <= 20)) {
+      read(fd, buf, 2);
+      if (buf[0] == '1') {
+        close(fd);
+        return;
+      } else {
+        usleep(100000);
+      }
+      sleep_count++;
+    }
+  } else {
+    sleep(2);
+  }
+}
+
+void healthd_board_init(struct healthd_config*)
+{
+  // use defaults
+}
+
+
+int healthd_board_battery_update(struct android::BatteryProperties*)
+{
+  // return 0 to log periodic polled battery status to kernel log
+  return 0;
+}
+
+void healthd_board_mode_charger_draw_battery(struct android::BatteryProperties*)
+{
+  
+}
+
+void healthd_board_mode_charger_battery_update(struct android::BatteryProperties* props)
+{
+  static int old_soc = -1;
+  int soc = props->batteryLevel;
+  if (old_soc != soc) {
+    old_soc = soc;
+    set_battery_soc_leds(soc);
+  }
+}
+
+void healthd_board_mode_charger_set_backlight(bool value)
+{
+  int fd;
+  char buffer[10];
+  
+  if (access(BACKLIGHT_PATH, R_OK | W_OK) != 0)
+  {
+    LOGW("Backlight control not support\n");
+  }
+  
+  memset(buffer, '\0', sizeof(buffer));
+  fd = open(BACKLIGHT_PATH, O_RDWR);
+  if (fd < 0) {
+    LOGE("Could not open backlight node : %s\n", strerror(errno));
+    goto cleanup;
+  }
+  LOGV("Enabling backlight\n");
+  snprintf(buffer, sizeof(buffer), "%d\n",
+  value?BACKLIGHT_ON_LEVEL:BACKLIGHT_OFF_LEVEL);
+  if (write(fd, buffer,strlen(buffer)) < 0) {
+    LOGE("Could not write to backlight node : %s\n", strerror(errno));
+    goto cleanup;
+  }
+  cleanup:
+  if (fd >= 0)
+  close(fd);
+}
+
+void healthd_board_mode_charger_init()
+{
+  int ret;
+  char buff[8] = "\0";
+  int charging_enabled = 0;
+  int fd;
+  
+  if (is_usb_charger_valid()) {
+    wait_for_usb_ps_ok();
+  }
+  
+  /* check the charging is enabled or not */
+  fd = open(CHARGING_ENABLED_PATH, O_RDONLY);
+  if (fd < 0)
+  return;
+  ret = read(fd, buff, sizeof(buff));
+  close(fd);
+  if (ret > 0 && sscanf(buff, "%d\n", &charging_enabled)) {
+    /* if charging is disabled, reboot and exit power off charging */
+    if (charging_enabled)
+    return;
+    LOGW("android charging is disabled, exit!\n");
+    android_reboot(ANDROID_RB_RESTART, 0, 0);
+  }
+}
diff --git a/light/Android.bp b/light/Android.bp
new file mode 100644
index 0000000..f629012
--- /dev/null
+++ b/light/Android.bp
@@ -0,0 +1,32 @@
+//
+// 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.
+
+cc_binary {
+    relative_install_path: "hw",
+    defaults: ["hidl_defaults"],
+    name: "android.hardware.light@2.0-service.FP2",
+    proprietary: true,
+    init_rc: ["android.hardware.light@2.0-service.FP2.rc"],
+    srcs: ["service.cpp", "Light.cpp"],
+    shared_libs: [
+        "libhardware",
+        "libhidlbase",
+        "libhidltransport",
+        "liblog",
+        "libhwbinder",
+        "libutils",
+        "android.hardware.light@2.0",
+    ],
+}
diff --git a/light/Light.cpp b/light/Light.cpp
new file mode 100644
index 0000000..f170fc3
--- /dev/null
+++ b/light/Light.cpp
@@ -0,0 +1,242 @@
+/*
+ * Copyright (C) 2017-2018 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.
+ */
+
+#define LOG_TAG "LightService"
+
+#include <log/log.h>
+
+#include "Light.h"
+
+#include <fstream>
+
+#define LEDS            "/sys/class/leds/"
+
+#define LCD_LED         LEDS "lcd-backlight/"
+#define RED_LED         LEDS "red/"
+#define GREEN_LED       LEDS "green/"
+#define BLUE_LED        LEDS "blue/"
+
+#define BLINK           "blink"
+#define BRIGHTNESS      "brightness"
+#define DUTY_PCTS       "duty_pcts"
+#define START_IDX       "start_idx"
+#define PAUSE_LO        "pause_lo"
+#define PAUSE_HI        "pause_hi"
+#define RAMP_STEP_MS    "ramp_step_ms"
+
+/*
+ * 8 duty percent steps.
+ */
+#define RAMP_STEPS 8
+/*
+ * Each step will stay on for 50ms by default.
+ */
+#define RAMP_STEP_DURATION 50
+/*
+ * Each value represents a duty percent (0 - 100) for the led pwm.
+ */
+static int32_t BRIGHTNESS_RAMP[RAMP_STEPS] = {0, 12, 25, 37, 50, 72, 85, 100};
+
+namespace {
+/*
+ * Write value to path and close file.
+ */
+static void set(std::string path, std::string value) {
+    std::ofstream file(path);
+
+    if (!file.is_open()) {
+        ALOGE("failed to write %s to %s", value.c_str(), path.c_str());
+        return;
+    }
+
+    file << value;
+}
+
+static void set(std::string path, int value) {
+    set(path, std::to_string(value));
+}
+
+static void handleBacklight(const LightState& state) {
+    uint32_t brightness = state.color & 0xFF;
+    set(LCD_LED BRIGHTNESS, brightness);
+}
+
+/*
+ * Scale each value of the brightness ramp according to the
+ * brightness of the color.
+ */
+static std::string getScaledRamp(uint32_t brightness) {
+    std::string ramp, pad;
+
+    for (auto const& step : BRIGHTNESS_RAMP) {
+        int32_t scaledStep = (step * brightness) / 0xFF;
+        ramp += pad + std::to_string(scaledStep);
+        pad = ",";
+    }
+
+    return ramp;
+}
+
+static void handleNotification(const LightState& state) {
+    uint32_t redBrightness, greenBrightness, blueBrightness, brightness;
+
+    /*
+     * Extract brightness from AARRGGBB.
+     */
+    redBrightness = (state.color >> 16) & 0xFF;
+    greenBrightness = (state.color >> 8) & 0xFF;
+    blueBrightness = state.color & 0xFF;
+
+    brightness = (state.color >> 24) & 0xFF;
+
+    /*
+     * Scale RGB brightness if the Alpha brightness is not 0xFF.
+     */
+    if (brightness != 0xFF) {
+        redBrightness = (redBrightness * brightness) / 0xFF;
+        greenBrightness = (greenBrightness * brightness) / 0xFF;
+        blueBrightness = (blueBrightness * brightness) / 0xFF;
+    }
+
+    /* Disable blinking. */
+    set(RED_LED BLINK, 0);
+    set(GREEN_LED BLINK, 0);
+    set(BLUE_LED BLINK, 0);
+
+    if (state.flashMode == Flash::TIMED && state.flashOnMs > 1) {
+        /*
+         * If the flashOnMs duration is not long enough to fit ramping up
+         * and down at the default step duration, step duration is modified
+         * to fit.
+         */
+        int32_t stepDuration = RAMP_STEP_DURATION;
+        int32_t pauseHi = state.flashOnMs - (stepDuration * RAMP_STEPS * 2);
+        int32_t pauseLo = state.flashOffMs;
+
+        if (pauseHi < 0) {
+            stepDuration = state.flashOnMs / (RAMP_STEPS * 2);
+            pauseHi = 0;
+        }
+
+        /* Red */
+        set(RED_LED START_IDX, 0 * RAMP_STEPS);
+        set(RED_LED DUTY_PCTS, getScaledRamp(redBrightness));
+        set(RED_LED PAUSE_LO, pauseLo);
+        set(RED_LED PAUSE_HI, pauseHi);
+        set(RED_LED RAMP_STEP_MS, stepDuration);
+
+        /* Green */
+        set(GREEN_LED START_IDX, 1 * RAMP_STEPS);
+        set(GREEN_LED DUTY_PCTS, getScaledRamp(greenBrightness));
+        set(GREEN_LED PAUSE_LO, pauseLo);
+        set(GREEN_LED PAUSE_HI, pauseHi);
+        set(GREEN_LED RAMP_STEP_MS, stepDuration);
+
+        /* Blue */
+        set(BLUE_LED START_IDX, 2 * RAMP_STEPS);
+        set(BLUE_LED DUTY_PCTS, getScaledRamp(blueBrightness));
+        set(BLUE_LED PAUSE_LO, pauseLo);
+        set(BLUE_LED PAUSE_HI, pauseHi);
+        set(BLUE_LED RAMP_STEP_MS, stepDuration);
+
+        /* Enable blinking. */
+        if (redBrightness > 0)
+            set(RED_LED BLINK, 1);
+        if (greenBrightness > 0)
+            set(GREEN_LED BLINK, 1);
+        if (blueBrightness > 0)
+            set(BLUE_LED BLINK, 1);
+    } else {
+        set(RED_LED BRIGHTNESS, redBrightness);
+        set(GREEN_LED BRIGHTNESS, greenBrightness);
+        set(BLUE_LED BRIGHTNESS, blueBrightness);
+    }
+}
+
+static inline bool isLit(const LightState& state) {
+    return state.color & 0x00ffffff;
+}
+
+/* Keep sorted in the order of importance. */
+static std::vector<LightBackend> backends = {
+    { Type::ATTENTION, handleNotification },
+    { Type::NOTIFICATIONS, handleNotification },
+    { Type::BATTERY, handleNotification },
+    { Type::BACKLIGHT, handleBacklight }
+};
+
+} // anonymous namespace
+
+namespace android {
+namespace hardware {
+namespace light {
+namespace V2_0 {
+namespace implementation {
+
+Return<Status> Light::setLight(Type type, const LightState& state) {
+    LightStateHandler handler = nullptr;
+    bool handled = false;
+
+    /* Lock global mutex until light state is updated. */
+    std::lock_guard<std::mutex> lock(globalLock);
+
+    /* Update the cached state value for the current type. */
+    for (LightBackend& backend : backends) {
+        if (backend.type == type) {
+            backend.state = state;
+            handler = backend.handler;
+        }
+    }
+
+    /* If no handler has been found, then the type is not supported. */
+    if (!handler) {
+        return Status::LIGHT_NOT_SUPPORTED;
+    }
+
+    /* Light up the type with the highest priority that matches the current handler. */
+    for (LightBackend& backend : backends) {
+        if (handler == backend.handler && isLit(backend.state)) {
+            handler(backend.state);
+            handled = true;
+            break;
+        }
+    }
+
+    /* If no type has been lit up, then turn off the hardware. */
+    if (!handled) {
+        handler(state);
+    }
+
+    return Status::SUCCESS;
+}
+
+Return<void> Light::getSupportedTypes(getSupportedTypes_cb _hidl_cb) {
+    std::vector<Type> types;
+
+    for (const LightBackend& backend : backends) {
+        types.push_back(backend.type);
+    }
+
+    _hidl_cb(types);
+
+    return Void();
+}
+
+}  // namespace implementation
+}  // namespace V2_0
+}  // namespace light
+}  // namespace hardware
+}  // namespace android
diff --git a/light/Light.h b/light/Light.h
new file mode 100644
index 0000000..ecc02be
--- /dev/null
+++ b/light/Light.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2017-2018 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.
+ */
+#ifndef ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
+#define ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
+
+#include <android/hardware/light/2.0/ILight.h>
+#include <hardware/lights.h>
+#include <hidl/Status.h>
+#include <map>
+#include <mutex>
+
+#include <vector>
+
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::light::V2_0::Flash;
+using ::android::hardware::light::V2_0::ILight;
+using ::android::hardware::light::V2_0::LightState;
+using ::android::hardware::light::V2_0::Status;
+using ::android::hardware::light::V2_0::Type;
+
+typedef void (*LightStateHandler)(const LightState&);
+
+struct LightBackend {
+    Type type;
+    LightState state;
+    LightStateHandler handler;
+
+    LightBackend(Type type, LightStateHandler handler) : type(type), handler(handler) {
+        this->state.color = 0xff000000;
+    }
+};
+
+namespace android {
+namespace hardware {
+namespace light {
+namespace V2_0 {
+namespace implementation {
+
+class Light : public ILight {
+   public:
+    Return<Status> setLight(Type type, const LightState& state) override;
+    Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb) override;
+
+   private:
+    std::mutex globalLock;
+};
+
+}  // namespace implementation
+}  // namespace V2_0
+}  // namespace light
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
diff --git a/light/android.hardware.light@2.0-service.FP2.rc b/light/android.hardware.light@2.0-service.FP2.rc
new file mode 100644
index 0000000..44e74c5
--- /dev/null
+++ b/light/android.hardware.light@2.0-service.FP2.rc
@@ -0,0 +1,31 @@
+on boot
+    chown system system /sys/class/leds/red/blink
+    chown system system /sys/class/leds/red/duty_pcts
+    chown system system /sys/class/leds/red/start_idx
+    chown system system /sys/class/leds/red/pause_hi
+    chown system system /sys/class/leds/red/pause_lo
+    chown system system /sys/class/leds/red/pause_high
+    chown system system /sys/class/leds/red/ramp_step_ms
+    chown system system /sys/class/leds/green/blink
+    chown system system /sys/class/leds/green/duty_pcts
+    chown system system /sys/class/leds/green/start_idx
+    chown system system /sys/class/leds/green/pause_hi
+    chown system system /sys/class/leds/green/pause_lo
+    chown system system /sys/class/leds/green/pause_high
+    chown system system /sys/class/leds/green/ramp_step_ms
+    chown system system /sys/class/leds/blue/blink
+    chown system system /sys/class/leds/blue/duty_pcts
+    chown system system /sys/class/leds/blue/start_idx
+    chown system system /sys/class/leds/blue/pause_hi
+    chown system system /sys/class/leds/blue/pause_lo
+    chown system system /sys/class/leds/blue/pause_high
+    chown system system /sys/class/leds/blue/ramp_step_ms
+
+service vendor.light-hal-2-0 /vendor/bin/hw/android.hardware.light@2.0-service.FP2
+    interface android.hardware.light@2.0::ILight default
+    class hal
+    user system
+    group system
+    seclabel u:object_r:hal_light_default_exec:s0
+    # shutting off lights while powering-off
+    shutdown critical
diff --git a/light/service.cpp b/light/service.cpp
new file mode 100644
index 0000000..e10b28f
--- /dev/null
+++ b/light/service.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2017-2018 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.
+ */
+
+#define LOG_TAG "android.hardware.light@2.0-service.FP2"
+
+#include <hidl/HidlTransportSupport.h>
+
+#include "Light.h"
+
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
+
+using android::hardware::light::V2_0::ILight;
+using android::hardware::light::V2_0::implementation::Light;
+
+using android::OK;
+using android::sp;
+using android::status_t;
+
+int main() {
+    android::sp<ILight> service = new Light();
+
+    configureRpcThreadpool(1, true);
+
+    status_t status = service->registerAsService();
+    if (status != OK) {
+        ALOGE("Cannot register Light HAL service.");
+        return 1;
+    }
+
+    ALOGI("Light HAL service ready.");
+
+    joinRpcThreadpool();
+
+    ALOGI("Light HAL service failed to join thread pool.");
+    return 1;
+}
diff --git a/manifest.xml b/manifest.xml
new file mode 100644
index 0000000..f828e53
--- /dev/null
+++ b/manifest.xml
@@ -0,0 +1,221 @@
+<manifest version="1.0" type="device">
+    <hal format="hidl">
+        <name>android.hardware.audio</name>
+        <transport>hwbinder</transport>
+        <version>2.0</version>
+        <interface>
+            <name>IDevicesFactory</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.audio.effect</name>
+        <transport>hwbinder</transport>
+        <version>2.0</version>
+        <interface>
+            <name>IEffectsFactory</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.camera.provider</name>
+        <transport arch="32">passthrough</transport>
+        <version>2.4</version>
+        <interface>
+            <name>ICameraProvider</name>
+            <instance>external/0</instance>
+            <instance>legacy/0</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.cas</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IMediaCasService</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.configstore</name>
+        <transport>hwbinder</transport>
+        <version>1.1</version>
+        <interface>
+            <name>ISurfaceFlingerConfigs</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.drm</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>ICryptoFactory</name>
+            <instance>default</instance>
+        </interface>
+        <interface>
+            <name>IDrmFactory</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.gnss</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IGnss</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.graphics.allocator</name>
+        <transport>hwbinder</transport>
+        <version>2.0</version>
+        <interface>
+            <name>IAllocator</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.graphics.composer</name>
+        <transport arch="32">passthrough</transport>
+        <version>2.1</version>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.graphics.mapper</name>
+        <transport arch="32">passthrough</transport>
+        <version>2.0</version>
+        <interface>
+            <name>IMapper</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.health</name>
+        <transport>hwbinder</transport>
+        <version>2.0</version>
+        <interface>
+            <name>IHealth</name>
+            <instance>backup</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.keymaster</name>
+        <transport>hwbinder</transport>
+        <version>3.0</version>
+        <interface>
+            <name>IKeymasterDevice</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.light</name>
+        <transport>hwbinder</transport>
+        <version>2.0</version>
+        <interface>
+            <name>ILight</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.media.omx</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IOmx</name>
+            <instance>default</instance>
+        </interface>
+        <interface>
+            <name>IOmxStore</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.memtrack</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IMemtrack</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.power</name>
+        <transport>hwbinder</transport>
+        <version>1.1</version>
+        <interface>
+            <name>IPower</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.radio</name>
+        <transport>hwbinder</transport>
+        <version>1.1</version>
+        <interface>
+            <name>IRadio</name>
+            <instance>slot1</instance>
+            <instance>slot2</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.radio.deprecated</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IOemHook</name>
+            <instance>slot1</instance>
+            <instance>slot2</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.renderscript</name>
+        <transport arch="32">passthrough</transport>
+        <version>1.0</version>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.sensors</name>
+        <transport arch="32">passthrough</transport>
+        <version>1.0</version>
+        <interface>
+            <name>ISensors</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.usb</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IUsb</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>android.hardware.vibrator</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IVibrator</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>vendor.lineage.power</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>ILineagePower</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl">
+        <name>vendor.lineage.trust</name>
+        <transport>hwbinder</transport>
+        <version>1.0</version>
+        <interface>
+            <name>IUsbRestrict</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+</manifest>
diff --git a/recovery.fstab b/recovery.fstab
new file mode 100644
index 0000000..4037b06
--- /dev/null
+++ b/recovery.fstab
@@ -0,0 +1,37 @@
+# Copyright (c) 2011, 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.
+
+# mount point	fstype		device			[device2] [length=]
+
+/dev/block/platform/msm_sdcc.1/by-name/system       /system         ext4    ro,barrier=1                                                    wait
+/dev/block/platform/msm_sdcc.1/by-name/cache        /cache          ext4    noatime,nosuid,nodev,barrier=1,data=ordered                     wait,check
+/dev/block/platform/msm_sdcc.1/by-name/userdata     /data           ext4    noatime,nosuid,nodev,barrier=1,data=ordered,noauto_da_alloc     wait,check,length=-16384
+/dev/block/platform/msm_sdcc.2/mmcblk1p1            /sdcard         vfat    nosuid,nodev                                                    wait
+/dev/block/platform/msm_sdcc.1/by-name/boot         /boot           emmc    defaults                                                        defaults
+/dev/block/platform/msm_sdcc.1/by-name/recovery     /recovery       emmc    defaults                                                        defaults
+/dev/block/platform/msm_sdcc.1/by-name/misc         /misc           emmc    defaults                                                        defaults
+/dev/block/platform/msm_sdcc.1/by-name/bootselect   /bootselect     emmc    defaults                                                        defaults
diff --git a/releasetools.py b/releasetools.py
new file mode 100644
index 0000000..68580a9
--- /dev/null
+++ b/releasetools.py
@@ -0,0 +1,362 @@
+# Copyright (C) 2009 The Android Open Source Project
+# Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Emit commands needed for QCOM devices during OTA installation
+(installing the radio image)."""
+
+import common
+import re
+
+
+bootImages = {}
+binImages = {}
+fwImages = {}
+
+
+# Parse filesmap file containing firmware residing places
+def LoadFilesMap(zip, name="RADIO/filesmap"):
+  try:
+    data = zip.read(name)
+  except KeyError:
+    print "Warning: could not find %s in %s." % (name, zip)
+    data = ""
+  d = {}
+  for line in data.split("\n"):
+    line = line.strip()
+    if not line or line.startswith("#"):
+      continue
+    pieces = line.split()
+    if not (len(pieces) == 2):
+      raise ValueError("malformed filesmap line: \"%s\"" % (line,))
+    d[pieces[0]] = pieces[1]
+  return d
+
+
+# Read firmware images from target files zip
+def GetRadioFiles(z):
+  out = {}
+  for info in z.infolist():
+    f = info.filename
+    if f.startswith("RADIO/") and (f.__len__() > len("RADIO/")):
+      fn = f[6:]
+      if fn.startswith("filesmap"):
+        continue
+      data = z.read(f)
+      out[fn] = common.File(f, data)
+  return out
+
+
+# Get firmware residing place from filesmap
+def GetFileDestination(fn, filesmap):
+  # if file is encoded disregard the .enc extention
+  if fn.endswith('.enc'):
+    fn = fn[:-4]
+
+  # get backup destination as well if present
+  backup = None
+  if fn + ".bak" in filesmap:
+    backup = filesmap[fn + ".bak"]
+
+  # If full filename is not specified in filesmap get only the name part
+  # and look for this token
+  if fn not in filesmap:
+    fn = fn.split(".")[0] + ".*"
+    if fn not in filesmap:
+      print "warning radio-update: '%s' not found in filesmap" % (fn)
+      return None, backup
+  return filesmap[fn], backup
+
+
+# Separate image types as each type needs different handling
+def SplitFwTypes(files):
+  boot = {}
+  bin = {}
+  fw = {}
+
+  for f in files:
+    extIdx = -1
+    dotSeparated = f.split(".")
+    while True:
+      if dotSeparated[extIdx] != 'p' and dotSeparated[extIdx] != 'enc':
+        break
+      extIdx -= 1
+
+    if dotSeparated[extIdx] == 'mbn':
+      boot[f] = files[f]
+    elif dotSeparated[extIdx] == 'bin' or dotSeparated[extIdx] == 'img':
+      bin[f] = files[f]
+    else:
+      fw[f] = files[f]
+  return boot, bin, fw
+
+
+# Prepare radio-update files and verify them
+def OTA_VerifyEnd(info, api_version, target_zip, source_zip=None):
+  if api_version < 3:
+    print "warning radio-update: no support for api_version less than 3"
+    return False
+
+  print "Loading radio filesmap..."
+  filesmap = LoadFilesMap(target_zip)
+  if filesmap == {}:
+    print "warning radio-update: no or invalid filesmap file found"
+    return False
+
+  print "Loading radio target..."
+  tgt_files = GetRadioFiles(target_zip)
+  if tgt_files == {}:
+    print "warning radio-update: no radio images in input target_files"
+    return False
+
+  src_files = None
+  if source_zip is not None:
+    print "Loading radio source..."
+    src_files = GetRadioFiles(source_zip)
+
+  update_list = {}
+  largest_source_size = 0
+
+  print "Preparing radio-update files..."
+  for fn in tgt_files:
+    dest, destBak = GetFileDestination(fn, filesmap)
+    if dest is None:
+      continue
+
+    tf = tgt_files[fn]
+    sf = None
+    if src_files is not None:
+      sf = src_files.get(fn, None)
+
+    full = getattr(info, 'full_radio', False) or sf is None or fn.endswith('.enc')
+    if not full:
+      # no difference - skip this file
+      if tf.sha1 == sf.sha1:
+        continue
+      d = common.Difference(tf, sf)
+      _, _, d = d.ComputePatch()
+      # no difference - skip this file
+      if d is None:
+        continue
+      # if patch is almost as big as the file - don't bother patching
+      full = len(d) > tf.size * common.OPTIONS.patch_threshold
+      if not full:
+        f = "patch/firmware-update/" + fn + ".p"
+        common.ZipWriteStr(info.output_zip, f, d)
+        update_list[f] = (dest, destBak, tf, sf)
+        largest_source_size = max(largest_source_size, sf.size)
+    if full:
+      f = "firmware-update/" + fn
+      common.ZipWriteStr(info.output_zip, f, tf.data)
+      update_list[f] = (dest, destBak, None, None)
+
+  global bootImages
+  global binImages
+  global fwImages
+  bootImages, binImages, fwImages = SplitFwTypes(update_list)
+
+  # If there are incremental patches verify them
+  if largest_source_size != 0:
+    info.script.Comment("---- radio update verification ----")
+    info.script.Print("Verifying radio-update...")
+
+    for f in bootImages:
+      dest, destBak, tf, sf = bootImages[f]
+      # Not incremental
+      if sf is None:
+        continue
+      info.script.PatchCheck("EMMC:%s:%d:%s:%d:%s" %
+              (dest, sf.size, sf.sha1, tf.size, tf.sha1))
+      if destBak is not None:
+        info.script.PatchCheck("EMMC:%s:%d:%s:%d:%s" %
+                (destBak, sf.size, sf.sha1, tf.size, tf.sha1))
+    for f in binImages:
+      dest, destBak, tf, sf = binImages[f]
+      # Not incremental
+      if sf is None:
+        continue
+      info.script.PatchCheck("EMMC:%s:%d:%s:%d:%s" %
+              (dest, sf.size, sf.sha1, tf.size, tf.sha1))
+
+    last_mounted = ""
+    for f in fwImages:
+      dest, destBak, tf, sf = fwImages[f]
+      # Not incremental
+      if sf is None:
+        continue
+      # Get the filename without the path and the patch (.p) extention
+      f = f.split("/")[-1][:-2]
+      # Parse filesmap destination paths for "/dev/" pattern in the beginng.
+      # This would mean that the file must be written to block device -
+      # fs mount needed
+      if dest.startswith("/dev/"):
+        if last_mounted != dest:
+          info.script.AppendExtra('unmount("/firmware");')
+          info.script.AppendExtra('mount("vfat", "EMMC", "%s", "/firmware");' %
+                                    (dest))
+          last_mounted = dest
+        dest = "/firmware/image/" + f
+      else:
+        dest = dest + "/" + f
+      info.script.PatchCheck(dest, tf.sha1, sf.sha1)
+
+    info.script.CacheFreeSpaceCheck(largest_source_size)
+  return True
+
+
+def FullOTA_Assertions(info):
+  #TODO: Implement device specific asserstions.
+  return
+
+
+def IncrementalOTA_Assertions(info):
+  #TODO: Implement device specific asserstions.
+  return
+
+
+def IncrementalOTA_VerifyEnd(info):
+ OTA_VerifyEnd(info, info.target_version, info.target_zip, info.source_zip)
+ return
+
+
+# This function handles only non-HLOS whole partition images
+def InstallRawImage(script, f, dest, tf, sf):
+  if f.endswith('.p'):
+    script.ApplyPatch("EMMC:%s:%d:%s:%d:%s" %
+                        (dest, sf.size, sf.sha1, tf.size, tf.sha1),
+                        "-", tf.size, tf.sha1, sf.sha1, f)
+  elif f.endswith('.enc'):
+    # Get the filename without the path
+    fn = f.split("/")[-1]
+    script.AppendExtra('package_extract_file("%s", "/tmp/%s");' % (f, fn))
+    script.AppendExtra('msm.decrypt("/tmp/%s", "%s");' % (fn, dest))
+  else:
+    script.AppendExtra('package_extract_file("%s", "%s");' % (f, dest))
+  return
+
+
+# This function handles only non-HLOS boot images - files list must contain
+# only such images (aboot, tz, etc)
+def InstallBootImages(script, files):
+  bakExists = False
+  # update main partitions
+  script.AppendExtra('ifelse(msm.boot_update("main"), (')
+  for f in files:
+    dest, destBak, tf, sf = files[f]
+    if destBak is not None:
+      bakExists = True
+    InstallRawImage(script, f, dest, tf, sf)
+  script.AppendExtra('), "");')
+
+  # update backup partitions
+  if bakExists:
+    script.AppendExtra('ifelse(msm.boot_update("backup"), (')
+    for f in files:
+      dest, destBak, tf, sf = files[f]
+      if destBak is not None:
+        InstallRawImage(script, f, destBak, tf, sf)
+    script.AppendExtra('), "");')
+  # just finalize primary update stage
+  else:
+    script.AppendExtra('msm.boot_update("backup");')
+
+  # finalize partitions update
+  script.AppendExtra('msm.boot_update("finalize");')
+  return
+
+
+# This function handles only non-HLOS bin images
+def InstallBinImages(script, files):
+  for f in files:
+    dest, _, tf, sf = files[f]
+    InstallRawImage(script, f, dest, tf, sf)
+  return
+
+
+# This function handles only non-HLOS firmware files that are not whole
+# partition images (modem, dsp, etc)
+def InstallFwImages(script, files):
+  last_mounted = ""
+
+  for f in files:
+    dest, _, tf, sf = files[f]
+    # Get the filename without the path
+    fn = f.split("/")[-1]
+    # Parse filesmap destination paths for "/dev/" pattern in the beginng.
+    # This would mean that the file must be written to block device -
+    # fs mount needed
+    if dest.startswith("/dev/"):
+      if last_mounted != dest:
+        script.AppendExtra('unmount("/firmware");')
+        script.AppendExtra('mount("vfat", "EMMC", "%s", "/firmware");' %
+                            (dest))
+        last_mounted = dest
+      dest = "/firmware/image/" + fn
+    else:
+      dest = dest + "/" + fn
+
+    if f.endswith('.p'):
+      script.ApplyPatch(dest[:-2], "-", tf.size, tf.sha1, sf.sha1, f)
+    elif f.endswith('.enc'):
+      script.AppendExtra('package_extract_file("%s", "/tmp/%s");' % (f, fn))
+      script.AppendExtra('msm.decrypt("/tmp/%s", "%s");' % (fn, dest[:-4]))
+    else:
+      script.AppendExtra('package_extract_file("%s", "%s");' % (f, dest))
+
+  if last_mounted != "":
+    script.AppendExtra('unmount("/firmware");')
+  return
+
+
+def OTA_InstallEnd(info):
+  print "Applying radio-update script modifications..."
+  info.script.Comment("---- radio update tasks ----")
+  info.script.Print("Patching firmware images...")
+
+  if bootImages != {}:
+    InstallBootImages(info.script, bootImages)
+  if binImages != {}:
+    InstallBinImages(info.script, binImages)
+  if fwImages != {}:
+    InstallFwImages(info.script, fwImages)
+  return
+
+
+def FullOTA_InstallEnd_MMC(info):
+  if OTA_VerifyEnd(info, info.input_version, info.input_zip):
+    OTA_InstallEnd(info)
+  return
+
+
+def FullOTA_InstallEnd_MTD(info):
+  print "warning radio-update: radio update for NAND devices not supported"
+  return
+
+
+def FullOTA_InstallEnd(info):
+  FullOTA_InstallEnd_MMC(info)
+  return
+
+def IncrementalOTA_InstallEnd_MMC(info):
+  OTA_InstallEnd(info)
+  return
+
+
+def IncrementalOTA_InstallEnd_MTD(info):
+  print "warning radio-update: radio update for NAND devices not supported"
+  return
+
+def IncrementalOTA_InstallEnd(info):
+  IncrementalOTA_InstallEnd_MMC(info)
+  return
diff --git a/root/Android.mk b/root/Android.mk
new file mode 100644
index 0000000..80f88fc
--- /dev/null
+++ b/root/Android.mk
@@ -0,0 +1,11 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+# Device init files
+include $(CLEAR_VARS)
+LOCAL_MODULE       := init.qcom.power.rc
+LOCAL_MODULE_TAGS  := optional
+LOCAL_MODULE_CLASS := ETC
+LOCAL_SRC_FILES    := init.qcom.power.rc
+LOCAL_MODULE_PATH  := $(TARGET_ROOT_OUT)
+include $(BUILD_PREBUILT)
diff --git a/root/init.qcom.fm.sh b/root/init.qcom.fm.sh
new file mode 100644
index 0000000..fb19d8b
--- /dev/null
+++ b/root/init.qcom.fm.sh
@@ -0,0 +1,90 @@
+#!/vendor/bin/sh
+# Copyright (c) 2009-2011, 2015, 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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.
+#
+
+setprop vendor.hw.fm.init 0
+
+mode=`getprop vendor.hw.fm.mode`
+version=197632
+
+LOG_TAG="qcom-fm"
+LOG_NAME="${0}:"
+
+loge ()
+{
+  /vendor/bin/log -t $LOG_TAG -p e "$LOG_NAME $@"
+}
+
+logi ()
+{
+  /vendor/bin/log -t $LOG_TAG -p i "$LOG_NAME $@"
+}
+
+failed ()
+{
+  loge "$1: exit code $2"
+  exit $2
+}
+
+logi "In FM shell Script"
+logi "mode: $mode"
+logi "Version : $version"
+
+#$fm_qsoc_patches <fm_chipVersion> <enable/disable WCM>
+#
+case $mode in
+  "normal")
+        logi "inserting the radio transport module"
+        echo 1 > /sys/module/radio_iris_transport/parameters/fmsmd_set
+        /vendor/bin/fm_qsoc_patches $version 0
+     ;;
+  "wa_enable")
+   /vendor/bin/fm_qsoc_patches $version 1
+     ;;
+  "wa_disable")
+   /vendor/bin/fm_qsoc_patches $version 2
+     ;;
+   *)
+    logi "Shell: Default case"
+    /vendor/bin/fm_qsoc_patches $version 0
+    ;;
+esac
+
+exit_code_fm_qsoc_patches=$?
+
+case $exit_code_fm_qsoc_patches in
+   0)
+	logi "FM QSoC calibration and firmware download succeeded"
+   ;;
+  *)
+	failed "FM QSoC firmware download and/or calibration failed" $exit_code_fm_qsoc_patches
+   ;;
+esac
+
+setprop vendor.hw.fm.init 1
+
+exit 0
diff --git a/root/init.qcom.power.rc b/root/init.qcom.power.rc
new file mode 100644
index 0000000..5b7507c
--- /dev/null
+++ b/root/init.qcom.power.rc
@@ -0,0 +1,159 @@
+# Copyright (c) 2016, Code Aurora Forum. 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 Code Aurora 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, 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.
+#
+
+on early-init
+    write /sys/block/mmcblk0/queue/scheduler "noop"
+    write /sys/block/mmcblk0/bdi/read_ahead_kb 512
+
+on enable-low-power
+    # Configure the hardware properly
+    write /sys/module/lpm_levels/enable_low_power/l2 4
+    write /sys/module/msm_pm/modes/cpu0/power_collapse/suspend_enabled 1
+    write /sys/module/msm_pm/modes/cpu1/power_collapse/suspend_enabled 1
+    write /sys/module/msm_pm/modes/cpu2/power_collapse/suspend_enabled 1
+    write /sys/module/msm_pm/modes/cpu3/power_collapse/suspend_enabled 1
+    write /sys/module/msm_pm/modes/cpu0/power_collapse/idle_enabled 1
+    write /sys/module/msm_pm/modes/cpu1/power_collapse/idle_enabled 1
+    write /sys/module/msm_pm/modes/cpu2/power_collapse/idle_enabled 1
+    write /sys/module/msm_pm/modes/cpu3/power_collapse/idle_enabled 1
+    write /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/suspend_enabled 1
+    write /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/suspend_enabled 1
+    write /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/suspend_enabled 1
+    write /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/suspend_enabled 1
+    write /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/idle_enabled 1
+    write /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/idle_enabled 1
+    write /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/idle_enabled 1
+    write /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/idle_enabled 1
+    write /sys/module/msm_pm/modes/cpu0/retention/idle_enabled 1
+    write /sys/module/msm_pm/modes/cpu1/retention/idle_enabled 1
+    write /sys/module/msm_pm/modes/cpu2/retention/idle_enabled 1
+    write /sys/module/msm_pm/modes/cpu3/retention/idle_enabled 1
+
+    # Disable thermal hotplug to switch governor
+    write /sys/module/msm_thermal/core_control/enabled 0
+
+    write /sys/devices/system/cpu/cpu1/online 1
+    write /sys/devices/system/cpu/cpu2/online 1
+    write /sys/devices/system/cpu/cpu3/online 1
+
+    # Configure the CPU governor
+    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "interactive"
+    write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor "interactive"
+    write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor "interactive"
+    write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor "interactive"
+    write /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay "19000 1400000:39000 1700000:19000"
+    write /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load 99
+    write /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq 1190400
+    write /sys/devices/system/cpu/cpufreq/interactive/io_is_busy 1
+    write /sys/devices/system/cpu/cpufreq/interactive/target_loads "85 1500000:90 1800000:70"
+    write /sys/devices/system/cpu/cpufreq/interactive/min_sample_time 40000
+    write /sys/devices/system/cpu/cpufreq/interactive/timer_rate 30000
+    write /sys/devices/system/cpu/cpufreq/interactive/sampling_down_factor 100000
+    write /sys/devices/system/cpu/cpufreq/interactive/timer_slack 30000
+    write /sys/devices/system/cpu/cpufreq/interactive/up_threshold_any_cpu_load 50
+    write /sys/devices/system/cpu/cpufreq/interactive/sync_freq 1036800
+    write /sys/devices/system/cpu/cpufreq/interactive/up_threshold_any_cpu_freq 1190400
+
+    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 300000
+    write /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq 300000
+    write /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq 300000
+    write /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq 300000
+    chown root system /sys/devices/system/cpu/cpu1/online
+    chown root system /sys/devices/system/cpu/cpu2/online
+    chown root system /sys/devices/system/cpu/cpu3/online
+    chmod 664 /sys/devices/system/cpu/cpu1/online
+    chmod 664 /sys/devices/system/cpu/cpu2/online
+    chmod 664 /sys/devices/system/cpu/cpu3/online
+
+    # Re-enable thermal hotplug
+    write /sys/module/msm_thermal/core_control/enabled 1
+
+    write /sys/class/devfreq/qcom,cpubw.42/governor "cpubw_hwmon"
+    write /sys/class/kgsl/kgsl-3d0/devfreq/governor "msm-adreno-tz"
+
+    # Input boost config
+    write /sys/module/cpu_boost/parameters/boost_ms 20
+    write /sys/module/cpu_boost/parameters/sync_threshold 1728000
+    write /sys/module/cpu_boost/parameters/input_boost_freq 1497600
+    write /sys/module/cpu_boost/parameters/input_boost_ms 40
+
+    write /dev/cpuctl/cpu.notify_on_migrate 1
+
+on charger
+    write /sys/module/lpm_levels/enable_low_power/l2 2
+    write /sys/module/msm_pm/modes/cpu0/power_collapse/suspend_enabled 1
+    write /sys/module/msm_pm/modes/cpu1/power_collapse/suspend_enabled 1
+    write /sys/module/msm_pm/modes/cpu2/power_collapse/suspend_enabled 1
+    write /sys/module/msm_pm/modes/cpu3/power_collapse/suspend_enabled 1
+    write /sys/module/msm_pm/modes/cpu0/power_collapse/idle_enabled 1
+    write /sys/module/msm_thermal/core_control/enabled 0
+    write /sys/devices/system/cpu/cpu1/online 1
+    write /sys/devices/system/cpu/cpu2/online 1
+    write /sys/devices/system/cpu/cpu3/online 1
+    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "powersave"
+    write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor "powersave"
+    write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor "powersave"
+    write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor "powersave"
+    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 300000
+    write /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq 300000
+    write /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq 300000
+    write /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq 300000
+    write /sys/module/msm_thermal/core_control/enabled 1
+    write /sys/devices/system/cpu/cpu1/online 0
+    write /sys/devices/system/cpu/cpu2/online 0
+    write /sys/devices/system/cpu/cpu3/online 0
+
+on boot
+    trigger enable-low-power
+
+on property:init.svc.recovery=running
+    write /sys/class/leds/button-backlight/brightness 255
+    trigger enable-low-power
+
+on property:recovery.perf.mode=1
+    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "performance"
+
+on property:recovery.perf.mode=0
+    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "interactive"
+
+on property:dev.bootcomplete=1
+    # Set I/O scheduler
+    setprop sys.io.scheduler "bfq"
+
+    # Set perfd properties
+    setprop ro.qualcomm.perf.cores_online 2
+
+    # Start perfd
+    rm /data/system/perfd/default_values
+    start mpdecision
+
+service mpdecision /vendor/bin/mpdecision --avg_comp
+    class main
+    user root
+    group root readproc
+    socket perfd seqpacket 0666 root system
+    disabled
diff --git a/root/init.qcom.rc b/root/init.qcom.rc
new file mode 100644
index 0000000..0703af0
--- /dev/null
+++ b/root/init.qcom.rc
@@ -0,0 +1,317 @@
+# Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+#       copyright notice, this list of conditions and the following
+#       disclaimer in the documentation and/or other materials provided
+#       with the distribution.
+#     * Neither the name of The Linux Foundation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#
+
+import /vendor/etc/init/hw/init.qcom.usb.rc
+import /vendor/etc/init/hw/init.qcom.power.rc
+
+on early-init
+    mount debugfs debugfs /sys/kernel/debug
+
+    # Turn off backlight on blank
+    write /sys/class/leds/lcd-backlight/trigger "backlight"
+
+on early-boot
+    write /sys/kernel/boot_adsp/boot 1
+
+    # SSR setup
+    write /sys/bus/msm_subsys/devices/subsys0/restart_level "related"
+    write /sys/bus/msm_subsys/devices/subsys1/restart_level "related"
+    write /sys/bus/msm_subsys/devices/subsys2/restart_level "related"
+    write /sys/bus/msm_subsys/devices/subsys3/restart_level "related"
+
+on init
+    # Set the property to indicate type of virtual display to 0
+    # 0 indicates that virtual display is not a Wifi display and that the
+    # session is not exercised through RemoteDisplay in the android framework
+    setprop persist.sys.wfd.virtual 0
+
+on fs
+    mount_all /vendor/etc/fstab.qcom
+
+    # Keeping following partitions outside fstab file. As user may not have
+    # these partition flashed on the device. Failure to mount any partition in fstab file
+    # results in failure to launch late-start class.
+
+    wait /dev/block/platform/msm_sdcc.1/by-name/persist
+    mount ext4 /dev/block/platform/msm_sdcc.1/by-name/persist /persist nosuid nodev barrier=1
+    restorecon_recursive   /persist
+
+    # We chown/chmod /persist again so because mount is run as root + defaults
+    chown system system /persist
+    chmod 0771 /persist
+
+    mkdir /persist/data 0700 system system
+    mkdir /persist/data/sfs 0700 system system
+    mkdir /persist/data/tz 0700 system system
+
+on post-fs-data
+    mkdir /data/tombstones 0771 system system
+    mkdir /tombstones/modem 0771 system system
+    mkdir /tombstones/lpass 0771 system system
+    mkdir /tombstones/wcnss 0771 system system
+    mkdir /tombstones/dsps 0771 system system
+    mkdir /data/usf 0700 system system
+
+    mkdir /data/media 0770 media_rw media_rw
+
+    # Create directory used by audio subsystem
+    mkdir /data/misc/audio 0770 audio audio
+
+    # Create directory for TZ Apps
+    mkdir /data/misc/qsee 0770 system system
+
+    # Create directory used by sensor subsystem
+    mkdir /persist/sensors 0775 system root
+    write /persist/sensors/sensors_settings 1
+    chmod 0644 /persist/sensors/sensors_settings
+    chown system root /persist/sensors/sensors_settings
+    mkdir /data/misc/sensors 0775 system system
+    restorecon_recursive /data/misc/sensors
+
+    # Create FM dir for patchdownloader
+    mkdir /data/misc/fm 0770 system system
+    chmod 0770 /data/misc/fm
+
+    # Create the directories used by CnE subsystem
+    mkdir /data/connectivity 0771 system system
+    chown system system /data/connectivity
+
+    # Create directory from IMS services
+    mkdir /data/shared 0755
+    chown system system /data/shared
+
+    # Create /data/time folder for time-services
+    mkdir /data/time/ 0700 system system
+
+    mkdir /data/audio/ 0770 media audio
+
+    # Create folder for mm-qcamera-daemon
+    mkdir /data/camera 0770 media camera
+
+    # camera sockets
+    mkdir /data/misc/camera 0770 camera camera
+
+    # Create PERFD deamon related dirs
+    mkdir /data/system/perfd 0770 root system
+    chmod 2770 /data/system/perfd
+
+    setprop vold.post_fs_data_done 1
+
+on boot
+    chmod 0660 /sys/module/radio_iris_transport/parameters/fmsmd_set
+    chmod 0660 /sys/class/rfkill/rfkill0/state
+    chmod 0660 /dev/ttyHS0
+
+    # access permission for secure touch
+    chmod 0660 /sys/devices/f9923000.i2c/i2c-1/1-004a/secure_touch_enable
+    chmod 0440 /sys/devices/f9923000.i2c/i2c-1/1-004a/secure_touch
+    chown system drmrpc /sys/devices/f9923000.i2c/i2c-1/1-004a/secure_touch_enable
+    chown system drmrpc /sys/devices/f9923000.i2c/i2c-1/1-004a/secure_touch
+    chmod 0660 /sys/devices/f9924000.i2c/i2c-2/2-004a/secure_touch_enable
+    chmod 0440 /sys/devices/f9924000.i2c/i2c-2/2-004a/secure_touch
+    chown system drmrpc /sys/devices/f9924000.i2c/i2c-2/2-004a/secure_touch_enable
+    chown system drmrpc /sys/devices/f9924000.i2c/i2c-2/2-004a/secure_touch
+    chmod 0775 /persist
+    chmod 0444 /persist/board_date.bin
+    chown system root /persist/sns.reg
+    chmod 770  /persist/sns.reg
+
+    # Create QMUX deamon socket area
+    mkdir /dev/socket/qmux_radio 0770 radio radio
+    chmod 2770 /dev/socket/qmux_radio
+    mkdir /dev/socket/qmux_audio 0770 media audio
+    chmod 2770 /dev/socket/qmux_audio
+
+    # Alarms
+    mkdir /persist/alarm 0770 system system
+
+    # Create NETMGR daemon socket area
+    mkdir /dev/socket/netmgr 0750 radio radio
+
+    # Charger
+    chown root system /sys/module/qpnp_charger/parameters/charger_monitor
+    chown root system /sys/class/power_supply/battery/input_current_max
+    chown root system /sys/class/power_supply/battery/input_current_trim
+    chown root system /sys/class/power_supply/battery/voltage_min
+    chmod 0644 /sys/module/qpnp_charger/parameters/charger_monitor
+    chmod 0644 /sys/class/power_supply/battery/input_current_max
+    chmod 0644 /sys/class/power_supply/battery/input_current_trim
+    chmod 0644 /sys/class/power_supply/battery/voltage_min
+
+    # Camera Recording
+    mkdir /dev/video
+    symlink /dev/video32 /dev/video/venus_dec
+    symlink /dev/video33 /dev/video/venus_enc
+
+# Allow usb charging to be disabled persistently
+on property:persist.usb.chgdisabled=1
+    write /sys/class/power_supply/battery/charging_enabled 0
+
+on property:persist.usb.chgdisabled=0
+    write /sys/class/power_supply/battery/charging_enabled 1
+
+# start camera server as daemon
+service qcamerasvr /vendor/bin/mm-qcamera-daemon
+    class late_start
+    user camera
+    group camera system inet input graphics
+
+service rmt_storage /vendor/bin/rmt_storage
+    class core
+    user root
+    group system wakelock
+
+service rfs_access /vendor/bin/rfs_access
+    class core
+    user system
+    group system net_raw
+
+# QMUX must be in multiple groups to support external process connections
+service qmuxd /vendor/bin/qmuxd
+    class main
+    user radio
+    group radio audio bluetooth gps diag oem_2950
+
+service netmgrd /vendor/bin/netmgrd
+    class main
+    user root
+    group root wifi wakelock radio inet oem_2950
+
+# QCOM sensor
+service sensors /vendor/bin/sensors.qcom
+    class late_start
+    user root
+    group root
+
+service irsc_util /vendor/bin/irsc_util "/vendor/etc/sec_config"
+    class main
+    user root
+    oneshot
+
+service qseecomd /vendor/bin/qseecomd
+   class core
+   user root
+   group root
+
+service qosmgrd /system/bin/qosmgr /system/etc/qosmgr_rules.xml
+   user system
+   group system
+   disabled
+
+service thermal-engine /vendor/bin/thermal-engine
+   class main
+   user root
+   group root
+   socket thermal-send-client stream 0666 system system
+   socket thermal-recv-client stream 0660 system system
+   socket thermal-recv-passive-client stream 0666 system system
+
+service time_daemon /vendor/bin/time_daemon
+   class late_start
+   user root
+   group root
+
+service adsprpcd /vendor/bin/adsprpcd
+   class main
+   user media
+   group media
+
+service imsqmidaemon /system/bin/imsqmidaemon
+    class main
+    user system
+    socket ims_qmid stream 0660 system radio
+    group radio net_raw log oem_2950
+
+service imsdatadaemon /system/bin/imsdatadaemon
+    class main
+    user system
+    socket ims_datad stream 0660 system radio
+    group system wifi radio inet net_raw log oem_2950 net_admin
+    disabled
+
+on property:sys.ims.QMI_DAEMON_STATUS=1
+    start imsdatadaemon
+
+service ims_rtp_daemon /system/bin/ims_rtp_daemon
+   class main
+   user system
+   socket ims_rtpd stream 0660 system radio
+   group radio net_raw diag oem_2950 log
+   disabled
+
+service imscmservice /system/bin/imscmservice
+   class main
+   user system
+   group radio net_raw diag oem_2950 log
+   disabled
+
+service ril-daemon1 /vendor/bin/hw/rild -c 2
+    class main
+    user radio
+    group radio cache inet misc audio log readproc wakelock oem_2950
+    capabilities BLOCK_SUSPEND NET_ADMIN NET_RAW
+
+on property:sys.ims.DATA_DAEMON_STATUS=1
+   start ims_rtp_daemon
+   start imscmservice
+
+service ppd /vendor/bin/mm-pp-daemon
+    class late_start
+    disabled
+    user system
+    socket pps stream 0660 system system
+    group system graphics
+
+on property:init.svc.surfaceflinger=stopped
+    stop ppd
+
+on property:init.svc.surfaceflinger=running
+    start ppd
+
+service charger /charger
+    class charger
+    critical
+    seclabel u:r:healthd:s0
+
+service TCMDServer /system/bin/TCMDServer
+    class main
+    group root
+    user root
+
+service loc_launcher /vendor/bin/loc_launcher
+    #loc_launcher will start as root and set its uid to gps
+    class late_start
+    group gps inet net_raw diag oem_2950 net_admin wifi
+
+service fm_dl /vendor/bin/init.qcom.fm.sh
+    class late_start
+    user root
+    group system
+    disabled
+    oneshot
diff --git a/root/init.qcom.usb.rc b/root/init.qcom.usb.rc
new file mode 100644
index 0000000..39175be
--- /dev/null
+++ b/root/init.qcom.usb.rc
@@ -0,0 +1,235 @@
+# Copyright (c) 2011-2012, Code Aurora Forum. 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 Code Aurora 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, 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.
+#
+
+on boot
+    write /sys/class/android_usb/android0/iSerial ${ro.serialno}
+    write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
+    write /sys/class/android_usb/android0/iProduct ${ro.product.model}
+    write /sys/class/android_usb/android0/f_rndis/manufacturer ${ro.product.manufacturer}
+    write /sys/class/android_usb/android0/f_rndis/vendorID 22D9
+    write /sys/class/android_usb/android0/f_rndis/wceis 1
+
+on post-fs
+    mkdir /dev/usb-ffs 0770 shell shell
+    mkdir /dev/usb-ffs/adb 0770 shell shell
+    mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
+    write /sys/class/android_usb/android0/f_ffs/aliases adb
+    setprop sys.usb.ffs.aio_compat 1
+
+on property:sys.usb.config=mtp
+    stop adbd
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 6764
+    write /sys/class/android_usb/android0/functions mtp
+    write /sys/class/android_usb/android0/enable 1
+    setprop sys.usb.state ${sys.usb.config}
+
+on property:sys.usb.config=mtp,adb
+    stop adbd
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 6765
+    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}
+
+on property:sys.usb.config=rndis,adb
+    stop adbd
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 6766
+    write /sys/class/android_usb/android0/functions rndis,adb
+    write /sys/class/android_usb/android0/enable 1
+    start adbd
+    setprop sys.usb.state ${sys.usb.config}
+
+on property:sys.usb.config=mass_storage,adb
+    stop adbd
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 6767
+    write /sys/class/android_usb/android0/functions adb,mass_storage
+    write /sys/class/android_usb/android0/enable 1
+    start adbd
+    setprop sys.usb.state ${sys.usb.config}
+
+on property:sys.usb.config=mass_storage
+    stop adbd
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 6768
+    write /sys/class/android_usb/android0/functions mass_storage
+    write /sys/class/android_usb/android0/enable 1
+    setprop sys.usb.state ${sys.usb.config}
+
+on property:sys.usb.config=adb
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 6769
+    write /sys/class/android_usb/android0/functions adb
+    write /sys/class/android_usb/android0/enable 1
+    start adbd
+    setprop sys.usb.state ${sys.usb.config}
+
+on property:sys.usb.config=rndis
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 676A
+    write /sys/class/android_usb/android0/functions rndis
+    write /sys/class/android_usb/android0/enable 1
+    setprop sys.usb.state ${sys.usb.config}
+
+on property:sys.usb.config=diag,adb
+    stop adbd
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/iSerial 0123456789ABCDEF
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 676C
+    write /sys/class/android_usb/android0/f_diag/clients diag
+    write /sys/class/android_usb/android0/f_serial/transports tty
+    write /sys/class/android_usb/android0/functions diag,adb
+    write /sys/class/android_usb/android0/enable 1
+    start adbd
+    setprop sys.usb.state ${sys.usb.config}
+
+on property:sys.usb.config=diag_mdm,adb
+    stop adbd
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/iSerial 0123456789ABCDEF
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 676D
+    write /sys/class/android_usb/android0/f_diag/clients diag_mdm
+    write /sys/class/android_usb/android0/f_serial/transports hsic
+    write /sys/class/android_usb/android0/f_rmnet/transports hsic,hsic
+    write /sys/class/android_usb/android0/functions diag,adb
+    write /sys/class/android_usb/android0/enable 1
+    start adbd
+    setprop sys.usb.state ${sys.usb.config}
+
+on property:sys.usb.config=diag,diag_mdm,serial_hsic,serial_tty,rmnet_hsic,mass_storage,adb
+    stop adbd
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/iSerial 0123456789ABCDEF
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 676F
+    write /sys/class/android_usb/android0/f_diag/clients diag,diag_mdm
+    write /sys/class/android_usb/android0/f_serial/transports hsic,tty
+    write /sys/class/android_usb/android0/f_serial/transport_names serial_hsic
+    write /sys/class/android_usb/android0/f_rmnet/transports hsic,hsic
+    write /sys/class/android_usb/android0/f_rmnet/transport_names rmnet_hsic
+    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet,mass_storage
+    write /sys/class/android_usb/android0/enable 1
+    start adbd
+    setprop sys.usb.state ${sys.usb.config}
+
+#added some configs for support ptp and cdrom by Xinhua.Song 2014-05-10
+on property:sys.usb.config=ptp
+    stop adbd
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 6771
+    write /sys/class/android_usb/android0/functions ptp
+    write /sys/class/android_usb/android0/enable 1
+    setprop sys.usb.state ${sys.usb.config}
+
+on property:sys.usb.config=ptp,adb
+    stop adbd
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 6772
+    write /sys/class/android_usb/android0/functions ptp,adb
+    write /sys/class/android_usb/android0/enable 1
+    start adbd
+    setprop sys.usb.state ${sys.usb.config}
+
+on property:sys.usb.config=mtp,mass_storage
+    stop adbd
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 6773
+    write /sys/class/android_usb/android0/functions mtp,mass_storage
+    write /sys/class/android_usb/android0/enable 1
+    setprop sys.usb.state ${sys.usb.config}
+
+on property:sys.usb.config=mtp,mass_storage,adb
+    stop adbd
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 6774
+    write /sys/class/android_usb/android0/functions mtp,mass_storage,adb
+    write /sys/class/android_usb/android0/enable 1
+    start adbd
+    setprop sys.usb.state ${sys.usb.config}
+
+#add a config for support rndis, diag and adb, added by Xinhua.Song 2014-05-10
+on property:sys.usb.config=rndis,diag,adb
+    stop adbd
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/iSerial 0123456789ABCDEF
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 6775
+    write /sys/class/android_usb/android0/f_diag/clients diag
+    write /sys/class/android_usb/android0/functions rndis,diag,adb
+    write /sys/class/android_usb/android0/enable 1
+    start adbd
+    setprop sys.usb.state ${sys.usb.config}
+
+# USB midi configuration
+on property:sys.usb.config=midi
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 6776
+    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}
+
+# USB midi configuration, with adb
+on property:sys.usb.config=midi,adb
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 6777
+    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}
+
+#add a config for default case by Xinhua.Song 2014-05-10
+on property:sys.usb.config=diag,serial_smd,serial_tty,rmnet_bam,mass_storage,adb
+    write /sys/class/android_usb/android0/enable 0
+    write /sys/class/android_usb/android0/iSerial 0123456789ABCDEF
+    write /sys/class/android_usb/android0/idVendor 05C6
+    write /sys/class/android_usb/android0/idProduct 9025
+    write /sys/class/android_usb/android0/f_diag/clients diag
+    write /sys/class/android_usb/android0/f_serial/transports smd,tty
+    write /sys/class/android_usb/android0/f_rmnet/transports smd,bam
+    write /sys/class/android_usb/android0/functions diag,adb,serial,rmnet,mass_storage
+    write /sys/class/android_usb/android0/enable 1
+    start adbd
+    setprop sys.usb.state ${sys.usb.config}
diff --git a/root/ueventd.qcom.rc b/root/ueventd.qcom.rc
new file mode 100644
index 0000000..0bec418
--- /dev/null
+++ b/root/ueventd.qcom.rc
@@ -0,0 +1,180 @@
+# Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in the
+#       documentation and/or other materials provided with the distribution.
+#     * Neither the name of The Linux Foundation nor
+#       the names of its contributors may be used to endorse or promote
+#       products derived from this software without specific prior written
+#       permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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.
+#
+
+# the DIAG device node is not world writable/readable.
+/dev/diag                 0660   system     oem_2950
+
+/dev/genlock              0666   system     system
+/dev/kgsl                 0666   system     system
+/dev/kgsl-3d0             0666   system     system
+/dev/kgsl-2d0             0666   root       root
+/dev/kgsl-2d1             0666   root       root
+/dev/ion                  0664   system     system
+/dev/rtc0                 0600   system     system
+/dev/smd0                 0660   system     system
+/dev/smd4                 0660   system     system
+/dev/smd_cxm_qmi          0640   radio      radio
+/dev/smd5                 0660   system     system
+/dev/smd6                 0660   system     system
+
+#permissions for CSVT
+/dev/smd11                0660   radio      radio
+
+/dev/radio0               0640   system     system
+/dev/smdcntl0             0640   radio      radio
+/dev/smdcntl1             0640   radio      radio
+/dev/smdcntl2             0640   radio      radio
+/dev/smdcntl3             0640   radio      radio
+/dev/smdcntl4             0640   radio      radio
+/dev/smdcntl5             0640   radio      radio
+/dev/smdcntl6             0640   radio      radio
+/dev/smdcntl7             0640   radio      radio
+/dev/smdcntl8             0640   radio      radio
+/dev/smdcntl9             0640   radio      radio
+/dev/smdcntl10            0640   radio      radio
+/dev/smdcntl11            0640   radio      radio
+/dev/smdcnt_rev0          0640   radio      radio
+/dev/smdcnt_rev1          0640   radio      radio
+/dev/smdcnt_rev2          0640   radio      radio
+/dev/smdcnt_rev3          0640   radio      radio
+/dev/smdcnt_rev4          0640   radio      radio
+/dev/smdcnt_rev5          0640   radio      radio
+/dev/smdcnt_rev6          0640   radio      radio
+/dev/smdcnt_rev7          0640   radio      radio
+/dev/smdcnt_rev8          0640   radio      radio
+/dev/smuxctl32            0640   radio      radio
+/dev/sdioctl0             0640   radio      radio
+/dev/sdioctl1             0640   radio      radio
+/dev/sdioctl2             0640   radio      radio
+/dev/sdioctl3             0640   radio      radio
+/dev/sdioctl4             0640   radio      radio
+/dev/sdioctl5             0640   radio      radio
+/dev/sdioctl6             0640   radio      radio
+/dev/sdioctl7             0640   radio      radio
+/dev/sdioctl8             0640   radio      radio
+/dev/rmnet_mux_ctrl       0640   radio      radio
+/dev/hsicctl0             0640   radio      radio
+/dev/hsicctl1             0640   radio      radio
+/dev/hsicctl2             0640   radio      radio
+/dev/hsicctl3             0640   radio      radio
+/dev/hsicctl4             0640   radio      radio
+/dev/hsicctl5             0640   radio      radio
+/dev/hsicctl6             0640   radio      radio
+/dev/hsicctl7             0640   radio      radio
+/dev/hsicctl8             0640   radio      radio
+/dev/hsicctl9             0640   radio      radio
+/dev/hsicctl10            0640   radio      radio
+/dev/hsicctl11            0640   radio      radio
+/dev/hsicctl12            0640   radio      radio
+/dev/hsicctl13            0640   radio      radio
+/dev/hsicctl14            0640   radio      radio
+/dev/hsicctl15            0640   radio      radio
+/dev/hsicctl16            0640   radio      radio
+/dev/video*               0660   system     camera
+/dev/media*               0660   system     camera
+/dev/v4l-subdev*          0660   system     camera
+/dev/qseecom              0660   system     drmrpc
+/dev/pft                  0660   system     drmrpc
+/dev/gemini0              0660   system     camera
+/dev/jpeg0                0660   system     camera
+/dev/jpeg1                0660   system     camera
+/dev/jpeg2                0660   system     camera
+/dev/adsprpc-smd          0660   system     media
+/dev/msm_camera/*         0660   system     camera
+/dev/gemini/              0660   system     camera
+/dev/mercury0             0660   system     camera
+/dev/msm_vidc_reg         0660   system     audio
+/dev/msm_vidc_dec         0660   system     audio
+/dev/msm_vidc_dec_sec     0660   system     audio
+/dev/msm_vidc_enc         0660   system     audio
+/dev/msm_rotator          0660   system     system
+
+#permissions for audio
+/dev/msm_qcelp            0660   system     audio
+/dev/msm_evrc             0660   system     audio
+/dev/msm_wma              0660   system     audio
+/dev/msm_wmapro           0660   system     audio
+/dev/msm_amrnb            0660   system     audio
+/dev/msm_amrwb            0660   system     audio
+/dev/msm_amrwbplus        0660   system     audio
+/dev/msm_aac              0660   system     audio
+/dev/msm_multi_aac        0660   system     audio
+/dev/msm_aac_in           0660   system     audio
+/dev/msm_qcelp_in         0660   system     audio
+/dev/msm_evrc_in          0660   system     audio
+/dev/msm_amrnb_in         0640   system     audio
+/dev/msm_a2dp_in          0660   system     audio
+/dev/msm_ac3              0660   system     audio
+/dev/msm_acdb             0660   system     audio
+/dev/msm_cad              0660   system     audio
+/dev/msm_fm               0660   system     audio
+/dev/msm_mvs              0660   system     audio
+/dev/msm_pcm_lp_dec       0660   system     audio
+/dev/msm_preproc_ctl      0660   system     audio
+/dev/msm_rtac             0660   system     audio
+/dev/msm_voicememo        0660   system     audio
+/dev/ttyHSL1              0660   system     system
+/dev/mdm                  0660   system     radio
+/sys/devices/virtual/smdpkt/smdcntl*       open_timeout   0664 radio radio
+/dev/sdio_tty_ciq_00      0660   system     system
+/dev/tty_sdio_00          0660   system     system
+/dev/ttyGS0               0660   system     system
+/dev/i2c-5                0660   media       media
+
+# DVB devices
+/dev/dvb/adapter0/demux*  0440   media       media
+/dev/dvb/adapter0/dvr*    0660   media       media
+/dev/dvb/adapter0/video*  0660   media       media
+
+# Broadcast devices
+/dev/tsc_mux0             0660   media       media
+/dev/tsc_ci0              0660   media       media
+
+# sensors
+/sys/devices/i2c-12/12-*  pollrate_ms 0664 system system
+/sys/devices/f9925000.i2c/i2c-0/0-* enable          0660     input     system
+/sys/devices/f9925000.i2c/i2c-0/0-* poll_delay      0660     input     system
+/sys/devices/virtual/optical_sensors/proximity      ps_adc         0660    input    system
+/sys/devices/virtual/optical_sensors/proximity      ps_poll_delay  0660    input    system
+/sys/devices/virtual/optical_sensors/lightsensor    ls_auto        0660    input    system
+/sys/devices/virtual/optical_sensors/lightsensor    ls_poll_delay  0660    input    system
+/sys/devices/virtual/input/input*                   poll           0660    input    system
+/sys/devices/virtual/input/input*                   pollrate_ms    0660    input    system
+
+# wlan
+/dev/wcnss_wlan           0660   system     system
+/dev/wcnss_ctrl           0660   system     system
+#nfc permissions
+/dev/nfc-nci              0660    nfc         nfc
+
+# UIO devices
+/dev/uio0                 0660   system     system
+/dev/uio1                 0660   system     system
+/dev/uio2                 0660   system     system
+
+# NFC
+/dev/pn544                0600   nfc        nfc
diff --git a/sepolicy/file.te b/sepolicy/file.te
new file mode 100644
index 0000000..3133932
--- /dev/null
+++ b/sepolicy/file.te
@@ -0,0 +1 @@
+type sensor_calibration_file, file_type;
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
new file mode 100644
index 0000000..e2a6e11
--- /dev/null
+++ b/sepolicy/file_contexts
@@ -0,0 +1,21 @@
+/dev/block/platform/msm_sdcc.1/by-name/pad                  u:object_r:misc_block_device:s0
+
+/persist/sns.reg                                            u:object_r:sensor_calibration_file:s0
+
+/sys/devices/leds-qpnp-(.*)?/leds(/.*)?                     u:object_r:sysfs_leds:s0
+/sys/devices/mdp(.*)/qcom,mdss_fb_primary(.*)/leds(/.*)?    u:object_r:sysfs_leds:s0
+
+/(vendor|system/vendor)/bin/init\.qcom\.fm\.sh              u:object_r:qti_init_shell_exec:s0
+
+/sys/devices/qpnp-bms-(.*)?/power_supply/bms(/.*)?                                   u:object_r:sysfs_battery_supply:s0
+
+# Light
+/(vendor|system/vendor)/bin/hw/android\.hardware\.light@2\.0-service.FP2            u:object_r:hal_light_default_exec:s0
+
+# USB HAL
+/(vendor|system/vendor)/bin/hw/android\.hardware\.usb@1\.0-service.basic       u:object_r:hal_usb_default_exec:s0
+
+# Power HAL
+/(vendor|system/vendor)/bin/hw/android\.hardware\.light@2\.0-service.FP2            u:object_r:hal_light_default_exec:s0
+
+/sys/devices/qpnp-bms-(.*)?/power_supply/bms(/.*)?                                   u:object_r:sysfs_battery_supply:s0
diff --git a/sepolicy/hal_light.te b/sepolicy/hal_light.te
new file mode 100644
index 0000000..b7c1835
--- /dev/null
+++ b/sepolicy/hal_light.te
@@ -0,0 +1,3 @@
+r_dir_file(hal_light, sysfs_graphics)
+allow hal_light sysfs_graphics:file rw_file_perms;
+
diff --git a/sepolicy/hal_light_default.te b/sepolicy/hal_light_default.te
new file mode 100644
index 0000000..ab61b20
--- /dev/null
+++ b/sepolicy/hal_light_default.te
@@ -0,0 +1,2 @@
+allow hal_light_default sysfs_graphics:file rw_file_perms;
+
diff --git a/sepolicy/hal_perf_default.te b/sepolicy/hal_perf_default.te
new file mode 100644
index 0000000..6aad79c
--- /dev/null
+++ b/sepolicy/hal_perf_default.te
@@ -0,0 +1,8 @@
+r_dir_file(hal_perf_default, hal_power_default)
+~
+~
+~
+~
+~
+~
+
diff --git a/sepolicy/hal_power.te b/sepolicy/hal_power.te
new file mode 100644
index 0000000..3239a54
--- /dev/null
+++ b/sepolicy/hal_power.te
@@ -0,0 +1,21 @@
+type hal_power, domain, coredomain;
+
+init_daemon_domain(hal_power)
+
+typeattribute hal_power_default data_between_core_and_vendor_violators;
+
+domain_auto_trans(init, hal_power_default_exec, hal_power)
+
+allow hal_power perfd:unix_stream_socket connectto;
+allow hal_power perfd_data_file:dir search;
+allow hal_power perfd_data_file:sock_file write;
+
+allow hal_power sysfs_soc:dir search;
+allow hal_power sysfs_soc:file { open read };
+
+# debugfs entries are only needed in user-debug or eng builds
+allow hal_power debugfs_rpm:file r_file_perms;
+
+allow hal_power debugfs_wlan:dir r_dir_perms;
+allow hal_power debugfs_wlan:file r_file_perms;
+
diff --git a/sepolicy/hal_power_default.te b/sepolicy/hal_power_default.te
new file mode 100644
index 0000000..7e14fbb
--- /dev/null
+++ b/sepolicy/hal_power_default.te
@@ -0,0 +1,32 @@
+allow hal_power_default debugfs_rpm:file { open read getattr };
+
+allow hal_power_default mpctl_socket:dir search;
+allow hal_power_default mpctl_socket:sock_file write;
+
+allow hal_power_default mpdecision:unix_stream_socket connectto;
+allow hal_power_default perfd:unix_stream_socket connectto;
+
+
+allow hal_power_default sysfs_graphics:dir search;
+allow hal_power_default sysfs_graphics:file r_file_perms;
+
+allow hal_power_default debugfs_rpm:file r_file_perms;
+
+allow hal_power_default debugfs_wlan:dir r_dir_perms;
+allow hal_power_default debugfs_wlan:file r_file_perms;
+
+allow hal_power_default sysfs_easel:dir search;
+allow hal_power_default sysfs_easel:file r_file_perms;
+
+
+# To do powerhint on nodes defined in powerhint.json
+allow hal_power_default sysfs_msm_subsys:dir search;
+allow hal_power_default sysfs_msm_subsys:file rw_file_perms;
+allow hal_power_default sysfs_devices_system_cpu:file rw_file_perms;
+allow hal_power_default latency_device:chr_file rw_file_perms;
+allow hal_power_default cgroup:dir search;
+allow hal_power_default cgroup:file rw_file_perms;
+
+# To get/set powerhal state property
+set_prop(hal_power_default, power_prop)
+
diff --git a/sepolicy/hal_power_default_exec.te b/sepolicy/hal_power_default_exec.te
new file mode 100644
index 0000000..2962e30
--- /dev/null
+++ b/sepolicy/hal_power_default_exec.te
@@ -0,0 +1,5 @@
+
+allow hal_power_default_exec init:fd use;
+allow hal_power_default_exec null_device:chr_file { read write };
+allow hal_power_default_exec vendor_file:file entrypoint;
+
diff --git a/sepolicy/hwservice_contexts b/sepolicy/hwservice_contexts
new file mode 100644
index 0000000..37fb82f
--- /dev/null
+++ b/sepolicy/hwservice_contexts
@@ -0,0 +1 @@
+vendor.lineage.power::ILineagePower                                     u:object_r:hal_power_hwservice:s0
diff --git a/sepolicy/init.te b/sepolicy/init.te
new file mode 100644
index 0000000..2b3088d
--- /dev/null
+++ b/sepolicy/init.te
@@ -0,0 +1,5 @@
+# Allow init to write in debugfs
+allow init debugfs:file write;
+
+allow init hal_power_default_exec:process { rlimitinh transition };
+
diff --git a/sepolicy/mm-qcamerad.te b/sepolicy/mm-qcamerad.te
new file mode 100644
index 0000000..c347485
--- /dev/null
+++ b/sepolicy/mm-qcamerad.te
@@ -0,0 +1,2 @@
+allow mm-qcamerad system_data_file:dir w_dir_perms;
+
diff --git a/sepolicy/perfd.te b/sepolicy/perfd.te
new file mode 100644
index 0000000..cfeb233
--- /dev/null
+++ b/sepolicy/perfd.te
@@ -0,0 +1,60 @@
+type perfd, domain;
+type perfd_exec, exec_type, vendor_file_type, file_type;
+
+init_daemon_domain(perfd)
+
+allow perfd self:capability { fsetid kill };
+
+allow perfd {
+    sysfs_devices_system_cpu
+    sysfs_cpu_online
+    sysfs_scsi_host
+    proc
+    sysfs
+}:file rw_file_perms;
+
+# Allow access to devfreq sysfs entry
+r_dir_file(perfd, sysfs_devfreq)
+allow perfd sysfs_devfreq:file write;
+
+# Allow access to msm_perf sysfs entry
+r_dir_file(perfd, sysfs_msm_perf)
+allow perfd sysfs_msm_perf:file write;
+
+# Allow access to msm_power sysfs entry
+r_dir_file(perfd, sysfs_msm_power)
+allow perfd sysfs_msm_power:file write;
+
+# Allow access to lib sysfs entry
+allow perfd sysfs_lib:file w_file_perms;
+
+# Allow access to kgsl sysfs entry
+r_dir_file(perfd, sysfs_kgsl)
+allow perfd sysfs_kgsl:file write;
+
+# Allow access to thermal sysfs entry
+allow perfd sysfs_thermal:dir search;
+allow perfd sysfs_thermal:file w_file_perms;
+
+# mpctl socket
+allow perfd mpctl_socket:dir rw_dir_perms;
+allow perfd mpctl_socket:sock_file create_file_perms;
+
+# default_values file
+allow perfd mpctl_data_file:dir rw_dir_perms;
+allow perfd mpctl_data_file:file create_file_perms;
+
+# Thermal lib access
+unix_socket_connect(perfd, thermal, thermal-engine)
+
+
+# Allow perfd to check for existence of other processes
+allow perfd domain:process signull;
+
+# Allow perfd to set properties
+set_prop(perfd, freq_prop)
+
+allow perfd cgroup:file r_file_perms;
+allow perfd sysfs:dir r_dir_perms;
+
+r_dir_file(perfd, hal_power_default)
diff --git a/sepolicy/system_app.te b/sepolicy/system_app.te
new file mode 100644
index 0000000..821d1c4
--- /dev/null
+++ b/sepolicy/system_app.te
@@ -0,0 +1,2 @@
+allow system_app sensor_calibration_file:file rw_file_perms;
+allow system_app sensors:unix_stream_socket connectto;
diff --git a/sepolicy/system_server.te b/sepolicy/system_server.te
new file mode 100644
index 0000000..c86acf7
--- /dev/null
+++ b/sepolicy/system_server.te
@@ -0,0 +1,2 @@
+# OTA with encrypted f2fs
+allow system_server ota_package_file:dir getattr;
diff --git a/sepolicy/uncrypt.te b/sepolicy/uncrypt.te
new file mode 100644
index 0000000..3ad9604
--- /dev/null
+++ b/sepolicy/uncrypt.te
@@ -0,0 +1,2 @@
+# OTA with encrypted f2fs
+allow uncrypt self:capability fowner;
diff --git a/system.prop b/system.prop
index e4c757c..957e9e7 100644
--- a/system.prop
+++ b/system.prop
@@ -1,53 +1,26 @@
 #
-# system.prop for FP2
+# system.prop for msm8974
 #
 
-# Audio
-dev.pm.dyn_samplingrate=1
-qcom.hw.aac.encoder=true
-ro.config.media_vol_steps=25
-ro.config.vc_call_vol_steps=7
+rild.libpath=/vendor/lib/libril-qc-qmi-1.so
+rild.libargs=-d /dev/smd0
+persist.rild.nitz_plmn=
+persist.rild.nitz_long_ons_0=
+persist.rild.nitz_long_ons_1=
+persist.rild.nitz_long_ons_2=
+persist.rild.nitz_long_ons_3=
+persist.rild.nitz_short_ons_0=
+persist.rild.nitz_short_ons_1=
+persist.rild.nitz_short_ons_2=
+persist.rild.nitz_short_ons_3=
+# ril.subscription.types=NV,RUIM
+DEVICE_PROVISIONED=1
+# Start in global mode
+ro.telephony.default_network=9
 
-# Bluetooth
-bluetooth.hfp.client=1
-ro.bluetooth.alwaysbleon=true
-vendor.qcom.bluetooth.soc=pronto
-ro.bluetooth.hfp.ver=1.7
-ro.qualcomm.bt.hci_transport=smd
-ro.bluetooth.dun=false
-ro.bluetooth.sap=false
-
-# Cabl
-ro.qualcomm.cabl=1
-
-# Camera
-ro.qc.sdk.camera.facialproc=false
-ro.qc.sdk.gestures.camera=false
-ro.qc.sdk.sensors.gestures=true
-# Enable tintless rolloff for camera
-persist.camera.tintless=enable
-
-# Dalvik heap
-dalvik.vm.heapstartsize=16m
-dalvik.vm.heapgrowthlimit=192m
-dalvik.vm.heapsize=512m
-dalvik.vm.heaptargetutilization=0.75
-dalvik.vm.heapminfree=2m
-dalvik.vm.heapmaxfree=8m
-
-# Display
-ro.sf.lcd_density=440
-
-# GPS
-persist.gps.qc_nlp_in_use=0
-ro.gps.agps_provider=1
-
-# Graphics
-debug.composition.type=c2d
-debug.egl.hw=1
-debug.hwui.use_buffer_age=false
 debug.sf.hw=1
-persist.demo.hdmirotationlock=false
+debug.egl.hw=1
+debug.composition.type=c2d
 persist.hwc.mdpcomp.enable=true
 debug.mdpcomp.idletime=9000
 debug.mdpcomp.4k2kSplit=1
@@ -63,94 +36,51 @@
 #
 persist.cne.feature=1
 
-# Graphics: OpenGL ES
-# 131072 is decimal for 0x20001 to report version 2.0
-# 196608 is decimal for 0x30000 to report version 3.0
-# 196609 is decimal for 0x30001 to report version 3.1
-ro.opengles.version=131072
+#system props for the MM modules
 
-# HWUI properties
-ro.hwui.drop_shadow_cache_size=6
-ro.hwui.gradient_cache_size=1
-ro.hwui.layer_cache_size=48
-ro.hwui.path_cache_size=32
-ro.hwui.r_buffer_cache_size=8
-ro.hwui.text_large_cache_height=1024
-ro.hwui.text_large_cache_width=2048
-ro.hwui.text_small_cache_height=1024
-ro.hwui.text_small_cache_width=1024
-ro.hwui.texture_cache_flushrate=0.4
-ro.hwui.texture_cache_size=72
-
-# Media
-vendor.audio.offload.buffer.size.kb=32
-debug.mdpcomp.4k2kSplit=1
-debug.mdpcomp.idletime=9000
-debug.mdpcomp.logs=0
-media.aac_51_output_enabled=true
-media.stagefright.enable-aac=true
-media.stagefright.enable-fma2dp=true
-media.stagefright.enable-http=true
 media.stagefright.enable-player=true
 media.stagefright.enable-http=true
 media.stagefright.enable-aac=true
 media.stagefright.enable-qcp=true
 media.stagefright.enable-fma2dp=true
 media.stagefright.enable-scan=true
-media.stagefright.use-awesome=true
-# 37491 is decimal sum of supported codecs in AAL
-# codecs: AVI AC3 ASF AAC QCP DTS 3G2 MP2TS
-mm.enable.qcom_parser=37491
-mm.enable.smoothstreaming=true
 mmp.enable.3g2=true
-ro.media.maxmem=1451891712
+mm.enable.smoothstreaming=true
+media.aac_51_output_enabled=true
+#37491 is decimal sum of supported codecs in AAL
+#codecs: AVI AC3 ASF AAC QCP DTS 3G2 MP2TS
+mm.enable.qcom_parser=37491
+
+# Default to AwesomePlayer
+media.stagefright.use-awesome=true
+
+# VIDC: debug_levels
 # 1:ERROR 2:HIGH 4:LOW 0:NOLOGS 7:AllLOGS
 vidc.debug.level=1
-
-# Memory optimizations
-ro.vendor.qti.am.reschedule_service=true
-ro.vendor.qti.sys.fw.bservice_enable=true
-
-# Network
-persist.cne.feature=1
+#
+# system props for the data modules
+#
+ro.use_data_netmgrd=true
 persist.data.netmgrd.qos.enable=true
 ro.data.large_tcp_window_size=true
-ro.use_data_netmgrd=true
 
-# Radio
-DEVICE_PROVISIONED=1
-persist.radio.apm_sim_not_pwdn=1
-persist.radio.multisim.config=dsds
-rild.libargs=-d /dev/smd0
-rild.libpath=/vendor/lib/libril-wrapper.so
-# Start in global mode
-ro.telephony.default_network=9,9
-telephony.lteOnGsmDevice=1
-
-# Time services
+#system props for time-services
 persist.timed.enable=true
 
-# Perfd
-ro.vendor.extension_library=libqti-perfd-client.so
+#
+# system prop for opengles version
+#
+# 196608 is decimal for 0x30000 to report version 3
+ro.opengles.version=196608
 
-# Wifi
-wifi.interface=wlan0
+# System property for cabl
+ro.qualcomm.cabl=1
 
 #
 # System props for telephony
 # System prop to turn on CdmaLTEPhone always
 telephony.lteOnCdmaDevice=0
 
-#
-# System props for bluetooth
-# System prop to turn on hfp client
-bluetooth.hfp.client=1
-
-#
-# System props for bluetooth LE Always on feature
-#
-ro.bluetooth.alwaysbleon=true
-
 #Simulate sdcard on /data/media
 #
 persist.fuse_sdcard=true
@@ -212,4 +142,3 @@
 
 #enable tintless rolloff for camera
 persist.camera.tintless=enable
-
diff --git a/vold.fstab b/vold.fstab
new file mode 100644
index 0000000..5bb6e6a
--- /dev/null
+++ b/vold.fstab
@@ -0,0 +1,29 @@
+# Copyright (c) 2011, 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.
+
+dev_mount sdcard /storage/sdcard1 auto /devices/msm_sdcc.2/mmc_host
+dev_mount usbotg /storage/usbotg auto /devices/platform/xhci-hcd/usb1
diff --git a/whitelist_appops.xml b/whitelist_appops.xml
new file mode 100644
index 0000000..8b5d823
--- /dev/null
+++ b/whitelist_appops.xml
@@ -0,0 +1,61 @@
+<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
+<!--
+/* 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.
+ */
+-->
+<whitelist-pkgs>
+<pkg name="android.process.acore"/>
+<pkg name="com.android.inputmethod.latin"/>
+<pkg name="com.google.process.location"/>
+<pkg name="com.qualcomm.services.location"/>
+<pkg name="com.android.launcher"/>
+<pkg name="com.google.process.gapps"/>
+<pkg name="com.google.android.apps.maps:GoogleLocationService"/>
+<pkg name="com.qualcomm.simcontacts"/>
+<pkg name="com.android.music"/>
+<pkg name="com.google.android.music:main"/>
+<pkg name="com.qualcomm.listen.voicewakeup"/>
+<pkg name="com.android.calendar"/>
+<pkg name="com.google.android.calendar"/>
+<pkg name="com.qualcomm.gesturetouchinjectionservice"/>
+<pkg name="com.android.vending"/>
+<pkg name="com.android.deskclock"/>
+<pkg name="com.android.providers.calendar"/>
+<pkg name="com.android.mms"/>
+<pkg name="android.process.media"/>
+<pkg name="com.quicinc.CrashLogger"/>
+<pkg name="com.android.musicfx"/>
+<pkg name="com.google.android.gallery3d"/>
+<pkg name="com.google.android.apps.uploader"/>
+<pkg name="com.google.android.apps.plus"/>
+<pkg name="com.google.android.youtube"/>
+<pkg name="com.qualcomm.timeservice"/>
+<pkg name="com.google.android.syncadapters.contacts"/>
+<pkg name="com.android.dialer"/>
+<pkg name="com.android.systemui"/>
+</whitelist-pkgs>