Snap for 4518400 from 872a4b3f2cba32121e3ba5c928ccc835f0d13578 to pi-release

Change-Id: Id9245e04af806eb0aaf153ecfda8a5595650bd4a
diff --git a/advancedFeatures.ini b/advancedFeatures.ini
new file mode 100644
index 0000000..29c1cf7
--- /dev/null
+++ b/advancedFeatures.ini
@@ -0,0 +1,6 @@
+GrallocSync = on
+LogcatPipe = on
+GLAsyncSwap = on
+GLESDynamicVersion = on
+GLDMA = on
+SystemAsRoot = on
diff --git a/fstab.ranchu b/fstab.ranchu
index cff906f..3eed0be 100644
--- a/fstab.ranchu
+++ b/fstab.ranchu
@@ -2,7 +2,5 @@
 #<src>                                                  <mnt_point>         <type>    <mnt_flags and options>                              <fs_mgr_flags>
 # The filesystem that contains the filesystem checker binary (typically /system) cannot
 # specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
-/dev/block/vda    /system             ext4      ro                                                    wait
-/dev/block/vdb    /cache              ext4      noatime,nosuid,nodev,nomblk_io_submit,errors=panic    wait
-/dev/block/vdc    /data               ext4      noatime,nosuid,nodev,nomblk_io_submit,errors=panic    wait
-#/devices/platform/goldfish_mmc.0                        auto                vfat      defaults                                             voldmanaged=sdcard:auto
+/dev/block/vdc                                          /data               ext4      noatime,nosuid,nodev,nomblk_io_submit,errors=panic   wait,check
+/devices/*/block/vde                                    auto                auto      defaults                                             voldmanaged=sdcard:auto,encryptable=userdata
diff --git a/init.ranchu.rc b/init.ranchu.rc
index c1c410a..9cc1a8a 100644
--- a/init.ranchu.rc
+++ b/init.ranchu.rc
@@ -1,26 +1,26 @@
 on fs
-        mount_all /fstab.ranchu
+    mount_all /fstab.ranchu
 
 on early-init
-    mount debugfs debugfs /sys/kernel/debug
+    mount debugfs debugfs /sys/kernel/debug mode=755
 
 on init
-    # See storage config details at http://source.android.com/tech/storage/
-    mkdir /storage/sdcard 0555 root root
 
-    export EXTERNAL_STORAGE /storage/sdcard
+    symlink /dev/goldfish_pipe /dev/android_pipe
+    symlink /dev/goldfish_pipe /dev/qemu_pipe
 
-    #symlink /storage/sdcard /sdcard
-    #symlink /storage/sdcard /mnt/sdcard
+on post-fs-data
+    setprop vold.post_fs_data_done 1
+
 
 on boot
-    setprop ARGH ARGH
-    setprop net.eth0.gw 10.0.2.2
-    setprop net.eth0.dns1 10.0.2.3
-    setprop net.gprs.local-ip 10.0.2.15
+    chown root system /sys/power/wake_lock
+    chown root system /sys/power/wake_unlock
     setprop ro.radio.use-ppp no
     setprop ro.build.product generic
     setprop ro.product.device generic
+    setprop ro.hardware.audio.primary goldfish
+    setprop ro.setupwizard.mode EMULATOR
 
 # fake some battery state
     setprop status.battery.state Slow
@@ -28,18 +28,91 @@
     setprop status.battery.level_raw  50
     setprop status.battery.level_scale 9
 
-# Disable GPU support
-    setprop ro.kernel.qemu 1
-    setprop ro.kernel.qemu.gles 0
-
-# disable RenderScript
-    setprop config.disable_renderscript 1
+# set up the GPU caching
+    setprop ro.hwui.texture_cache_size 72
+    setprop ro.hwui.layer_cache_size 48
+    setprop ro.hwui.r_buffer_cache_size 8
+    setprop ro.hwui.path_cache_size 32
+    setprop ro.hwui.gradient_cache_size 1
+    setprop ro.hwui.drop_shadow_cache_size 6
+    setprop ro.hwui.texture_cache_flushrate 0.4
+    setprop ro.hwui.text_small_cache_width 1024
+    setprop ro.hwui.text_small_cache_height 1024
+    setprop ro.hwui.text_large_cache_width 2048
+    setprop ro.hwui.text_large_cache_height 1024
 
 # disable some daemons the emulator doesn't want
     stop dund
     stop akmd
 
+# start essential services
+# These were written for the classic emulator, but are applicable to ranchu
+    start goldfish-logcat
+#    start goldfish-setup
+
+
 # enable Google-specific location features,
 # like NetworkLocationProvider and LocationCollector
     setprop ro.com.google.locationfeatures 1
 
+#emulator is not much useful before boot complete
+#start it later
+on property:sys.boot_completed=1
+    setprop sys.usb.config adb
+    start adbd
+    start goldfish-logcat
+
+on property:qemu.adbd=start
+    setprop sys.usb.config adb
+    start adbd
+    start goldfish-logcat
+
+service ranchu-setup /vendor/bin/init.ranchu-core.sh
+    class core
+    user root
+    group root
+    oneshot
+
+service ranchu-net /vendor/bin/init.ranchu-net.sh
+    class late_start
+    user root
+    group root wakelock
+    oneshot
+
+# The qemu-props program is used to set various system
+# properties on boot. It must be run early during the boot
+# process to avoid race conditions with other daemons that
+# might read them (e.g. surface flinger), so define it in
+# class 'core'
+#
+service qemu-props /vendor/bin/qemu-props
+    class core
+    user root
+    group root
+    oneshot
+
+on property:qemu.logcat=start
+    start goldfish-logcat
+
+# -Q is a special logcat option that forces the
+# program to check wether it runs on the emulator
+# if it does, it redirects its output to the device
+# named by the androidboot.console kernel option
+# if not, is simply exits immediately
+# logd user added to prevent logcat from logging content.
+# log group added to support access to read logs socket.
+service goldfish-logcat /system/bin/logcat -Q
+    user logd
+    group log
+    oneshot
+
+service fingerprintd /system/bin/fingerprintd
+    class late_start
+    user system
+
+service bugreport /system/bin/dumpstate -d -p -B \
+        -o /data/user_de/0/com.android.shell/files/bugreports/bugreport
+    class main
+    disabled
+    oneshot
+    keycodes 114 115 116
diff --git a/qemu_arm.mk b/qemu_arm.mk
index d5e3e4a..3e84249 100644
--- a/qemu_arm.mk
+++ b/qemu_arm.mk
@@ -13,6 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+PRODUCT_COPY_FILES += \
+    prebuilts/qemu-kernel/arm/3.18/kernel-qemu2:kernel-ranchu
+
 $(call inherit-product, $(LOCAL_PATH)/qemu_base.mk)
 
 # Overrides
diff --git a/qemu_arm64.mk b/qemu_arm64.mk
index 5e6f3dc..d19a02b 100644
--- a/qemu_arm64.mk
+++ b/qemu_arm64.mk
@@ -13,6 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+PRODUCT_COPY_FILES += \
+    prebuilts/qemu-kernel/arm64/3.18/kernel-qemu2:kernel-ranchu
+
 $(call inherit-product, $(LOCAL_PATH)/qemu_base.mk)
 
 # Overrides
diff --git a/qemu_base.mk b/qemu_base.mk
index 3a8925c..eadb5a9 100644
--- a/qemu_base.mk
+++ b/qemu_base.mk
@@ -58,23 +58,30 @@
     logd \
     logwrapper \
     mkshrc \
-    netd \
     qemu-props \
     reboot \
     service \
     servicemanager \
+    hwservicemanager \
+    vndservice \
+    vndservicemanager \
     sh \
     toolbox \
     toybox \
-    vold \
+    vold
+
+# SELinux packages are added as dependencies of the selinux_policy
+# phony package.
+PRODUCT_PACKAGES += \
+    selinux_policy \
 
 # SELinux packages
-PRODUCT_PACKAGES += \
-    sepolicy \
-    file_contexts \
-    seapp_contexts \
-    property_contexts \
-    mac_permissions.xml \
+#PRODUCT_PACKAGES += \
+#    sepolicy \
+#    file_contexts \
+#    seapp_contexts \
+#    property_contexts \
+#    mac_permissions.xml \
 
 PRODUCT_COPY_FILES += \
     system/core/rootdir/init.usb.rc:root/init.usb.rc \
@@ -82,8 +89,38 @@
     system/core/rootdir/ueventd.rc:root/ueventd.rc \
     system/core/rootdir/etc/hosts:system/etc/hosts \
 
+PRODUCT_FULL_TREBLE_OVERRIDE := true
+
 PRODUCT_COPY_FILES += \
-    device/generic/goldfish/fstab.goldfish:root/fstab.goldfish \
-    device/generic/goldfish/init.goldfish.rc:root/init.goldfish.rc \
-    device/generic/goldfish/init.goldfish.sh:system/etc/init.goldfish.sh \
-    device/generic/goldfish/ueventd.goldfish.rc:root/ueventd.goldfish.rc \
+    device/generic/qemu/fstab.ranchu:root/fstab.ranchu \
+    device/generic/qemu/init.ranchu.rc:root/init.ranchu.rc \
+    device/generic/qemu/ueventd.ranchu.rc:root/ueventd.ranchu.rc \
+
+PRODUCT_COPY_FILES += \
+    device/generic/goldfish/data/etc/config.ini:config.ini \
+    device/generic/qemu/advancedFeatures.ini:advancedFeatures.ini \
+
+#$(call inherit-product, $(SRC_TARGET_DIR)/product/core_tiny.mk)
+ifeq ($(TARGET_CORE_JARS),)
+$(error TARGET_CORE_JARS is empty; cannot initialize PRODUCT_BOOT_JARS variable)
+endif
+
+# The order matters
+PRODUCT_BOOT_JARS := \
+    $(TARGET_CORE_JARS) \
+
+
+
+# The set of packages we want to force 'speed' compilation on.
+PRODUCT_DEXPREOPT_SPEED_APPS := \
+
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+    ro.zygote=zygote32
+PRODUCT_COPY_FILES += \
+    system/core/rootdir/init.zygote32.rc:root/init.zygote32.rc
+
+PRODUCT_PROPERTY_OVERRIDES += \
+    ro.carrier=unknown
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/runtime_libart.mk)
+
diff --git a/qemu_mips.mk b/qemu_mips.mk
index cceba12..082f457 100644
--- a/qemu_mips.mk
+++ b/qemu_mips.mk
@@ -13,6 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+PRODUCT_COPY_FILES += \
+    prebuilts/qemu-kernel/mips/3.18/kernel-qemu2:kernel-ranchu
+
 $(call inherit-product, $(LOCAL_PATH)/qemu_base.mk)
 
 # Overrides
diff --git a/qemu_mips64.mk b/qemu_mips64.mk
index 191b728..b06e006 100644
--- a/qemu_mips64.mk
+++ b/qemu_mips64.mk
@@ -13,6 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+PRODUCT_COPY_FILES += \
+    prebuilts/qemu-kernel/mips64/3.18/kernel-qemu2:kernel-ranchu
+
 $(call inherit-product, $(LOCAL_PATH)/qemu_base.mk)
 
 # Overrides
diff --git a/qemu_x86.mk b/qemu_x86.mk
index 3d1a7a9..a1c9e45 100644
--- a/qemu_x86.mk
+++ b/qemu_x86.mk
@@ -13,6 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+PRODUCT_COPY_FILES += \
+    prebuilts/qemu-kernel/x86/3.18/kernel-qemu2:kernel-ranchu
+
 $(call inherit-product, $(LOCAL_PATH)/qemu_base.mk)
 
 # Overrides
diff --git a/qemu_x86_64.mk b/qemu_x86_64.mk
index e948060..9461bb1 100644
--- a/qemu_x86_64.mk
+++ b/qemu_x86_64.mk
@@ -13,6 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+PRODUCT_COPY_FILES += \
+    prebuilts/qemu-kernel/x86_64/3.18/kernel-qemu2:kernel-ranchu
+
 $(call inherit-product, $(LOCAL_PATH)/qemu_base.mk)
 
 # Overrides
diff --git a/ueventd.ranchu.rc b/ueventd.ranchu.rc
index a9e5de5..50d6c53 100644
--- a/ueventd.ranchu.rc
+++ b/ueventd.ranchu.rc
@@ -1,5 +1,6 @@
 # These settings are specific to running under the Android emulator
 /dev/qemu_trace           0666   system     system
-/dev/android_pipe         0666   system     system
+/dev/goldfish_pipe        0666   system     system
 /dev/ttyS*                0666   system     system
 /proc                     0666   system     system
+/dev/goldfish_sync        0666   system     system