Merge branch 'cm-12.1' of https://github.com/vince2678/android_device_samsung_gprimeltecan into cm-12.1
diff --git a/Android.mk b/Android.mk
index 645ef78..0b38ad7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -7,67 +7,67 @@
 
 include $(CLEAR_VARS)
 
-# AiO /firmware
-FIRMWARE_IMAGES := \
-    cmnlib.b00 cmnlib.b01 cmnlib.b02 cmnlib.b03 cmnlib.mdt \
-    dmverity.b00 dmverity.b01 dmverity.b02 dmverity.b03 dmverity.mdt \
-    isdbtmm.b00 isdbtmm.b01 isdbtmm.b02 isdbtmm.b03 isdbtmm.mdt \
-    keymaste.b00 keymaste.b01 keymaste.b02 keymaste.b03 keymaste.mdt \
-    playread.b00 playread.b01 playread.b02 playread.b03 playread.mdt \
-    prov.b00 prov.b01 prov.b02 prov.b03 prov.mdt \
-    reactive.b00 reactive.b01 reactive.b02 reactive.b03 reactive.mdt \
-    sec_stor.b00 sec_stor.b01 sec_stor.b02 sec_stor.b03 sec_stor.mdt \
-    skm.b00 skm.b01 skm.b02 skm.b03 skm.mdt \
-    skmm_ta.b00 skmm_ta.b01 skmm_ta.b02 skmm_ta.b03 skmm_ta.mdt \
-    sshdcpap.b00 sshdcpap.b01 sshdcpap.b02 sshdcpap.b03 sshdcpap.mdt \
-    tbase.b00 tbase.b01 tbase.b02 tbase.b03 tbase.mdt \
-    tima_atn.b00 tima_atn.b01 tima_atn.b02 tima_atn.b03 tima_atn.mdt \
-    tima_key.b00 tima_key.b01 tima_key.b02 tima_key.b03 tima_key.mdt \
-    tima_lkm.b00 tima_lkm.b01 tima_lkm.b02 tima_lkm.b03 tima_lkm.mdt \
-    tima_pkm.b00 tima_pkm.b01 tima_pkm.b02 tima_pkm.b03 tima_pkm.mdt \
-    tz_ccm.b00 tz_ccm.b01 tz_ccm.b02 tz_ccm.b03 tz_ccm.mdt \
-    tz_otp.b00 tz_otp.b01 tz_otp.b02 tz_otp.b03 tz_otp.mdt \
-    venus.b00 venus.b01 venus.b02 venus.b03 venus.b04 venus.mdt \
-    wcnss.b00 wcnss.b01 wcnss.b02 wcnss.b04 wcnss.b06 wcnss.b09 wcnss.b10 wcnss.b11 wcnss.mdt \
-    widevine.b00 widevine.b01 widevine.b02 widevine.b03 widevine.mdt \
+## AiO /firmware
+#FIRMWARE_IMAGES := \
+#    cmnlib.b00 cmnlib.b01 cmnlib.b02 cmnlib.b03 cmnlib.mdt \
+#    dmverity.b00 dmverity.b01 dmverity.b02 dmverity.b03 dmverity.mdt \
+#    isdbtmm.b00 isdbtmm.b01 isdbtmm.b02 isdbtmm.b03 isdbtmm.mdt \
+#    keymaste.b00 keymaste.b01 keymaste.b02 keymaste.b03 keymaste.mdt \
+#    playread.b00 playread.b01 playread.b02 playread.b03 playread.mdt \
+#    prov.b00 prov.b01 prov.b02 prov.b03 prov.mdt \
+#    reactive.b00 reactive.b01 reactive.b02 reactive.b03 reactive.mdt \
+#    sec_stor.b00 sec_stor.b01 sec_stor.b02 sec_stor.b03 sec_stor.mdt \
+#    skm.b00 skm.b01 skm.b02 skm.b03 skm.mdt \
+#    skmm_ta.b00 skmm_ta.b01 skmm_ta.b02 skmm_ta.b03 skmm_ta.mdt \
+#    sshdcpap.b00 sshdcpap.b01 sshdcpap.b02 sshdcpap.b03 sshdcpap.mdt \
+#    tbase.b00 tbase.b01 tbase.b02 tbase.b03 tbase.mdt \
+#    tima_atn.b00 tima_atn.b01 tima_atn.b02 tima_atn.b03 tima_atn.mdt \
+#    tima_key.b00 tima_key.b01 tima_key.b02 tima_key.b03 tima_key.mdt \
+#    tima_lkm.b00 tima_lkm.b01 tima_lkm.b02 tima_lkm.b03 tima_lkm.mdt \
+#    tima_pkm.b00 tima_pkm.b01 tima_pkm.b02 tima_pkm.b03 tima_pkm.mdt \
+#    tz_ccm.b00 tz_ccm.b01 tz_ccm.b02 tz_ccm.b03 tz_ccm.mdt \
+#    tz_otp.b00 tz_otp.b01 tz_otp.b02 tz_otp.b03 tz_otp.mdt \
+#    venus.b00 venus.b01 venus.b02 venus.b03 venus.b04 venus.mdt \
+#    wcnss.b00 wcnss.b01 wcnss.b02 wcnss.b04 wcnss.b06 wcnss.b09 wcnss.b10 wcnss.b11 wcnss.mdt \
+#    widevine.b00 widevine.b01 widevine.b02 widevine.b03 widevine.mdt \
 
-FIRMWARE_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(FIRMWARE_IMAGES)))
-$(FIRMWARE_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
-	@echo "Firmware link: $@"
-	@mkdir -p $(dir $@)
-	@rm -rf $@
-	$(hide) ln -sf /firmware/image/$(notdir $@) $@
+#FIRMWARE_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(FIRMWARE_IMAGES)))
+#$(FIRMWARE_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
+#	@echo "Firmware link: $@"
+#	@mkdir -p $(dir $@)
+#	@rm -rf $@
+#	$(hide) ln -sf /firmware/image/$(notdir $@) $@
 
-ALL_DEFAULT_INSTALLED_MODULES += $(FIRMWARE_SYMLINKS)
+#ALL_DEFAULT_INSTALLED_MODULES += $(FIRMWARE_SYMLINKS)
 
-# /firmware-modem
-FIRMWARE_MODEM_IMAGES := \
-    mba.mbn modem.b00 modem.b01 modem.b02 modem.b03 modem.b04 \
-    modem.b05 modem.b06 modem.b07 modem.b08 modem.b10 modem.b11 \
-    modem.b14 modem.b15 modem.b16 modem.b17 modem.b18 modem.b19 \
-    modem.b20 modem.b23 modem.b24 modem.b25 modem.b27 modem.b28 \
-    modem.mdt
+## /firmware-modem
+#FIRMWARE_MODEM_IMAGES := \
+#    mba.mbn modem.b00 modem.b01 modem.b02 modem.b03 modem.b04 \
+#    modem.b05 modem.b06 modem.b07 modem.b08 modem.b10 modem.b11 \
+#    modem.b14 modem.b15 modem.b16 modem.b17 modem.b18 modem.b19 \
+#    modem.b20 modem.b23 modem.b24 modem.b25 modem.b27 modem.b28 \
+#    modem.mdt
 
-FIRMWARE_MODEM_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(FIRMWARE_MODEM_IMAGES)))
-$(FIRMWARE_MODEM_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
-	@echo "Firmware Modem link: $@"
-	@mkdir -p $(dir $@)
-	@rm -rf $@
-	$(hide) ln -sf /firmware-modem/image/$(notdir $@) $@
+#FIRMWARE_MODEM_SYMLINKS := $(addprefix $(TARGET_OUT_ETC)/firmware/,$(notdir $(FIRMWARE_MODEM_IMAGES)))
+#$(FIRMWARE_MODEM_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
+#	@echo "Firmware Modem link: $@"
+#	@mkdir -p $(dir $@)
+#	@rm -rf $@
+#	$(hide) ln -sf /firmware-modem/image/$(notdir $@) $@
 
-ALL_DEFAULT_INSTALLED_MODULES += $(FIRMWARE_MODEM_SYMLINKS)
+#ALL_DEFAULT_INSTALLED_MODULES += $(FIRMWARE_MODEM_SYMLINKS)
 
 # Create links for audcal data files
 $(shell mkdir -p $(TARGET_OUT)/vendor/firmware/keymaster; \
-    ln -sf /firmware/image/keymaste.b00 \
+    ln -sf /etc/firmware/keymaste.b00 \
     $(TARGET_OUT)/vendor/firmware/keymaster/keymaster.b00; \
-    ln -sf /firmware/image/keymaste.b01 \
+    ln -sf /etc/firmware/keymaste.b01 \
     $(TARGET_OUT)/vendor/firmware/keymaster/keymaster.b01; \
-    ln -sf /firmware/image/keymaste.b02 \
+    ln -sf /etc/firmware/keymaste.b02 \
     $(TARGET_OUT)/vendor/firmware/keymaster/keymaster.b02; \
-    ln -sf /firmware/image/keymaste.b03 \
+    ln -sf /etc/firmware/keymaste.b03 \
     $(TARGET_OUT)/vendor/firmware/keymaster/keymaster.b03; \
-    ln -sf /firmware/image/keymaste.mdt \
+    ln -sf /etc/firmware/keymaste.mdt \
     $(TARGET_OUT)/vendor/firmware/keymaster/keymaster.mdt)
 
 #Create link for wifi config
diff --git a/BoardConfig.mk b/BoardConfig.mk
index 3f6cdb2..f5bab2f 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -162,10 +162,10 @@
     file.te \
     healthd.te \
     qseecomd.te \
-    misc.te \
     surfaceflinger.te \
     system_server.te \
     wcnss_service.te \
+    misc.te \
     file_contexts \
     property_contexts
 
diff --git a/device.mk b/device.mk
index e0fa131..eff0086 100644
--- a/device.mk
+++ b/device.mk
@@ -147,7 +147,15 @@
 # GPS
 PRODUCT_PACKAGES += \
     gps.msm8916 \
-    gps.default
+    gps.default \
+    libloc_core \
+    libgps.utils \
+    libloc_eng \
+    libloc_api_v02
+
+#Sensors
+PRODUCT_PACKAGES += \
+    sensors.default
 
 PRODUCT_COPY_FILES += \
     $(LOCAL_PATH)/gps/flp.conf:system/etc/flp.conf \
@@ -197,9 +205,6 @@
     libstagefrighthw \
     qcmediaplayer
 
-# Overlay
-DEVICE_PACKAGE_OVERLAYS += $(LOCAL_PATH)/overlay
-
 # Permissions
 PRODUCT_COPY_FILES += \
     frameworks/native/data/etc/android.hardware.audio.low_latency.xml:system/etc/permissions/android.hardware.audio.low_latency.xml \
diff --git a/rootdir/etc/init.rc b/rootdir/etc/init.rc
index 7baedbd..ddb6b54 100644
--- a/rootdir/etc/init.rc
+++ b/rootdir/etc/init.rc
@@ -74,6 +74,7 @@
     write /sys/fs/cgroup/memory/sw/memory.move_charge_at_immigrate 1
     chown root system /sys/fs/cgroup/memory/sw/tasks
     chmod 0660 /sys/fs/cgroup/memory/sw/tasks
+    chmod 0220 /sys/fs/cgroup/memory/cgroup.event_control
 
     mkdir /system
     mkdir /data 0771 system system
@@ -138,7 +139,7 @@
     chmod 0660 /dev/cpuctl/tasks
     write /dev/cpuctl/cpu.shares 1024
     write /dev/cpuctl/cpu.rt_runtime_us 950000
-    write /dev/cpuctl/cpu.rt_period_us 1000000
+    write /dev/cpuctl/cpu.rt_period_us 1000000  
 
     mkdir /dev/cpuctl/apps
     chown system system /dev/cpuctl/apps/tasks
@@ -154,6 +155,24 @@
     write /dev/cpuctl/apps/bg_non_interactive/cpu.shares 52
     write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_runtime_us 700000
     write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_period_us 1000000
+    
+    # Create cgroup mount points for process groups
+    mkdir /dev/cpuctl
+    mount cgroup none /dev/cpuctl cpu
+    chown system system /dev/cpuctl
+    chown system system /dev/cpuctl/tasks
+    chmod 0666 /dev/cpuctl/tasks
+    write /dev/cpuctl/cpu.shares 1024
+    write /dev/cpuctl/cpu.rt_runtime_us 800000
+    write /dev/cpuctl/cpu.rt_period_us 1000000
+
+    mkdir /dev/cpuctl/bg_non_interactive
+    chown system system /dev/cpuctl/bg_non_interactive/tasks
+    chmod 0666 /dev/cpuctl/bg_non_interactive/tasks
+    # 5.0 %
+    write /dev/cpuctl/bg_non_interactive/cpu.shares 52
+    write /dev/cpuctl/bg_non_interactive/cpu.rt_runtime_us 700000
+    write /dev/cpuctl/bg_non_interactive/cpu.rt_period_us 1000000
 
     # qtaguid will limit access to specific data based on group memberships.
     #   net_bw_acct grants impersonation of socket owners.
@@ -200,6 +219,21 @@
     # issued fs triggers have completed.
     trigger load_all_props_action
 
+	modprobe ansi_cprng
+	modprobe core_ctl
+	modprobe dma_test
+	modprobe evbug
+	modprobe gator
+	modprobe mmc_block_test
+	modprobe mmc_test
+	modprobe msm-buspm-dev
+	modprobe oprofile
+	modprobe radio-iris-transport
+	modprobe spidev
+	modprobe tcp_htcp
+	modprobe tcp_westwood
+	modprobe test-iosched
+
     # Remove a file to wake up anything waiting for firmware.
     trigger firmware_mounts_complete
 
diff --git a/sepolicy/misc.te b/sepolicy/misc.te
index d9be616..061b2d7 100644
--- a/sepolicy/misc.te
+++ b/sepolicy/misc.te
@@ -1,5 +1,3 @@
-
-
 #============= init_shell ==============
 allow init_shell bluetooth_loader_exec:file execute_no_trans;
 
@@ -10,11 +8,11 @@
 allow mediaserver sysfs_wake_lock:file { read write };
 
 #============= mm-qcamerad ==============
-allow mm-qcamerad sysfs:file write;
+allow mm-qcamerad sysfs:file { read write };
 allow mm-qcamerad system_data_file:sock_file { create unlink };
 
 #============= rild ==============
-allow rild proc_net:file write;
+allow rild proc_net:file { read write };
 
 #============= shell ==============
 allow shell block_device:dir search;
@@ -27,4 +25,4 @@
 allow ueventd vfat:dir search;
 
 #============= wcnss_service ==============
-allow wcnss_service system_data_file:dir write;
+allow wcnss_service system_data_file:dir { read write };